<?php
$folder="";
$not_access=1;
require('includes.php');

//Do not control for the super admins
if ( (isset($grantedCalls)) 
  && (is_array($grantedCalls)) 
  && (count($grantedCalls)>0) 
  && $_SESSION['general_admin']==0 ) {
        $keySearch = "";
        $pagename = (isset($pagename))  ?   $pagename
                                        :   '';
        //get all tabs for the script 
        for ($i=0;$i<count($grantedCalls);$i++) {
            $keySearch.= "'".$grantedCalls[$i]."',";
        }
        $keySearch = substr($keySearch, 0, strlen($keySearch)-1);
        $DB->getResults($ctrl_scriptAccess,$DB->escape($_SESSION['user_id']),$keySearch);
        if ($DB->nbResults()==0) {
            error_log("User with id ".$_SESSION['user_id']." tried to access file ".$pagename);
            //exit the script if acces restricted
            exit();
        }
        else {
            $DB->freeResults();
        }
}
?>