PHP Classes

File: permissions.class.php

Recommend this page to a friend!
  Classes of Igor Feghali   Power 2 Protect   permissions.class.php   Download  
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
Author: By
Last change: File was splitted into class code (permissions.class.php) + protect code (protect.php).
Date: 18 years ago
Size: 1,156 bytes
 

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

?>