This is (kind-of) reference implementation for different database back-ends */ function perm_init() { global $dbm,$SCRIPT_FILENAME; $db_file=dirname($SCRIPT_FILENAME)."/.perm"; $dbm = @dba_open($db_file,"c","gdbm"); if ($dbm == 0) { Error("Permission error","Can't open database named $db_file"); exit; } } function perm_end() { global $dbm; dba_close($dbm); } // update #USERS# key with current list of users // input: $users - array of logins function perm_update_users($users) { global $dbm; perm_init(); dba_replace("#USERS#",implode(":",$users),$dbm); perm_end(); } function perm_html_add() { global $dbm; perm_init(); if (dba_exists("#USERS#",$dbm)) { $out=' read
read/write
deny access

'; } perm_end(); return $out; } function perm_html_display($path) { global $dbm; perm_init(); if (dba_exists("#USERS#",$dbm)) { foreach (explode(":",dba_fetch("#USERS#",$dbm)) as $u) { $u = explode("\t",$u); $key=$path.":".$u[0]; if (dba_exists($key,$dbm)) { $out.=''.$u[1].''.dba_fetch($key,$dbm).''; } } } perm_end(); $out.='
'; return $out; } function perm_add($file,$login,$perm) { global $dbm; perm_init(); function inc($key,$perm) { global $dbm; if (dba_exists($key,$dbm)) { foreach (explode(":",dba_fetch($key,dbm)) as $a) { $b = explode("=",$a); if ($b[0] == $perm) $b[1]++; $out[]=$b[0]."=".$b[1]; } } else { $out[]="$perm=1"; } dba_replace($key,implode(":",$out),$dbm); } $f = $file; do { print "$f $perm
\n"; inc("$f:$login",$perm); $f = dirname($f)."/"; } while($f != "//"); perm_end(); } ?>