if else gek
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
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
<?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")
{
// 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";
$IPBestand = "poll_ips.php";
$ipadres = $REMOTE_ADDR;
include ("$IPBestand");
$gedaan = explode(" ", $gedaan);
$aantal = count ($gedaan);
$watnu = "ja";
for ($tel = 0; $tel < $aantal ; $tel++){
if ($ipadres == $gedaan[$tel]){
$watnu = "";}
}
if ($watnu == "ja"){
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);
include ("$IPBestand");
$file2 = fopen("$IPBestand","w+");
fputs($file2, "<?PHP\n\$gedaan = \"$gedaan $ipadres\";\n?> ");
fclose ($file2);
echo "Bedankt voor uw mening";
}
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<TABLE CELLSPACING=2 CELLPADDING=1 BORDER=1>";
echo "<tr><th>Keuzes</th><th>Percentage</th><th>Aantal stemmen</th></tr>";
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><td> $ANSWER[$key] </td><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\"> $percent_float % </td><td>$file_array[$key]</td></tr>";
}
echo "</TABLE><br>";
} else {
echo"je hebt al gestemt";
}
}
} 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")
{
// 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";
$IPBestand = "poll_ips.php";
$ipadres = $REMOTE_ADDR;
include ("$IPBestand");
$gedaan = explode(" ", $gedaan);
$aantal = count ($gedaan);
$watnu = "ja";
for ($tel = 0; $tel < $aantal ; $tel++){
if ($ipadres == $gedaan[$tel]){
$watnu = "";}
}
if ($watnu == "ja"){
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);
include ("$IPBestand");
$file2 = fopen("$IPBestand","w+");
fputs($file2, "<?PHP\n\$gedaan = \"$gedaan $ipadres\";\n?> ");
fclose ($file2);
echo "Bedankt voor uw mening";
}
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<TABLE CELLSPACING=2 CELLPADDING=1 BORDER=1>";
echo "<tr><th>Keuzes</th><th>Percentage</th><th>Aantal stemmen</th></tr>";
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><td> $ANSWER[$key] </td><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\"> $percent_float % </td><td>$file_array[$key]</td></tr>";
}
echo "</TABLE><br>";
} else {
echo"je hebt al gestemt";
}
}
} else {
echo"<h1>E R R O R</H1>";
}
} else {
echo"<h1>E R R O R</H1>";
}
}
}
?>
wat klopt hier niet?(ik weet dat er heel veel if en else dingen in zitten)
owja op het begin en eind zit een check of je wel ingelogd ben
niemand heeft zeker zin om zo'n script na te kijken
Wat werkt er niet dan? Of wat is de error? Dat zoekt makkelijker op een zondag :P
dit is de script(zonder error en misukte anti meerdere keren stemen):
// Het bestand waarin de resultaten worden opgeslagen
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
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
<?
$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);
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>"; ?>
$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);
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>"; ?>
Gewijzigd op 08/02/2004 18:05:00 door Harm A
In IP blocken vroeg ik dat ook kijk maar ff ;)