Voting does count/not working/voting page doesnt appear [HELP]

Status
Not open for further replies.

Sly

I don't break the rules I bend them.
Oct 28, 2016
246
38
What the problem is, is that the voting page doesnt appear it says voted when I validate, and takes me to robbo.pw/client?voted (as I set it on findretros.com)

What is the problem?
Heres my setup.

Settings on findretros.com
redirect after vote = robbo.pw/client?voted
Client.php
PHP:
<?php
    staffCheck();
    Game::sso();  
    Game::homeRoom();  

   
    require_once 'findretros_config.php';
    require_once 'findretros.php';
    require_once 'validate.php';
   
?>

findretros_config.php

PHP:
<?php

$_CONFIG = array(

    /* What is "username" of your page on FindRetros? */
   
    'pagename' => 'robbo',

    /* 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' => 'https://findretros.com/'

);

findretros.php
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;

    }

}

validate.php
PHP:
<?php
require_once 'findretros_config.php';
require_once 'findretros.php';
$FindRetros = new FindRetros();
if($FindRetros->hasClientVoted()) {
    echo 'You have voted!';
}else{
    // echo 'You have yet to vote!';
    $FindRetros->redirectClientToVote();
}
 
Last edited:

RastaLulz

fight teh power
Staff member
May 3, 2010
3,926
3,921
No where are instantiating the FindRetros class, checking if the client has voted, and then executing code based on that.

 

Sly

I don't break the rules I bend them.
Oct 28, 2016
246
38
No where are instantiating the FindRetros class, checking if the client has voted, and then executing code based on that.

OK could you please explain this in a nooby way for me to understand =]
 
No where are instantiating the FindRetros class, checking if the client has voted, and then executing code based on that.

Josh, it says it's voted but the voting doesnt count.. why?
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,194
3,901
OK could you please explain this in a nooby way for me to understand =]
 

Josh, it says it's voted but the voting doesnt count.. why?

Votes seem to be going through, however... Suspiciously enough 3 hours ago 8 votes were declined due to be detected as a proxy/VPN.

Play fair. :)
 
  • Like
Reactions: Sly

Sly

I don't break the rules I bend them.
Oct 28, 2016
246
38
Votes seem to be going through, however... Suspiciously enough 3 hours ago 8 votes were declined due to be detected as a proxy/VPN.

Play fair. :)
Sledmore as I have endless respect towards you and other staff members within FindRetros/DevB, I never have used VPN's/Proxies to gain votes I will alert my staff if they are using it not to. But thankyou for this. But however this still hasn't answered my question...

Does this mean people are trying to access my server with VPNS?

added; Yes you're right votes are going through but the problem comes AFTER voting.. some users are getting a re-direct error I don't know if Its the CMS or what I highly doubt it is not.

I also know for a fact that some users are able to connect normally without any problems and 10/20% are not able to connect could it be a port issue witin my VPS?
 

JynX

Posting Freak
Feb 6, 2016
710
438
Is your return URL over HTTPS or HTTP?

Fuck the above question.

Your voting is wrong, remove the include for validate.php and use this instead at the top:
PHP:
<?php
require('findretros.php');
require('findretros_config.php');

$FindRetros = new FindRetros();
if($FindRetros->hasClientVoted())  // Has the user voted?
{
// Yes, do nothing (Let them on the client..)
} 
else {
    $FindRetros->redirectClientToVote(); // No they haven't make them vote then go to client
}
?>
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,132
2,456
Try the fix provided by JynX. This isn't a problem with FindRetros, but rather your config.

Votes do come trough. When someone uses a VPN/proxy which is blocked, the vote will simply not count. Neither you nor the user who votes will be made aware of this.
 
Status
Not open for further replies.

Users who are viewing this thread

Top