JustPaste.it

<?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='' rel="nofollow" title="Style" />
<title>Voter pour "<?php echo htmlentities($req1['nom']); ?>"</title>
</head>
<body>
<div class="header">
<a href=''><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 '<font color="red">Vous ne pouvez voter qu\'une fois par heure et par site.</font>';
}
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>Votre vote a &eacute;t&eacute; enregistr&eacute; avec succ&egrave;s.</strong>';
}
}
else
{
//We display the form
?>
<form action="vote.php?id=<?php echo $id; ?>" method="post">
<input type="hidden" name="confirmation" value="true" />
&Ecirc;tes-vous s&ucirc;r de vouloir voter pour "<?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=''>Retour &agrave; l'accueil</a>
</div>
</body>
</html>
<?php
}
}
?>