Call Back Guide (Vote Check)
By using our new Callback System you can realize a fast and save way to reward your players for voting in seconds!
In order to do so you just have to upload a callback script to your webserver and put the direct link to this script into the "Callback" input box inside the user control panel. You will find an example callback script below.
Q: What does Callback System mean?
A: The Callback System catches your players Vote, checks our database if he voted already today, and then calls a script located on your server telling the script if your player voted already.
The script on your server will then be able to reward your player automatically with whatever you want, for example Vote Points, InGame currency or Items etc.
Q: How does it work?
A: After you set up your callback script on your server, and put the link to it inside your settings you need to use the Callback Button Code.
The Code includes a part like:
<a href="http://votezone.eu/index.php?a=in&u=YourSiteName&id={$p_callback_id}
">
The important thing in that code is {$p_callback_id}
this has to contain the ID that you identify your player with. For example Player "Juggernaut" has the account ID "1417" the link would be:
<a href="http://votezone.eu/index.php?a=in&u=YourSiteName&id=1417">
<?php echo '"http://votezone.eu/index.php?a=in&u=YourSiteName&id=' . $_SESSION['PlayerID'] . '"' ?>
If you store the ID ("1417") inside the Session Variable.
Q: What does it do, exactly?
A: The whole System starts on your website! You put our button code into your Website (edited like shown above) and a player of yours klicks on it to vote.
Your player is then forwarded to our gateway page. On this gateway page our system checks the database if your player voted already on that day.
Regarding on the result of this check, the system calls the Callback script on your server and passes the information to it. Your script can then either reward your player, or not. You could also reward your player for voting even if he voted already etc. Your possibilities are limitless on this.
After the call to your Callback script, the user is forwarded to a confirmation page where he can see that he voted successfully, after that our database gets updated so he wont be able to be rewarded for voting again on the same day (as long as you reward your players for valid votes only).
Q: Can this be hacked?!
A: As you see above, this system is theoretically 100% safe, only possibility to "hack" this system is to make fake calls to your Callback script, but we also have a solution for this!
To prevent fake calls, we do an IP check inside the callback script. By doing so, only calls from our Toplist Server will be accepted. Every other call is simply rejected.
If you want to, you could even do a "Hacker" log, where you log all attempts with time, ip and username/playerID so you can punish them afterwards.
Example Callback Script
You can use this Script on your Webserver to listen to our Callback System, all you have to do is add your rewarding. For example an SQL query to add InGame currency.
PHP code:
$ipsWhitelist = array(
'217.160.231.179' //This is the IP of the Toplist Server, only calls from the Toplist are accepted
); //for now, you may add other IPs to listen to!
function _VoteReward($userId, $valid)
{
if($valid == 1)
{
//Log to Callback.log | Comment out if you dont want a log
file_put_contents("callback.log", "Callback Script called! User Voted already =( Time: " . date("d.m.Y H:m:s", time()) . " User: " . $userId . "\n", FILE_APPEND);
}
else if($valid == 0)
{
//TODO: Insert Vote Reward
//Log to Callback.log | Comment out if you dont want a log
file_put_contents("callback.log", "Callback Script called! User didnt Vote yet! :D Time: " . date("d.m.Y H:m:s", time()) . " User: " . $userId . "\n", FILE_APPEND);
}
}
//-------------------------- Don't change anything below this! -----------------------------
$userId = isset($_POST['userid']) ? $_POST['userid'] : null;
$valid = isset($_POST['voted']) ? $_POST['voted'] : null;
$result = false;
if (!empty($userId) && !empty($valid))
{
//check if IP is in whitelist
if (in_array($_SERVER['REMOTE_ADDR'], $ipsWhitelist))
{
$result = true;
_VoteReward($userId, $valid);
}
}
if ($result) {
echo 'OK';
}
?>