| 
<?
 /* #INFO############################################
 Author: Igor Feghali
 (c) 2003-2006, [email protected]
 ----------------------------------------------------
 This file is part of Power 2 Protect Class
 ----------------------------------------------------
 ################################################# */
 
 /* #DESCRIPTION#####################################
 Verifies if logged user has access to the current
 web page. This file must be included in all the
 files you want to protect.
 ################################################# */
 
 // #INCLUDES########################################
 include("config.inc.php");
 include("permissions.class.php");
 // #################################################
 
 // #CHECK SESSION###################################
 if (!isset($_SESSION["usercode"]))
 {
 header("location: ".$location_accessdenied);
 exit;
 }
 // #################################################
 
 // #COUNT THE NUMBER OF USER TYPES##################
 $sql = "select * from $table_usertype";
 $result = mysql_query($sql,$con) or die (mysql_error());
 $howmany_usert = mysql_num_rows($result);
 // #################################################
 
 // #GET THE SETTINGS FOR THE CURRENT PAGE###########
 $sql = "select accesskey from $table_perm where page ='".$PHP_SELF."'";
 $result = mysql_query($sql,$con) or die (mysql_error());
 // #################################################
 
 // #INSTANTIATES CLASS##############################
 $permtable = new permissions;
 // #################################################
 
 // #VERIFY ACCESS ONLY IF WE HAVE PERMISSIONS SET###
 if (mysql_num_rows($result) > 0)
 {
 $row = mysql_fetch_array($result);
 if (!$permtable->get($row["accesskey"],$usertype,$howmany_usert))
 {
 header("location: ".$location_accessdenied);
 exit;
 }
 }
 // #################################################
 
 // #CLEAN UP THE HOUSE##############################
 unset($sql);
 unset($result);
 unset($howmany_usert);
 unset($row);
 unset($permtable);
 // #################################################
 
 ?>
 
 |