Originally Said By: Ray Borduin
This has to be done a little differently with our extensions. Advanced page access rules are only available in Databridge, but I see you don't own that product.
The easiest solution (if you don't own DataBridge) is to save the same session variables that Dreamweaver login uses so that you can use the old restrict access server behavior based on user group.
They use:
MM_Username and MM_UserGroup
You can add those variable names to the list of saved columns in your login (it doesn't matter which column you use for MM_Username, but save the access group column as MM_UserGroup).
Then you can just use the Adobe Restrict Access to Page server behavior to do access group based page access.
If I understand you sir, do you mean I should the following
1. Restrict access to using Adobe Restrict Access as seen below
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "SuperAdmin,Administrator";
$MM_donotCheckaccess = "false";
// *** 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 == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "errorlogin.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;
}
?>
2. Add those variable names (which are: MM_Username and MM_UserGroup) to the list of saved columns in your login as seen below
<?php
$Authenticate = new WA_MySQLi_Auth($DBMS);
$Authenticate->Action = "authenticate";
$Authenticate->Trigger = ($_SERVER["REQUEST_METHOD"] === "POST");
$Authenticate->Name = "Administrator";
$Authenticate->Table = "admin_login";
$Authenticate->addFilter("user_name", "=", "s", "".((isset($_POST["user_name"]))?$_POST["user_name"]:"") ."");
$Authenticate->addFilter("password", "=", "s", "".((isset($_POST["password"]))?md5($_POST["password"]):"") ."");
$Authenticate->addFilter("level", "=", "s", "".((isset($_POST["level"]))?$_POST["level"]:"") ."");
$Authenticate->storeResult("MM_Username", "MM_Username");
$Authenticate->storeResult("password", "password");
$Authenticate->storeResult("MM_UserGroup", "MM_UserGroup");
$Authenticate->RememberMe = (false);
$Authenticate->SaveLogin = (true);
$Authenticate->AutoReturn = false;
$SuccessRedirect = "dashboard.php";
$FailedRedirect = "errorlogin.php";
if (function_exists("rel2abs")) $SuccessRedirect = $SuccessRedirect?rel2abs($SuccessRedirect,dirname(__FILE__)):"";
if (function_exists("rel2abs")) $FailedRedirect = $FailedRedirect?rel2abs($FailedRedirect,dirname(__FILE__)):"";
$Authenticate->SuccessRedirect = $SuccessRedirect;
$Authenticate->FailRedirect = $FailedRedirect;
$Authenticate->execute();
?
Kindly advice please.
Thank you so much