<?php
include('config.php');
//We check if the ID is defined
if(isset($_GET['id']))
{
$id = intval($_GET['id']);
//We check if the website exists
$req1 = mysql_query('select name from topsite where id="'.$id.'"');
if(mysql_num_rows($req1)>0)
{
$req1 = mysql_fetch_array($req1);
if(isset($_POST['confirmation']) and $_POST['confirmation']=='true')
{
setcookie('topsitevote_'.$id, 'true', time()+3600);
}
?>
<!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" />
<link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
<title>Vote for "<?php echo htmlentities($req1['nom']); ?>"</title>
</head>
<body>
<div class="header">
<a href="<?php echo $url_topsite; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Top site" /></a>
</div>
<div class="content">
<?php
//We check if the user has already voted
if(isset($_COOKIE['topsitevote_'.$id]))
{
echo 'Vous ne pouvez voter qu\'une fois par heure et par site.';
}
else
{
//If the vote has been confirmed
if(isset($_POST['confirmation']) and $_POST['confirmation']=='true')
{
//We add the vote
if(mysql_query('update topsite set votes=votes+1 where id="'.$id.'"'))
{
echo '<strong>Your vote has successfully been recorded.</strong>';
}
}
else
{
//We display the form
?>
<form action="vote.php?id=<?php echo $id; ?>" method="post">
<input type="hidden" name="confirmation" value="true" />
Are you sure that you want to vote for "<?php echo htmlentities($req1['name']); ?>"?<br />
<input type="submit" value="Yes" /> <input type="button" value="No" onclick="javascript:history.back();" />
</form>
<?php
}
}
?>
</div>
<div class="foot">
<a href="<?php echo $url_topsite; ?>">Return to the Top site</a> - <a href="http://www.webestools.com/">Webestools</a>
</div>
</body>
</html>
<?php
}
}
?>