PHP Classes
Icontem

File: protect.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Igor Feghali  >  Power 2 Protect  >  protect.php  
File: protect.php
Role: Auxiliary script
Content type: text/plain
Description: Protection script
Class: Power 2 Protect
Restrict user access to pages based on permissions
 

Contents

Class file image Download
<?

/* #INFO############################################
Author: Igor Feghali
(c) 2003-2006, ifeghali@interveritas.net
----------------------------------------------------
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);
// #################################################

?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products