Code:
<?php
/**
* Vote 4 Coins Script for topliste.*****************
*
* Coded by 'ChuckNorris
*
* Changelog:
* 25.07.2014 Add time limit (stop flooding with vote links in skype)
*
* @copyright 'ChuckNorris 2014 All rights reserved
*/
//******************** CONFIGURATION AREA ********************//
$DELAY = 60 * 60 * 24;// Time Limit / f.e. 60 Sekunden * 60 Minuten * 24 Stunden = 24 Stunden (in Sekunden)
$ID='3542'; // Enter side id here
$API_KEY='zensiert'; // Enter api key here
$VoteCoins='100'; // Enter coins to get here
$sqlServ = mysql_connect("Nichtsda", "root", "Nichtsda");
$hpDB = 'account';
//****************** END CONFIGURATION AREA *******************//
//***************** DO NOT CHANGE CODE HERE *******************//
$REQUEST='votes';
$topl_curl=curl_init();
curl_setopt($topl_curl, CURLOPT_URL,
'http://*********************/api?id=' . urlencode($ID) . '&request=' . urlencode($REQUEST) . '&vuid=9999');
curl_setopt($topl_curl, CURLOPT_HEADER, 0);
curl_setopt($topl_curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($topl_curl, CURLOPT_HTTPHEADER, array('X_APIKEY: ' . $API_KEY));
$topl_data=curl_exec($topl_curl);
$topl_info=curl_getinfo($topl_curl);
if (!curl_errno($topl_curl))
{
if ($topl_info['http_code'] == 200)
{
$Data=json_decode($topl_data, true);
foreach($Data as $vuid)
{
$CheckVoteLog_SQL = "SELECT UNIX_TIMESTAMP(`lastVote`) as lastVote FROM `" . $hpDB . "`.`v4c` WHERE `aid`='" . $vuid . "'";
$result = mysql_query($CheckVoteLog_SQL, $sqlServ);
echo mysql_error();
$lastVoteTime = 0;
if(mysql_num_rows($result) == 0) {
$AddVoteLog_SQL = "INSERT INTO `" . $hpDB . "`.`v4c`(`aid`, `lastVote`) VALUES('" . $vuid . "', NOW())";
mysql_query($AddVoteLog_SQL);
} else {
$UpdateVoteLog_SQL = "UPDATE `" . $hpDB . "`.`v4c` SET `lastVote`=NOW() WHERE `aid`='" . $vuid . "'";
mysql_query($UpdateVoteLog_SQL);
$lastVoteTime = mysql_result($result, 0, "lastVote");
}
if($lastVoteTime < time() - $DELAY) {
$PlayerNewCoins_SQL = "UPDATE account.account
SET coins = coins + ".$VoteCoins."
WHERE id = '".$vuid."'";
mysql_query($PlayerNewCoins_SQL, $sqlServ);
}
}
}
}
else
{
echo 'Curl error: ' . curl_error($topl_curl);
}
curl_close($topl_curl);
?>