Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F7170606
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/phplib/perm.inc b/phplib/perm.inc
index 4014a39..9c4f682 100644
--- a/phplib/perm.inc
+++ b/phplib/perm.inc
@@ -1,114 +1,113 @@
<?php
/*
* Session Management for PHP3
*
* Copyright (c) 1998,1999 SH Online Dienst GmbH
* Boris Erdmann, Kristian Koehntopp
*
* $Id: perm.inc,v 1.1.1.1 2004-04-29 10:18:10 adigeo Exp $
*
*/
class Perm {
var $classname = "Perm";
## Hash ("Name" => Permission-Bitmask)
var $permissions = array ();
##
## Permission code
##
function check($p) {
global $auth;
if (! $this->have_perm($p)) {
if (! isset($auth->auth["perm"]) ) {
$auth->auth["perm"] = "";
}
$this->perm_invalid($auth->auth["perm"], $p);
exit();
}
}
function have_perm($p) {
global $auth;
if (! isset($auth->auth["perm"]) ) {
$auth->auth["perm"] = "";
}
$pageperm = preg_split("/,/", $p);
$userperm = preg_split("/,/", $auth->auth["perm"]);
list ($ok0, $pagebits) = $this->permsum($pageperm);
list ($ok1, $userbits) = $this->permsum($userperm);
$has_all = (($userbits & $pagebits) == $pagebits);
if (!($has_all && $ok0 && $ok1) ) {
return false;
} else {
return true;
}
}
##
## Permission helpers.
##
function permsum($p) {
global $auth;
if (!is_array($p)) {
return array(false, 0);
}
$perms = $this->permissions;
$r = 0;
- reset($p);
- while(list($key, $val) = each($p)) {
+ foreach($p as $key=>$val) {
if (!isset($perms[$val])) {
return array(false, 0);
}
$r |= $perms[$val];
}
return array(true, $r);
}
## Look for a match within an list of strints
## I couldn't figure out a way to do this generally using ereg().
function perm_islisted($perms, $look_for) {
$permlist = explode( ",", $perms );
- while( list($a,$b) = each($permlist) ) {
+ foreach ($permlist as $a=>$b) {
if( $look_for == $b ) { return true; };
};
return false;
}
## Return a complete <select> tag for permission
## selection.
function perm_sel($name, $current = "", $class = "") {
reset($this->permissions);
- $ret = sprintf("<select multiple size=8 name=\"%s[]\"%s>\n",
+ $ret = sprintf("<select multiple size=10 multiple='multiple' name=\"%s[]\"%s>\n",
$name,
($class!="")?" class=$class":"");
- while(list($k, $v) = each($this->permissions)) {
+ foreach ($this->permissions as $k=>$v) {
$ret .= sprintf(" <option%s%s>%s\n",
$this->perm_islisted($current,$k)?" selected":"",
($class!="")?" class=$class":"",
$k);
}
$ret .= "</select>";
return $ret;
}
##
## Dummy Method. Must be overridden by user.
##
function perm_invalid($does_have, $must_have) {
printf("Access denied.\n");
}
}
?>
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Nov 26, 5:00 AM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3414176
Default Alt Text
(2 KB)
Attached To
Mode
rCDRT CDRTool
Attached
Detach File
Event Timeline
Log In to Comment