2008-09-15, 09:54 AM
(This post was last modified: 2008-09-18, 01:16 PM by Ryan Gordon.)
MyBB 1.4.1, PHP 5.2.4
I have found that logged regular user is made a moderator while accessing forums main page (he can see reported posts). In inc/functions.php I have added a debug message to is_moderator() function:
The problem is that this users UID is 2 (not 30) and his username - koziolek (not "Amandi"). It seems that problem lies in array_merge which reindex the keys. Look at file inc/class_datacache.php in function build_moderators():
Debug print_r() shows:
I have found that logged regular user is made a moderator while accessing forums main page (he can see reported posts). In inc/functions.php I have added a debug message to is_moderator() function:
$modcache = $cache->read('moderators');
if(!empty($modcache))
{
foreach($modcache as $modusers)
{
if(isset($modusers[$uid]) && $modusers[$uid]['mid'])
{
print_r($modusers[$uid]) ;
return true;
}
}
}
return false;
and it printed:Array
(
[mid] => 89
[fid] => 32
[uid] => 30
[caneditposts] => 1
[candeleteposts] => 1
[canviewips] => 1
[canopenclosethreads] => 1
[canmanagethreads] => 1
[canmovetononmodforum] => 1
[username] => Amandi
[usergroup] => 6
[displaygroup] => 15
)
The problem is that this users UID is 2 (not 30) and his username - koziolek (not "Amandi"). It seems that problem lies in array_merge which reindex the keys. Look at file inc/class_datacache.php in function build_moderators():
// Append - local settings override that of a parent - array_merge works here
if($this->moderators[$forum['fid']])
{
if(is_array($forum_mods))
{
print_r($forum_mods) ; // DEBUG
print_r($this->moderators[$forum['fid']]) ; // DEBUG
$forum_mods = array_merge($forum_mods, $this->moderators[$forum['fid']]);
print_r($forum_mods) ; // DEBUG
}
else
{
$forum_mods = $this->moderators[$forum['fid']];
}
}
Debug print_r() shows:
$forum_mods - before array_merge():
Array
(
[1] => Array
(
[mid] => 1
[fid] => 1
[uid] => 1
[caneditposts] => 1
[candeleteposts] => 1
[canviewips] => 1
[canopenclosethreads] => 1
[canmanagethreads] => 1
[canmovetononmodforum] => 1
[username] => admin
[usergroup] => 4
[displaygroup] => 0
)
)
$this->moderators[$forum['fid']] - before array_merge():
Array
(
[12780] => Array
(
[mid] => 151
[fid] => 35
[uid] => 12780
[caneditposts] => 1
[candeleteposts] => 1
[canviewips] => 1
[canopenclosethreads] => 1
[canmanagethreads] => 1
[canmovetononmodforum] => 1
[username] => m.płochocki
[usergroup] => 8
[displaygroup] => 0
)
[11377] => Array
(
[mid] => 149
[fid] => 35
[uid] => 11377
[caneditposts] => 1
[candeleteposts] => 1
[canviewips] => 1
[canopenclosethreads] => 1
[canmanagethreads] => 1
[canmovetononmodforum] => 1
[username] => p.bijata
[usergroup] => 8
[displaygroup] => 0
)
)
$forum_mods - after array_merge() - look at array keys:
Array
(
[0] => Array
(
[mid] => 1
[fid] => 1
[uid] => 1
[caneditposts] => 1
[candeleteposts] => 1
[canviewips] => 1
[canopenclosethreads] => 1
[canmanagethreads] => 1
[canmovetononmodforum] => 1
[username] => admin
[usergroup] => 4
[displaygroup] => 0
)
[1] => Array
(
[mid] => 151
[fid] => 35
[uid] => 12780
[caneditposts] => 1
[candeleteposts] => 1
[canviewips] => 1
[canopenclosethreads] => 1
[canmanagethreads] => 1
[canmovetononmodforum] => 1
[username] => m.płochocki
[usergroup] => 8
[displaygroup] => 0
)
[2] => Array
(
[mid] => 149
[fid] => 35
[uid] => 11377
[caneditposts] => 1
[candeleteposts] => 1
[canviewips] => 1
[canopenclosethreads] => 1
[canmanagethreads] => 1
[canmovetononmodforum] => 1
[username] => p.bijata
[usergroup] => 8
[displaygroup] => 0
)
)
www.kozik.net.pl
- So... Maybe you shouldn't have hacked it.
- And why don't you try not breathing. Hurts, dunnit. (userfriendly.org)
- So... Maybe you shouldn't have hacked it.
- And why don't you try not breathing. Hurts, dunnit. (userfriendly.org)