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
find retro problem
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="Synapse" data-source="post: 431091" data-attributes="member: 13644"><p>EDIT: Overthought it, wasn't the code: for anyone else having issue the error is you need to make your header location: <a href="https://findretros.com/servers/YOURHOTEL/vote?minimal=1&return=1" target="_blank">https://findretros.com/servers/YOURHOTEL/vote?minimal=1&return=1</a> (the old API system doesn't pass the return parameter to the new system)</p><p></p><p></p><p></p><p></p><p></p><p>It's looking for voted, and you're giving it novote, thinking you've not voted.</p><p></p><p>ALSO after further review of your code:</p><p></p><p></p><p>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.</p><p></p><p>After rewriting the code, I realized what you were trying to achieve (I think) and decided to clean it up a tad:</p><p>[code]</p><p><?php</p><p>if(!isset($_GET['voted']) || $_SESSION['user']['last_vote'] < timestamp()) {</p><p> $userip = "{$_SERVER['HTTP_CF_CONNECTING_IP']}";</p><p> $current_url = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);</p><p> $url = 'http://votingapi.com/validate.php?user=Lucid&ip=' . $userip;</p><p> $context = stream_context_create(array('http' => array('timeout' => 1)));</p><p> $data = @file_get_contents($url, 1, $context);</p><p></p><p> if(!$data || !is_numeric($data)) {</p><p> return "Error";</p><p> }</p><p></p><p> elseif($data > 2) {</p><p> header ("Location: http://votingapi.com/vote.php?username=Lucid&api=https:!!lucidhotel.pw!client?novote");</p><p> }</p><p></p><p> else {</p><p> // Wait an hour before you check again (reduces server load, increases load speed)</p><p> $_SESSION['user']['last_vote'] = timestamp()+3600;</p><p> }</p><p>}</p><p></p><p>else {</p><p> header ("Location: http://votingapi.com/vote.php?username=Lucid&api=https:!!lucidhotel.pw!client?novote");</p><p>}</p><p></p><p>[/code]</p><p>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</p><p></p><p>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.</p></blockquote><p></p>
[QUOTE="Synapse, post: 431091, member: 13644"] EDIT: Overthought it, wasn't the code: for anyone else having issue the error is you need to make your header location: [URL]https://findretros.com/servers/YOURHOTEL/vote?minimal=1&return=1[/URL] (the old API system doesn't pass the return parameter to the new system) It's looking for voted, and you're giving it novote, thinking you've not voted. ALSO after further review of your code: 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"); } [/code] 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. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
find retro problem
Top