poll
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
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
<?php
if ($login == "")
{
echo"<h1>E R R O R</H1>";
} else {
if ($pass == "")
{
echo"<h1>E R R O R</H1>";
} else {
if ($login == "$login")
{
if ($pass == "$pass")
{
$n = "0";
$ips = fopen("ip.txt","a");
$ips = explode("|", $ips);
$ip = $_SERVER['REMOTE_ADDR'];
while ($var[$n] != "") {
if ($var[$n] == $ip){
echo "Je hebt al gestemd";
}
else
{
// Het bestand waarin de resultaten worden opgeslagen
$RESULT_FILE_NAME = "poll_data.txt";
// De vraag
$QUESTION = "Wat vindt u van deze poll?";
// De antwoorden (je mag er zoveel bij zetten als je wilt
$ANSWER = array("Super Goed", "Goed", "Normaal", "Slecht", "Super Slecht");
// De tekst die op de stem knop staat
$STEMTEKST = " stem! ";
// De tekst die op de knop staat om de resultaten te bekijken
$RESULTATENTEKST = " Bekijk de resultaten ";
// De map waarin de plaatjes van het stemmen staan
$IMG_DIR_URL = "vote";
// De tijd in miniseconden dat je moet wachten tot je nog een keer mag stemmen
$REVOTE_TIME = 3600;
// Hieronder hoef je niks te veranderen
if (! $vote && ! $result) {
echo "<FORM METHOD=\"POST\">\n";
echo "$QUESTION<br><br>\n";
while (list($key, $val) = each($ANSWER)) {
echo "<INPUT TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\"> $val<br>\n";
}
echo "<br><INPUT TYPE=\"Submit\" NAME=\"vote\" VALUE=\"$STEMTEKST\" style=\"background-color: #FFFFFF; color: #000000; font-family: Verdana; font-size: 8 pt; border: 1 solid #A1A1A1\">\n";
echo "<INPUT TYPE=\"Submit\" NAME=\"result\" VALUE=\"$RESULTATENTEKST\" style=\"background-color: #FFFFFF; color: #000000; font-family: Verdana; font-size: 8 pt; border: 1 solid #A1A1A1\">\n";
echo "</FORM>";
} else {
$file_array = file($RESULT_FILE_NAME);
if ($answer < count($ANSWER) && $vote) {
if (count($file_array) < count($ANSWER)) {
$file_array = array("0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n");
}
$old_answer = $file_array[$answer];
$old_answer = preg_replace("/\n\r*/", "", $old_answer);
$file_array[$answer] = ($old_answer + 1)."\n";
$file = join('', $file_array);
$fp = fopen("$RESULT_FILE_NAME", "w"); flock($fp, 1);
fputs($fp, $file);
flock($fp, 3);
fclose($fp);
$ip = $_SERVER['REMOTE_ADDR'];
$tekst = "$ip"."|";
$fileips = fopen("ip.txt","a");
fputs($fileips,$tekst);
fclose($fileips);
echo "Bedankt voor uw mening";
}
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<TABLE cellSpacing=0 cellPadding=0 border=0 style=\"border: 1 solid #A1A1A1\">\n";
echo "<tr>\n<th colspan=\"0\" background=\"menutop.jpg\" height=\"16\" valign=\"top\"><font face=\"verdana\" size=\"1\">Keuzes</font></th>\n<th colspan=\"0\" background=\"menutop.jpg\" height=\"16\" valign=\"top\"><font face=\"verdana\" size=\"1\">Percentage</font></th>\n<th colspan=\"0\" background=\"menutop.jpg\" height=\"16\" valign=\"top\"><font face=\"verdana\" size=\"1\">Aantal stemmen</font></th>\n</tr>\n";
while (list($key, $val) = each($ANSWER)) {
$percent = $file_array[$key] * 100 / $total;
$percent_int = floor($percent);
$percent_float = number_format($percent, 1);
$tp += $percent_float;
echo "<tr>\n<td><font face=\"verdana\" size=\"1\"> $ANSWER[$key] </font></td>\n<td><img height=16 src=\"$IMG_DIR_URL/vote_left.gif\"><img height=16 width=\"$percent_int\" src=\"$IMG_DIR_URL/vote_middle.gif\"><img height=16 src=\"$IMG_DIR_URL/vote_right.gif\"><font face=\"verdana\" size=\"1\"> $percent_float % </font></td>\n<td><font face=\"verdana\" size=\"1\">$file_array[$key]</font></td>\n</tr>\n";
}
echo "<tr>\n<th colspan=\"0\" background=\"menubottom.jpg\" height=\"16\" valign=\"top\"><font face=\"verdana\" size=\"1\"> </font></th>\n<th colspan=\"0\" background=\"menubottom.jpg\" height=\"16\" valign=\"top\"><font face=\"verdana\" size=\"1\"> </font></th>\n<th colspan=\"0\" background=\"menubottom.jpg\" height=\"16\" valign=\"top\"><font face=\"verdana\" size=\"1\"> </font></th>\n</tr>\n";
echo "</TABLE><br>";
}
}
} else {
echo"<h1>E R R O R</H1>";
}
} else {
echo"<h1>E R R O R</H1>";
}
}
}
?>
if ($login == "")
{
echo"<h1>E R R O R</H1>";
} else {
if ($pass == "")
{
echo"<h1>E R R O R</H1>";
} else {
if ($login == "$login")
{
if ($pass == "$pass")
{
$n = "0";
$ips = fopen("ip.txt","a");
$ips = explode("|", $ips);
$ip = $_SERVER['REMOTE_ADDR'];
while ($var[$n] != "") {
if ($var[$n] == $ip){
echo "Je hebt al gestemd";
}
else
{
// Het bestand waarin de resultaten worden opgeslagen
$RESULT_FILE_NAME = "poll_data.txt";
// De vraag
$QUESTION = "Wat vindt u van deze poll?";
// De antwoorden (je mag er zoveel bij zetten als je wilt
$ANSWER = array("Super Goed", "Goed", "Normaal", "Slecht", "Super Slecht");
// De tekst die op de stem knop staat
$STEMTEKST = " stem! ";
// De tekst die op de knop staat om de resultaten te bekijken
$RESULTATENTEKST = " Bekijk de resultaten ";
// De map waarin de plaatjes van het stemmen staan
$IMG_DIR_URL = "vote";
// De tijd in miniseconden dat je moet wachten tot je nog een keer mag stemmen
$REVOTE_TIME = 3600;
// Hieronder hoef je niks te veranderen
if (! $vote && ! $result) {
echo "<FORM METHOD=\"POST\">\n";
echo "$QUESTION<br><br>\n";
while (list($key, $val) = each($ANSWER)) {
echo "<INPUT TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\"> $val<br>\n";
}
echo "<br><INPUT TYPE=\"Submit\" NAME=\"vote\" VALUE=\"$STEMTEKST\" style=\"background-color: #FFFFFF; color: #000000; font-family: Verdana; font-size: 8 pt; border: 1 solid #A1A1A1\">\n";
echo "<INPUT TYPE=\"Submit\" NAME=\"result\" VALUE=\"$RESULTATENTEKST\" style=\"background-color: #FFFFFF; color: #000000; font-family: Verdana; font-size: 8 pt; border: 1 solid #A1A1A1\">\n";
echo "</FORM>";
} else {
$file_array = file($RESULT_FILE_NAME);
if ($answer < count($ANSWER) && $vote) {
if (count($file_array) < count($ANSWER)) {
$file_array = array("0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n");
}
$old_answer = $file_array[$answer];
$old_answer = preg_replace("/\n\r*/", "", $old_answer);
$file_array[$answer] = ($old_answer + 1)."\n";
$file = join('', $file_array);
$fp = fopen("$RESULT_FILE_NAME", "w"); flock($fp, 1);
fputs($fp, $file);
flock($fp, 3);
fclose($fp);
$ip = $_SERVER['REMOTE_ADDR'];
$tekst = "$ip"."|";
$fileips = fopen("ip.txt","a");
fputs($fileips,$tekst);
fclose($fileips);
echo "Bedankt voor uw mening";
}
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<TABLE cellSpacing=0 cellPadding=0 border=0 style=\"border: 1 solid #A1A1A1\">\n";
echo "<tr>\n<th colspan=\"0\" background=\"menutop.jpg\" height=\"16\" valign=\"top\"><font face=\"verdana\" size=\"1\">Keuzes</font></th>\n<th colspan=\"0\" background=\"menutop.jpg\" height=\"16\" valign=\"top\"><font face=\"verdana\" size=\"1\">Percentage</font></th>\n<th colspan=\"0\" background=\"menutop.jpg\" height=\"16\" valign=\"top\"><font face=\"verdana\" size=\"1\">Aantal stemmen</font></th>\n</tr>\n";
while (list($key, $val) = each($ANSWER)) {
$percent = $file_array[$key] * 100 / $total;
$percent_int = floor($percent);
$percent_float = number_format($percent, 1);
$tp += $percent_float;
echo "<tr>\n<td><font face=\"verdana\" size=\"1\"> $ANSWER[$key] </font></td>\n<td><img height=16 src=\"$IMG_DIR_URL/vote_left.gif\"><img height=16 width=\"$percent_int\" src=\"$IMG_DIR_URL/vote_middle.gif\"><img height=16 src=\"$IMG_DIR_URL/vote_right.gif\"><font face=\"verdana\" size=\"1\"> $percent_float % </font></td>\n<td><font face=\"verdana\" size=\"1\">$file_array[$key]</font></td>\n</tr>\n";
}
echo "<tr>\n<th colspan=\"0\" background=\"menubottom.jpg\" height=\"16\" valign=\"top\"><font face=\"verdana\" size=\"1\"> </font></th>\n<th colspan=\"0\" background=\"menubottom.jpg\" height=\"16\" valign=\"top\"><font face=\"verdana\" size=\"1\"> </font></th>\n<th colspan=\"0\" background=\"menubottom.jpg\" height=\"16\" valign=\"top\"><font face=\"verdana\" size=\"1\"> </font></th>\n</tr>\n";
echo "</TABLE><br>";
}
}
} else {
echo"<h1>E R R O R</H1>";
}
} else {
echo"<h1>E R R O R</H1>";
}
}
}
?>
en de foutmelding is... *trommelgeroffel*..
Elwin
}
} <--
} else {
echo"<h1>E R R O R</H1>";
}
} else {
echo"<h1>E R R O R</H1>";
}
}
}
Er moet een } bij.
Dit had je zelf ook heel makkelijk kunnen doen, gewoon kijken wat er gebeurd als je er een } bij of weghaald....
heb je hier ook loginschermpje voor ofzo?
bij dit soort scripts is het misschien ook makkelijker om gewoon een link te geven naar een .phps bestand