<?
 
 
/* #INFO############################################ 
Author: Igor Feghali 
(c) 2003-2006, [email protected] 
---------------------------------------------------- 
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
 
 
?> 
 
 |