Poll
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
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?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";
} }
?>
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";
} }
?>
Ik wil niet dat 1 persoon 5 keer per minuut kan stemmen, daarvoor zit er overigens al een ip-check op. Maar ik wil dat er totaal maar 5 keer per minuut kan worden gestemd (preventie tegen proxies).