Question: Page, User access
Moderator: General Moderators
Question: Page, User access
Ok.. basicly this is what i want to do. Restrict page access. Also for each user a differant menu bar is been loaded up. Now i can i put that best. Using database ofcourse. An administrator has the option to asign pages, or menu items to the users.
Well i already have the page access written. So thats not really the problem. Altho i does need some changes ofcourse.. after having the level access put in to all of it.
My problem kinda is how to set up the db up best. Meaning asigning which Menu Items to load up when a certen user logs in.
Thats why i was thinking of unserialize(key_array_exist), assigning MenuItems ids to User ids. than checking them with something like this.
page access looks like this at the moment.
My problem kinda is how to set up the db up best. Meaning asigning which Menu Items to load up when a certen user logs in.
Thats why i was thinking of unserialize(key_array_exist), assigning MenuItems ids to User ids. than checking them with something like this.
Code: Select all
array_key_exists('name', $_COOKIE) ? $_COOKIE['name'] : 'Whatever';page access looks like this at the moment.
Code: Select all
function authenticate($username, $password) {
$dbc = new database( );
$dbc->connect() or die( $dbc->getError() );
global $db;
$sql = mysql_query("SELECT * FROM users WHERE login='$username' AND active='1'");
$data = mysql_fetch_array($sql);
$encrypted_password = $data['password'];
$unique_id = $data['unique_id'];
$password = crypt($password, $encrypted_password);
if ($password == $encrypted_password) {
$date=date("Y-m-d H:i:s");
$dbc->setQuery("UPDATE users SET session='".$_COOKIE['PHPSESSID']."' ,lastlogin='$date' WHERE unique_id='$unique_id'");
$result = $dbc->select("users", array('login'=>"ikk") );
if ($result) {
foreach ($result as $row) {
$_SESSION = array("unique_id"=>$row->unique_id,
"level"=>$row->level,
"valid"=>"yes",
"user"=>$row->login);
}
}
return 1;
}else{
return 0;
}
}