[PHP] Gegevens opslaan
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
151
152
153
154
155
156
157
158
159
160
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
151
152
153
154
155
156
157
158
159
160
<?php
session_start();
//uitlogfunctie
if ($_GET['action'] == "logout")
{
session_unset();
session_destroy();
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF\">";
}
include ("poll.txt");
//sessiezetten
if (isset($_POST['username']) AND isset($_POST['password']) AND $_POST['username'] == "******" AND $_POST['password']== "******")
{
$_SESSION['kotmingelogd'] = 1;
$_SESSION['inlogip'] = $_SERVER['REMOTE_ADDR'];
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF\">";
}
//check op ingelogd zijn
if (isset($_SESSION['kotmingelogd']) AND isset($_SESSION['inlogip']) AND $_SESSION['kotmingelogd'] == 1 AND $_SESSION['inlogip'] == $_SERVER['REMOTE_ADDR'])
{
if (isset($_POST['admin_soort'])) {
if ($_POST['admin_vraag'] == "") { echo "Je hebt geen vraag ingevuld! Ga terug."; }
elseif ($_POST['admin_soort'] == "") { echo "Je hebt geen keuze gemaakt tussen nieuwe poll en poll updaten!"; }
else {
if ($_POST['admin_soort'] == "update") {
$file = fopen("poll.txt","w+");
fputs ($file, "<?\n");
fputs ($file, "\$plaatje[0] = \"".$_POST['admin_plaatje[0]']."\";\n");
fputs ($file, "\$plaatje[1] = \"".$_POST['admin_plaatje[1]']."\";\n");
fputs ($file, "\$plaatje[2] = \"".$_POST['admin_plaatje[2]']."\";\n\n");
fputs ($file, "\$antwoord[0] = \"".$_POST['admin_antwoord[0]']."\";\n");
fputs ($file, "\$antwoord[1] = \"".$_POST['admin_antwoord[1]']."\";\n");
fputs ($file, "\$antwoord[2] = \"".$_POST['admin_antwoord[2]']."\";\n\n");
if ($antwoord[0] == "" AND $_POST['admin_antwoord[0]'] != "") { fputs ($file, "\$votes[0] = \"0\";\n"); } else { fputs ($file, "\$votes[0] = \"$votes[0]\";\n"); }
if ($antwoord[1] == "" AND $_POST['admin_antwoord[1]'] != "") { fputs ($file, "\$votes[1] = \"0\";\n"); } else { fputs ($file, "\$votes[1] = \"$votes[1]\";\n"); }
if ($antwoord[2] == "" AND $_POST['admin_antwoord[2]'] != "") { fputs ($file, "\$votes[2] = \"0\";\n"); } else { fputs ($file, "\$votes[2] = \"$votes[2]\";\n\n"); }
fputs ($file, "\$totaal = \"$totaal\";\n");
fputs ($file, "\$vraag = \"".$_POST['$admin_vraag']."\";\n");
fputs ($file, "?>");
fclose ($file);
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF\">";
}
elseif ($_POST['admin_soort'] == "new") {
$file = fopen("poll.txt","w+");
fputs ($file, "<?\n");
fputs ($file, "\$plaatje[0] = \"".$_POST['admin_plaatje[0]']."\";\n");
fputs ($file, "\$plaatje[1] = \"".$_POST['admin_plaatje[1]']."\";\n");
fputs ($file, "\$plaatje[2] = \"".$_POST['admin_plaatje[2]']."\";\n\n");
fputs ($file, "\$antwoord[0] = \"".$_POST['admin_antwoord[0]']."\";\n");
fputs ($file, "\$antwoord[1] = \"".$_POST['admin_antwoord[1]']."\";\n");
fputs ($file, "\$antwoord[2] = \"".$_POST['admin_antwoord[2]']."\";\n\n");
if ($_POST['admin_antwoord[0]'] == "") { fputs ($file, "\$votes[0] = \"\";\n"); } else { fputs ($file, "\$votes[0] = \"0\";\n"); }
if ($_POST['admin_antwoord[1]'] == "") { fputs ($file, "\$votes[1] = \"\";\n"); } else { fputs ($file, "\$votes[1] = \"0\";\n"); }
if ($_POST['admin_antwoord[2]'] == "") { fputs ($file, "\$votes[2] = \"\";\n"); } else { fputs ($file, "\$votes[2] = \"0\";\n\n"); }
fputs ($file, "\$totaal = \"0\";\n");
fputs ($file, "\$vraag = \"".$_POST['admin_vraag']."\";\n");
fputs ($file, "?>");
fclose ($file);
$file = fopen("ip.php","w+");
fputs ($file, "");
fclose ($file);
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF\">";
}
}
}
elseif ($_GET['clean'] == "ip") {
$file = fopen("ip.php","w+");
fputs ($file, "");
fclose ($file);
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF\">";
}
else
{
echo "Hey, Admin | <a href=\"$PHP_SELF?action=logout\">Logout</a><br><br>\n";
echo "- <a href=\"$PHP_SELF?clean=ip\">Leeg het IP-bestand</a><br><br>\n";
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
echo "<form method=\"post\">\n";
echo "<tr><td><font face=\"verdana\" size=\"1\">Vraag:<br><br></td>\n";
echo " <td> <input size=\"40\" type=\"text\" name=\"admin_vraag\" value=\"$vraag\">
<font size=\"1\">Totaal $totaal stem(men)<br><br></td></tr>\n";
echo "<tr><td><font face=\"verdana\" size=\"1\">Antwoord 1: </td>\n";
echo " <td> <input size=\"30\" type=\"text\" name=\"admin_antwoord[0]\" value=\"".stripslashes($antwoord[0])."\"> <font face=\"verdana\" size=\"1\">Afbeelding:</font><input type=\"text\" name=\"admin_plaatje[0]\" value=\"".stripslashes($plaatje[0])."\"> <font size=\"1\">Stemmen: $votes[0] </td></tr>\n";
echo "<tr><td><font face=\"verdana\" size=\"1\">Antwoord 2: </td>\n";
echo " <td> <input size=\"30\" type=\"text\" name=\"admin_antwoord[1]\" value=\"".stripslashes($antwoord[1])."\"> <font face=\"verdana\" size=\"1\">Afbeelding:</font><input type=\"text\" name=\"admin_plaatje[1]\" value=\"".stripslashes($plaatje[1])."\"> <font size=\"1\">Stemmen: $votes[1] </td></tr>\n";
echo "<tr><td><font face=verdana size=1>Antwoord 3: </td>\n";
echo " <td> <input size=\"30\" type=\"text\" name=\"admin_antwoord[2]\" value=\"".stripslashes($antwoord[2])."\"> <font face=verdana size=\"1\">Afbeelding:</font><input type=\"text\" name=\"admin_plaatje[2]\" value=\"".stripslashes($plaatje[2])."\"> <font size=\"1\">Stemmen: $votes[2] </td></tr>\n";
echo "</table>\n\n";
echo "<br>Geen antwoorden meer? De rest gewoon leeg laten.<br><br>\n\n";
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>\n";
echo "<td><input type=\"radio\" name=\"admin_soort\" value=\"new\"></td><td><font size=\"1\">Een nieuwe poll starten</td></tr>\n";
echo "<tr><td><input type=\"radio\" name=\"admin_soort\" value=\"update\" CHECKED></td><td><font size=\"1\">Deze poll updaten</td></tr></table>\n";
echo "<br><input style=\"font-face: verdana; font-size: 9px\" type=\"submit\" value=\"Verstuur!\">";
}
}
else
{
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
echo " <form method=\"post\">\n";
echo " <tr>\n";
echo " <td>\n";
echo " Gebruikersnaam:\n";
echo " </td>\n";
echo " <td>\n";
echo " <input type=\"text\" name=\"username\">\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>\n";
echo " Wachtwoord:\n";
echo " </td>\n";
echo " <td>\n";
echo " <input type=\"password\" name=\"password\">\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<br><input type=\"submit\" value=\" Login! \">\n";
}
?>
session_start();
//uitlogfunctie
if ($_GET['action'] == "logout")
{
session_unset();
session_destroy();
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF\">";
}
include ("poll.txt");
//sessiezetten
if (isset($_POST['username']) AND isset($_POST['password']) AND $_POST['username'] == "******" AND $_POST['password']== "******")
{
$_SESSION['kotmingelogd'] = 1;
$_SESSION['inlogip'] = $_SERVER['REMOTE_ADDR'];
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF\">";
}
//check op ingelogd zijn
if (isset($_SESSION['kotmingelogd']) AND isset($_SESSION['inlogip']) AND $_SESSION['kotmingelogd'] == 1 AND $_SESSION['inlogip'] == $_SERVER['REMOTE_ADDR'])
{
if (isset($_POST['admin_soort'])) {
if ($_POST['admin_vraag'] == "") { echo "Je hebt geen vraag ingevuld! Ga terug."; }
elseif ($_POST['admin_soort'] == "") { echo "Je hebt geen keuze gemaakt tussen nieuwe poll en poll updaten!"; }
else {
if ($_POST['admin_soort'] == "update") {
$file = fopen("poll.txt","w+");
fputs ($file, "<?\n");
fputs ($file, "\$plaatje[0] = \"".$_POST['admin_plaatje[0]']."\";\n");
fputs ($file, "\$plaatje[1] = \"".$_POST['admin_plaatje[1]']."\";\n");
fputs ($file, "\$plaatje[2] = \"".$_POST['admin_plaatje[2]']."\";\n\n");
fputs ($file, "\$antwoord[0] = \"".$_POST['admin_antwoord[0]']."\";\n");
fputs ($file, "\$antwoord[1] = \"".$_POST['admin_antwoord[1]']."\";\n");
fputs ($file, "\$antwoord[2] = \"".$_POST['admin_antwoord[2]']."\";\n\n");
if ($antwoord[0] == "" AND $_POST['admin_antwoord[0]'] != "") { fputs ($file, "\$votes[0] = \"0\";\n"); } else { fputs ($file, "\$votes[0] = \"$votes[0]\";\n"); }
if ($antwoord[1] == "" AND $_POST['admin_antwoord[1]'] != "") { fputs ($file, "\$votes[1] = \"0\";\n"); } else { fputs ($file, "\$votes[1] = \"$votes[1]\";\n"); }
if ($antwoord[2] == "" AND $_POST['admin_antwoord[2]'] != "") { fputs ($file, "\$votes[2] = \"0\";\n"); } else { fputs ($file, "\$votes[2] = \"$votes[2]\";\n\n"); }
fputs ($file, "\$totaal = \"$totaal\";\n");
fputs ($file, "\$vraag = \"".$_POST['$admin_vraag']."\";\n");
fputs ($file, "?>");
fclose ($file);
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF\">";
}
elseif ($_POST['admin_soort'] == "new") {
$file = fopen("poll.txt","w+");
fputs ($file, "<?\n");
fputs ($file, "\$plaatje[0] = \"".$_POST['admin_plaatje[0]']."\";\n");
fputs ($file, "\$plaatje[1] = \"".$_POST['admin_plaatje[1]']."\";\n");
fputs ($file, "\$plaatje[2] = \"".$_POST['admin_plaatje[2]']."\";\n\n");
fputs ($file, "\$antwoord[0] = \"".$_POST['admin_antwoord[0]']."\";\n");
fputs ($file, "\$antwoord[1] = \"".$_POST['admin_antwoord[1]']."\";\n");
fputs ($file, "\$antwoord[2] = \"".$_POST['admin_antwoord[2]']."\";\n\n");
if ($_POST['admin_antwoord[0]'] == "") { fputs ($file, "\$votes[0] = \"\";\n"); } else { fputs ($file, "\$votes[0] = \"0\";\n"); }
if ($_POST['admin_antwoord[1]'] == "") { fputs ($file, "\$votes[1] = \"\";\n"); } else { fputs ($file, "\$votes[1] = \"0\";\n"); }
if ($_POST['admin_antwoord[2]'] == "") { fputs ($file, "\$votes[2] = \"\";\n"); } else { fputs ($file, "\$votes[2] = \"0\";\n\n"); }
fputs ($file, "\$totaal = \"0\";\n");
fputs ($file, "\$vraag = \"".$_POST['admin_vraag']."\";\n");
fputs ($file, "?>");
fclose ($file);
$file = fopen("ip.php","w+");
fputs ($file, "");
fclose ($file);
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF\">";
}
}
}
elseif ($_GET['clean'] == "ip") {
$file = fopen("ip.php","w+");
fputs ($file, "");
fclose ($file);
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF\">";
}
else
{
echo "Hey, Admin | <a href=\"$PHP_SELF?action=logout\">Logout</a><br><br>\n";
echo "- <a href=\"$PHP_SELF?clean=ip\">Leeg het IP-bestand</a><br><br>\n";
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
echo "<form method=\"post\">\n";
echo "<tr><td><font face=\"verdana\" size=\"1\">Vraag:<br><br></td>\n";
echo " <td> <input size=\"40\" type=\"text\" name=\"admin_vraag\" value=\"$vraag\">
<font size=\"1\">Totaal $totaal stem(men)<br><br></td></tr>\n";
echo "<tr><td><font face=\"verdana\" size=\"1\">Antwoord 1: </td>\n";
echo " <td> <input size=\"30\" type=\"text\" name=\"admin_antwoord[0]\" value=\"".stripslashes($antwoord[0])."\"> <font face=\"verdana\" size=\"1\">Afbeelding:</font><input type=\"text\" name=\"admin_plaatje[0]\" value=\"".stripslashes($plaatje[0])."\"> <font size=\"1\">Stemmen: $votes[0] </td></tr>\n";
echo "<tr><td><font face=\"verdana\" size=\"1\">Antwoord 2: </td>\n";
echo " <td> <input size=\"30\" type=\"text\" name=\"admin_antwoord[1]\" value=\"".stripslashes($antwoord[1])."\"> <font face=\"verdana\" size=\"1\">Afbeelding:</font><input type=\"text\" name=\"admin_plaatje[1]\" value=\"".stripslashes($plaatje[1])."\"> <font size=\"1\">Stemmen: $votes[1] </td></tr>\n";
echo "<tr><td><font face=verdana size=1>Antwoord 3: </td>\n";
echo " <td> <input size=\"30\" type=\"text\" name=\"admin_antwoord[2]\" value=\"".stripslashes($antwoord[2])."\"> <font face=verdana size=\"1\">Afbeelding:</font><input type=\"text\" name=\"admin_plaatje[2]\" value=\"".stripslashes($plaatje[2])."\"> <font size=\"1\">Stemmen: $votes[2] </td></tr>\n";
echo "</table>\n\n";
echo "<br>Geen antwoorden meer? De rest gewoon leeg laten.<br><br>\n\n";
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>\n";
echo "<td><input type=\"radio\" name=\"admin_soort\" value=\"new\"></td><td><font size=\"1\">Een nieuwe poll starten</td></tr>\n";
echo "<tr><td><input type=\"radio\" name=\"admin_soort\" value=\"update\" CHECKED></td><td><font size=\"1\">Deze poll updaten</td></tr></table>\n";
echo "<br><input style=\"font-face: verdana; font-size: 9px\" type=\"submit\" value=\"Verstuur!\">";
}
}
else
{
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
echo " <form method=\"post\">\n";
echo " <tr>\n";
echo " <td>\n";
echo " Gebruikersnaam:\n";
echo " </td>\n";
echo " <td>\n";
echo " <input type=\"text\" name=\"username\">\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>\n";
echo " Wachtwoord:\n";
echo " </td>\n";
echo " <td>\n";
echo " <input type=\"password\" name=\"password\">\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<br><input type=\"submit\" value=\" Login! \">\n";
}
?>
Er zijn nog geen reacties op dit bericht.