Dynamic user levels

ianraba
Posts: 34
Joined: 2010-06-24 17:44

Dynamic user levels

Post by ianraba » 2016-12-11 11:15

Hi
I have a system i am developing with the userlevels created by admin and dynamically added to includes/tng/tNG_config.inc.php
all good
however I am trying to get the restrict access code to behave dynamically but at login page i just get 'You must have the proper credentials to access this page. Please login.'
however checking access on non restricted pages i can echo out the user id, access level and email address so the user is actively logged in but just can't access the page with dynamic user levels
I basically have this, Kollection adds the database element below the restrict access code... any ideas? No errors are given
am in development mode, it just refuses access :-)

// Require the MXI classes
require_once ('../includes/mxi/MXI.php');

// Load the tNG classes
require_once('../includes/tng/tNG.inc.php');

// Make unified connection variable
$conn_ammedia = new KT_connection($ammedia, $database_ammedia);

//Start Restrict Access To Page
$restrict = new tNG_RestrictAccess($conn_ammedia, "../");
//Grand Levels: Level
do {
$restrict->addLevel("{$row_userlevel['options_id']}");
$restrict->Execute();
} while ($row_userlevel = mysql_fetch_assoc($userlevel));
//End Restrict Access To Page

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_ammedia, $ammedia);
$query_userlevel = "SELECT * FROM options WHERE options_subid = 1 ORDER BY options_name ASC";
$userlevel = mysql_query($query_userlevel, $ammedia) or die(mysql_error());
$row_userlevel = mysql_fetch_assoc($userlevel);
$totalRows_userlevel = mysql_num_rows($userlevel);

User avatar
Fred
Site Admin
Posts: 491
Joined: 2010-02-15 12:10
Location: Armagh, Northern Ireland
Contact:

Re: Dynamic user levels

Post by Fred » 2016-12-17 16:53

Ian think you have a bit of a mess here.
I think your "$restrict->Execute();" should be outside the loop like this

Code: Select all

//Start Restrict Access To Page
$restrict = new tNG_RestrictAccess($conn_ammedia, "../");
//Grand Levels: Level
do {  
  $restrict->addLevel("{$row_userlevel['options_id']}");
} while ($row_userlevel = mysql_fetch_assoc($userlevel));
  $restrict->Execute();
//End Restrict Access To Page

Post Reply