Dit is mijn code:
Wanneer iemand stemt met ip adres 172.16.46.367 dan kan iemand met ip adres 172.16.46.36 niet meer stemmen. Het gaat dus telkens om het laatste stukje.
PHP:
<body bgcolor="Ivory" text="Black" link="Black" vlink="Black" alink="Red"> <?
include ("poll.txt");
if ($stem) {
$ip = fopen("ip.php", "r");
$contents = fread($ip, filesize("ip.php"));
$uip = $REMOTE_ADDR;
if (eregi("$uip", $contents)) {
echo "<font face=Tahoma size=2><b>Je hebt al gestemd! Bij de volgende poll mag je weer meedoen.</b></font><br><br>";
}
else {
$ip = fopen("ip.php", "a");
fputs ($ip, "<? //$REMOTE_ADDR ?>\n");
fclose ($ip);
$file = fopen("poll.txt", "w+");
fputs ($file, "<?\n");
fputs ($file, "\$antwoord[0] = \"$antwoord[0]\";\n");
fputs ($file, "\$antwoord[1] = \"$antwoord[1]\";\n");
fputs ($file, "\$antwoord[2] = \"$antwoord[2]\";\n");
fputs ($file, "\$antwoord[3] = \"$antwoord[3]\";\n");
fputs ($file, "\$antwoord[4] = \"$antwoord[4]\";\n");
fputs ($file, "\$antwoord[5] = \"$antwoord[5]\";\n");
fputs ($file, "\$antwoord[6] = \"$antwoord[6]\";\n");
fputs ($file, "\$antwoord[7] = \"$antwoord[7]\";\n");
fputs ($file, "\$antwoord[8] = \"$antwoord[8]\";\n");
fputs ($file, "\$antwoord[9] = \"$antwoord[9]\";\n\n");
if ($stem == $antwoord[0]) { $plusone = $votes[0] + 1; fputs ($file, "\$votes[0] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[0] = \"$votes[0]\";\n"); }
if ($stem == $antwoord[1]) { $plusone = $votes[1] + 1; fputs ($file, "\$votes[1] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[1] = \"$votes[1]\";\n"); }
if ($stem == $antwoord[2]) { $plusone = $votes[2] + 1; fputs ($file, "\$votes[2] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[2] = \"$votes[2]\";\n"); }
if ($stem == $antwoord[3]) { $plusone = $votes[3] + 1; fputs ($file, "\$votes[3] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[3] = \"$votes[3]\";\n"); }
if ($stem == $antwoord[4]) { $plusone = $votes[4] + 1; fputs ($file, "\$votes[4] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[4] = \"$votes[4]\";\n"); }
if ($stem == $antwoord[5]) { $plusone = $votes[5] + 1; fputs ($file, "\$votes[5] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[5] = \"$votes[5]\";\n"); }
if ($stem == $antwoord[6]) { $plusone = $votes[6] + 1; fputs ($file, "\$votes[6] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[6] = \"$votes[6]\";\n"); }
if ($stem == $antwoord[7]) { $plusone = $votes[7] + 1; fputs ($file, "\$votes[7] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[7] = \"$votes[7]\";\n"); }
if ($stem == $antwoord[8]) { $plusone = $votes[8] + 1; fputs ($file, "\$votes[8] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[8] = \"$votes[8]\";\n"); }
if ($stem == $antwoord[9]) { $plusone = $votes[9] + 1; fputs ($file, "\$votes[9] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[9] = \"$votes[9]\";\n"); }
$plusone = $totaal + 1;
fputs ($file, "\$totaal = \"$plusone\";\n");
fputs ($file, "\$vraag = \"$vraag\";\n");
fputs ($file, "?>");
fclose ($file);
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF";
if ($QUERY_STRING) { echo "?$QUERY_STRING\">"; } else { echo "\">"; }
} }
if ($vraag == "") { echo "<font face=Tahoma size=2><br><b>Er is helaas nog geen poll open"; }
else {
$ip = fopen("ip.php", "r");
$contents = fread($ip, filesize("ip.php"));
$uip = $REMOTE_ADDR;
if (eregi("$uip", $contents)) {
echo " <font face=Tahoma size=2><b>$vraag</b> <font size=2>$totaal ";
if ($totaal == "1") { echo "stem"; } else { echo "stemmen"; }
echo " uitgebracht</font>\n\n";
echo "<table cellpadding=0 cellspacing=0 border=0>\n";
echo " <tr>\n";
echo " <td>\n";
for ($i = 0; $i < count($antwoord); $i++) {
if ($antwoord[$i] == "") { echo ""; } else {
echo " <font face=Tahoma size=2>$antwoord[$i]</b><br></font>\n";
} }
echo " </td>\n";
echo " <td valign=top>\n\n";
echo " <table cellpadding=0 cellspacing=0 border=0>\n";
for ($i = 0; $i < count($votes); $i++) {
if ($votes[$i] == "") { echo ""; } else {
echo " <tr>\n";
echo " <td align=right>\n";
echo " <font face=Tahoma size=2>";
echo (round(($votes[$i] / $totaal) * 100, 1));
echo "%</font>\n";
echo " </td>\n";
echo " <td>\n";
echo " <img style=\"border: 1 solid #000000\" src=balk.gif height=7 width=";
echo (round(($votes[$i] / $totaal) * 100, 1));
echo "><font face=Tahoma size=0,5> $votes[$i] ";
if ($votes[$i] == "1") { echo "stem"; } else { echo "stemmen"; }
echo "<br></font>\n";
echo " </td>\n";
echo " </tr>\n";
} }
echo " </table>\n\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n\n";
} else {
echo " <font face=Tahoma size=2><b>$vraag</b><br>\n\n";
echo "<table cellpadding=0 cellspacing=0 border=0>\n";
echo " <form name=form method=post><font face=Tahoma size=2>\n";
for ($i = 0; $i < count($antwoord); $i++) {
if ($antwoord[$i] == "") { echo ""; } else {
echo " <tr>\n";
echo " <td>\n";
echo " <input type=radio name=stem value=\"$antwoord[$i]\" id=\"$antwoord[$i]\">\n";
echo " </td>\n";
echo " <td>";
echo "<font size=2><label for=\"$antwoord[$i]\">$antwoord[$i]</label></font>";
echo "</td>\n";
echo " </tr>\n";
} }
echo "</table>\n\n";
echo "<input style=\"font-face: Tahoma; font-size: 9px\" type=submit value=\" Stem! \">\n";
echo "</form>\n\n";
} }
?>
Wanneer iemand stemt met ip adres 172.16.46.367 dan kan iemand met ip adres 172.16.46.36 niet meer stemmen. Het gaat dus telkens om het laatste stukje.