Login   Register  
PHP Classes
elePHPant
Icontem

File: permissions.class.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Igor Feghali  >  Power 2 Protect  >  permissions.class.php  
File: permissions.class.php
Role: Class source
Content type: text/plain
Description: Power 2 Protect Class
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#####################################
The main class.
################################################# */

class permissions
{
    function 
get($acck,$usertype,$howmany_userst)
    {
        
$i 0;
        
$perm = array();
        
$acc = array();
        
$maxperm pow(2,$howmany_userst) - 1;
        
$howmany_userst--;
        while (
$i <= $howmany_userst)
        {
            
$cod pow(2,$i);
            
$perm[$i] = $cod;
            
$i++;
        }
        
$i $howmany_userst;
        
$j 0;
        while ((
$acck 0) && ($acck <= $maxperm))
        {
            if (
$perm[$i] <= $acck)
            {
                
$acc[$j] = $perm[$i];
                
$acck -= $perm[$i];
                
$j++;
            }
            
$i--;
        }
        
$this->maxper $maxperm;
        
$this->acc $acc;
        
$this->perm $perm;
        foreach (
$acc as $key => $val)
        {
            if (
$val == $usertype)
            {
                return 
true;
            }
        }
    } 
// end of get
// end of class

?>