root / branches / phpBB-3_0_0 / phpBB / includes / auth.php
History | View | Annotate | Download (29.3 kB)
| 1 | 5423 | acydburn | <?php
|
|---|---|---|---|
| 2 | 7736 | acydburn | /**
|
| 3 | 5423 | acydburn | * |
| 4 | 5423 | acydburn | * @package phpBB3 |
| 5 | 7736 | acydburn | * @version $Id$ |
| 6 | 7736 | acydburn | * @copyright (c) 2005 phpBB Group |
| 7 | 7736 | acydburn | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 8 | 5423 | acydburn | * |
| 9 | 5423 | acydburn | */ |
| 10 | 5423 | acydburn | |
| 11 | 5423 | acydburn | /**
|
| 12 | 8146 | acydburn | * @ignore |
| 13 | 8146 | acydburn | */ |
| 14 | 8146 | acydburn | if (!defined('IN_PHPBB')) |
| 15 | 8146 | acydburn | {
|
| 16 | 8146 | acydburn | exit;
|
| 17 | 8146 | acydburn | } |
| 18 | 8146 | acydburn | |
| 19 | 8146 | acydburn | /**
|
| 20 | 6058 | acydburn | * Permission/Auth class |
| 21 | 5423 | acydburn | * @package phpBB3 |
| 22 | 5423 | acydburn | */ |
| 23 | 5423 | acydburn | class auth |
| 24 | 5423 | acydburn | {
|
| 25 | 5423 | acydburn | var $acl = array(); |
| 26 | 5697 | acydburn | var $cache = array(); |
| 27 | 5423 | acydburn | var $acl_options = array(); |
| 28 | 5697 | acydburn | var $acl_forum_ids = false; |
| 29 | 5423 | acydburn | |
| 30 | 5423 | acydburn | /**
|
| 31 | 5423 | acydburn | * Init permissions |
| 32 | 5423 | acydburn | */ |
| 33 | 5423 | acydburn | function acl(&$userdata) |
| 34 | 5423 | acydburn | {
|
| 35 | 5423 | acydburn | global $db, $cache; |
| 36 | 5423 | acydburn | |
| 37 | 5697 | acydburn | $this->acl = $this->cache = $this->acl_options = array(); |
| 38 | 5697 | acydburn | $this->acl_forum_ids = false; |
| 39 | 5423 | acydburn | |
| 40 | 7386 | acydburn | if (($this->acl_options = $cache->get('_acl_options')) === false) |
| 41 | 5423 | acydburn | {
|
| 42 | 8384 | acydburn | $sql = 'SELECT auth_option_id, auth_option, is_global, is_local |
| 43 | 5423 | acydburn | FROM ' . ACL_OPTIONS_TABLE . ' |
| 44 | 5423 | acydburn | ORDER BY auth_option_id';
|
| 45 | 5423 | acydburn | $result = $db->sql_query($sql); |
| 46 | 5423 | acydburn | |
| 47 | 5423 | acydburn | $global = $local = 0; |
| 48 | 5920 | acydburn | $this->acl_options = array(); |
| 49 | 5423 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 50 | 5423 | acydburn | {
|
| 51 | 5423 | acydburn | if ($row['is_global']) |
| 52 | 5423 | acydburn | {
|
| 53 | 5423 | acydburn | $this->acl_options['global'][$row['auth_option']] = $global++; |
| 54 | 5423 | acydburn | } |
| 55 | 5423 | acydburn | |
| 56 | 5423 | acydburn | if ($row['is_local']) |
| 57 | 5423 | acydburn | {
|
| 58 | 5423 | acydburn | $this->acl_options['local'][$row['auth_option']] = $local++; |
| 59 | 5423 | acydburn | } |
| 60 | 8384 | acydburn | |
| 61 | 8384 | acydburn | $this->acl_options['id'][$row['auth_option']] = (int) $row['auth_option_id']; |
| 62 | 8384 | acydburn | $this->acl_options['option'][(int) $row['auth_option_id']] = $row['auth_option']; |
| 63 | 5423 | acydburn | } |
| 64 | 5423 | acydburn | $db->sql_freeresult($result); |
| 65 | 5423 | acydburn | |
| 66 | 7386 | acydburn | $cache->put('_acl_options', $this->acl_options); |
| 67 | 5423 | acydburn | } |
| 68 | 9894 | acydburn | |
| 69 | 9894 | acydburn | if (!trim($userdata['user_permissions'])) |
| 70 | 5423 | acydburn | {
|
| 71 | 5423 | acydburn | $this->acl_cache($userdata); |
| 72 | 5423 | acydburn | } |
| 73 | 5423 | acydburn | |
| 74 | 8985 | acydburn | // Fill ACL array
|
| 75 | 8985 | acydburn | $this->_fill_acl($userdata['user_permissions']); |
| 76 | 5423 | acydburn | |
| 77 | 8985 | acydburn | // Verify bitstring length with options provided...
|
| 78 | 8985 | acydburn | $renew = false; |
| 79 | 8985 | acydburn | $global_length = sizeof($this->acl_options['global']); |
| 80 | 8985 | acydburn | $local_length = sizeof($this->acl_options['local']); |
| 81 | 8985 | acydburn | |
| 82 | 8985 | acydburn | // Specify comparing length (bitstring is padded to 31 bits)
|
| 83 | 8985 | acydburn | $global_length = ($global_length % 31) ? ($global_length - ($global_length % 31) + 31) : $global_length; |
| 84 | 8985 | acydburn | $local_length = ($local_length % 31) ? ($local_length - ($local_length % 31) + 31) : $local_length; |
| 85 | 8985 | acydburn | |
| 86 | 8985 | acydburn | // You thought we are finished now? Noooo... now compare them.
|
| 87 | 8985 | acydburn | foreach ($this->acl as $forum_id => $bitstring) |
| 88 | 8985 | acydburn | {
|
| 89 | 8985 | acydburn | if (($forum_id && strlen($bitstring) != $local_length) || (!$forum_id && strlen($bitstring) != $global_length)) |
| 90 | 8985 | acydburn | {
|
| 91 | 8985 | acydburn | $renew = true; |
| 92 | 8985 | acydburn | break;
|
| 93 | 8985 | acydburn | } |
| 94 | 8985 | acydburn | } |
| 95 | 8985 | acydburn | |
| 96 | 8985 | acydburn | // If a bitstring within the list does not match the options, we have a user with incorrect permissions set and need to renew them
|
| 97 | 8985 | acydburn | if ($renew) |
| 98 | 8985 | acydburn | {
|
| 99 | 8985 | acydburn | $this->acl_cache($userdata); |
| 100 | 8985 | acydburn | $this->_fill_acl($userdata['user_permissions']); |
| 101 | 8985 | acydburn | } |
| 102 | 8985 | acydburn | |
| 103 | 8985 | acydburn | return;
|
| 104 | 8985 | acydburn | } |
| 105 | 8985 | acydburn | |
| 106 | 8985 | acydburn | /**
|
| 107 | 8985 | acydburn | * Fill ACL array with relevant bitstrings from user_permissions column |
| 108 | 8985 | acydburn | * @access private |
| 109 | 8985 | acydburn | */ |
| 110 | 8985 | acydburn | function _fill_acl($user_permissions) |
| 111 | 8985 | acydburn | {
|
| 112 | 11115 | git-gate | $seq_cache = array(); |
| 113 | 8985 | acydburn | $this->acl = array(); |
| 114 | 8985 | acydburn | $user_permissions = explode("\n", $user_permissions); |
| 115 | 8985 | acydburn | |
| 116 | 5423 | acydburn | foreach ($user_permissions as $f => $seq) |
| 117 | 5423 | acydburn | {
|
| 118 | 5423 | acydburn | if ($seq) |
| 119 | 5423 | acydburn | {
|
| 120 | 5423 | acydburn | $i = 0; |
| 121 | 5423 | acydburn | |
| 122 | 5486 | acydburn | if (!isset($this->acl[$f])) |
| 123 | 5486 | acydburn | {
|
| 124 | 5486 | acydburn | $this->acl[$f] = ''; |
| 125 | 5486 | acydburn | } |
| 126 | 5486 | acydburn | |
| 127 | 5423 | acydburn | while ($subseq = substr($seq, $i, 6)) |
| 128 | 5423 | acydburn | {
|
| 129 | 11115 | git-gate | if (isset($seq_cache[$subseq])) |
| 130 | 11115 | git-gate | {
|
| 131 | 11115 | git-gate | $converted = $seq_cache[$subseq]; |
| 132 | 11115 | git-gate | } |
| 133 | 11115 | git-gate | else
|
| 134 | 11115 | git-gate | {
|
| 135 | 11115 | git-gate | $converted = $seq_cache[$subseq] = str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT); |
| 136 | 11115 | git-gate | } |
| 137 | 11115 | git-gate | |
| 138 | 5423 | acydburn | // We put the original bitstring into the acl array
|
| 139 | 11115 | git-gate | $this->acl[$f] .= $converted; |
| 140 | 5423 | acydburn | $i += 6; |
| 141 | 5423 | acydburn | } |
| 142 | 5423 | acydburn | } |
| 143 | 5423 | acydburn | } |
| 144 | 5423 | acydburn | } |
| 145 | 5423 | acydburn | |
| 146 | 5423 | acydburn | /**
|
| 147 | 5423 | acydburn | * Look up an option |
| 148 | 5468 | acydburn | * if the option is prefixed with !, then the result becomes negated |
| 149 | 5987 | acydburn | * |
| 150 | 5987 | acydburn | * If a forum id is specified the local option will be combined with a global option if one exist. |
| 151 | 5987 | acydburn | * If a forum id is not specified, only the global option will be checked. |
| 152 | 5423 | acydburn | */ |
| 153 | 5423 | acydburn | function acl_get($opt, $f = 0) |
| 154 | 5423 | acydburn | {
|
| 155 | 5423 | acydburn | $negate = false; |
| 156 | 5423 | acydburn | |
| 157 | 5423 | acydburn | if (strpos($opt, '!') === 0) |
| 158 | 5423 | acydburn | {
|
| 159 | 5423 | acydburn | $negate = true; |
| 160 | 5423 | acydburn | $opt = substr($opt, 1); |
| 161 | 5423 | acydburn | } |
| 162 | 5423 | acydburn | |
| 163 | 5697 | acydburn | if (!isset($this->cache[$f][$opt])) |
| 164 | 5423 | acydburn | {
|
| 165 | 5423 | acydburn | // We combine the global/local option with an OR because some options are global and local.
|
| 166 | 5423 | acydburn | // If the user has the global permission the local one is true too and vice versa
|
| 167 | 5697 | acydburn | $this->cache[$f][$opt] = false; |
| 168 | 5423 | acydburn | |
| 169 | 5423 | acydburn | // Is this option a global permission setting?
|
| 170 | 5423 | acydburn | if (isset($this->acl_options['global'][$opt])) |
| 171 | 5423 | acydburn | {
|
| 172 | 5423 | acydburn | if (isset($this->acl[0])) |
| 173 | 5423 | acydburn | {
|
| 174 | 6808 | acydburn | $this->cache[$f][$opt] = $this->acl[0][$this->acl_options['global'][$opt]]; |
| 175 | 5423 | acydburn | } |
| 176 | 5423 | acydburn | } |
| 177 | 5423 | acydburn | |
| 178 | 5423 | acydburn | // Is this option a local permission setting?
|
| 179 | 5987 | acydburn | // But if we check for a global option only, we won't combine the options...
|
| 180 | 5987 | acydburn | if ($f != 0 && isset($this->acl_options['local'][$opt])) |
| 181 | 5423 | acydburn | {
|
| 182 | 7241 | acydburn | if (isset($this->acl[$f]) && isset($this->acl[$f][$this->acl_options['local'][$opt]])) |
| 183 | 5423 | acydburn | {
|
| 184 | 6808 | acydburn | $this->cache[$f][$opt] |= $this->acl[$f][$this->acl_options['local'][$opt]]; |
| 185 | 5423 | acydburn | } |
| 186 | 5423 | acydburn | } |
| 187 | 5423 | acydburn | } |
| 188 | 7665 | davidmj | |
| 189 | 5423 | acydburn | // Founder always has all global options set to true...
|
| 190 | 5697 | acydburn | return ($negate) ? !$this->cache[$f][$opt] : $this->cache[$f][$opt]; |
| 191 | 5423 | acydburn | } |
| 192 | 5423 | acydburn | |
| 193 | 5423 | acydburn | /**
|
| 194 | 5423 | acydburn | * Get forums with the specified permission setting |
| 195 | 5423 | acydburn | * if the option is prefixed with !, then the result becomes nagated |
| 196 | 5423 | acydburn | * |
| 197 | 5468 | acydburn | * @param bool $clean set to true if only values needs to be returned which are set/unset |
| 198 | 5423 | acydburn | */ |
| 199 | 5423 | acydburn | function acl_getf($opt, $clean = false) |
| 200 | 5423 | acydburn | {
|
| 201 | 5423 | acydburn | $acl_f = array(); |
| 202 | 5423 | acydburn | $negate = false; |
| 203 | 5423 | acydburn | |
| 204 | 5423 | acydburn | if (strpos($opt, '!') === 0) |
| 205 | 5423 | acydburn | {
|
| 206 | 5423 | acydburn | $negate = true; |
| 207 | 5423 | acydburn | $opt = substr($opt, 1); |
| 208 | 5423 | acydburn | } |
| 209 | 5423 | acydburn | |
| 210 | 5486 | acydburn | // If we retrieve a list of forums not having permissions in, we need to get every forum_id
|
| 211 | 5486 | acydburn | if ($negate) |
| 212 | 5486 | acydburn | {
|
| 213 | 5697 | acydburn | if ($this->acl_forum_ids === false) |
| 214 | 5486 | acydburn | {
|
| 215 | 5486 | acydburn | global $db; |
| 216 | 5486 | acydburn | |
| 217 | 8146 | acydburn | $sql = 'SELECT forum_id |
| 218 | 5486 | acydburn | FROM ' . FORUMS_TABLE; |
| 219 | 8985 | acydburn | |
| 220 | 5486 | acydburn | if (sizeof($this->acl)) |
| 221 | 5486 | acydburn | {
|
| 222 | 6271 | acydburn | $sql .= ' WHERE ' . $db->sql_in_set('forum_id', array_keys($this->acl), true); |
| 223 | 5486 | acydburn | } |
| 224 | 5486 | acydburn | $result = $db->sql_query($sql); |
| 225 | 5486 | acydburn | |
| 226 | 5697 | acydburn | $this->acl_forum_ids = array(); |
| 227 | 5486 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 228 | 5486 | acydburn | {
|
| 229 | 5697 | acydburn | $this->acl_forum_ids[] = $row['forum_id']; |
| 230 | 5486 | acydburn | } |
| 231 | 5486 | acydburn | $db->sql_freeresult($result); |
| 232 | 5486 | acydburn | } |
| 233 | 5486 | acydburn | } |
| 234 | 8985 | acydburn | |
| 235 | 5423 | acydburn | if (isset($this->acl_options['local'][$opt])) |
| 236 | 5423 | acydburn | {
|
| 237 | 5423 | acydburn | foreach ($this->acl as $f => $bitstring) |
| 238 | 5423 | acydburn | {
|
| 239 | 5423 | acydburn | // Skip global settings
|
| 240 | 5423 | acydburn | if (!$f) |
| 241 | 5423 | acydburn | {
|
| 242 | 5423 | acydburn | continue;
|
| 243 | 5423 | acydburn | } |
| 244 | 5423 | acydburn | |
| 245 | 5697 | acydburn | $allowed = (!isset($this->cache[$f][$opt])) ? $this->acl_get($opt, $f) : $this->cache[$f][$opt]; |
| 246 | 5423 | acydburn | |
| 247 | 5423 | acydburn | if (!$clean) |
| 248 | 5423 | acydburn | {
|
| 249 | 5423 | acydburn | $acl_f[$f][$opt] = ($negate) ? !$allowed : $allowed; |
| 250 | 5423 | acydburn | } |
| 251 | 5423 | acydburn | else
|
| 252 | 5423 | acydburn | {
|
| 253 | 5423 | acydburn | if (($negate && !$allowed) || (!$negate && $allowed)) |
| 254 | 5423 | acydburn | {
|
| 255 | 5423 | acydburn | $acl_f[$f][$opt] = 1; |
| 256 | 5423 | acydburn | } |
| 257 | 5423 | acydburn | } |
| 258 | 5423 | acydburn | } |
| 259 | 5423 | acydburn | } |
| 260 | 5423 | acydburn | |
| 261 | 5486 | acydburn | // If we get forum_ids not having this permission, we need to fill the remaining parts
|
| 262 | 5697 | acydburn | if ($negate && sizeof($this->acl_forum_ids)) |
| 263 | 5486 | acydburn | {
|
| 264 | 5697 | acydburn | foreach ($this->acl_forum_ids as $f) |
| 265 | 5486 | acydburn | {
|
| 266 | 5486 | acydburn | $acl_f[$f][$opt] = 1; |
| 267 | 5486 | acydburn | } |
| 268 | 5486 | acydburn | } |
| 269 | 5486 | acydburn | |
| 270 | 5423 | acydburn | return $acl_f; |
| 271 | 5423 | acydburn | } |
| 272 | 5423 | acydburn | |
| 273 | 5423 | acydburn | /**
|
| 274 | 5545 | acydburn | * Get local permission state for any forum. |
| 275 | 5545 | acydburn | * |
| 276 | 5545 | acydburn | * Returns true if user has the permission in one or more forums, false if in no forum. |
| 277 | 5545 | acydburn | * If global option is checked it returns the global state (same as acl_get($opt)) |
| 278 | 5545 | acydburn | * Local option has precedence... |
| 279 | 5545 | acydburn | */ |
| 280 | 5545 | acydburn | function acl_getf_global($opt) |
| 281 | 5545 | acydburn | {
|
| 282 | 6681 | acydburn | if (is_array($opt)) |
| 283 | 6681 | acydburn | {
|
| 284 | 6774 | naderman | // evaluates to true as soon as acl_getf_global is true for one option
|
| 285 | 6681 | acydburn | foreach ($opt as $check_option) |
| 286 | 6681 | acydburn | {
|
| 287 | 6774 | naderman | if ($this->acl_getf_global($check_option)) |
| 288 | 6774 | naderman | {
|
| 289 | 6774 | naderman | return true; |
| 290 | 6774 | naderman | } |
| 291 | 6681 | acydburn | } |
| 292 | 6681 | acydburn | |
| 293 | 6774 | naderman | return false; |
| 294 | 6681 | acydburn | } |
| 295 | 6681 | acydburn | |
| 296 | 5545 | acydburn | if (isset($this->acl_options['local'][$opt])) |
| 297 | 5545 | acydburn | {
|
| 298 | 5545 | acydburn | foreach ($this->acl as $f => $bitstring) |
| 299 | 5545 | acydburn | {
|
| 300 | 5545 | acydburn | // Skip global settings
|
| 301 | 5545 | acydburn | if (!$f) |
| 302 | 5545 | acydburn | {
|
| 303 | 5545 | acydburn | continue;
|
| 304 | 5545 | acydburn | } |
| 305 | 5545 | acydburn | |
| 306 | 6774 | naderman | // as soon as the user has any permission we're done so return true
|
| 307 | 6774 | naderman | if ((!isset($this->cache[$f][$opt])) ? $this->acl_get($opt, $f) : $this->cache[$f][$opt]) |
| 308 | 5545 | acydburn | {
|
| 309 | 6774 | naderman | return true; |
| 310 | 5545 | acydburn | } |
| 311 | 5545 | acydburn | } |
| 312 | 5545 | acydburn | } |
| 313 | 5545 | acydburn | else if (isset($this->acl_options['global'][$opt])) |
| 314 | 5545 | acydburn | {
|
| 315 | 6774 | naderman | return $this->acl_get($opt); |
| 316 | 5545 | acydburn | } |
| 317 | 5545 | acydburn | |
| 318 | 6774 | naderman | return false; |
| 319 | 5545 | acydburn | } |
| 320 | 5545 | acydburn | |
| 321 | 5545 | acydburn | /**
|
| 322 | 5423 | acydburn | * Get permission settings (more than one) |
| 323 | 5423 | acydburn | */ |
| 324 | 5423 | acydburn | function acl_gets() |
| 325 | 5423 | acydburn | {
|
| 326 | 5423 | acydburn | $args = func_get_args(); |
| 327 | 5423 | acydburn | $f = array_pop($args); |
| 328 | 5423 | acydburn | |
| 329 | 5423 | acydburn | if (!is_numeric($f)) |
| 330 | 5423 | acydburn | {
|
| 331 | 5423 | acydburn | $args[] = $f; |
| 332 | 5423 | acydburn | $f = 0; |
| 333 | 5423 | acydburn | } |
| 334 | 5423 | acydburn | |
| 335 | 5423 | acydburn | // alternate syntax: acl_gets(array('m_', 'a_'), $forum_id)
|
| 336 | 5423 | acydburn | if (is_array($args[0])) |
| 337 | 5423 | acydburn | {
|
| 338 | 5423 | acydburn | $args = $args[0]; |
| 339 | 5423 | acydburn | } |
| 340 | 5423 | acydburn | |
| 341 | 5423 | acydburn | $acl = 0; |
| 342 | 5423 | acydburn | foreach ($args as $opt) |
| 343 | 5423 | acydburn | {
|
| 344 | 5423 | acydburn | $acl |= $this->acl_get($opt, $f); |
| 345 | 5423 | acydburn | } |
| 346 | 5423 | acydburn | |
| 347 | 5423 | acydburn | return $acl; |
| 348 | 5423 | acydburn | } |
| 349 | 5423 | acydburn | |
| 350 | 5423 | acydburn | /**
|
| 351 | 5423 | acydburn | * Get permission listing based on user_id/options/forum_ids |
| 352 | 11310 | git-gate | * |
| 353 | 11310 | git-gate | * Be careful when using this function with permissions a_, m_, u_ and f_ ! |
| 354 | 11310 | git-gate | * It may not work correctly. When a user group grants an a_* permission, |
| 355 | 11310 | git-gate | * e.g. a_foo, but the user's a_foo permission is set to "Never", then |
| 356 | 11310 | git-gate | * the user does not in fact have the a_ permission. |
| 357 | 11310 | git-gate | * But the user will still be listed as having the a_ permission. |
| 358 | 11310 | git-gate | * |
| 359 | 11310 | git-gate | * For more information see: http://tracker.phpbb.com/browse/PHPBB3-10252 |
| 360 | 5423 | acydburn | */ |
| 361 | 5423 | acydburn | function acl_get_list($user_id = false, $opts = false, $forum_id = false) |
| 362 | 5423 | acydburn | {
|
| 363 | 8384 | acydburn | if ($user_id !== false && !is_array($user_id) && $opts === false && $forum_id === false) |
| 364 | 8384 | acydburn | {
|
| 365 | 8384 | acydburn | $hold_ary = array($user_id => $this->acl_raw_data_single_user($user_id)); |
| 366 | 8384 | acydburn | } |
| 367 | 8384 | acydburn | else
|
| 368 | 8384 | acydburn | {
|
| 369 | 8384 | acydburn | $hold_ary = $this->acl_raw_data($user_id, $opts, $forum_id); |
| 370 | 8384 | acydburn | } |
| 371 | 5423 | acydburn | |
| 372 | 5423 | acydburn | $auth_ary = array(); |
| 373 | 5423 | acydburn | foreach ($hold_ary as $user_id => $forum_ary) |
| 374 | 5423 | acydburn | {
|
| 375 | 5423 | acydburn | foreach ($forum_ary as $forum_id => $auth_option_ary) |
| 376 | 5423 | acydburn | {
|
| 377 | 5423 | acydburn | foreach ($auth_option_ary as $auth_option => $auth_setting) |
| 378 | 5423 | acydburn | {
|
| 379 | 5423 | acydburn | if ($auth_setting) |
| 380 | 5423 | acydburn | {
|
| 381 | 5423 | acydburn | $auth_ary[$forum_id][$auth_option][] = $user_id; |
| 382 | 5423 | acydburn | } |
| 383 | 5423 | acydburn | } |
| 384 | 5423 | acydburn | } |
| 385 | 5423 | acydburn | } |
| 386 | 5423 | acydburn | |
| 387 | 5423 | acydburn | return $auth_ary; |
| 388 | 5423 | acydburn | } |
| 389 | 5423 | acydburn | |
| 390 | 5423 | acydburn | /**
|
| 391 | 5423 | acydburn | * Cache data to user_permissions row |
| 392 | 5423 | acydburn | */ |
| 393 | 5423 | acydburn | function acl_cache(&$userdata) |
| 394 | 5423 | acydburn | {
|
| 395 | 5423 | acydburn | global $db; |
| 396 | 6015 | acydburn | |
| 397 | 5423 | acydburn | // Empty user_permissions
|
| 398 | 5423 | acydburn | $userdata['user_permissions'] = ''; |
| 399 | 6015 | acydburn | |
| 400 | 8384 | acydburn | $hold_ary = $this->acl_raw_data_single_user($userdata['user_id']); |
| 401 | 5517 | acydburn | |
| 402 | 5423 | acydburn | // Key 0 in $hold_ary are global options, all others are forum_ids
|
| 403 | 5423 | acydburn | |
| 404 | 5423 | acydburn | // If this user is founder we're going to force fill the admin options ...
|
| 405 | 5423 | acydburn | if ($userdata['user_type'] == USER_FOUNDER) |
| 406 | 5423 | acydburn | {
|
| 407 | 5423 | acydburn | foreach ($this->acl_options['global'] as $opt => $id) |
| 408 | 5423 | acydburn | {
|
| 409 | 5423 | acydburn | if (strpos($opt, 'a_') === 0) |
| 410 | 5423 | acydburn | {
|
| 411 | 8384 | acydburn | $hold_ary[0][$this->acl_options['id'][$opt]] = ACL_YES; |
| 412 | 5423 | acydburn | } |
| 413 | 5423 | acydburn | } |
| 414 | 5423 | acydburn | } |
| 415 | 5423 | acydburn | |
| 416 | 5790 | acydburn | $hold_str = $this->build_bitstring($hold_ary); |
| 417 | 5790 | acydburn | |
| 418 | 5790 | acydburn | if ($hold_str) |
| 419 | 5790 | acydburn | {
|
| 420 | 5790 | acydburn | $userdata['user_permissions'] = $hold_str; |
| 421 | 5790 | acydburn | |
| 422 | 5790 | acydburn | $sql = 'UPDATE ' . USERS_TABLE . " |
| 423 | 5790 | acydburn | SET user_permissions = '" . $db->sql_escape($userdata['user_permissions']) . "', |
| 424 | 5790 | acydburn | user_perm_from = 0 |
| 425 | 5790 | acydburn | WHERE user_id = " . $userdata['user_id']; |
| 426 | 5790 | acydburn | $db->sql_query($sql); |
| 427 | 5790 | acydburn | } |
| 428 | 5790 | acydburn | |
| 429 | 5790 | acydburn | return;
|
| 430 | 5790 | acydburn | } |
| 431 | 5790 | acydburn | |
| 432 | 5790 | acydburn | /**
|
| 433 | 5790 | acydburn | * Build bitstring from permission set |
| 434 | 5790 | acydburn | */ |
| 435 | 5790 | acydburn | function build_bitstring(&$hold_ary) |
| 436 | 5790 | acydburn | {
|
| 437 | 5423 | acydburn | $hold_str = ''; |
| 438 | 5790 | acydburn | |
| 439 | 5423 | acydburn | if (sizeof($hold_ary)) |
| 440 | 5423 | acydburn | {
|
| 441 | 5423 | acydburn | ksort($hold_ary); |
| 442 | 5574 | acydburn | |
| 443 | 5423 | acydburn | $last_f = 0; |
| 444 | 5423 | acydburn | |
| 445 | 5423 | acydburn | foreach ($hold_ary as $f => $auth_ary) |
| 446 | 5423 | acydburn | {
|
| 447 | 5423 | acydburn | $ary_key = (!$f) ? 'global' : 'local'; |
| 448 | 5423 | acydburn | |
| 449 | 5423 | acydburn | $bitstring = array(); |
| 450 | 5423 | acydburn | foreach ($this->acl_options[$ary_key] as $opt => $id) |
| 451 | 5423 | acydburn | {
|
| 452 | 8384 | acydburn | if (isset($auth_ary[$this->acl_options['id'][$opt]])) |
| 453 | 5423 | acydburn | {
|
| 454 | 8384 | acydburn | $bitstring[$id] = $auth_ary[$this->acl_options['id'][$opt]]; |
| 455 | 5423 | acydburn | |
| 456 | 5423 | acydburn | $option_key = substr($opt, 0, strpos($opt, '_') + 1); |
| 457 | 5423 | acydburn | |
| 458 | 5423 | acydburn | // If one option is allowed, the global permission for this option has to be allowed too
|
| 459 | 5423 | acydburn | // example: if the user has the a_ permission this means he has one or more a_* permissions
|
| 460 | 8384 | acydburn | if ($auth_ary[$this->acl_options['id'][$opt]] == ACL_YES && (!isset($bitstring[$this->acl_options[$ary_key][$option_key]]) || $bitstring[$this->acl_options[$ary_key][$option_key]] == ACL_NEVER)) |
| 461 | 5423 | acydburn | {
|
| 462 | 5622 | acydburn | $bitstring[$this->acl_options[$ary_key][$option_key]] = ACL_YES; |
| 463 | 5423 | acydburn | } |
| 464 | 5423 | acydburn | } |
| 465 | 5423 | acydburn | else
|
| 466 | 5423 | acydburn | {
|
| 467 | 6115 | acydburn | $bitstring[$id] = ACL_NEVER; |
| 468 | 5423 | acydburn | } |
| 469 | 5423 | acydburn | } |
| 470 | 5423 | acydburn | |
| 471 | 5423 | acydburn | // Now this bitstring defines the permission setting for the current forum $f (or global setting)
|
| 472 | 5423 | acydburn | $bitstring = implode('', $bitstring); |
| 473 | 5423 | acydburn | |
| 474 | 5423 | acydburn | // The line number indicates the id, therefore we have to add empty lines for those ids not present
|
| 475 | 5423 | acydburn | $hold_str .= str_repeat("\n", $f - $last_f); |
| 476 | 8985 | acydburn | |
| 477 | 5423 | acydburn | // Convert bitstring for storage - we do not use binary/bytes because PHP's string functions are not fully binary safe
|
| 478 | 6452 | acydburn | for ($i = 0, $bit_length = strlen($bitstring); $i < $bit_length; $i += 31) |
| 479 | 5423 | acydburn | {
|
| 480 | 5423 | acydburn | $hold_str .= str_pad(base_convert(str_pad(substr($bitstring, $i, 31), 31, 0, STR_PAD_RIGHT), 2, 36), 6, 0, STR_PAD_LEFT); |
| 481 | 5423 | acydburn | } |
| 482 | 5423 | acydburn | |
| 483 | 5423 | acydburn | $last_f = $f; |
| 484 | 5423 | acydburn | } |
| 485 | 5423 | acydburn | unset($bitstring); |
| 486 | 5423 | acydburn | |
| 487 | 5790 | acydburn | $hold_str = rtrim($hold_str); |
| 488 | 5423 | acydburn | } |
| 489 | 5423 | acydburn | |
| 490 | 5790 | acydburn | return $hold_str; |
| 491 | 5423 | acydburn | } |
| 492 | 5423 | acydburn | |
| 493 | 5423 | acydburn | /**
|
| 494 | 5423 | acydburn | * Clear one or all users cached permission settings |
| 495 | 5423 | acydburn | */ |
| 496 | 5423 | acydburn | function acl_clear_prefetch($user_id = false) |
| 497 | 5423 | acydburn | {
|
| 498 | 8384 | acydburn | global $db, $cache; |
| 499 | 5423 | acydburn | |
| 500 | 8384 | acydburn | // Rebuild options cache
|
| 501 | 8384 | acydburn | $cache->destroy('_role_cache'); |
| 502 | 8384 | acydburn | |
| 503 | 8384 | acydburn | $sql = 'SELECT * |
| 504 | 8384 | acydburn | FROM ' . ACL_ROLES_DATA_TABLE . ' |
| 505 | 8384 | acydburn | ORDER BY role_id ASC';
|
| 506 | 8384 | acydburn | $result = $db->sql_query($sql); |
| 507 | 8384 | acydburn | |
| 508 | 8384 | acydburn | $this->role_cache = array(); |
| 509 | 8384 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 510 | 8384 | acydburn | {
|
| 511 | 8390 | acydburn | $this->role_cache[$row['role_id']][$row['auth_option_id']] = (int) $row['auth_setting']; |
| 512 | 8384 | acydburn | } |
| 513 | 8384 | acydburn | $db->sql_freeresult($result); |
| 514 | 8384 | acydburn | |
| 515 | 8390 | acydburn | foreach ($this->role_cache as $role_id => $role_options) |
| 516 | 8390 | acydburn | {
|
| 517 | 8390 | acydburn | $this->role_cache[$role_id] = serialize($role_options); |
| 518 | 8390 | acydburn | } |
| 519 | 8390 | acydburn | |
| 520 | 8384 | acydburn | $cache->put('_role_cache', $this->role_cache); |
| 521 | 8384 | acydburn | |
| 522 | 8384 | acydburn | // Now empty user permissions
|
| 523 | 6271 | acydburn | $where_sql = ''; |
| 524 | 5423 | acydburn | |
| 525 | 6271 | acydburn | if ($user_id !== false) |
| 526 | 6271 | acydburn | {
|
| 527 | 6271 | acydburn | $user_id = (!is_array($user_id)) ? $user_id = array((int) $user_id) : array_map('intval', $user_id); |
| 528 | 6271 | acydburn | $where_sql = ' WHERE ' . $db->sql_in_set('user_id', $user_id); |
| 529 | 6271 | acydburn | } |
| 530 | 6271 | acydburn | |
| 531 | 5423 | acydburn | $sql = 'UPDATE ' . USERS_TABLE . " |
| 532 | 5790 | acydburn | SET user_permissions = '', |
| 533 | 5790 | acydburn | user_perm_from = 0 |
| 534 | 5423 | acydburn | $where_sql"; |
| 535 | 5423 | acydburn | $db->sql_query($sql); |
| 536 | 5423 | acydburn | |
| 537 | 5423 | acydburn | return;
|
| 538 | 5423 | acydburn | } |
| 539 | 5423 | acydburn | |
| 540 | 5423 | acydburn | /**
|
| 541 | 5574 | acydburn | * Get assigned roles |
| 542 | 5574 | acydburn | */ |
| 543 | 5574 | acydburn | function acl_role_data($user_type, $role_type, $ug_id = false, $forum_id = false) |
| 544 | 5574 | acydburn | {
|
| 545 | 5574 | acydburn | global $db; |
| 546 | 5574 | acydburn | |
| 547 | 5574 | acydburn | $roles = array(); |
| 548 | 5574 | acydburn | |
| 549 | 5574 | acydburn | $sql_id = ($user_type == 'user') ? 'user_id' : 'group_id'; |
| 550 | 5574 | acydburn | |
| 551 | 6271 | acydburn | $sql_ug = ($ug_id !== false) ? ((!is_array($ug_id)) ? "AND a.$sql_id = $ug_id" : 'AND ' . $db->sql_in_set("a.$sql_id", $ug_id)) : ''; |
| 552 | 6271 | acydburn | $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? "AND a.forum_id = $forum_id" : 'AND ' . $db->sql_in_set('a.forum_id', $forum_id)) : ''; |
| 553 | 5574 | acydburn | |
| 554 | 5574 | acydburn | // Grab assigned roles...
|
| 555 | 5574 | acydburn | $sql = 'SELECT a.auth_role_id, a.' . $sql_id . ', a.forum_id |
| 556 | 5574 | acydburn | FROM ' . (($user_type == 'user') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE) . ' a, ' . ACL_ROLES_TABLE . " r |
| 557 | 5574 | acydburn | WHERE a.auth_role_id = r.role_id |
| 558 | 5574 | acydburn | AND r.role_type = '" . $db->sql_escape($role_type) . "' |
| 559 | 5574 | acydburn | $sql_ug |
| 560 | 5574 | acydburn | $sql_forum |
| 561 | 5824 | acydburn | ORDER BY r.role_order ASC";
|
| 562 | 5574 | acydburn | $result = $db->sql_query($sql); |
| 563 | 5574 | acydburn | |
| 564 | 5574 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 565 | 5574 | acydburn | {
|
| 566 | 5574 | acydburn | $roles[$row[$sql_id]][$row['forum_id']] = $row['auth_role_id']; |
| 567 | 5574 | acydburn | } |
| 568 | 5574 | acydburn | $db->sql_freeresult($result); |
| 569 | 5574 | acydburn | |
| 570 | 5574 | acydburn | return $roles; |
| 571 | 5574 | acydburn | } |
| 572 | 5574 | acydburn | |
| 573 | 5574 | acydburn | /**
|
| 574 | 5423 | acydburn | * Get raw acl data based on user/option/forum |
| 575 | 5423 | acydburn | */ |
| 576 | 5423 | acydburn | function acl_raw_data($user_id = false, $opts = false, $forum_id = false) |
| 577 | 5423 | acydburn | {
|
| 578 | 5423 | acydburn | global $db; |
| 579 | 5423 | acydburn | |
| 580 | 7452 | acydburn | $sql_user = ($user_id !== false) ? ((!is_array($user_id)) ? 'user_id = ' . (int) $user_id : $db->sql_in_set('user_id', array_map('intval', $user_id))) : ''; |
| 581 | 7452 | acydburn | $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : ''; |
| 582 | 5423 | acydburn | |
| 583 | 8384 | acydburn | $sql_opts = $sql_opts_select = $sql_opts_from = ''; |
| 584 | 8384 | acydburn | $hold_ary = array(); |
| 585 | 5468 | acydburn | |
| 586 | 5468 | acydburn | if ($opts !== false) |
| 587 | 5468 | acydburn | {
|
| 588 | 8384 | acydburn | $sql_opts_select = ', ao.auth_option'; |
| 589 | 8384 | acydburn | $sql_opts_from = ', ' . ACL_OPTIONS_TABLE . ' ao'; |
| 590 | 6601 | acydburn | $this->build_auth_option_statement('ao.auth_option', $opts, $sql_opts); |
| 591 | 5468 | acydburn | } |
| 592 | 5468 | acydburn | |
| 593 | 8384 | acydburn | $sql_ary = array(); |
| 594 | 5423 | acydburn | |
| 595 | 8384 | acydburn | // Grab non-role settings - user-specific
|
| 596 | 8384 | acydburn | $sql_ary[] = 'SELECT a.user_id, a.forum_id, a.auth_setting, a.auth_option_id' . $sql_opts_select . ' |
| 597 | 8384 | acydburn | FROM ' . ACL_USERS_TABLE . ' a' . $sql_opts_from . ' |
| 598 | 8384 | acydburn | WHERE a.auth_role_id = 0 ' .
|
| 599 | 8384 | acydburn | (($sql_opts_from) ? 'AND a.auth_option_id = ao.auth_option_id ' : '') . |
| 600 | 8384 | acydburn | (($sql_user) ? 'AND a.' . $sql_user : '') . " |
| 601 | 8384 | acydburn | $sql_forum |
| 602 | 8384 | acydburn | $sql_opts"; |
| 603 | 5885 | davidmj | |
| 604 | 8384 | acydburn | // Now the role settings - user-specific
|
| 605 | 8384 | acydburn | $sql_ary[] = 'SELECT a.user_id, a.forum_id, r.auth_option_id, r.auth_setting, r.auth_option_id' . $sql_opts_select . ' |
| 606 | 8384 | acydburn | FROM ' . ACL_USERS_TABLE . ' a, ' . ACL_ROLES_DATA_TABLE . ' r' . $sql_opts_from . ' |
| 607 | 8985 | acydburn | WHERE a.auth_role_id = r.role_id ' .
|
| 608 | 8384 | acydburn | (($sql_opts_from) ? 'AND r.auth_option_id = ao.auth_option_id ' : '') . |
| 609 | 8384 | acydburn | (($sql_user) ? 'AND a.' . $sql_user : '') . " |
| 610 | 6015 | acydburn | $sql_forum |
| 611 | 8384 | acydburn | $sql_opts"; |
| 612 | 5423 | acydburn | |
| 613 | 8384 | acydburn | foreach ($sql_ary as $sql) |
| 614 | 5423 | acydburn | {
|
| 615 | 8384 | acydburn | $result = $db->sql_query($sql); |
| 616 | 8384 | acydburn | |
| 617 | 8384 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 618 | 8384 | acydburn | {
|
| 619 | 8384 | acydburn | $option = ($sql_opts_select) ? $row['auth_option'] : $this->acl_options['option'][$row['auth_option_id']]; |
| 620 | 8384 | acydburn | $hold_ary[$row['user_id']][$row['forum_id']][$option] = $row['auth_setting']; |
| 621 | 8384 | acydburn | } |
| 622 | 8384 | acydburn | $db->sql_freeresult($result); |
| 623 | 5423 | acydburn | } |
| 624 | 5423 | acydburn | |
| 625 | 8384 | acydburn | $sql_ary = array(); |
| 626 | 5885 | davidmj | |
| 627 | 8384 | acydburn | // Now grab group settings - non-role specific...
|
| 628 | 8384 | acydburn | $sql_ary[] = 'SELECT ug.user_id, a.forum_id, a.auth_setting, a.auth_option_id' . $sql_opts_select . ' |
| 629 | 9625 | acydburn | FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g' . $sql_opts_from . ' |
| 630 | 8384 | acydburn | WHERE a.auth_role_id = 0 ' .
|
| 631 | 8384 | acydburn | (($sql_opts_from) ? 'AND a.auth_option_id = ao.auth_option_id ' : '') . ' |
| 632 | 7182 | naderman | AND a.group_id = ug.group_id |
| 633 | 9625 | acydburn | AND g.group_id = ug.group_id |
| 634 | 7182 | naderman | AND ug.user_pending = 0 |
| 635 | 9625 | acydburn | AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) |
| 636 | 7182 | naderman | ' . (($sql_user) ? 'AND ug.' . $sql_user : '') . " |
| 637 | 7182 | naderman | $sql_forum |
| 638 | 8384 | acydburn | $sql_opts"; |
| 639 | 7182 | naderman | |
| 640 | 8384 | acydburn | // Now grab group settings - role specific...
|
| 641 | 8384 | acydburn | $sql_ary[] = 'SELECT ug.user_id, a.forum_id, r.auth_setting, r.auth_option_id' . $sql_opts_select . ' |
| 642 | 9625 | acydburn | FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g, ' . ACL_ROLES_DATA_TABLE . ' r' . $sql_opts_from . ' |
| 643 | 8384 | acydburn | WHERE a.auth_role_id = r.role_id ' .
|
| 644 | 8384 | acydburn | (($sql_opts_from) ? 'AND r.auth_option_id = ao.auth_option_id ' : '') . ' |
| 645 | 8384 | acydburn | AND a.group_id = ug.group_id |
| 646 | 9625 | acydburn | AND g.group_id = ug.group_id |
| 647 | 8384 | acydburn | AND ug.user_pending = 0 |
| 648 | 9625 | acydburn | AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) |
| 649 | 6015 | acydburn | ' . (($sql_user) ? 'AND ug.' . $sql_user : '') . " |
| 650 | 6015 | acydburn | $sql_forum |
| 651 | 8384 | acydburn | $sql_opts"; |
| 652 | 5423 | acydburn | |
| 653 | 7182 | naderman | foreach ($sql_ary as $sql) |
| 654 | 5423 | acydburn | {
|
| 655 | 7182 | naderman | $result = $db->sql_query($sql); |
| 656 | 7182 | naderman | |
| 657 | 7182 | naderman | while ($row = $db->sql_fetchrow($result)) |
| 658 | 5423 | acydburn | {
|
| 659 | 8384 | acydburn | $option = ($sql_opts_select) ? $row['auth_option'] : $this->acl_options['option'][$row['auth_option_id']]; |
| 660 | 8384 | acydburn | |
| 661 | 8384 | acydburn | if (!isset($hold_ary[$row['user_id']][$row['forum_id']][$option]) || (isset($hold_ary[$row['user_id']][$row['forum_id']][$option]) && $hold_ary[$row['user_id']][$row['forum_id']][$option] != ACL_NEVER)) |
| 662 | 5622 | acydburn | {
|
| 663 | 8384 | acydburn | $hold_ary[$row['user_id']][$row['forum_id']][$option] = $row['auth_setting']; |
| 664 | 8384 | acydburn | |
| 665 | 8384 | acydburn | // If we detect ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again)
|
| 666 | 8384 | acydburn | if ($row['auth_setting'] == ACL_NEVER) |
| 667 | 5622 | acydburn | {
|
| 668 | 8384 | acydburn | $flag = substr($option, 0, strpos($option, '_') + 1); |
| 669 | 8985 | acydburn | |
| 670 | 7182 | naderman | if (isset($hold_ary[$row['user_id']][$row['forum_id']][$flag]) && $hold_ary[$row['user_id']][$row['forum_id']][$flag] == ACL_YES) |
| 671 | 5622 | acydburn | {
|
| 672 | 7182 | naderman | unset($hold_ary[$row['user_id']][$row['forum_id']][$flag]); |
| 673 | 8384 | acydburn | |
| 674 | 8384 | acydburn | /* if (in_array(ACL_YES, $hold_ary[$row['user_id']][$row['forum_id']]))
|
| 675 | 7182 | naderman | {
|
| 676 | 7182 | naderman | $hold_ary[$row['user_id']][$row['forum_id']][$flag] = ACL_YES; |
| 677 | 7182 | naderman | } |
| 678 | 8384 | acydburn | */ |
| 679 | 5622 | acydburn | } |
| 680 | 5622 | acydburn | } |
| 681 | 5622 | acydburn | } |
| 682 | 5423 | acydburn | } |
| 683 | 7182 | naderman | $db->sql_freeresult($result); |
| 684 | 5423 | acydburn | } |
| 685 | 5423 | acydburn | |
| 686 | 5423 | acydburn | return $hold_ary; |
| 687 | 5423 | acydburn | } |
| 688 | 5423 | acydburn | |
| 689 | 5423 | acydburn | /**
|
| 690 | 5553 | acydburn | * Get raw user based permission settings |
| 691 | 5553 | acydburn | */ |
| 692 | 5553 | acydburn | function acl_user_raw_data($user_id = false, $opts = false, $forum_id = false) |
| 693 | 5553 | acydburn | {
|
| 694 | 5553 | acydburn | global $db; |
| 695 | 5553 | acydburn | |
| 696 | 7452 | acydburn | $sql_user = ($user_id !== false) ? ((!is_array($user_id)) ? 'user_id = ' . (int) $user_id : $db->sql_in_set('user_id', array_map('intval', $user_id))) : ''; |
| 697 | 7452 | acydburn | $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : ''; |
| 698 | 5553 | acydburn | |
| 699 | 6601 | acydburn | $sql_opts = ''; |
| 700 | 8384 | acydburn | $hold_ary = $sql_ary = array(); |
| 701 | 5553 | acydburn | |
| 702 | 5553 | acydburn | if ($opts !== false) |
| 703 | 5553 | acydburn | {
|
| 704 | 6601 | acydburn | $this->build_auth_option_statement('ao.auth_option', $opts, $sql_opts); |
| 705 | 5553 | acydburn | } |
| 706 | 5553 | acydburn | |
| 707 | 8384 | acydburn | // Grab user settings - non-role specific...
|
| 708 | 8384 | acydburn | $sql_ary[] = 'SELECT a.user_id, a.forum_id, a.auth_setting, a.auth_option_id, ao.auth_option |
| 709 | 8384 | acydburn | FROM ' . ACL_USERS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . ' ao |
| 710 | 8384 | acydburn | WHERE a.auth_role_id = 0 |
| 711 | 8384 | acydburn | AND a.auth_option_id = ao.auth_option_id ' .
|
| 712 | 8384 | acydburn | (($sql_user) ? 'AND a.' . $sql_user : '') . " |
| 713 | 8384 | acydburn | $sql_forum |
| 714 | 8384 | acydburn | $sql_opts |
| 715 | 8384 | acydburn | ORDER BY a.forum_id, ao.auth_option";
|
| 716 | 5553 | acydburn | |
| 717 | 8384 | acydburn | // Now the role settings - user-specific
|
| 718 | 8384 | acydburn | $sql_ary[] = 'SELECT a.user_id, a.forum_id, r.auth_option_id, r.auth_setting, r.auth_option_id, ao.auth_option |
| 719 | 8384 | acydburn | FROM ' . ACL_USERS_TABLE . ' a, ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' ao |
| 720 | 8384 | acydburn | WHERE a.auth_role_id = r.role_id |
| 721 | 8384 | acydburn | AND r.auth_option_id = ao.auth_option_id ' .
|
| 722 | 8384 | acydburn | (($sql_user) ? 'AND a.' . $sql_user : '') . " |
| 723 | 6015 | acydburn | $sql_forum |
| 724 | 8384 | acydburn | $sql_opts |
| 725 | 8384 | acydburn | ORDER BY a.forum_id, ao.auth_option";
|
| 726 | 5885 | davidmj | |
| 727 | 8384 | acydburn | foreach ($sql_ary as $sql) |
| 728 | 8384 | acydburn | {
|
| 729 | 8384 | acydburn | $result = $db->sql_query($sql); |
| 730 | 5553 | acydburn | |
| 731 | 8384 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 732 | 8384 | acydburn | {
|
| 733 | 8384 | acydburn | $hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']] = $row['auth_setting']; |
| 734 | 8384 | acydburn | } |
| 735 | 8384 | acydburn | $db->sql_freeresult($result); |
| 736 | 5553 | acydburn | } |
| 737 | 5553 | acydburn | |
| 738 | 5553 | acydburn | return $hold_ary; |
| 739 | 5553 | acydburn | } |
| 740 | 5553 | acydburn | |
| 741 | 5553 | acydburn | /**
|
| 742 | 5468 | acydburn | * Get raw group based permission settings |
| 743 | 5468 | acydburn | */ |
| 744 | 5468 | acydburn | function acl_group_raw_data($group_id = false, $opts = false, $forum_id = false) |
| 745 | 5468 | acydburn | {
|
| 746 | 5468 | acydburn | global $db; |
| 747 | 5468 | acydburn | |
| 748 | 7452 | acydburn | $sql_group = ($group_id !== false) ? ((!is_array($group_id)) ? 'group_id = ' . (int) $group_id : $db->sql_in_set('group_id', array_map('intval', $group_id))) : ''; |
| 749 | 7452 | acydburn | $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : ''; |
| 750 | 5468 | acydburn | |
| 751 | 6601 | acydburn | $sql_opts = ''; |
| 752 | 8384 | acydburn | $hold_ary = $sql_ary = array(); |
| 753 | 6366 | acydburn | |
| 754 | 5468 | acydburn | if ($opts !== false) |
| 755 | 5468 | acydburn | {
|
| 756 | 6601 | acydburn | $this->build_auth_option_statement('ao.auth_option', $opts, $sql_opts); |
| 757 | 5468 | acydburn | } |
| 758 | 5468 | acydburn | |
| 759 | 8384 | acydburn | // Grab group settings - non-role specific...
|
| 760 | 8384 | acydburn | $sql_ary[] = 'SELECT a.group_id, a.forum_id, a.auth_setting, a.auth_option_id, ao.auth_option |
| 761 | 8384 | acydburn | FROM ' . ACL_GROUPS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . ' ao |
| 762 | 8384 | acydburn | WHERE a.auth_role_id = 0 |
| 763 | 8384 | acydburn | AND a.auth_option_id = ao.auth_option_id ' .
|
| 764 | 8384 | acydburn | (($sql_group) ? 'AND a.' . $sql_group : '') . " |
| 765 | 8384 | acydburn | $sql_forum |
| 766 | 8384 | acydburn | $sql_opts |
| 767 | 8384 | acydburn | ORDER BY a.forum_id, ao.auth_option";
|
| 768 | 5468 | acydburn | |
| 769 | 8384 | acydburn | // Now grab group settings - role specific...
|
| 770 | 8384 | acydburn | $sql_ary[] = 'SELECT a.group_id, a.forum_id, r.auth_setting, r.auth_option_id, ao.auth_option |
| 771 | 8384 | acydburn | FROM ' . ACL_GROUPS_TABLE . ' a, ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' ao |
| 772 | 8384 | acydburn | WHERE a.auth_role_id = r.role_id |
| 773 | 8384 | acydburn | AND r.auth_option_id = ao.auth_option_id ' .
|
| 774 | 8384 | acydburn | (($sql_group) ? 'AND a.' . $sql_group : '') . " |
| 775 | 8384 | acydburn | $sql_forum |
| 776 | 8384 | acydburn | $sql_opts |
| 777 | 8384 | acydburn | ORDER BY a.forum_id, ao.auth_option";
|
| 778 | 6015 | acydburn | |
| 779 | 8384 | acydburn | foreach ($sql_ary as $sql) |
| 780 | 8384 | acydburn | {
|
| 781 | 8384 | acydburn | $result = $db->sql_query($sql); |
| 782 | 6015 | acydburn | |
| 783 | 8384 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 784 | 8384 | acydburn | {
|
| 785 | 8384 | acydburn | $hold_ary[$row['group_id']][$row['forum_id']][$row['auth_option']] = $row['auth_setting']; |
| 786 | 8384 | acydburn | } |
| 787 | 8384 | acydburn | $db->sql_freeresult($result); |
| 788 | 8384 | acydburn | } |
| 789 | 5885 | davidmj | |
| 790 | 8384 | acydburn | return $hold_ary; |
| 791 | 8384 | acydburn | } |
| 792 | 5885 | davidmj | |
| 793 | 8384 | acydburn | /**
|
| 794 | 8384 | acydburn | * Get raw acl data based on user for caching user_permissions |
| 795 | 8384 | acydburn | * This function returns the same data as acl_raw_data(), but without the user id as the first key within the array. |
| 796 | 8384 | acydburn | */ |
| 797 | 8384 | acydburn | function acl_raw_data_single_user($user_id) |
| 798 | 8384 | acydburn | {
|
| 799 | 8384 | acydburn | global $db, $cache; |
| 800 | 8384 | acydburn | |
| 801 | 8384 | acydburn | // Check if the role-cache is there
|
| 802 | 8384 | acydburn | if (($this->role_cache = $cache->get('_role_cache')) === false) |
| 803 | 8384 | acydburn | {
|
| 804 | 8384 | acydburn | $this->role_cache = array(); |
| 805 | 8384 | acydburn | |
| 806 | 8384 | acydburn | // We pre-fetch roles
|
| 807 | 8384 | acydburn | $sql = 'SELECT * |
| 808 | 8384 | acydburn | FROM ' . ACL_ROLES_DATA_TABLE . ' |
| 809 | 8384 | acydburn | ORDER BY role_id ASC';
|
| 810 | 8384 | acydburn | $result = $db->sql_query($sql); |
| 811 | 8384 | acydburn | |
| 812 | 8384 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 813 | 8384 | acydburn | {
|
| 814 | 8390 | acydburn | $this->role_cache[$row['role_id']][$row['auth_option_id']] = (int) $row['auth_setting']; |
| 815 | 8384 | acydburn | } |
| 816 | 8384 | acydburn | $db->sql_freeresult($result); |
| 817 | 8384 | acydburn | |
| 818 | 8390 | acydburn | foreach ($this->role_cache as $role_id => $role_options) |
| 819 | 8390 | acydburn | {
|
| 820 | 8390 | acydburn | $this->role_cache[$role_id] = serialize($role_options); |
| 821 | 8390 | acydburn | } |
| 822 | 8390 | acydburn | |
| 823 | 8384 | acydburn | $cache->put('_role_cache', $this->role_cache); |
| 824 | 8384 | acydburn | } |
| 825 | 8384 | acydburn | |
| 826 | 8384 | acydburn | $hold_ary = array(); |
| 827 | 8384 | acydburn | |
| 828 | 8384 | acydburn | // Grab user-specific permission settings
|
| 829 | 8384 | acydburn | $sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting |
| 830 | 8384 | acydburn | FROM ' . ACL_USERS_TABLE . ' |
| 831 | 8384 | acydburn | WHERE user_id = ' . $user_id; |
| 832 | 6601 | acydburn | $result = $db->sql_query($sql); |
| 833 | 5468 | acydburn | |
| 834 | 5468 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 835 | 5468 | acydburn | {
|
| 836 | 8384 | acydburn | // If a role is assigned, assign all options included within this role. Else, only set this one option.
|
| 837 | 8384 | acydburn | if ($row['auth_role_id']) |
| 838 | 8384 | acydburn | {
|
| 839 | 8390 | acydburn | $hold_ary[$row['forum_id']] = (empty($hold_ary[$row['forum_id']])) ? unserialize($this->role_cache[$row['auth_role_id']]) : $hold_ary[$row['forum_id']] + unserialize($this->role_cache[$row['auth_role_id']]); |
| 840 | 8384 | acydburn | } |
| 841 | 8384 | acydburn | else
|
| 842 | 8384 | acydburn | {
|
| 843 | 8384 | acydburn | $hold_ary[$row['forum_id']][$row['auth_option_id']] = $row['auth_setting']; |
| 844 | 8384 | acydburn | } |
| 845 | 5468 | acydburn | } |
| 846 | 5468 | acydburn | $db->sql_freeresult($result); |
| 847 | 5468 | acydburn | |
| 848 | 8384 | acydburn | // Now grab group-specific permission settings
|
| 849 | 8384 | acydburn | $sql = 'SELECT a.forum_id, a.auth_option_id, a.auth_role_id, a.auth_setting |
| 850 | 9625 | acydburn | FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g |
| 851 | 8384 | acydburn | WHERE a.group_id = ug.group_id |
| 852 | 9625 | acydburn | AND g.group_id = ug.group_id |
| 853 | 8384 | acydburn | AND ug.user_pending = 0 |
| 854 | 9625 | acydburn | AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) |
| 855 | 8384 | acydburn | AND ug.user_id = ' . $user_id; |
| 856 | 8384 | acydburn | $result = $db->sql_query($sql); |
| 857 | 8384 | acydburn | |
| 858 | 8384 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 859 | 8384 | acydburn | {
|
| 860 | 8384 | acydburn | if (!$row['auth_role_id']) |
| 861 | 8384 | acydburn | {
|
| 862 | 8384 | acydburn | $this->_set_group_hold_ary($hold_ary[$row['forum_id']], $row['auth_option_id'], $row['auth_setting']); |
| 863 | 8384 | acydburn | } |
| 864 | 8502 | acydburn | else if (!empty($this->role_cache[$row['auth_role_id']])) |
| 865 | 8384 | acydburn | {
|
| 866 | 8390 | acydburn | foreach (unserialize($this->role_cache[$row['auth_role_id']]) as $option_id => $setting) |
| 867 | 8384 | acydburn | {
|
| 868 | 8384 | acydburn | $this->_set_group_hold_ary($hold_ary[$row['forum_id']], $option_id, $setting); |
| 869 | 8384 | acydburn | } |
| 870 | 8384 | acydburn | } |
| 871 | 8384 | acydburn | } |
| 872 | 8384 | acydburn | $db->sql_freeresult($result); |
| 873 | 8384 | acydburn | |
| 874 | 5468 | acydburn | return $hold_ary; |
| 875 | 5468 | acydburn | } |
| 876 | 5468 | acydburn | |
| 877 | 5468 | acydburn | /**
|
| 878 | 8384 | acydburn | * Private function snippet for setting a specific piece of the hold_ary |
| 879 | 8384 | acydburn | */ |
| 880 | 8384 | acydburn | function _set_group_hold_ary(&$hold_ary, $option_id, $setting) |
| 881 | 8384 | acydburn | {
|
| 882 | 8384 | acydburn | if (!isset($hold_ary[$option_id]) || (isset($hold_ary[$option_id]) && $hold_ary[$option_id] != ACL_NEVER)) |
| 883 | 8384 | acydburn | {
|
| 884 | 8384 | acydburn | $hold_ary[$option_id] = $setting; |
| 885 | 8384 | acydburn | |
| 886 | 8384 | acydburn | // If we detect ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again)
|
| 887 | 8384 | acydburn | if ($setting == ACL_NEVER) |
| 888 | 8384 | acydburn | {
|
| 889 | 8384 | acydburn | $flag = substr($this->acl_options['option'][$option_id], 0, strpos($this->acl_options['option'][$option_id], '_') + 1); |
| 890 | 8384 | acydburn | $flag = (int) $this->acl_options['id'][$flag]; |
| 891 | 8985 | acydburn | |
| 892 | 8384 | acydburn | if (isset($hold_ary[$flag]) && $hold_ary[$flag] == ACL_YES) |
| 893 | 8384 | acydburn | {
|
| 894 | 8384 | acydburn | unset($hold_ary[$flag]); |
| 895 | 8384 | acydburn | |
| 896 | 8384 | acydburn | /* This is uncommented, because i suspect this being slightly wrong due to mixed permission classes being possible
|
| 897 | 8384 | acydburn | if (in_array(ACL_YES, $hold_ary)) |
| 898 | 8384 | acydburn | {
|
| 899 | 8384 | acydburn | $hold_ary[$flag] = ACL_YES; |
| 900 | 8384 | acydburn | }*/ |
| 901 | 8384 | acydburn | } |
| 902 | 8384 | acydburn | } |
| 903 | 8384 | acydburn | } |
| 904 | 8384 | acydburn | } |
| 905 | 8384 | acydburn | |
| 906 | 8384 | acydburn | /**
|
| 907 | 5423 | acydburn | * Authentication plug-ins is largely down to Sergey Kanareykin, our thanks to him. |
| 908 | 5423 | acydburn | */ |
| 909 | 5423 | acydburn | function login($username, $password, $autologin = false, $viewonline = 1, $admin = 0) |
| 910 | 5423 | acydburn | {
|
| 911 | 5423 | acydburn | global $config, $db, $user, $phpbb_root_path, $phpEx; |
| 912 | 5423 | acydburn | |
| 913 | 6015 | acydburn | $method = trim(basename($config['auth_method'])); |
| 914 | 6228 | acydburn | include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx); |
| 915 | 5423 | acydburn | |
| 916 | 6228 | acydburn | $method = 'login_' . $method; |
| 917 | 6228 | acydburn | if (function_exists($method)) |
| 918 | 5423 | acydburn | {
|
| 919 | 11215 | git-gate | $login = $method($username, $password, $user->ip, $user->browser, $user->forwarded_for); |
| 920 | 5423 | acydburn | |
| 921 | 6228 | acydburn | // If the auth module wants us to create an empty profile do so and then treat the status as LOGIN_SUCCESS
|
| 922 | 6228 | acydburn | if ($login['status'] == LOGIN_SUCCESS_CREATE_PROFILE) |
| 923 | 5423 | acydburn | {
|
| 924 | 6228 | acydburn | // we are going to use the user_add function so include functions_user.php if it wasn't defined yet
|
| 925 | 6228 | acydburn | if (!function_exists('user_add')) |
| 926 | 6151 | naderman | {
|
| 927 | 6517 | acydburn | include($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
| 928 | 6228 | acydburn | } |
| 929 | 6151 | naderman | |
| 930 | 6228 | acydburn | user_add($login['user_row'], (isset($login['cp_data'])) ? $login['cp_data'] : false); |
| 931 | 6151 | naderman | |
| 932 | 6228 | acydburn | $sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type |
| 933 | 6228 | acydburn | FROM ' . USERS_TABLE . " |
| 934 | 6494 | naderman | WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; |
| 935 | 6228 | acydburn | $result = $db->sql_query($sql); |
| 936 | 6228 | acydburn | $row = $db->sql_fetchrow($result); |
| 937 | 6228 | acydburn | $db->sql_freeresult($result); |
| 938 | 6151 | naderman | |
| 939 | 6228 | acydburn | if (!$row) |
| 940 | 6228 | acydburn | {
|
| 941 | 6228 | acydburn | return array( |
| 942 | 6228 | acydburn | 'status' => LOGIN_ERROR_EXTERNAL_AUTH, |
| 943 | 6228 | acydburn | 'error_msg' => 'AUTH_NO_PROFILE_CREATED', |
| 944 | 6228 | acydburn | 'user_row' => array('user_id' => ANONYMOUS), |
| 945 | 6151 | naderman | ); |
| 946 | 6151 | naderman | } |
| 947 | 6151 | naderman | |
| 948 | 6228 | acydburn | $login = array( |
| 949 | 6228 | acydburn | 'status' => LOGIN_SUCCESS, |
| 950 | 6228 | acydburn | 'error_msg' => false, |
| 951 | 6228 | acydburn | 'user_row' => $row, |
| 952 | 6228 | acydburn | ); |
| 953 | 6228 | acydburn | } |
| 954 | 5622 | acydburn | |
| 955 | 6228 | acydburn | // If login succeeded, we will log the user in... else we pass the login array through...
|
| 956 | 6228 | acydburn | if ($login['status'] == LOGIN_SUCCESS) |
| 957 | 6228 | acydburn | {
|
| 958 | 6436 | acydburn | $old_session_id = $user->session_id; |
| 959 | 6436 | acydburn | |
| 960 | 6436 | acydburn | if ($admin) |
| 961 | 6436 | acydburn | {
|
| 962 | 6436 | acydburn | global $SID, $_SID; |
| 963 | 6436 | acydburn | |
| 964 | 6436 | acydburn | $cookie_expire = time() - 31536000; |
| 965 | 6436 | acydburn | $user->set_cookie('u', '', $cookie_expire); |
| 966 | 6436 | acydburn | $user->set_cookie('sid', '', $cookie_expire); |
| 967 | 6436 | acydburn | unset($cookie_expire); |
| 968 | 6436 | acydburn | |
| 969 | 6436 | acydburn | $SID = '?sid='; |
| 970 | 6436 | acydburn | $user->session_id = $_SID = ''; |
| 971 | 6436 | acydburn | } |
| 972 | 6436 | acydburn | |
| 973 | 6228 | acydburn | $result = $user->session_create($login['user_row']['user_id'], $admin, $autologin, $viewonline); |
| 974 | 5622 | acydburn | |
| 975 | 6228 | acydburn | // Successful session creation
|
| 976 | 6228 | acydburn | if ($result === true) |
| 977 | 6228 | acydburn | {
|
| 978 | 6436 | acydburn | // If admin re-authentication we remove the old session entry because a new one has been created...
|
| 979 | 6436 | acydburn | if ($admin) |
| 980 | 6436 | acydburn | {
|
| 981 | 6436 | acydburn | // the login array is used because the user ids do not differ for re-authentication
|
| 982 | 6436 | acydburn | $sql = 'DELETE FROM ' . SESSIONS_TABLE . " |
| 983 | 6436 | acydburn | WHERE session_id = '" . $db->sql_escape($old_session_id) . "' |
| 984 | 6436 | acydburn | AND session_user_id = {$login['user_row']['user_id']}"; |
| 985 | 6436 | acydburn | $db->sql_query($sql); |
| 986 | 6436 | acydburn | } |
| 987 | 6436 | acydburn | |
| 988 | 5622 | acydburn | return array( |
| 989 | 6228 | acydburn | 'status' => LOGIN_SUCCESS, |
| 990 | 6228 | acydburn | 'error_msg' => false, |
| 991 | 5622 | acydburn | 'user_row' => $login['user_row'], |
| 992 | 5622 | acydburn | ); |
| 993 | 5423 | acydburn | } |
| 994 | 5622 | acydburn | |
| 995 | 6228 | acydburn | return array( |
| 996 | 6228 | acydburn | 'status' => LOGIN_BREAK, |
| 997 | 6228 | acydburn | 'error_msg' => $result, |
| 998 | 6228 | acydburn | 'user_row' => $login['user_row'], |
| 999 | 6228 | acydburn | ); |
| 1000 | 5423 | acydburn | } |
| 1001 | 6228 | acydburn | |
| 1002 | 6228 | acydburn | return $login; |
| 1003 | 5423 | acydburn | } |
| 1004 | 5423 | acydburn | |
| 1005 | 5423 | acydburn | trigger_error('Authentication method not found', E_USER_ERROR); |
| 1006 | 5423 | acydburn | } |
| 1007 | 6366 | acydburn | |
| 1008 | 6366 | acydburn | /**
|
| 1009 | 6366 | acydburn | * Fill auth_option statement for later querying based on the supplied options |
| 1010 | 6366 | acydburn | */ |
| 1011 | 6601 | acydburn | function build_auth_option_statement($key, $auth_options, &$sql_opts) |
| 1012 | 6366 | acydburn | {
|
| 1013 | 6366 | acydburn | global $db; |
| 1014 | 6366 | acydburn | |
| 1015 | 6366 | acydburn | if (!is_array($auth_options)) |
| 1016 | 6366 | acydburn | {
|
| 1017 | 6366 | acydburn | if (strpos($auth_options, '%') !== false) |
| 1018 | 6366 | acydburn | {
|
| 1019 | 7789 | acydburn | $sql_opts = "AND $key " . $db->sql_like_expression(str_replace('%', $db->any_char, $auth_options)); |
| 1020 | 6366 | acydburn | } |
| 1021 | 6366 | acydburn | else
|
| 1022 | 6366 | acydburn | {
|
| 1023 | 6366 | acydburn | $sql_opts = "AND $key = '" . $db->sql_escape($auth_options) . "'"; |
| 1024 | 6366 | acydburn | } |
| 1025 | 6366 | acydburn | } |
| 1026 | 6366 | acydburn | else
|
| 1027 | 6366 | acydburn | {
|
| 1028 | 6601 | acydburn | $is_like_expression = false; |
| 1029 | 6366 | acydburn | |
| 1030 | 6366 | acydburn | foreach ($auth_options as $option) |
| 1031 | 6366 | acydburn | {
|
| 1032 | 6366 | acydburn | if (strpos($option, '%') !== false) |
| 1033 | 6366 | acydburn | {
|
| 1034 | 6366 | acydburn | $is_like_expression = true; |
| 1035 | 6366 | acydburn | } |
| 1036 | 6366 | acydburn | } |
| 1037 | 6366 | acydburn | |
| 1038 | 6366 | acydburn | if (!$is_like_expression) |
| 1039 | 6366 | acydburn | {
|
| 1040 | 6366 | acydburn | $sql_opts = 'AND ' . $db->sql_in_set($key, $auth_options); |
| 1041 | 6366 | acydburn | } |
| 1042 | 6366 | acydburn | else
|
| 1043 | 6366 | acydburn | {
|
| 1044 | 6366 | acydburn | $sql = array(); |
| 1045 | 6366 | acydburn | |
| 1046 | 6366 | acydburn | foreach ($auth_options as $option) |
| 1047 | 6366 | acydburn | {
|
| 1048 | 6601 | acydburn | if (strpos($option, '%') !== false) |
| 1049 | 6601 | acydburn | {
|
| 1050 | 7789 | acydburn | $sql[] = $key . ' ' . $db->sql_like_expression(str_replace('%', $db->any_char, $option)); |
| 1051 | 6601 | acydburn | } |
| 1052 | 6601 | acydburn | else
|
| 1053 | 6601 | acydburn | {
|
| 1054 | 6601 | acydburn | $sql[] = $key . " = '" . $db->sql_escape($option) . "'"; |
| 1055 | 6601 | acydburn | } |
| 1056 | 6366 | acydburn | } |
| 1057 | 6366 | acydburn | |
| 1058 | 6366 | acydburn | $sql_opts = 'AND (' . implode(' OR ', $sql) . ')'; |
| 1059 | 6366 | acydburn | } |
| 1060 | 6366 | acydburn | } |
| 1061 | 6366 | acydburn | } |
| 1062 | 5423 | acydburn | } |
| 1063 | 5423 | acydburn | |
| 1064 | 5423 | acydburn | ?> |

