ini_acl.php
Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 uses('controller/components/acl_base');
00033
00034
00035
00036
00037
00038
00039 class INI_ACL extends AclBase {
00040
00041
00042
00043
00044
00045 var $config = null;
00046
00047
00048
00049
00050 function __construct() {
00051 }
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 function check($aro, $aco, $acoAction = null) {
00063 if ($this->config == null) {
00064 $this->config = $this->readConfigFile(CONFIGS . 'acl.ini.php');
00065 }
00066 $aclConfig = $this->config;
00067
00068
00069 if (isset($aclConfig[$aro]['deny'])) {
00070 $userDenies = $this->arrayTrim(explode(",", $aclConfig[$aro]['deny']));
00071
00072 if (array_search($aco, $userDenies)) {
00073
00074 return false;
00075 }
00076 }
00077
00078
00079 if (isset($aclConfig[$aro]['allow'])) {
00080 $userAllows = $this->arrayTrim(explode(",", $aclConfig[$aro]['allow']));
00081
00082 if (array_search($aco, $userAllows)) {
00083
00084 return true;
00085 }
00086 }
00087
00088
00089 if (isset($aclConfig[$aro]['groups'])) {
00090 $userGroups = $this->arrayTrim(explode(",", $aclConfig[$aro]['groups']));
00091
00092 foreach ($userGroups as $group) {
00093
00094 if (array_key_exists($group, $aclConfig)) {
00095
00096 if (isset($aclConfig[$group]['deny'])) {
00097 $groupDenies=$this->arrayTrim(explode(",", $aclConfig[$group]['deny']));
00098
00099 if (array_search($aco, $groupDenies)) {
00100
00101 return false;
00102 }
00103 }
00104
00105
00106 if (isset($aclConfig[$group]['allow'])) {
00107 $groupAllows = $this->arrayTrim(explode(",", $aclConfig[$group]['allow']));
00108
00109 if (array_search($aco, $groupAllows)) {
00110
00111 return true;
00112 }
00113 }
00114 }
00115 }
00116 }
00117
00118
00119
00120 return false;
00121 }
00122
00123
00124
00125
00126
00127
00128
00129 function readConfigFile($fileName) {
00130 $fileLineArray = file($fileName);
00131
00132 foreach ($fileLineArray as $fileLine) {
00133 $dataLine = trim($fileLine);
00134 $firstChar = substr($dataLine, 0, 1);
00135
00136 if ($firstChar != ';' && $dataLine != '') {
00137 if ($firstChar == '[' && substr($dataLine, -1, 1) == ']') {
00138 $sectionName = preg_replace('/[\[\]]/', '', $dataLine);
00139 } else {
00140 $delimiter = strpos($dataLine, '=');
00141
00142 if ($delimiter > 0) {
00143 $key = strtolower(trim(substr($dataLine, 0, $delimiter)));
00144 $value = trim(substr($dataLine, $delimiter + 1));
00145
00146 if (substr($value, 0, 1) == '"' && substr($value, -1) == '"') {
00147 $value = substr($value, 1, -1);
00148 }
00149
00150 $iniSetting[$sectionName][$key]=stripcslashes($value);
00151 } else {
00152 if (!isset($sectionName)) {
00153 $sectionName = '';
00154 }
00155
00156 $iniSetting[$sectionName][strtolower(trim($dataLine))]='';
00157 }
00158 }
00159 } else {
00160 }
00161 }
00162
00163 return $iniSetting;
00164 }
00165
00166
00167
00168
00169
00170
00171
00172 function arrayTrim($array) {
00173 foreach ($array as $key => $value) {
00174 $array[$key] = trim($value);
00175 }
00176 array_unshift($array, "");
00177 return $array;
00178 }
00179 }
00180 ?>