find retro problem

olliedean

ollie.cool
Jan 28, 2013
433
107
Return URL is:

Have it on my client.php:
Code:
<?php include_once ("forcevote.php");
?>

in forcevote.php:
Code:
<?php
if(isset($_GET['voted'])) {
}
else {
$userip = "{$_SERVER['HTTP_CF_CONNECTING_IP']}";
$current_url = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
$url = 'http://votingapi.com/validate.php?user=Lucid&ip=' . $userip;
$context = stream_context_create(array('http' => array('timeout' => 1)));
$data = @file_get_contents($url, 1, $context);
if(!$data || !is_numeric($data)) {
return "Error";
}
else if ($data == 1 || $data == 2) {
}
else {
header ("Location: http://votingapi.com/vote.php?username=Lucid&api=https:!!lucidhotel.pw!client?novote");
exit;
}
}

When I try enter the client, it shows this.
lO-V7ynIQPeecI_9vvQ6vw.png
 

Synapse

PogChamp
Mar 3, 2012
164
59
EDIT: Overthought it, wasn't the code: for anyone else having issue the error is you need to make your header location: (the old API system doesn't pass the return parameter to the new system)

Return URL is:

if(isset($_GET['voted'])) {

It's looking for voted, and you're giving it novote, thinking you've not voted.

ALSO after further review of your code:
if(isset($_GET['voted'])) { } else { $userip = "{$_SERVER['HTTP_CF_CONNECTING_IP']}"; $current_url = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1); $url = ' ' . $userip; $context = stream_context_create(array('http' => array('timeout' => 1))); $data = @file_get_contents($url, 1, $context); if(!$data || !is_numeric($data)) { return "Error"; } else if ($data == 1 || $data == 2) {

You're immediately closing the bracket for the voted if clause, and saying already to do that. They're probably returning to your site with ?voted or ?novote, triggering that which is saying if they have that DON'T run the code below it. Which is the opposite of what you're doing. Actually the more I read your code, the less I understand why it doesn't return a 500.

After rewriting the code, I realized what you were trying to achieve (I think) and decided to clean it up a tad:
Code:
<?php
if(!isset($_GET['voted']) || $_SESSION['user']['last_vote'] < timestamp()) {
    $userip = "{$_SERVER['HTTP_CF_CONNECTING_IP']}";
    $current_url = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
    $url = 'http://votingapi.com/validate.php?user=Lucid&ip=' . $userip;
    $context = stream_context_create(array('http' => array('timeout' => 1)));
    $data = @file_get_contents($url, 1, $context);

    if(!$data || !is_numeric($data)) {
        return "Error";
    }

    elseif($data > 2) {
       header ("Location: http://votingapi.com/vote.php?username=Lucid&api=https:!!lucidhotel.pw!client?novote");
    }

    else {
        // Wait an hour before you check again (reduces server load, increases load speed)
        $_SESSION['user']['last_vote'] = timestamp()+3600;
    }
}

else {
    header ("Location: http://votingapi.com/vote.php?username=Lucid&api=https:!!lucidhotel.pw!client?novote");
}
This code is untested, and may not do EXACTLY what you want it to do (your code was somewhat difficult to understand). But with minor modifications this should work. Also you need to match the $_GET['voted'] with the ?voted, also in most CMS this isn't passed in the URL due to url rewrite, so you have to make a URL rewrite for it (as most hotels do) to youthotel.com/client/voted instead of yourhotel.com/client?voted

Basically the code I wrote, if someone tries to pass ?voted to your server, it checks the votingapi if they have really voted. If not, it redirects them to vote. If thevoting api returns an error, it lets them on (not their fault, they shouldn't be punished!) If there is no voted parameter, it sends them to the voting api automatically, without other logic. If data is not bigger than 1 or 2, sends them to the voting API. If not it does nothing.
 
Last edited:

olliedean

ollie.cool
Jan 28, 2013
433
107
What did you set as your postback URL in FindRetros?

 
I've changed the code to this:
Code:
<?php
$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
$url = 'http://votingapi.com/validate.php?user=Lucid&ip=' . $ip;
$hasvoted = @file_get_contents($url);
if($hasvoted != '1' && $hasvoted != '2'){
 header ("Location: https://findretros.com/servers/Lucid/vote?minimal=1&return=1");
 exit;
}
?>
And I get: findretros.com redirected you too many times.

Am I going to have to make a record on namecheap? if so, what?
 

treebeard

Member
Jan 16, 2018
317
173

 
I've changed the code to this:
Code:
<?php
$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
$url = 'http://votingapi.com/validate.php?user=Lucid&ip=' . $ip;
$hasvoted = @file_get_contents($url);
if($hasvoted != '1' && $hasvoted != '2'){
 header ("Location: https://findretros.com/servers/Lucid/vote?minimal=1&return=1");
 exit;
}
?>
And I get: findretros.com redirected you too many times.

Am I going to have to make a record on namecheap? if so, what?
Just use the code here:
Everything will work fine if you use the legit code and follow the example.
 

Users who are viewing this thread

Top