science-ation/committee_auth.php
james 3deae5e029 Implement authorizaiton for admin/config sections
Use committee members for authorization
Add auth required checks in all admin/config sections
2005-02-16 22:50:43 +00:00

46 lines
1009 B
PHP

<?
$accesscache=array();
function auth_has_access($access="")
{
global $accesscache;
if(in_array($access,$accesscache))
{
if($accesscache[$access]=='Y') return true;
else return false;
}
else
{
$q=mysql_query("SELECT access_admin, access_config, access_super FROM committees_members WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['committee_member_id']."' AND deleted='N'");
$r=mysql_fetch_object($q);
$accesscache['admin']=$r->access_admin;
$accesscache['config']=$r->access_config;
$accesscache['super']=$r->access_super;
switch($access)
{
case "config": if($r->access_config=='Y') return true; break;
case "admin": if($r->access_admin=='Y') return true; break;
case "super": if($r->access_super=='Y') return true; break;
default:
return false;
break;
}
}
return false;
}
function auth_required($access="")
{
global $config;
if(!auth_has_access($access))
header("Location: ".$config['SFIABDIRECTORY']."/committee_login.php");
}
?>