<STYLE type=text/css>
TD {
COLOR: #000000; FONT-FAMILY: Verdana, Helvetica, Arial; FONT-SIZE: 11px
}
</style>
<?
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
/********* PHP Voting SYSTEM v1.0 ************
Copyright 2004, Cgixp Team
You have to leave the copyright.
If you have any problem just let us know.
E-mail: mali75850@yahoo.com
Website:
http://www.cgixp.tk**********************************************/
$ficdest1=explode(".",basename($PHP_SELF));
$ficdest="vote/".$ficdest1[0].".dat";
$ip = getenv(REMOTE_ADDR);
if(file_exists($ficdest)) {
$compteur=fopen($ficdest, "r");
$old_stats=file($ficdest);
$stats=explode("|", $old_stats[0]);
fclose($compteur);
$new_count=$stats[0];
$ip_hit=$ip;
}
else {
$nouveau_compteur=fopen($ficdest, "w");
fputs($nouveau_compteur, "0|0|0|0|");
fclose($nouveau_compteur);
}
if (!empty($envoi)&& $note !="") {
$vote=fopen($ficdest, "r");
$old_stats=file($ficdest);
$stats=explode("|", $old_stats[0]);
fclose($vote);
$nbr_votes=$stats[0];
$moy_votes=$stats[1];
if ($stats[3] != $ip) {
$new_count = $stats[0]+1;
if($note=="Good"){
$moy_votes1=$moy_votes+1;
$statical=$stats[2];
}elseif($note=="Bad"){
$statical=$stats[2]+1;
$moy_votes1=$moy_votes;
}
$vote=fopen($ficdest, "w");
$new_stats=fputs($vote, "$new_count|$moy_votes1|$statical|$ip|");
fclose($vote);
echo "<font face=Verdana size=2 color=blue>Thank you for voting</font>";
}
else { echo "<font face=Verdana size=2 color=red>You have already voted</font>";
$vote=fopen($ficdest, "w");
$new_stats=fputs($vote, "$stats[0]|$stats[1]|$stats[2]|$ip|");
fclose($vote);
}
}
?>
<!-- Copyright Cgixp Team Visit
http://www.cgixp.tk to get this script for Free -->
<?php
print ("<form method=post>");
$old_stats=file($ficdest);
$stats=explode("|", $old_stats[0]);
$total=($stats[1]+$stats[2]);
if($total<="0"){
$total="1";
$mtotal="Not yet voted";
}else{
if($total=="1"){$spell="vote";}else{$spell="votes";}
$mtotal="$total $spell";
}
$gpercentage=(($stats[1]/$total)*1000);
$goodp=round(($gpercentage / 10 * 10))/10;
$bpercentage=(($stats[2]/$total)*1000);
$badp=round(($bpercentage / 10 * 10))/10;
echo "<table><tr><td><img src=images/thumbs_up.gif>$goodp %</td><td> </td><td><img src=images/thumbs_down.gif>$badp %</td><td>[$mtotal]</td></tr></table>";
echo"<table><tr><td align=center><img src=images/thumbs_up.gif></td><td><input type=radio name=note value=Good>Good</td>";
echo"<td align=center><img src=images/thumbs_down.gif></td><td><input type=radio name=note value=Bad>Bad</td>";
print ("<td><input type=hidden name=envoi value=1><input type=submit value=Vote style=background:#ffcc00;border-width:1;Border-color:#ffcc00;></td></tr></table></form></font>");
?>
Dette virker fint, bortset fra at man klikker på ratio's i stedet for søjlen når man skal "vote"