PHP Code:
<?php
require 'includes/db.php';
if(!($user -> LoggedIn()))
{
header('Location: login.php');
die();
}
$errors = array();
if($cloudflare == true){
$user_ip = $_SERVER["HTTP_CF_CONNECTING_IP"];
}else{
$user_ip = $_SERVER["REMOTE_ADDR"];
}
[MENTION=404551]sEsSiOn[/MENTION]_start();
$username = $_SESSION['username'];
$votesql = $odb -> prepare("SELECT * FROM PS_Website.dbo.votes WHERE UserID = :id");
$votesql -> execute(array(":id" => $username));
$row = $votesql -> fetch();
if($row == NULL){
$ipCheck = $odb -> prepare("SELECT * FROM PS_Website.dbo.votes WHERE UserIp = :ip");
$ipCheck -> execute(array(":ip" => $user_ip));
$ipRow = $ipCheck -> fetch();
if($ipRow != NULL){
if($ipRow['topDate'] != NULL){
$topDate = date("m/d/y h:i:s A", strtotime($ipRow['topDate']));
$topDateNext = date("m/d/y h:i:s A", strtotime($ipRow['topDate'] . " +12 hours"));
if(strtotime(date("m/d/y h:i:s A")) < strtotime($topDateNext)){
$topDisabled = "disabled";
$topTimeTill = $topDateNext;
$topVoted = true;
}else{
$topDisabled = "";
$topTimeTill = "Now";
$topVoted = false;
}
}else{
$topDisabled = "";
$topDate = "Never Voted";
$topTimeTill = "Never Voted";
$topVoted = false;
}
if($ipRow['xtremeDate'] != NULL){
$xtremeDate = date("m/d/y h:i:s A", strtotime($ipRow['xtremeDate']));
$xtremeDateNext = date("m/d/y h:i:s A", strtotime($ipRow['xtremeDate'] . " +12 hours"));
if(strtotime(date("m/d/y h:i:s A")) < strtotime($xtremeDateNext)){
$xtremeDisabled = "disabled";
$xtremeTimeTill = $xtremeDateNext;
$xtremeVoted = true;
}else{
$xtremeDisabled = "";
$xtremeTimeTill = "Now";
$xtremeVoted = false;
}
}else{
$xtremeDisabled = "";
$xtremeDate = "Never Voted";
$xtremeTimeTill = "Never Voted";
$xtremeVoted = false;
}
if($ipRow['oxigenDate'] != NULL){
$oxigenDate = date("m/d/y h:i:s A", strtotime($ipRow['oxigenDate']));
$oxigenDateNext = date("m/d/y h:i:s A", strtotime($ipRow['oxigenDate'] . " +12 hours"));
if(strtotime(date("m/d/y h:i:s A")) < strtotime($oxigenDateNext)){
$oxigenDisabled = "disabled";
$oxigenTimeTill = $oxigenDateNext;
$oxigenVoted = true;
}else{
$oxigenDisabled = "";
$oxigenTimeTill = "Now";
$oxigenVoted = false;
}
}else{
$oxigenDisabled = "";
$oxigenDate = "Never Voted";
$oxigenTimeTill = "Never Voted";
$oxigenVoted = false;
}
}else{
// User Has Never Voted
$topDate = "Never Voted";
$topTimeTill = "Never Voted";
$xtremeDate = "Never Voted";
$xtremeTimeTill = "Never Voted";
$oxigenDate = "Never Voted";
$oxigenTimeTill = "Never Voted";
$topVoted = false;
$xtremeVoted = false;
$oxigenVoted = false;
}
$insertUser = $odb -> prepare("INSERT INTO PS_Website.dbo.votes(UserID,UserIp) VALUES (:username,:ip)");
$insertUser -> execute(array(':username' => $username, ':ip' => '127.0.0.1'));
}else{
if($row['topDate'] != NULL){
$topDate = date("m/d/y h:i:s A", strtotime($row['topDate']));
$topDateNext = date("m/d/y h:i:s A", strtotime($row['topDate'] . " +12 hours"));
if($row['topLink'] == "unclicked"){
$topDisabled = "";
$topTimeTill = "Backlink Unclicked";
$topVoted = false;
}else if(strtotime(date("m/d/y h:i:s A")) < strtotime($topDateNext)){
$topDisabled = "disabled";
$topTimeTill = $topDateNext;
$topVoted = true;
}else{
$topDisabled = "";
$topTimeTill = "Now";
$topVoted = false;
}
}else{
$topDisabled = "";
$topDate = "Never Voted";
$topTimeTill = "Never Voted";
$topVoted = false;
}
if($row['xtremeDate'] != NULL){
$xtremeDate = date("m/d/y h:i:s A", strtotime($row['xtremeDate']));
$xtremeDateNext = date("m/d/y h:i:s A", strtotime($row['xtremeDate'] . " +12 hours"));
if($row['xtremeLink'] == "unclicked"){
$xtremeDisabled = "";
$xtremeTimeTill = "Backlink Unclicked";
$xtremeVoted = false;
}else if(strtotime(date("m/d/y h:i:s A")) < strtotime($xtremeDateNext)){
$xtremeDisabled = "disabled";
$xtremeTimeTill = $xtremeDateNext;
$xtremeVoted = true;
}else{
$xtremeDisabled = "";
$xtremeTimeTill = "Now";
$xtremeVoted = false;
}
}else{
$xtremeDisabled = "";
$xtremeDate = "Never Voted";
$xtremeTimeTill = "Never Voted";
$xtremeVoted = false;
}
if($row['oxigenDate'] != NULL){
$oxigenDate = date("m/d/y h:i:s A", strtotime($row['oxigenDate']));
$oxigenDateNext = date("m/d/y h:i:s A", strtotime($row['oxigenDate'] . " +12 hours"));
if($row['oxigenLink'] == "unclicked"){
$oxigenDisabled = "";
$oxigenTimeTill = "Backlink Unclicked";
$oxigenVoted = false;
}else if(strtotime(date("m/d/y h:i:s A")) < strtotime($oxigenDateNext)){
$oxigenDisabled = "disabled";
$oxigenTimeTill = $oxigenDateNext;
$oxigenVoted = true;
}else{
$oxigenDisabled = "";
$oxigenTimeTill = "Now";
$oxigenVoted = false;
}
}else{
$oxigenDisabled = "";
$oxigenDate = "Never Voted";
$oxigenTimeTill = "Never Voted";
$oxigenVoted = false;
}
}
if(isset($_POST["top_x"], $_POST["top_y"]))
{
if($topVoted != false){
$errors["Voted"] = "You can't vote again!";
}
if(count($errors) == 0) {
// insertUserVote //
$insertVote = $odb -> prepare("UPDATE PS_Website.dbo.votes SET UserIp = :ip, topDate=GETDATE(), topLink = 'unclicked' WHERE UserID = :username");
$insertVote -> execute(array(':ip' => $user_ip, ':username' => $username));
header("Location:".$topURL);
exit;
}
}
if(isset($_POST["xtreme_x"], $_POST["xtreme_y"]))
{
if($xtremeVoted != false){
$errors["Voted"] = "You can't vote again!";
}
if(count($errors) == 0) {
// insertUserVote //
$insertVote = $odb -> prepare("UPDATE PS_Website.dbo.votes SET UserIp = :ip, xtremeDate=GETDATE(), xtremeLink = 'unclicked' WHERE UserID = :username");
$insertVote -> execute(array(':ip' => $user_ip, ':username' => $username));
header("Location:".$xtremeURL);
exit;
}
}
if(isset($_POST["oxigen_x"], $_POST["oxigen_y"]))
{
if($oxigenVoted != false){
$errors["Voted"] = "You can't vote again!";
}
if(count($errors) == 0) {
// insertUserVote //
$insertVote = $odb -> prepare("UPDATE PS_Website.dbo.votes SET UserIp = :ip, oxigenDate=GETDATE(), oxigenLink = 'unclicked' WHERE UserID = :username");
$insertVote -> execute(array(':ip' => $user_ip, ':username' => $username));
header("Location:".$oxigenURL);
exit;
}
}
?>
<!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>
<title>Vote System | KoDusk</title>
<style>
body {
text-align: center;
}
table.vote
{
width:70%;
margin:0 auto;
text-align:center;
}
th.vote, td.vote
{
padding: 5px;
}
table.vote
{
border-collapse: collapse; border-spacing: 0;
}
input[type="image"]:disabled
{
opacity:.5;
cursor:default;
}
</style>
</head>
<body>
<form action="" method="post">
<div style="width:500px; padding:10px;">
<?php
if(count($errors) != 0) {
foreach($errors as $error) {
echo $error;
}
} else {
echo $success;
}
?><left>
<table class="vote">
<tr class="vote">
<td class="vote" colspan="3">
Welcome <?php echo $username; ?> <a href="logout.php">Logout</a>
</td>
</tr>
<tr class="vote">
<td class="vote">Vote Site</td>
<td class="vote">Last voted</td>
<td class="vote">Next vote</td>
</tr>
<tr class="vote">
<td class="vote"><input type="image" name="top" src="images/topofgames.gif" draggable="false" style="-moz-user-select: none;" <?php echo $topDisabled; ?> /></td>
<td class="vote"><?php echo $topDate; ?></td>
<td class="vote"><?php echo $topTimeTill; ?></td>
</tr>
<tr class="vote">
<td class="vote"><input type="image" name="xtreme" src="images/xtremetop100.jpg" draggable="false" style="-moz-user-select: none;" <?php echo $xtremeDisabled; ?> /></td>
<td class="vote"><?php echo $xtremeDate; ?></td>
<td class="vote"><?php echo $xtremeTimeTill; ?></td>
</tr>
<tr class="vote">
<td class="vote"><input type="image" name="oxigen" src="images/oxigentop100.png" draggable="false" style="-moz-user-select: none;" <?php echo $oxigenDisabled; ?> /></td>
<td class="vote"><?php echo $oxigenDate; ?></td>
<td class="vote"><?php echo $oxigenTimeTill; ?></td>
</tr>
<tr class="vote">
<td class="vote" colspan="3">
In order to receive the points after voting, you need to return to our website by clicking on the Simply Shaiya link from the respective voting website.
<br />
</td>
</tr>
</table></left>
</div>
</form>
</body>
</html>
Sorry been busy for a few days With RL.