Page 1 of 1

Question: Page, User access

Posted: Tue Aug 01, 2006 1:43 pm
by ol4pr0
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.

Posted: Tue Aug 01, 2006 1:50 pm
by Luke
are you asking a question?

Posted: Tue Aug 01, 2006 1:53 pm
by thiscatis
i don't think anyone will do that for free :)

If you post some code we might help you out

Posted: Tue Aug 01, 2006 1:57 pm
by ol4pr0
Well yes , i am asking on how i could do that best.

I was thinking about using serialize. than look for array_key_exist but.. maybe there is a better way to do so.


I dont have a code yet. Cuase i am not about to write something dumb and than having to rewrite it again.

Posted: Tue Aug 01, 2006 1:58 pm
by Luke
that is a pretty broad project for one thread... let's do things one at a time... what would you like to do first? Authentication? Database design?

Posted: Tue Aug 01, 2006 2:02 pm
by ol4pr0
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.

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;		
		}   
	}