Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
FindRetros Voting Not Workin
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="gochad" data-source="post: 454073" data-attributes="member: 84522"><p>Hey there ive done everything right and idk why it doeset work heres the code</p><p></p><p></p><p></p><p>[SPOILER="findretros.php"]</p><p><?php</p><p>class FindRetros {</p><p> private $pageName, $callTimeout, $usingCloudFlare, $apiPath;</p><p> function __construct() {</p><p> global $_CONFIG;</p><p> $this->pageName = $_CONFIG['pagename'];</p><p> $this->requestTimeout = $_CONFIG['timeout'];</p><p> $this->usingCloudFlare = $_CONFIG['cloudflare'];</p><p> $this->apiPath = $_CONFIG['api'];</p><p> if($this->usingCloudFlare) {</p><p> if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {</p><p> $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];</p><p> }</p><p> }</p><p> }</p><p> public function hasClientVoted() {</p><p></p><p> if(!$this->_isVoteCookieSet()) {</p><p> $urlRequest = $this->apiPath . 'validate.php?user=' . $this->pageName . '&ip=' . $_SERVER['REMOTE_ADDR'];</p><p> $dataRequest = $this->_makeCurlRequest($urlRequest);</p><p> if(in_array($dataRequest, array(1, 2))) {</p><p> $this->_setVoteCookie();</p><p> return true;</p><p> }else if($dataRequest == 3) {</p><p> return false;</p><p> }else{</p><p> /* There's something wrong with FindRetros, so we will mark the user as voted and have them proceed as if they voted. */</p><p> $this->_setVoteCookie();</p><p> return true;</p><p> }</p><p> }</p><p> return true;</p><p> }</p><p> public function redirectClientToVote() {</p><p> header('Location: ' . $this->apiPath . 'rankings/vote/' . $this->pageName);</p><p> exit;</p><p> }</p><p> private function _makeCurlRequest($url) {</p><p> if(function_exists('curl_version')) {</p><p> $curl = curl_init();</p><p> curl_setopt($curl, CURLOPT_URL, $url);</p><p> curl_setopt($curl, CURLOPT_HEADER, 0);</p><p> curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);</p><p> curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);</p><p> curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);</p><p> curl_setopt($curl, CURLOPT_TIMEOUT, $this->requestTimeout);</p><p> curl_setopt($curl, CURLOPT_USERAGENT, 'FindRetros Vote Validator');</p><p> $requestData = curl_exec($curl);</p><p> curl_close($curl);</p><p> }else{</p><p> $requestData = stream_context_create(array('http' => array('timeout' => $this->requestTimeout)));</p><p> return @file_get_contents($url, 0, $requestData);</p><p> }</p><p> return $requestData;</p><p> }</p><p> private function _setVoteCookie() {</p><p> $rankingsResetTime = $this->_getRankingsResetTime();</p><p> setcookie('voting_stamp', $rankingsResetTime, $rankingsResetTime);</p><p> }</p><p> private function _isVoteCookieSet() {</p><p> if(isset($_COOKIE['voting_stamp'])) {</p><p> if($_COOKIE['voting_stamp'] == $this->_getRankingsResetTime()) {</p><p> return true;</p><p> }else{</p><p> setcookie('voting_stamp', '');</p><p> return false;</p><p> }</p><p> }</p><p> return false;</p><p> }</p><p> private function _getRankingsResetTime() {</p><p> $serverDefaultTime = date_default_timezone_get();</p><p> date_default_timezone_set('America/Chicago');</p><p> $rankingsResetTime = mktime(0, 0, 0, date('n'), date('j') + 1);</p><p></p><p> date_default_timezone_set($serverDefaultTime);</p><p> </p><p> return $rankingsResetTime;</p><p> }</p><p>}</p><p><?php</p><p>class FindRetros {</p><p> private $pageName, $callTimeout, $usingCloudFlare, $apiPath;</p><p> function __construct() {</p><p> global $_CONFIG;</p><p> $this->pageName = $_CONFIG['pagename'];</p><p> $this->requestTimeout = $_CONFIG['timeout'];</p><p> $this->usingCloudFlare = $_CONFIG['cloudflare'];</p><p> $this->apiPath = $_CONFIG['api'];</p><p> if($this->usingCloudFlare) {</p><p> if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {</p><p> $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];</p><p> }</p><p> }</p><p> }</p><p> public function hasClientVoted() {</p><p></p><p> if(!$this->_isVoteCookieSet()) {</p><p> $urlRequest = $this->apiPath . 'validate.php?user=' . $this->pageName . '&ip=' . $_SERVER['REMOTE_ADDR'];</p><p> $dataRequest = $this->_makeCurlRequest($urlRequest);</p><p> if(in_array($dataRequest, array(1, 2))) {</p><p> $this->_setVoteCookie();</p><p> return true;</p><p> }else if($dataRequest == 3) {</p><p> return false;</p><p> }else{</p><p> /* There's something wrong with FindRetros, so we will mark the user as voted and have them proceed as if they voted. */</p><p> $this->_setVoteCookie();</p><p> return true;</p><p> }</p><p> }</p><p> return true;</p><p> }</p><p> public function redirectClientToVote() {</p><p> header('Location: ' . $this->apiPath . 'rankings/vote/' . $this->pageName);</p><p> exit;</p><p> }</p><p> private function _makeCurlRequest($url) {</p><p> if(function_exists('curl_version')) {</p><p> $curl = curl_init();</p><p> curl_setopt($curl, CURLOPT_URL, $url);</p><p> curl_setopt($curl, CURLOPT_HEADER, 0);</p><p> curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);</p><p> curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);</p><p> curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);</p><p> curl_setopt($curl, CURLOPT_TIMEOUT, $this->requestTimeout);</p><p> curl_setopt($curl, CURLOPT_USERAGENT, 'FindRetros Vote Validator');</p><p> $requestData = curl_exec($curl);</p><p> curl_close($curl);</p><p> }else{</p><p> $requestData = stream_context_create(array('http' => array('timeout' => $this->requestTimeout)));</p><p> return @file_get_contents($url, 0, $requestData);</p><p> }</p><p> return $requestData;</p><p> }</p><p> private function _setVoteCookie() {</p><p> $rankingsResetTime = $this->_getRankingsResetTime();</p><p> setcookie('voting_stamp', $rankingsResetTime, $rankingsResetTime);</p><p> }</p><p> private function _isVoteCookieSet() {</p><p> if(isset($_COOKIE['voting_stamp'])) {</p><p> if($_COOKIE['voting_stamp'] == $this->_getRankingsResetTime()) {</p><p> return true;</p><p> }else{</p><p> setcookie('voting_stamp', '');</p><p> return false;</p><p> }</p><p> }</p><p> return false;</p><p> }</p><p> private function _getRankingsResetTime() {</p><p> $serverDefaultTime = date_default_timezone_get();</p><p> date_default_timezone_set('America/Chicago');</p><p> $rankingsResetTime = mktime(0, 0, 0, date('n'), date('j') + 1);</p><p></p><p> date_default_timezone_set($serverDefaultTime);</p><p> </p><p> return $rankingsResetTime;</p><p> }</p><p>}</p><p>[/SPOILER]</p><p>[SPOILER="findretoros_config.php"]</p><p><?php</p><p>$_CONFIG = array(</p><p> /* What is "Yumbo Hotel" of your page on FindRetros? */</p><p></p><p> 'pagename' => 'yumbo69',</p><p> /* How many seconds should it take to try and reach FindRetros if it's down? */</p><p> 'timeout' => 2,</p><p> /* Are you using CloudFlare? If so, set this to true. */</p><p> 'cloudflare' => true,</p><p> /* Incase FindRetros.com has a new domain, change it below. */</p><p> 'api' => '<a href="https://findretros.com/" target="_blank">https://findretros.com/</a>'</p><p>);</p><p>[/SPOILER]</p><p>[SPOILER="me.php"]</p><p><?php</p><p></p><p></p><p></p><p>require_once 'findretros_config.php';</p><p></p><p>require_once 'findretros.php';</p><p></p><p></p><p></p><p>$findRetros = new FindRetros();</p><p></p><p></p><p></p><p>if(!$findRetros->hasClientVoted()) {</p><p></p><p> $findRetros->redirectClientToVote();</p><p></p><p>}</p><p></p><p></p><p></p><p>?></p><p><!DOCTYPE html></p><p>[/SPOILER]</p></blockquote><p></p>
[QUOTE="gochad, post: 454073, member: 84522"] Hey there ive done everything right and idk why it doeset work heres the code [SPOILER="findretros.php"] <?php class FindRetros { private $pageName, $callTimeout, $usingCloudFlare, $apiPath; function __construct() { global $_CONFIG; $this->pageName = $_CONFIG['pagename']; $this->requestTimeout = $_CONFIG['timeout']; $this->usingCloudFlare = $_CONFIG['cloudflare']; $this->apiPath = $_CONFIG['api']; if($this->usingCloudFlare) { if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; } } } public function hasClientVoted() { if(!$this->_isVoteCookieSet()) { $urlRequest = $this->apiPath . 'validate.php?user=' . $this->pageName . '&ip=' . $_SERVER['REMOTE_ADDR']; $dataRequest = $this->_makeCurlRequest($urlRequest); if(in_array($dataRequest, array(1, 2))) { $this->_setVoteCookie(); return true; }else if($dataRequest == 3) { return false; }else{ /* There's something wrong with FindRetros, so we will mark the user as voted and have them proceed as if they voted. */ $this->_setVoteCookie(); return true; } } return true; } public function redirectClientToVote() { header('Location: ' . $this->apiPath . 'rankings/vote/' . $this->pageName); exit; } private function _makeCurlRequest($url) { if(function_exists('curl_version')) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_TIMEOUT, $this->requestTimeout); curl_setopt($curl, CURLOPT_USERAGENT, 'FindRetros Vote Validator'); $requestData = curl_exec($curl); curl_close($curl); }else{ $requestData = stream_context_create(array('http' => array('timeout' => $this->requestTimeout))); return @file_get_contents($url, 0, $requestData); } return $requestData; } private function _setVoteCookie() { $rankingsResetTime = $this->_getRankingsResetTime(); setcookie('voting_stamp', $rankingsResetTime, $rankingsResetTime); } private function _isVoteCookieSet() { if(isset($_COOKIE['voting_stamp'])) { if($_COOKIE['voting_stamp'] == $this->_getRankingsResetTime()) { return true; }else{ setcookie('voting_stamp', ''); return false; } } return false; } private function _getRankingsResetTime() { $serverDefaultTime = date_default_timezone_get(); date_default_timezone_set('America/Chicago'); $rankingsResetTime = mktime(0, 0, 0, date('n'), date('j') + 1); date_default_timezone_set($serverDefaultTime); return $rankingsResetTime; } } <?php class FindRetros { private $pageName, $callTimeout, $usingCloudFlare, $apiPath; function __construct() { global $_CONFIG; $this->pageName = $_CONFIG['pagename']; $this->requestTimeout = $_CONFIG['timeout']; $this->usingCloudFlare = $_CONFIG['cloudflare']; $this->apiPath = $_CONFIG['api']; if($this->usingCloudFlare) { if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; } } } public function hasClientVoted() { if(!$this->_isVoteCookieSet()) { $urlRequest = $this->apiPath . 'validate.php?user=' . $this->pageName . '&ip=' . $_SERVER['REMOTE_ADDR']; $dataRequest = $this->_makeCurlRequest($urlRequest); if(in_array($dataRequest, array(1, 2))) { $this->_setVoteCookie(); return true; }else if($dataRequest == 3) { return false; }else{ /* There's something wrong with FindRetros, so we will mark the user as voted and have them proceed as if they voted. */ $this->_setVoteCookie(); return true; } } return true; } public function redirectClientToVote() { header('Location: ' . $this->apiPath . 'rankings/vote/' . $this->pageName); exit; } private function _makeCurlRequest($url) { if(function_exists('curl_version')) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_TIMEOUT, $this->requestTimeout); curl_setopt($curl, CURLOPT_USERAGENT, 'FindRetros Vote Validator'); $requestData = curl_exec($curl); curl_close($curl); }else{ $requestData = stream_context_create(array('http' => array('timeout' => $this->requestTimeout))); return @file_get_contents($url, 0, $requestData); } return $requestData; } private function _setVoteCookie() { $rankingsResetTime = $this->_getRankingsResetTime(); setcookie('voting_stamp', $rankingsResetTime, $rankingsResetTime); } private function _isVoteCookieSet() { if(isset($_COOKIE['voting_stamp'])) { if($_COOKIE['voting_stamp'] == $this->_getRankingsResetTime()) { return true; }else{ setcookie('voting_stamp', ''); return false; } } return false; } private function _getRankingsResetTime() { $serverDefaultTime = date_default_timezone_get(); date_default_timezone_set('America/Chicago'); $rankingsResetTime = mktime(0, 0, 0, date('n'), date('j') + 1); date_default_timezone_set($serverDefaultTime); return $rankingsResetTime; } } [/SPOILER] [SPOILER="findretoros_config.php"] <?php $_CONFIG = array( /* What is "Yumbo Hotel" of your page on FindRetros? */ 'pagename' => 'yumbo69', /* How many seconds should it take to try and reach FindRetros if it's down? */ 'timeout' => 2, /* Are you using CloudFlare? If so, set this to true. */ 'cloudflare' => true, /* Incase FindRetros.com has a new domain, change it below. */ 'api' => '[URL]https://findretros.com/[/URL]' ); [/SPOILER] [SPOILER="me.php"] <?php require_once 'findretros_config.php'; require_once 'findretros.php'; $findRetros = new FindRetros(); if(!$findRetros->hasClientVoted()) { $findRetros->redirectClientToVote(); } ?> <!DOCTYPE html> [/SPOILER] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
FindRetros Voting Not Workin
Top