$perm){ $perm = $acl[2]; } } //we had a match - return it return $perm; } //get next higher namespace $ns = getNS($ns); if($path != '\*'){ $path = $ns.':\*'; if($path == ':\*') $path = '\*'; }else{ //we did this already //looks like there is something wrong with the ACL //break here return $perm; } }while(1); //this should never loop endless } /** * Create a pronouncable password * * @see: http://www.phpbuilder.com/annotate/message.php3?id=1014451 */ function auth_pwgen(){ $pw = ''; $c = 'bcdfghjklmnprstvwz'; //vowels except hard to speak ones $v = 'aeiou'; //consonants $a = $c.$v; //both //use two syllables... for($i=0;$i < 2; $i++){ $pw .= $c[rand(0, strlen($c)-1)]; $pw .= $v[rand(0, strlen($v)-1)]; $pw .= $a[rand(0, strlen($a)-1)]; } //... and add a nice number $pw .= rand(10,99); return $pw; } /** * If you want to authenticate against something * else then the builtin flatfile auth system * You have to reimplement the "required auth * functions" */ /** * required auth function * * Checks if the given user exists and the given * plaintext password is correct */ function auth_checkPass($user,$pass){ $users = auth_loadUserData(); $pass = md5($pass); //encode pass if($users[$user]['pass'] == $pass){ return true; }else{ return false; } } /** * required auth function * * Checks if the given user is in the given group */ /* function auth_checkGroup($user,$group){ $users = auth_loadUserData(); $pass = md5($pass); //encode pass if(!count($users[$user]['grps'])){ return false; } return in_array($group,$users[$user]['grps']); } */ /** * Required auth function * * Returns info about the given user needs to contain * at least these fields: * * name string full name of the user * mail string email addres of the user * grps array list of groups the user is in */ function auth_getUserData($user){ $users = auth_loadUserData(); return $users[$user]; } /** * used by the plaintext auth functions * loads the user file into a datastructure */ function auth_loadUserData(){ $data = array(); $lines = file('conf/users.auth'); foreach($lines as $line){ $line = preg_replace('/#.*$/','',$line); //ignore comments $line = trim($line); if(empty($line)) continue; $row = split(":",$line,5); $groups = split(",",$row[4]); $data[$row[0]]['pass'] = $row[1]; $data[$row[0]]['name'] = urldecode($row[2]); $data[$row[0]]['mail'] = $row[3]; $data[$row[0]]['grps'] = $groups; } return $data; } function auth_saveUserData($data){ } ?>