Beste php'ers,
Ik heb hier een textbased poll en nu zou ik graag willen dat er maar 5 stemmen per minuut kunnen worden uitgebracht.
Weet iemand hoe ik dit kan doen?
Poll.php
<?php
include ("poll.txt");
if ($stem) {
$ip = fopen("ip.php", "r");
@$contents = fread($ip, filesize("ip.php"));
$uip = $REMOTE_ADDR;
if (eregi("$uip", $contents)) {
echo "<b>Je hebt al gestemd!</b><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 "<b>Er is geen poll open</b>"; }
else {
$ip = fopen("ip.php", "r");
@$contents = fread($ip, filesize("ip.php"));
$uip = $REMOTE_ADDR;
if (eregi("$uip", $contents)) {
echo "<b>".stripslashes($vraag)."</b><br>";
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 " <b>".stripslashes($antwoord[$i])."</b><br>\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 (round(($votes[$i] / $totaal) * 100, 1));
echo " </td>\n";
echo " <td>\n";
echo " <img style=\"border: 1 solid #000000\" src=\"orange.gif\" height=\"7\" width= ";
echo (round(($votes[$i] / $totaal) * 100, 1));
echo ' '.$votes[$i].' ';
if ($votes[$i] == "1") { echo "stem"; } else { echo "stemmen"; }
echo "<br>\n";
echo " </td>\n";
echo " </tr>\n";
} }
echo " </table>\n\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n\n";
echo "<font size=\"1\">$totaal ";
if ($totaal == "1") { echo "stem"; } else { echo "stemmen"; }
echo " uitgebracht\n";
} else {
echo "".$vraag."<br>\n";
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
echo " <form name=\"form\" method=\"post\">\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 "<label for=\"$antwoord[$i]\">".stripslashes($antwoord[$i])."</label>";
echo "</td>\n";
echo " </tr>\n";
} }
echo "</table>\n\n";
echo "<input style=\"font-face: verdana; font-size: 9px\" type=submit value=\" Stem! \">\n";
echo "</form>\n\n";
} }
?>
730 views