Ledensysteem fout je kan iets bekijken waar je geen rechten toe hebt
terwijl in admin.php safe_admin.php include staat. iemand een idee. ik heb dit ook met als alleen geregistreerde en admins het mogen bekijken. dat ook al ben je niet ingelogd het toch kan zien.
safe_admin.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
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
<?php
###################################
## PHPMYLOGON: A LOGIN SYSTEM ##
## (c) 2006 Jorik Berkepas ##
## Under the GNU GPL license ##
## [email protected] ##
###################################
// Inlucde this file (safe_admin.php) to let a page only access by admins
include_once("config.php");
include_once("lang/lang_".$lang.".php");
include_once("connect.php");
if(isset($_SESSION['user_id'])) {
// Login ok, set lastactive
$sql = "UPDATE `".$db_tbl."` SET lastactive=NOW() WHERE id='".$_SESSION['user_id']."'";
mysql_query($sql);
if($_SESSION['user_status'] == 1) {
// State ok, ready
}else{
echo $safeadmin_rights;
exit();
}
}else{
if(isset($_COOKIE['cookie_id'])) {
$sql = "SELECT cookie_pass,state FROM `".$db_tbl."` WHERE id='".$_COOKIE['cookie_id']."'";
$query = mysql_query($sql);
$row = mysql_fetch_object($query);
$dbpass = htmlspecialchars($row->cookie_pass);
$dbstatus = htmlspecialchars($row->state);
if($dbpass == $_COOKIE['cookie_pass']) {
$_SESSION['user_id'] = $_COOKIE['cookie_id'];
$_SESSION['user_status'] = $dbstatus;
}else{
setcookie("cookie_id", "", time() - 3600);
setcookie("cookie_pass", "", time() - 3600);
header("Location: login.php");
}
}else{
header("Location: login.php");
}
}
?>
###################################
## PHPMYLOGON: A LOGIN SYSTEM ##
## (c) 2006 Jorik Berkepas ##
## Under the GNU GPL license ##
## [email protected] ##
###################################
// Inlucde this file (safe_admin.php) to let a page only access by admins
include_once("config.php");
include_once("lang/lang_".$lang.".php");
include_once("connect.php");
if(isset($_SESSION['user_id'])) {
// Login ok, set lastactive
$sql = "UPDATE `".$db_tbl."` SET lastactive=NOW() WHERE id='".$_SESSION['user_id']."'";
mysql_query($sql);
if($_SESSION['user_status'] == 1) {
// State ok, ready
}else{
echo $safeadmin_rights;
exit();
}
}else{
if(isset($_COOKIE['cookie_id'])) {
$sql = "SELECT cookie_pass,state FROM `".$db_tbl."` WHERE id='".$_COOKIE['cookie_id']."'";
$query = mysql_query($sql);
$row = mysql_fetch_object($query);
$dbpass = htmlspecialchars($row->cookie_pass);
$dbstatus = htmlspecialchars($row->state);
if($dbpass == $_COOKIE['cookie_pass']) {
$_SESSION['user_id'] = $_COOKIE['cookie_id'];
$_SESSION['user_status'] = $dbstatus;
}else{
setcookie("cookie_id", "", time() - 3600);
setcookie("cookie_pass", "", time() - 3600);
header("Location: login.php");
}
}else{
header("Location: login.php");
}
}
?>
Safe.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
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
<?php
###################################
## PHPMYLOGON: A LOGIN SYSTEM ##
## (c) 2006 Jorik Berkepas ##
## Under the GNU GPL license ##
## [email protected] ##
###################################
// Inlucde this file (safe.php) to let a page only access by members/admins
include_once("config.php");
include_once("lang/lang_".$lang.".php");
include_once("connect.php");
if(isset($_SESSION['user_id'])) {
// Login ok, update last active
$sql = "UPDATE `".$db_tbl."` SET lastactive=NOW() WHERE id='".$_SESSION['user_id']."'";
mysql_query($sql);
}else{
if(isset($_COOKIE['cookie_id'])) {
$sql = "SELECT cookie_pass,state FROM `".$db_tbl."` WHERE id='".$_COOKIE['cookie_id']."'";
$query = mysql_query($sql);
$row = mysql_fetch_object($query);
$dbpass = htmlspecialchars($row->cookie_pass);
$dbstatus = htmlspecialchars($row->state);
if($dbpass == $_COOKIE['cookie_pass']) {
$_SESSION['user_id'] = $_COOKIE['cookie_id'];
$_SESSION['user_status'] = $dbstatus;
}else{
setcookie("cookie_id", "", time() - 3600);
setcookie("cookie_pass", "", time() - 3600);
header("Location: login.php");
}
}else{
header("Location: login.php");
}
}
?>
###################################
## PHPMYLOGON: A LOGIN SYSTEM ##
## (c) 2006 Jorik Berkepas ##
## Under the GNU GPL license ##
## [email protected] ##
###################################
// Inlucde this file (safe.php) to let a page only access by members/admins
include_once("config.php");
include_once("lang/lang_".$lang.".php");
include_once("connect.php");
if(isset($_SESSION['user_id'])) {
// Login ok, update last active
$sql = "UPDATE `".$db_tbl."` SET lastactive=NOW() WHERE id='".$_SESSION['user_id']."'";
mysql_query($sql);
}else{
if(isset($_COOKIE['cookie_id'])) {
$sql = "SELECT cookie_pass,state FROM `".$db_tbl."` WHERE id='".$_COOKIE['cookie_id']."'";
$query = mysql_query($sql);
$row = mysql_fetch_object($query);
$dbpass = htmlspecialchars($row->cookie_pass);
$dbstatus = htmlspecialchars($row->state);
if($dbpass == $_COOKIE['cookie_pass']) {
$_SESSION['user_id'] = $_COOKIE['cookie_id'];
$_SESSION['user_status'] = $dbstatus;
}else{
setcookie("cookie_id", "", time() - 3600);
setcookie("cookie_pass", "", time() - 3600);
header("Location: login.php");
}
}else{
header("Location: login.php");
}
}
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
if(isset($_COOKIE['cookie_id'])) {
$sql = "SELECT cookie_pass,state FROM `".$db_tbl."` WHERE id='".$_COOKIE['cookie_id']."'";
$query = mysql_query($sql);
$row = mysql_fetch_object($query);
$dbpass = htmlspecialchars($row->cookie_pass);
$dbstatus = htmlspecialchars($row->state);
if($dbpass == $_COOKIE['cookie_pass']) {
$_SESSION['user_id'] = $_COOKIE['cookie_id'];
$_SESSION['user_status'] = $dbstatus;
}else{
setcookie("cookie_id", "", time() - 3600);
setcookie("cookie_pass", "", time() - 3600);
header("Location: login.php");
}
}else{
header("Location: login.php");
}
?>
if(isset($_COOKIE['cookie_id'])) {
$sql = "SELECT cookie_pass,state FROM `".$db_tbl."` WHERE id='".$_COOKIE['cookie_id']."'";
$query = mysql_query($sql);
$row = mysql_fetch_object($query);
$dbpass = htmlspecialchars($row->cookie_pass);
$dbstatus = htmlspecialchars($row->state);
if($dbpass == $_COOKIE['cookie_pass']) {
$_SESSION['user_id'] = $_COOKIE['cookie_id'];
$_SESSION['user_status'] = $dbstatus;
}else{
setcookie("cookie_id", "", time() - 3600);
setcookie("cookie_pass", "", time() - 3600);
header("Location: login.php");
}
}else{
header("Location: login.php");
}
?>
moet je natuurlijk wel controleren of iemand ook daadwerkelijk admin is. Want dat doe je nog niet.
Daarnaast wil ik je heel erg aanraden, die cookies niet te gebruiken en zeker geen wachtwoorden en id's erin te zetten, je controleert ook niet of er wel geldige informatie hierin staat, dus is dit zeer sql-injection gevoelig.
Ook heb je geen or die (mysql_error()); bij de uitvoering van je query staan. En waar wijs jij de variabele $db_tbl een waarde toe?
ik heb niet zo veel verstand van php dus ik heb geen idee wat je bedoelt