Jump to content

Accessibility for each file depending on position declared


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...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.