Jump to content

Accessibility for each file depending on position declared


surveen

Recommended Posts

Hello All,

 

I have designed a small php module Which has more than 80 .php files. I want to give the access level for all those files through a global access.php file. But i am not getting how it can be developed. I made a table in database which has all the scripts name. When those are checked value 1 it has to be visible for those users who come under a perticular position like MD, CEO, Sales Manager etc. Here is my table structure

 

post-173769-0-24977300-1417588501_thumb.jpg

 

and i tried doing like this 

 

if($_SESSION['pos']=='admin')
{
echo "<h1> SORRY YOU DONT HAVE ACCESS </h1>";
}
else
{
// file contents...
}
 
But this will become manual and also for single position ie 'admin'. 
 
Can somebody show me the path how it has to be structured and how these accessibility can be done.
 
Thanks 
 

You could associate a number with the position (usually called a 'role') and then decide permissions based on that number. For instance, if role 'admin' has a level of 1000 and role 'CEO' has a level of 900, then a page with an access level of 950 will be viewable to admin users but not CEO users. Something like this:

$pageAccessLevel = $queryResults['access_level'];
$userLevel = $_SESSION['role_level'];
if($pageAccessLevel > $userLevel){
	print("<p>You have insufficient rights to view this page. Begone!</p>");
	die();
}
// rest of page script...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.