Code:
<?php
$vote_checking = false;
$host = "localhost";
$user = "toomuchp_vote";
$pass = "123vote123";
$name = "toomuchp_voting";
$vote1 = array("name" => "Moparscape", "url" => "http://www.moparscape.org/serverstatus.php?action=up&server=toomuchpk.no-ip.biz");
$vote2 = array("name" => "Mmorpgtoplist", "url" => "http://www.mmorpgtoplist.com/in.php?site=46598");
$vote4 = array("name" => "Rune-Server", "url" => "http://www.rune-server.org/top.php?act=vote&sid=4595");
$vote5 = array("name" => "Top100arena", "url" => "http://runescape.top100arena.com/in.asp?id=63465");
if(!@mysql_connect($host, $user, $pass)) {
die("error connecting to mysql server - " . mysql_error());
}
if(!@mysql_select_db($name)) {
die("error selecting mysql database - " . mysql_error());
}
if($vote_checking) {
$sql = mysql_query("SELECT * FROM `tempvotes`");
if (mysql_num_rows($sql) > 0) {
while ($row = mysql_fetch_array($sql)) {
if((time() - $row['time']) > 3600)
mysql_query("DELETE FROM `tempvotes` WHERE `id` = '" . $row['id'] . "'");
}
}
}
$sql = mysql_query("SELECT * FROM `votes`");
if (mysql_num_rows($sql) > 0) {
while ($row = mysql_fetch_array($sql)) {
if ((time() - $row['time']) > strtotime("+1 day", $row['time'])) {
mysql_query("DELETE FROM `votes` WHERE `authcode` = '" . $row['authcode'] . "'");
}
}
}
if($vote_checking) {
if(isset($_GET['postback'])) {
$id = anti_sql($_GET['postback']);
mysql_query("UPDATE `tempvotes` SET `voted`='1' WHERE `id` = '" . $id . "'") or die("error running query - " . mysql_error());
}
}
function checkIP($sqlConnect) {
$query = $sqlConnect->query("SELECT * FROM `authcodes` WHERE `ipaddress` = '".$_SERVER['REMOTE_ADDR']."' ORDER BY `id` desc LIMIT 1");
if ($query->num_rows > 0) {
while ($result = $query->fetch_assoc()) {
if (time() - $result['time'] < 60*60*24) {
return true;
} else {
return false;
}
}
} else {
return false;
}
}
function checkSession() {
if (isset($_SESSION['votetime'])) {
if (time() - $_SESSION['votetime'] < 60*60*24) {
return true;
} else {
return false;
}
} else {
return false;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Toomuchpk - Vote</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="vote.js"></script>
</head>
<body>
<table width="75%" border="0" cellpadding="1" align="center" id="box">
<tr>
<noscript><div style="text-align: center; color:red;">YOU DO NOT HAVE JAVASCRIPT ENABLED YOU MAY NOT VOTE.</div></noscript>
<td class="contents">
<h3>Vote for us</h3>
<p>Voting for us each day helps us become more popular each day. How you may think? The more votes we get the higher ranked we are on RuneScape private server lists. The higher we are the more times people may want to click on us and join. So to becomming a great server we need votes to make us stand out from the rest.</p>
<p>We offer an reward for voting us, now we only offer this reward when you vote at all 4 sites below. To do so click each button fill the recaptcha image and vote. Then come back and wait for the timer and then you will be given an Auth code. Use this auth code in-game by doing ::auth authcode to receive your reward.</p>
<noscript><div style="text-align: center; color:red; font-weight: bold;">YOU DO NOT HAVE JAVASCRIPT ENABLED YOU MAY NOT VOTE.</div></noscript>
<?php
if(@fsockopen($_SERVER['REMOTE_ADDR'], 80, $errno, $errstr, 1)) {
echo "<div style=\"text-align:center; color:red;\">Proxy ban. ;-)</div>";
} else if(mysql_num_rows(mysql_query("SELECT * FROM `votes` WHERE `ipaddress` = '" . $_SERVER['REMOTE_ADDR'] . "' LIMIT 1;")) > 0) {
echo "<div style=\"text-align:center; color:red;\"><p>You have already voted in the last 24 hours. But you can get your friends to vote for you, just remember to ask them for the auth code.</div>";
echo "<div align=\"center\"><textarea readonly=\"readonly\" onClick=\"this.focus();this.select();\" style=\"width:315px; height:15px;\">http://toomuchpk.com/vote.php</textarea></div>";
} else if(isset($_POST['confirm'])) {
$voteid = anti_sql($_POST['voteid']);
$give_auth = true;
if($vote_checking) {
$query = mysql_query("SELECT * FROM `tempvotes` WHERE `id` = '".$voteid."'");
if(mysql_num_rows($query) > 0) {
$row = mysql_fetch_array($query);
if($row['voted'] == 1) {
mysql_query("DELETE FROM `tempvotes` WHERE `id`='".$voteid."'");
} else {
$give_auth = false;
echo "<div style=\"text-align:center; color:red;\">It has been detected that you have not actually voted at the websites. Go back and actually vote at the sites. ;-)</div>";
}
}
}
if($give_auth) {
$auth = random_auth();
mysql_query("INSERT INTO `votes` (`time`, `authcode`, `ipaddress`) VALUES('".time()."', '".$auth."', '".$_SERVER['REMOTE_ADDR']."')");
echo "<div style=\"text-align:center; color:yellow;\">Your auth code is ".$auth." type ::auth ".$auth." to receive your reward in-game.</div>";
}
} else {
if($vote_checking) {
$randomid = rand(10000, 20000);
mysql_query("INSERT INTO `tempvotes` (`id`, `time`, `ipaddress`) VALUES('".$randomid."', '".time()."', '".$_SERVER['REMOTE_ADDR']."')");
}
?>
<p>
<div id="vote" align="center">
<form>
<input type="button" value="Vote: <?php echo $vote1['name']; ?>" onclick="window.open('<?php echo $vote1['url']; ?>'); setStatus(1);"/>
<input type="button" value="Vote: <?php echo $vote2['name']; ?>" onclick="window.open('<?php echo $vote2['url']; ?>'); setStatus(2);"/>
<input type="button" value="Vote: <?php echo $vote4['name']; ?>" onclick="window.open('<?php echo $vote4['url']; ?>'); setStatus(4);"/>
<input type="button" value="Vote: <?php echo $vote5['name']; ?>" onclick="window.open('<?php echo $vote5['url']; ?>'); setStatus(5);"/>
</form>
</p>
<div id="votewarning"></div>
<div id="votestatus">
<form method="post" name="voted">
<input type="hidden" name="confirm" value="true"/>
<?php if($vote_checking) { ?>
<input type="hidden" name="voteid" value="<?php echo $randomid; ?>"/>
<?php } ?>
<input type="button" name="reward" value="Reward" onclick="javascript:checkStatus()"/>
</form>
</div>
</form>
</div>
<?php } ?>
</td>
</tr>
</table>
<div id="footer">Copyright © 2011 <a href="http://toomuchpk.com">Tanner</a> <!-- Please leave credits alone. ;-(-->System by <a href="http://toomuchpk.com">Tanner</a>.
</body>
</html>
<?php
function anti_sql($sql)
{
return mysql_real_escape_string($sql);
}
function random_auth()
{
$random = "";
for ($i=0; $i<6; $i++)
{
$d=rand(1,30)%2;
$random .= strtolower($d ? chr(rand(65,90)) : chr(rand(48,57)));
}
return $random;
}
?>