FindRetros API - Not Working REVCMS

Flukey

Officially the gratest alive!
Sep 17, 2018
105
18
Hey guys its really annoying me now i have tried everything to get force vote to work but nothing seems to work? i am using revcms do anyone have a fix for this?

thanks in advance....

Joshua...





<forcevote.php>
<?php
2
3 class FindRetros {
4
5 private $pageName, $callTimeout, $usingCloudFlare, $apiPath;
6
7 function __construct() {
8
9 global $_CONFIG;
10
11 $this->pageName = $_CONFIG['forcehotel2019'];
12 $this->requestTimeout = $_CONFIG['timeout'];
13 $this->usingCloudFlare = $_CONFIG['cloudflare'];
14 $this->apiPath = $_CONFIG['api'];
15
16 if($this->usingCloudFlare) {
17
18 if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
19
20 $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
21
22 }
23
24 }
25
26 }
27
28 public function hasClientVoted() {
29
30 if(!$this->_isVoteCookieSet()) {
31
32 $urlRequest = $this->apiPath . 'validate.php?user=' . $this->pageName . '&ip=' . $_SERVER['REMOTE_ADDR'];
33
34 $dataRequest = $this->_makeCurlRequest($urlRequest);
35
36 if(in_array($dataRequest, array(1, 2))) {
37
38 $this->_setVoteCookie();
39
40 return true;
41
42 }else if($dataRequest == 3) {
43
44 return false;
45
46 }else{
47
48 /* There's something wrong with FindRetros, so we will mark the user as voted and have them proceed as if they voted. */
49
50 $this->_setVoteCookie();
51
52 return true;
53
54 }
55
56 }
57
58 return true;
59
60 }
61
62 public function redirectClientToVote() {
63
64 header('Location: ' . $this->apiPath . 'rankings/vote/' . $this->pageName);
65
66 exit;
67
68 }
69
70 private function _makeCurlRequest($url) {
71
72 if(function_exists('curl_version')) {
73
74 $curl = curl_init();
75
76 curl_setopt($curl, CURLOPT_URL, $url);
77 curl_setopt($curl, CURLOPT_HEADER, 0);
78 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
79 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
80 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
81 curl_setopt($curl, CURLOPT_TIMEOUT, $this->requestTimeout);
82 curl_setopt($curl, CURLOPT_USERAGENT, 'FindRetros Vote Validator');
83
84 $requestData = curl_exec($curl);
85
86 curl_close($curl);
87
88 }else{
89
90 $requestData = stream_context_create(array('http' => array('timeout' => $this->requestTimeout)));
91
92 return @file_get_contents($url, 0, $requestData);
93
94 }
95
96 return $requestData;
97
98 }
99
100 private function _setVoteCookie() {
101
102 $rankingsResetTime = $this->_getRankingsResetTime();
103
104 setcookie('voting_stamp', $rankingsResetTime, $rankingsResetTime);
105
106 }
107
108 private function _isVoteCookieSet() {
109
110 if(isset($_COOKIE['voting_stamp'])) {
111
112 if($_COOKIE['voting_stamp'] == $this->_getRankingsResetTime()) {
113
114 return true;
115
116 }else{
117
118 setcookie('voting_stamp', '');
119
120 return false;
121
122 }
123
124 }
125
126 return false;
127
128 }
129
130 private function _getRankingsResetTime() {
131
132 $serverDefaultTime = date_default_timezone_get();
133
134 date_default_timezone_set('America/Chicago');
135
136 $rankingsResetTime = mktime(0, 0, 0, date('n'), date('j') + 1);
137
138 date_default_timezone_set($serverDefaultTime);
139
140 return $rankingsResetTime;
141
142 }
143
144 }
 

Users who are viewing this thread

Top