Umfrage letzte IP sperren
Möchte nicht nur das der letzte gesperrt wird sondern möchte, das jede Ip gesperrt wird, die schon gevotet hat und das eine Fehlermeldung kommt "Sie haben bereits ihr vote abgegeben". Kann mir jemand helfen?
<?
$varia=file("fragen.txt");
$frage=array_pop($varia);
echo "$frage";
echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
$i=0;
while(isset($varia[$i])) {
$j=$i+1;
echo "<input type=\"radio\" name=\"ant\" value=\"$j\">$varia[$i]<br>";
$i++;
}
echo "<input type=\"submit\" value=\"abstimmen\">";
echo "</form>";
$z=file("antworten.txt");
$ant = isset($_POST['ant']) ? $_POST['ant'] : "";
if ($ant!='') {
$lvote=fopen("lastip.txt","r");
$lv=fgets($lvote,255);
fclose($lvote);
$ip = getenv ("REMOTE_ADDR");
if ($lv!=$ip) {
$z[$ant-1]=$z[$ant-1]+1;
$datei=fopen("antworten.txt","w");
foreach ($z as $save) {fputs($datei,chop($save)."\n");}
fclose($datei);
$lvote=fopen("lastip.txt","w");
fputs($lvote,"$ip");
fclose($lvote);
}
}
$laenge=90;
$gesamt=0;
foreach($z as $zahl)
{ $gesamt=$gesamt+$zahl; }
$proz=array();
foreach ($z as $zahl) {
if ($gesamt!=0) {
$p=round($zahl/$gesamt*10000)/100;
array_push($proz,$p);
}
}
$max=1;
foreach ($z as $zahl) {
$zahl=$zahl*10/10;
if($zahl > $max) { $max=$zahl; }
}
$breite=array();
foreach ($z as $zahl)
{
$b=$zahl*$laenge/$max;
array_push($breite,$b);
}
$i=0;
while (isset($z[$i]))
{
echo "$varia[$i]<br>";
echo "<img src=\"balken_blau.gif\" border=\"0\" width=\"$breite[$i]\" height=\"12\" alt=\"$z[$i] Stimmen\">";
$x=$laenge-$breite[$i];
echo "<img src=\"balken_grau.gif\" border=\"0\" width=\"$x\" height=\"12\" alt=\"$z[$i] Stimmen\">";
echo "$proz[$i]%";
echo "<br>";
$i++;
}
echo "<br>Stimmen: $gesamt (100%)";
?>
Danke schon einmal Jackson
Please also mark the comments that contributed to the solution of the article
Content-Key: 67750
Url: https://administrator.de/contentid/67750
Printed on: April 18, 2024 at 11:04 o'clock
4 Comments
Latest comment