开发者

Not able to restrict access to a page in php5

I have 2 pages: admin.php and admin_index.php. I have a username and password field in admin.php, which I authenticate using a database. If the user is authenticated, the admin_index.php loads. I added the restrict access page server behaviour to admin_index.php page using dreamweaver cs5. But if I try to directly access the admin_index.php page using the url, I am still able to. The session code for both the pages is right on top of all other stuff and it is:

<?php 
if (!iss开发者_StackOverflow中文版et($_SESSION)) {
session_name("ckfinder");   
session_start();
$_SESSION['site'] = "wildgameservices"; 
} 
?>

Can anyone please point out my mistake?

edit: I have cleared cookies before I test the page each time.

edit: custom code added by dreamweaver for authentication:

<?php
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
// For security, start by assuming the visitor is NOT authorized. 
$isValid = False; 

// When a visitor has logged into this site, the Session variable MM_Username set      
equal to their username. 
// Therefore, we know that a user is NOT logged in if that Session variable is blank. 
if (!empty($UserName)) { 
// Besides being logged in, you may restrict access to only certain users based on an 
ID established when they login. 
// Parse the strings into arrays. 
$arrUsers = Explode(",", $strUsers); 
$arrGroups = Explode(",", $strGroups); 
if (in_array($UserName, $arrUsers)) { 
  $isValid = true; 
} 
// Or, you may restrict access to only certain users based on their username. 
if (in_array($UserGroup, $arrGroups)) { 
  $isValid = true; 
} 
if (($strUsers == "") && true) { 
  $isValid = true; 
} 
} 
return $isValid; 
}

$MM_restrictGoTo = "admin.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers,     

$_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" .    

urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo); 
exit;
}


Don't you need to do an if statement and check for valid session? Something like this maybe

if($_SESSION['site'] != "wildgameservices"){
  return;
  // or exit(); not sure what you want
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜