foute scrijfwijze?
Wat doe ik hier verkeerd. Ik heb een vermoeden dat het te maken heeft met de ", maar ik ben nie zeker.
Gewijzigd op 01/01/1970 01:00:00 door Jvuz
Tip: Gebruik een editor met syntax highlighting, dan zie je veel sneller wat je verkeerd doet.
Gewijzigd op 01/01/1970 01:00:00 door Willem Jan Z
Dat had ik al geprobeerd, maar ik blijf de fout krijgen.
Lijkt me stug..
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
// Config : [ You must set these options ]
$sql_host = "localhost" ; // MySQL host
$sql_user = "user" ; // MySQL username
$sql_pass = "pass" ; // MySQL password
$sql_db = "db" ; // Database name
// End of config //
$link = mysql_connect ($sql_host, $sql_user, $sql_pass) or die("Could not connect : " . mysql_error());
mysql_select_db ($sql_db) or die ("Could not select database '{$sql_db}' .");
$query = "SHOW TABLES FROM $sql_db" ;
$r = mysql_query ($query) or die ("Query failed : " . mysql_error());
$dbase = 0 ;
while ($row = mysql_fetch_row($r)) if ($row[0]=="protect_users") $dbase = 1 ;
if ($dbase != 1)
{
$query = "CREATE TABLE protect_users (id CHAR(20), passwd CHAR(34))" ;
$r = mysql_query($query) or die("Query failed : " . mysql_error());
$pass = crypt('phpclub', 'pc') ;
$query = "INSERT INTO protect_users VALUES ('admin', '{$pass}')";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
}
login_check() ;
if(isset($_GET['logout'])) protect_logout() ;
if($_COOKIE['protect_user']=='admin') protect_admin() ;
/******** Functions : ********/
function login_check()
{
global $link ;
if (!isset($_COOKIE['protect_user']) || !isset($_COOKIE['protect_passwd'])) login_get() ;
$chars = count_chars($_COOKIE['protect_user']) ;
if($chars[0] || $chars[ord("'")]) { setcookie("protect_user", '', time(), '/') ;
die('Alarm !') ; }
$user = addslashes($_COOKIE['protect_user']) ;
$passwd = $_COOKIE['protect_passwd'] ;
$query = "SELECT * FROM protect_users WHERE id = '{$user}'";
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) == 0) login_get() ; // user_not_found()
$row = mysql_fetch_assoc($rr) ;
if($row["passwd"] != $passwd) login_get() ; // password_error()
}
function login_get()
{
if (isset($_POST['user']) && isset($_POST['passwd'])) {
setcookie("protect_user", $_POST['user'], time()+864000, '/') ;
setcookie("protect_passwd", crypt($_POST['passwd'], 'pc'), time()+864000, '/') ;
die("<meta http-equiv='refresh' content='0; url=?'><a href='?'>Wait ...</a>") ;
}
echo "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">" ;
echo '<html xmlns="http://www.w3.org/1999/xhtml">' ;
echo "<head>" ;
echo "<title>Koninklijke Harmonie "De Heren van Zichem"</title>" ;
echo "<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />" ;
echo "<link rel="stylesheet" href="http://www.herenvanzichem.be/pages/style.css" type="text/css" />" ;
echo "<script src="http://www.herenvanzichem.be/pages/script.js" type="text/javascript"></script>" ;
echo "</head>" ;
echo "<body>" ;
echo "<div id="container"><a name="top"></a>" ;
echo "<div id="header">" ;
echo "<img src="http://www.herenvanzichem.be/images/logo.jpg" alt="Koninklijke Harmonie "De Heren van Zichem"" />" ;
echo "</div>" ;
echo "<?php" ;
echo "include "http://www.herenvanzichem.be/pages/menu.php";" ;
echo "?>" ;
echo "<div id="content">" ;
echo "<table width='50%'><tr><td align='center'><table>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td>Username :</td><td><input name='user'></td></tr>" ;
echo "<tr><td>Password :</td><td><input type='password' name='passwd'></td></tr>\r\n" ;
die("<tr><td> </td><td align='center'><input type='submit' name='Login' value='Login'></td></tr></form></table></td></tr></table>") ;
echo "<div id="footer">" ;
echo "2005-2006©Koninklijke Harmonie "De Heren van Zichem"" ;
echo "</div>" ;
echo "</div>" ;
echo "</body>" ;
echo "</html>" ;
}
function protect_admin()
{
echo "<html><head><title>Admin Section</title><style type='text/css'>TD {font-size: 12}</style></head><body><table width='100%'><tr><td align='center'>" ;
if (isset($_POST['add_user']) && isset($_POST['add_passwd'])) add_user($_POST['add_user'], $_POST['add_passwd']) ;
elseif (isset($_POST['chg_user']) && isset($_POST['chg_passwd'])) chg_user($_POST['chg_user'], $_POST['chg_passwd']) ;
elseif (isset($_POST['del_user'])) del_user($_POST['del_user']) ;
elseif (isset($_POST['list_users'])) list_users() ;
echo "<table><form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>Add a New User</b></font></td></tr>" ;
echo "<tr><td>Username :</td><td><input name='add_user'></td></tr>" ;
echo "<tr><td>Password :</td><td><input type='password' name='add_passwd'></td></tr>\r\n" ;
echo "<tr><td> </td><td align='center'><input type='submit' name='add' value='Add'><hr></td></tr></form>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>Change Users Info</b></font></td></tr>" ;
echo "<tr><td>Username :</td><td><input name='chg_user'></td></tr>" ;
echo "<tr><td>New Pass :</td><td><input type='password' name='chg_passwd'></td></tr>\r\n" ;
echo "<tr><td> </td><td align='center'><input type='submit' name='chg' value='Update'><hr></td></tr></form>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>Delete a User</b></font></td></tr>" ;
echo "<tr><td>Username :</td><td><input name='del_user'></td></tr>" ;
echo "<tr><td> </td><td align='center'><input type='submit' name='chg' value='Delete'><hr></td></tr></form>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>List All Users</b></font></td></tr>" ;
echo "<tr><td> </td><td align='center'><input type='hidden' name='list_users' value='1'><input type='submit' name='lst' value='List Users'><hr></td></tr></form>" ;
die("</form></table><hr width=50%>[ <a href='?logout=1'>Logout</a> ]</td></tr></table></body></html>") ;
}
function add_user($u, $p)
{
global $link ;
$chars = count_chars($u) ;
if($chars[0] || $chars[ord("'")] || !$u || !$p) { die('Bad username/password .') ; }
$query = "SELECT * FROM protect_users WHERE id = '{$u}'";
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) != 0) { echo('<font color=red>User already exists .</font><hr width=50%>') ;
return ; }
$pass = crypt($p, 'pc') ;
$query = "INSERT INTO protect_users VALUES ('{$u}', '{$pass}')";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<font color=red>User added .</font><hr width=50%>" ;
}
function chg_user($u, $p)
{
global $link ;
$chars = count_chars($u) ;
if($chars[0] || $chars[ord("'")] || !$u || !$p) { die('Bad username/password .') ; }
$query = "SELECT * FROM protect_users WHERE id = '{$u}'" ;
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) == 0) { echo('<font color=red>User doesnt exist .</font><hr width=50%>') ;
return ; }
$pass = crypt($p, 'pc') ;
$query = "UPDATE protect_users SET passwd = '{$pass}' WHERE id = '{$u}'";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<font color=red>User changed .</font><hr width=50%>" ;
if ($u=='admin') { die("<meta http-equiv='refresh' content='2; url=?'><a href='?'>Wait ...</a>") ; }
}
function del_user($u)
{
global $link ;
if ($u=='admin') die("User 'admin' can not be deleted .") ;
$chars = count_chars($u) ;
if($chars[0] || $chars[ord("'")] || !$u) { die('Bad username .') ; }
$query = "SELECT * FROM protect_users WHERE id = '{$u}'" ;
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) == 0) { echo('<font color=red>User doesnt exist .</font><hr width=50%>') ;
return ; }
$query = "DELETE FROM protect_users WHERE id = '{$u}'";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<font color=red>User deleted .</font><hr width=50%>" ;
}
function list_users()
{
global $link ;
$query = "SELECT id FROM protect_users";
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<table>" ;
while ($id = mysql_fetch_row($rr)) echo "<tr><td><font color=red>{$id[0]}</font></td></tr>" ;
echo "</table><hr width=50%>" ;
}
function protect_logout()
{
setcookie("protect_user", '', time(), '/') ;
setcookie("protect_passwd", '', time(), '/') ;
die("<center><font size=-1>Logged out .<br> [ <a href='javascript:history.back(1)'>Back</a> ]") ;
}
?>
// Config : [ You must set these options ]
$sql_host = "localhost" ; // MySQL host
$sql_user = "user" ; // MySQL username
$sql_pass = "pass" ; // MySQL password
$sql_db = "db" ; // Database name
// End of config //
$link = mysql_connect ($sql_host, $sql_user, $sql_pass) or die("Could not connect : " . mysql_error());
mysql_select_db ($sql_db) or die ("Could not select database '{$sql_db}' .");
$query = "SHOW TABLES FROM $sql_db" ;
$r = mysql_query ($query) or die ("Query failed : " . mysql_error());
$dbase = 0 ;
while ($row = mysql_fetch_row($r)) if ($row[0]=="protect_users") $dbase = 1 ;
if ($dbase != 1)
{
$query = "CREATE TABLE protect_users (id CHAR(20), passwd CHAR(34))" ;
$r = mysql_query($query) or die("Query failed : " . mysql_error());
$pass = crypt('phpclub', 'pc') ;
$query = "INSERT INTO protect_users VALUES ('admin', '{$pass}')";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
}
login_check() ;
if(isset($_GET['logout'])) protect_logout() ;
if($_COOKIE['protect_user']=='admin') protect_admin() ;
/******** Functions : ********/
function login_check()
{
global $link ;
if (!isset($_COOKIE['protect_user']) || !isset($_COOKIE['protect_passwd'])) login_get() ;
$chars = count_chars($_COOKIE['protect_user']) ;
if($chars[0] || $chars[ord("'")]) { setcookie("protect_user", '', time(), '/') ;
die('Alarm !') ; }
$user = addslashes($_COOKIE['protect_user']) ;
$passwd = $_COOKIE['protect_passwd'] ;
$query = "SELECT * FROM protect_users WHERE id = '{$user}'";
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) == 0) login_get() ; // user_not_found()
$row = mysql_fetch_assoc($rr) ;
if($row["passwd"] != $passwd) login_get() ; // password_error()
}
function login_get()
{
if (isset($_POST['user']) && isset($_POST['passwd'])) {
setcookie("protect_user", $_POST['user'], time()+864000, '/') ;
setcookie("protect_passwd", crypt($_POST['passwd'], 'pc'), time()+864000, '/') ;
die("<meta http-equiv='refresh' content='0; url=?'><a href='?'>Wait ...</a>") ;
}
echo "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">" ;
echo '<html xmlns="http://www.w3.org/1999/xhtml">' ;
echo "<head>" ;
echo "<title>Koninklijke Harmonie "De Heren van Zichem"</title>" ;
echo "<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />" ;
echo "<link rel="stylesheet" href="http://www.herenvanzichem.be/pages/style.css" type="text/css" />" ;
echo "<script src="http://www.herenvanzichem.be/pages/script.js" type="text/javascript"></script>" ;
echo "</head>" ;
echo "<body>" ;
echo "<div id="container"><a name="top"></a>" ;
echo "<div id="header">" ;
echo "<img src="http://www.herenvanzichem.be/images/logo.jpg" alt="Koninklijke Harmonie "De Heren van Zichem"" />" ;
echo "</div>" ;
echo "<?php" ;
echo "include "http://www.herenvanzichem.be/pages/menu.php";" ;
echo "?>" ;
echo "<div id="content">" ;
echo "<table width='50%'><tr><td align='center'><table>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td>Username :</td><td><input name='user'></td></tr>" ;
echo "<tr><td>Password :</td><td><input type='password' name='passwd'></td></tr>\r\n" ;
die("<tr><td> </td><td align='center'><input type='submit' name='Login' value='Login'></td></tr></form></table></td></tr></table>") ;
echo "<div id="footer">" ;
echo "2005-2006©Koninklijke Harmonie "De Heren van Zichem"" ;
echo "</div>" ;
echo "</div>" ;
echo "</body>" ;
echo "</html>" ;
}
function protect_admin()
{
echo "<html><head><title>Admin Section</title><style type='text/css'>TD {font-size: 12}</style></head><body><table width='100%'><tr><td align='center'>" ;
if (isset($_POST['add_user']) && isset($_POST['add_passwd'])) add_user($_POST['add_user'], $_POST['add_passwd']) ;
elseif (isset($_POST['chg_user']) && isset($_POST['chg_passwd'])) chg_user($_POST['chg_user'], $_POST['chg_passwd']) ;
elseif (isset($_POST['del_user'])) del_user($_POST['del_user']) ;
elseif (isset($_POST['list_users'])) list_users() ;
echo "<table><form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>Add a New User</b></font></td></tr>" ;
echo "<tr><td>Username :</td><td><input name='add_user'></td></tr>" ;
echo "<tr><td>Password :</td><td><input type='password' name='add_passwd'></td></tr>\r\n" ;
echo "<tr><td> </td><td align='center'><input type='submit' name='add' value='Add'><hr></td></tr></form>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>Change Users Info</b></font></td></tr>" ;
echo "<tr><td>Username :</td><td><input name='chg_user'></td></tr>" ;
echo "<tr><td>New Pass :</td><td><input type='password' name='chg_passwd'></td></tr>\r\n" ;
echo "<tr><td> </td><td align='center'><input type='submit' name='chg' value='Update'><hr></td></tr></form>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>Delete a User</b></font></td></tr>" ;
echo "<tr><td>Username :</td><td><input name='del_user'></td></tr>" ;
echo "<tr><td> </td><td align='center'><input type='submit' name='chg' value='Delete'><hr></td></tr></form>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>List All Users</b></font></td></tr>" ;
echo "<tr><td> </td><td align='center'><input type='hidden' name='list_users' value='1'><input type='submit' name='lst' value='List Users'><hr></td></tr></form>" ;
die("</form></table><hr width=50%>[ <a href='?logout=1'>Logout</a> ]</td></tr></table></body></html>") ;
}
function add_user($u, $p)
{
global $link ;
$chars = count_chars($u) ;
if($chars[0] || $chars[ord("'")] || !$u || !$p) { die('Bad username/password .') ; }
$query = "SELECT * FROM protect_users WHERE id = '{$u}'";
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) != 0) { echo('<font color=red>User already exists .</font><hr width=50%>') ;
return ; }
$pass = crypt($p, 'pc') ;
$query = "INSERT INTO protect_users VALUES ('{$u}', '{$pass}')";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<font color=red>User added .</font><hr width=50%>" ;
}
function chg_user($u, $p)
{
global $link ;
$chars = count_chars($u) ;
if($chars[0] || $chars[ord("'")] || !$u || !$p) { die('Bad username/password .') ; }
$query = "SELECT * FROM protect_users WHERE id = '{$u}'" ;
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) == 0) { echo('<font color=red>User doesnt exist .</font><hr width=50%>') ;
return ; }
$pass = crypt($p, 'pc') ;
$query = "UPDATE protect_users SET passwd = '{$pass}' WHERE id = '{$u}'";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<font color=red>User changed .</font><hr width=50%>" ;
if ($u=='admin') { die("<meta http-equiv='refresh' content='2; url=?'><a href='?'>Wait ...</a>") ; }
}
function del_user($u)
{
global $link ;
if ($u=='admin') die("User 'admin' can not be deleted .") ;
$chars = count_chars($u) ;
if($chars[0] || $chars[ord("'")] || !$u) { die('Bad username .') ; }
$query = "SELECT * FROM protect_users WHERE id = '{$u}'" ;
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) == 0) { echo('<font color=red>User doesnt exist .</font><hr width=50%>') ;
return ; }
$query = "DELETE FROM protect_users WHERE id = '{$u}'";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<font color=red>User deleted .</font><hr width=50%>" ;
}
function list_users()
{
global $link ;
$query = "SELECT id FROM protect_users";
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<table>" ;
while ($id = mysql_fetch_row($rr)) echo "<tr><td><font color=red>{$id[0]}</font></td></tr>" ;
echo "</table><hr width=50%>" ;
}
function protect_logout()
{
setcookie("protect_user", '', time(), '/') ;
setcookie("protect_passwd", '', time(), '/') ;
die("<center><font size=-1>Logged out .<br> [ <a href='javascript:history.back(1)'>Back</a> ]") ;
}
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?
echo "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">" ;
echo '<html xmlns="http://www.w3.org/1999/xhtml">' ;
echo "<head>" ;
echo "<title>Koninklijke Harmonie "De Heren van Zichem"</title>" ;
echo "<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />" ;
echo "<link rel="stylesheet" href="http://www.herenvanzichem.be/pages/style.css" type="text/css" />" ;
?>
echo "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">" ;
echo '<html xmlns="http://www.w3.org/1999/xhtml">' ;
echo "<head>" ;
echo "<title>Koninklijke Harmonie "De Heren van Zichem"</title>" ;
echo "<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />" ;
echo "<link rel="stylesheet" href="http://www.herenvanzichem.be/pages/style.css" type="text/css" />" ;
?>
dan moet je daar toch een belletje bij gaan branden..
wes:
dan moet je daar toch een belletje bij gaan branden..
Of een lichtje gaan rinkelen. :)
hier geen menu krijg. En als ik de broncode opvraag, krijg ik alles op één lijn. Hoe kan ik dat oplossen?
Dit zijn de functies:
Hoe komt het dat ik Dit zijn de functies:
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
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
/******** Functions : ********/
function login_check()
{
global $link ;
if (!isset($_COOKIE['protect_user']) || !isset($_COOKIE['protect_passwd'])) login_get() ;
$chars = count_chars($_COOKIE['protect_user']) ;
if($chars[0] || $chars[ord("'")]) { setcookie("protect_user", '', time(), '/') ;
die('Alarm !') ; }
$user = addslashes($_COOKIE['protect_user']) ;
$passwd = $_COOKIE['protect_passwd'] ;
$query = "SELECT * FROM protect_users WHERE id = '{$user}'";
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) == 0) login_get() ; // user_not_found()
$row = mysql_fetch_assoc($rr) ;
if($row["passwd"] != $passwd) login_get() ; // password_error()
}
function login_get()
{
if (isset($_POST['user']) && isset($_POST['passwd'])) {
setcookie("protect_user", $_POST['user'], time()+864000, '/') ;
setcookie("protect_passwd", crypt($_POST['passwd'], 'pc'), time()+864000, '/') ;
die("<meta http-equiv='refresh' content='0; url=?'><a href='?'>Wait ...</a>") ;
}
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ;
echo '<html xmlns="http://www.w3.org/1999/xhtml">' ;
echo '<head>' ;
echo '<title>Koninklijke Harmonie "De Heren van Zichem"</title>' ;
echo '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />' ;
echo '<link rel="stylesheet" href="http://www.herenvanzichem.be/pages/style.css" type="text/css" />' ;
echo '<script src="http://www.herenvanzichem.be/pages/script.js" type="text/javascript"></script>' ;
echo '</head>' ;
echo '<body>' ;
echo '<div id="container"><a name="top"></a>' ;
echo '<div id="header">' ;
echo '<img src="http://www.herenvanzichem.be/images/logo.jpg" alt="Koninklijke Harmonie "De Heren van Zichem"" /><br />' ;
echo '</div>' ;
echo '<?php include "http://www.herenvanzichem.be/pages/menu.php";?>' ;
echo '<div id="content"><br />' ;
echo '<table width="50%"><tr><td align="center"><table><br />' ;
echo '<form action="?" method="post"><br />' ;
echo '<tr><td>Username :</td><td><input name="user"></td></tr>' ;
echo '<tr><td>Password :</td><td><input type="password" name="passwd"></td></tr>' ;
die('<tr><td> </td><td align="center"><input type="submit" name="Login" value="Login"></td></tr></form></table></td></tr></table><br />') ;
echo '<div id="footer"><br />' ;
echo '2005-2006©Koninklijke Harmonie "De Heren van Zichem"<br />' ;
echo '</div><br />' ;
echo '</div><br />' ;
echo '</body><br />' ;
echo '</html><br />' ;
}
function protect_admin()
{
echo '<html><head><title>Admin Section</title><style type="text/css">TD {font-size: 12}</style></head><body><table width="100%"><tr><td align="center">' ;
if (isset($_POST['add_user']) && isset($_POST['add_passwd'])) add_user($_POST['add_user'], $_POST['add_passwd']) ;
elseif (isset($_POST['chg_user']) && isset($_POST['chg_passwd'])) chg_user($_POST['chg_user'], $_POST['chg_passwd']) ;
elseif (isset($_POST['del_user'])) del_user($_POST['del_user']) ;
elseif (isset($_POST['list_users'])) list_users() ;
echo "<table><form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>Add a New User</b></font></td></tr>" ;
echo "<tr><td>Username :</td><td><input name='add_user'></td></tr>" ;
echo "<tr><td>Password :</td><td><input type='password' name='add_passwd'></td></tr>\r\n" ;
echo "<tr><td> </td><td align='center'><input type='submit' name='add' value='Add'><hr></td></tr></form>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>Change Users Info</b></font></td></tr>" ;
echo "<tr><td>Username :</td><td><input name='chg_user'></td></tr>" ;
echo "<tr><td>New Pass :</td><td><input type='password' name='chg_passwd'></td></tr>\r\n" ;
echo "<tr><td> </td><td align='center'><input type='submit' name='chg' value='Update'><hr></td></tr></form>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>Delete a User</b></font></td></tr>" ;
echo "<tr><td>Username :</td><td><input name='del_user'></td></tr>" ;
echo "<tr><td> </td><td align='center'><input type='submit' name='chg' value='Delete'><hr></td></tr></form>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>List All Users</b></font></td></tr>" ;
echo "<tr><td> </td><td align='center'><input type='hidden' name='list_users' value='1'><input type='submit' name='lst' value='List Users'><hr></td></tr></form>" ;
die("</form></table><hr width=50%>[ <a href='?logout=1'>Logout</a> ]</td></tr></table></body></html>") ;
}
function add_user($u, $p)
{
global $link ;
$chars = count_chars($u) ;
if($chars[0] || $chars[ord("'")] || !$u || !$p) { die('Bad username/password .') ; }
$query = "SELECT * FROM protect_users WHERE id = '{$u}'";
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) != 0) { echo('<font color=red>User already exists .</font><hr width=50%>') ;
return ; }
$pass = crypt($p, 'pc') ;
$query = "INSERT INTO protect_users VALUES ('{$u}', '{$pass}')";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<font color=red>User added .</font><hr width=50%>" ;
}
function chg_user($u, $p)
{
global $link ;
$chars = count_chars($u) ;
if($chars[0] || $chars[ord("'")] || !$u || !$p) { die('Bad username/password .') ; }
$query = "SELECT * FROM protect_users WHERE id = '{$u}'" ;
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) == 0) { echo('<font color=red>User doesnt exist .</font><hr width=50%>') ;
return ; }
$pass = crypt($p, 'pc') ;
$query = "UPDATE protect_users SET passwd = '{$pass}' WHERE id = '{$u}'";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<font color=red>User changed .</font><hr width=50%>" ;
if ($u=='admin') { die("<meta http-equiv='refresh' content='2; url=?'><a href='?'>Wait ...</a>") ; }
}
function del_user($u)
{
global $link ;
if ($u=='admin') die("User 'admin' can not be deleted .") ;
$chars = count_chars($u) ;
if($chars[0] || $chars[ord("'")] || !$u) { die('Bad username .') ; }
$query = "SELECT * FROM protect_users WHERE id = '{$u}'" ;
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) == 0) { echo('<font color=red>User doesnt exist .</font><hr width=50%>') ;
return ; }
$query = "DELETE FROM protect_users WHERE id = '{$u}'";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<font color=red>User deleted .</font><hr width=50%>" ;
}
function list_users()
{
global $link ;
$query = "SELECT id FROM protect_users";
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<table>" ;
while ($id = mysql_fetch_row($rr)) echo "<tr><td><font color=red>{$id[0]}</font></td></tr>" ;
echo "</table><hr width=50%>" ;
}
function protect_logout()
{
setcookie("protect_user", '', time(), '/') ;
setcookie("protect_passwd", '', time(), '/') ;
die("<center><font size=-1>Logged out .<br> [ <a href='javascript:history.back(1)'>Back</a> ]") ;
}
?>
function login_check()
{
global $link ;
if (!isset($_COOKIE['protect_user']) || !isset($_COOKIE['protect_passwd'])) login_get() ;
$chars = count_chars($_COOKIE['protect_user']) ;
if($chars[0] || $chars[ord("'")]) { setcookie("protect_user", '', time(), '/') ;
die('Alarm !') ; }
$user = addslashes($_COOKIE['protect_user']) ;
$passwd = $_COOKIE['protect_passwd'] ;
$query = "SELECT * FROM protect_users WHERE id = '{$user}'";
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) == 0) login_get() ; // user_not_found()
$row = mysql_fetch_assoc($rr) ;
if($row["passwd"] != $passwd) login_get() ; // password_error()
}
function login_get()
{
if (isset($_POST['user']) && isset($_POST['passwd'])) {
setcookie("protect_user", $_POST['user'], time()+864000, '/') ;
setcookie("protect_passwd", crypt($_POST['passwd'], 'pc'), time()+864000, '/') ;
die("<meta http-equiv='refresh' content='0; url=?'><a href='?'>Wait ...</a>") ;
}
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ;
echo '<html xmlns="http://www.w3.org/1999/xhtml">' ;
echo '<head>' ;
echo '<title>Koninklijke Harmonie "De Heren van Zichem"</title>' ;
echo '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />' ;
echo '<link rel="stylesheet" href="http://www.herenvanzichem.be/pages/style.css" type="text/css" />' ;
echo '<script src="http://www.herenvanzichem.be/pages/script.js" type="text/javascript"></script>' ;
echo '</head>' ;
echo '<body>' ;
echo '<div id="container"><a name="top"></a>' ;
echo '<div id="header">' ;
echo '<img src="http://www.herenvanzichem.be/images/logo.jpg" alt="Koninklijke Harmonie "De Heren van Zichem"" /><br />' ;
echo '</div>' ;
echo '<?php include "http://www.herenvanzichem.be/pages/menu.php";?>' ;
echo '<div id="content"><br />' ;
echo '<table width="50%"><tr><td align="center"><table><br />' ;
echo '<form action="?" method="post"><br />' ;
echo '<tr><td>Username :</td><td><input name="user"></td></tr>' ;
echo '<tr><td>Password :</td><td><input type="password" name="passwd"></td></tr>' ;
die('<tr><td> </td><td align="center"><input type="submit" name="Login" value="Login"></td></tr></form></table></td></tr></table><br />') ;
echo '<div id="footer"><br />' ;
echo '2005-2006©Koninklijke Harmonie "De Heren van Zichem"<br />' ;
echo '</div><br />' ;
echo '</div><br />' ;
echo '</body><br />' ;
echo '</html><br />' ;
}
function protect_admin()
{
echo '<html><head><title>Admin Section</title><style type="text/css">TD {font-size: 12}</style></head><body><table width="100%"><tr><td align="center">' ;
if (isset($_POST['add_user']) && isset($_POST['add_passwd'])) add_user($_POST['add_user'], $_POST['add_passwd']) ;
elseif (isset($_POST['chg_user']) && isset($_POST['chg_passwd'])) chg_user($_POST['chg_user'], $_POST['chg_passwd']) ;
elseif (isset($_POST['del_user'])) del_user($_POST['del_user']) ;
elseif (isset($_POST['list_users'])) list_users() ;
echo "<table><form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>Add a New User</b></font></td></tr>" ;
echo "<tr><td>Username :</td><td><input name='add_user'></td></tr>" ;
echo "<tr><td>Password :</td><td><input type='password' name='add_passwd'></td></tr>\r\n" ;
echo "<tr><td> </td><td align='center'><input type='submit' name='add' value='Add'><hr></td></tr></form>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>Change Users Info</b></font></td></tr>" ;
echo "<tr><td>Username :</td><td><input name='chg_user'></td></tr>" ;
echo "<tr><td>New Pass :</td><td><input type='password' name='chg_passwd'></td></tr>\r\n" ;
echo "<tr><td> </td><td align='center'><input type='submit' name='chg' value='Update'><hr></td></tr></form>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>Delete a User</b></font></td></tr>" ;
echo "<tr><td>Username :</td><td><input name='del_user'></td></tr>" ;
echo "<tr><td> </td><td align='center'><input type='submit' name='chg' value='Delete'><hr></td></tr></form>" ;
echo "<form action='?' method='post'>" ;
echo "<tr><td colspan=2><font color=blue><b>List All Users</b></font></td></tr>" ;
echo "<tr><td> </td><td align='center'><input type='hidden' name='list_users' value='1'><input type='submit' name='lst' value='List Users'><hr></td></tr></form>" ;
die("</form></table><hr width=50%>[ <a href='?logout=1'>Logout</a> ]</td></tr></table></body></html>") ;
}
function add_user($u, $p)
{
global $link ;
$chars = count_chars($u) ;
if($chars[0] || $chars[ord("'")] || !$u || !$p) { die('Bad username/password .') ; }
$query = "SELECT * FROM protect_users WHERE id = '{$u}'";
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) != 0) { echo('<font color=red>User already exists .</font><hr width=50%>') ;
return ; }
$pass = crypt($p, 'pc') ;
$query = "INSERT INTO protect_users VALUES ('{$u}', '{$pass}')";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<font color=red>User added .</font><hr width=50%>" ;
}
function chg_user($u, $p)
{
global $link ;
$chars = count_chars($u) ;
if($chars[0] || $chars[ord("'")] || !$u || !$p) { die('Bad username/password .') ; }
$query = "SELECT * FROM protect_users WHERE id = '{$u}'" ;
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) == 0) { echo('<font color=red>User doesnt exist .</font><hr width=50%>') ;
return ; }
$pass = crypt($p, 'pc') ;
$query = "UPDATE protect_users SET passwd = '{$pass}' WHERE id = '{$u}'";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<font color=red>User changed .</font><hr width=50%>" ;
if ($u=='admin') { die("<meta http-equiv='refresh' content='2; url=?'><a href='?'>Wait ...</a>") ; }
}
function del_user($u)
{
global $link ;
if ($u=='admin') die("User 'admin' can not be deleted .") ;
$chars = count_chars($u) ;
if($chars[0] || $chars[ord("'")] || !$u) { die('Bad username .') ; }
$query = "SELECT * FROM protect_users WHERE id = '{$u}'" ;
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
if (mysql_num_rows($rr) == 0) { echo('<font color=red>User doesnt exist .</font><hr width=50%>') ;
return ; }
$query = "DELETE FROM protect_users WHERE id = '{$u}'";
$r = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<font color=red>User deleted .</font><hr width=50%>" ;
}
function list_users()
{
global $link ;
$query = "SELECT id FROM protect_users";
$rr = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<table>" ;
while ($id = mysql_fetch_row($rr)) echo "<tr><td><font color=red>{$id[0]}</font></td></tr>" ;
echo "</table><hr width=50%>" ;
}
function protect_logout()
{
setcookie("protect_user", '', time(), '/') ;
setcookie("protect_passwd", '', time(), '/') ;
die("<center><font size=-1>Logged out .<br> [ <a href='javascript:history.back(1)'>Back</a> ]") ;
}
?>
broncode verhaal vang je af met /r/n bijv
wes:
broncode verhaal vang je af met /r/n bijv
Andere kant op: \n\r
Code (php)
1
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n\r' ;
jvuz:
Als ik het zo doe
dan krijg ik dit
Code (php)
1
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">nr' ;
Code (php)
1
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\r\n";
Edit: Foutje, " vergeten, dankje SanThe :)
Gewijzigd op 01/01/1970 01:00:00 door Alfred -
Code (php)
1
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n\r";
Gewijzigd op 01/01/1970 01:00:00 door - SanThe -
Wil je dat een probleem toch wordt bekeken dan bijv. gericht een stuk code neerzetten waar jij veronderstelt dat de fout zit.
Hebben we meer code nodig dan vragen we zeker hierom.
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /opt/www/vanattenhovenj/web/www.herenvanzichem.be/pages/login.php on line 81
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /opt/www/vanattenhovenj/web/www.herenvanzichem.be/pages/login.php on line 81
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /opt/www/vanattenhovenj/web/www.herenvanzichem.be/pages/login.php on line 81
jvuz:
Dan krijg ik deze errors:
Warning: Unexpected character in input: '' (ASCII=92) state=1 in /opt/www/vanattenhovenj/web/www.herenvanzichem.be/pages/login.php on line 81
Warning: Unexpected character in input: '' (ASCII=92) state=1 in /opt/www/vanattenhovenj/web/www.herenvanzichem.be/pages/login.php on line 81
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /opt/www/vanattenhovenj/web/www.herenvanzichem.be/pages/login.php on line 81
Warning: Unexpected character in input: '' (ASCII=92) state=1 in /opt/www/vanattenhovenj/web/www.herenvanzichem.be/pages/login.php on line 81
Warning: Unexpected character in input: '' (ASCII=92) state=1 in /opt/www/vanattenhovenj/web/www.herenvanzichem.be/pages/login.php on line 81
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /opt/www/vanattenhovenj/web/www.herenvanzichem.be/pages/login.php on line 81
Neem SanThe zijn code, ik was " " vergeten... SanThe heeft het helemaal juist.. Sorry.
Je echo geeft een plaatje?
include("pages/menu.php");
Edit: En zet error_reporting(E_ALL); bovenin je script, dan zie je waar het fout gaat.
Gewijzigd op 01/01/1970 01:00:00 door - SanThe -
Nee, het lukt niet :(