Exemplo n.º 1
0
        }
    }
}
if ($mybb->input['action'] == "logout" && $mybb->user) {
    if (verify_post_check($mybb->input['my_post_key'])) {
        $db->delete_query("adminsessions", "sid='" . $db->escape_string($mybb->cookies['adminsid']) . "'");
        my_unsetcookie('adminsid');
        $logged_out = true;
    }
}
if (!isset($mybb->user['usergroup'])) {
    $mybbgroups = 1;
} else {
    $mybbgroups = $mybb->user['usergroup'] . "," . $mybb->user['additionalgroups'];
}
$mybb->usergroup = usergroup_permissions($mybbgroups);
$is_super_admin = is_super_admin($mybb->user['uid']);
if ($mybb->usergroup['cancp'] != 1 && !$is_super_admin || !$mybb->user['uid']) {
    $uid = 0;
    if (isset($mybb->user['uid'])) {
        $uid = (int) $mybb->user['uid'];
    }
    $db->delete_query("adminsessions", "uid = '{$uid}'");
    unset($mybb->user);
    my_unsetcookie('adminsid');
}
if (!empty($mybb->user['uid'])) {
    $query = $db->simple_select("adminoptions", "*", "uid='" . $mybb->user['uid'] . "'");
    $admin_options = $db->fetch_array($query);
    if (!empty($admin_options['cplanguage']) && file_exists(MYBB_ROOT . "inc/languages/" . $admin_options['cplanguage'] . "/admin/home_dashboard.lang.php")) {
        $cp_language = $admin_options['cplanguage'];
Exemplo n.º 2
0
     $query = $db->simple_select("usergroups", "*", "gid='{$gid}'");
     $usergroup = $db->fetch_array($query);
     $query = $db->simple_select("forums", "*", "fid='{$fid}'");
     $forum = $db->fetch_array($query);
     $sperms = $permission_data;
     $sql = build_parent_list($fid);
     $query = $db->simple_select("forumpermissions", "*", "{$sql} AND gid='{$gid}'");
     $customperms = $db->fetch_array($query);
     if ($permission_data['pid']) {
         $permission_data['usecustom'] = 1;
         echo $form->generate_hidden_field("pid", $pid);
     } else {
         echo $form->generate_hidden_field("fid", $fid);
         echo $form->generate_hidden_field("gid", $gid);
         if (!$customperms['pid']) {
             $permission_data = usergroup_permissions($gid);
         } else {
             $permission_data = forum_permissions($fid, 0, $gid);
         }
     }
 }
 $groups = array('canviewthreads' => 'viewing', 'canview' => 'viewing', 'canonlyviewownthreads' => 'viewing', 'candlattachments' => 'viewing', 'canpostthreads' => 'posting_rating', 'canpostreplys' => 'posting_rating', 'canonlyreplyownthreads' => 'posting_rating', 'canpostattachments' => 'posting_rating', 'canratethreads' => 'posting_rating', 'caneditposts' => 'editing', 'candeleteposts' => 'editing', 'candeletethreads' => 'editing', 'caneditattachments' => 'editing', 'modposts' => 'moderate', 'modthreads' => 'moderate', 'modattachments' => 'moderate', 'mod_edit_posts' => 'moderate', 'canpostpolls' => 'polls', 'canvotepolls' => 'polls', 'cansearch' => 'misc');
 $groups = $plugins->run_hooks("admin_forum_management_permission_groups", $groups);
 $tabs = array();
 foreach (array_unique(array_values($groups)) as $group) {
     $lang_group = "group_" . $group;
     $tabs[$group] = $lang->{$lang_group};
 }
 if ($mybb->input['ajax'] == 1) {
     $page->output_tab_control($tabs, false, "tabs2");
 } else {
Exemplo n.º 3
0
 /**
  * Load a search engine spider.
  *
  * @param int The ID of the search engine spider
  */
 function load_spider($spider_id)
 {
     global $mybb, $time, $db, $lang;
     // Fetch the spider preferences from the database
     $query = $db->simple_select("spiders", "*", "sid='{$spider_id}'", array('limit' => 1));
     $spider = $db->fetch_array($query);
     // Set up some defaults
     $time = TIME_NOW;
     $this->is_spider = true;
     if ($spider['usergroup']) {
         $mybb->user['usergroup'] = $spider['usergroup'];
     } else {
         $mybb->user['usergroup'] = 1;
     }
     $mybb->user['username'] = '';
     $mybb->user['uid'] = 0;
     $mybb->user['displaygroup'] = $mybb->user['usergroup'];
     // Set spider language
     if ($spider['language'] && $lang->language_exists($spider['language'])) {
         $mybb->settings['bblanguage'] = $spider['language'];
     }
     // Set spider theme
     if ($spider['theme']) {
         $mybb->user['style'] = $spider['theme'];
     }
     // Gather a full permission set for this spider.
     $mybb->usergroup = usergroup_permissions($mybb->user['usergroup']);
     $mydisplaygroup = usergroup_displaygroup($mybb->user['displaygroup']);
     $mybb->usergroup = array_merge($mybb->usergroup, $mydisplaygroup);
     // Update spider last minute (only do so on two minute intervals - decrease load for quick spiders)
     if ($spider['lastvisit'] < TIME_NOW - 120) {
         $updated_spider = array("lastvisit" => TIME_NOW);
         $db->update_query("spiders", $updated_spider, "sid='{$spider_id}'", 1);
     }
     // Update the online data.
     if (!defined("NO_ONLINE")) {
         $this->sid = "bot=" . $spider_id;
         $this->create_session();
     }
 }
Exemplo n.º 4
0
/**
 * Build the forum permissions for a specific forum, user or group
 *
 * @param int The forum ID to build permissions for (0 builds for all forums)
 * @param int The user to build the permissions for (0 will select the uid automatically)
 * @param int The group of the user to build permissions for (0 will fetch it)
 * @return array Forum permissions for the specific forum or forums
 */
function forum_permissions($fid = 0, $uid = 0, $gid = 0)
{
    global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $cached_forum_permissions_permissions, $cached_forum_permissions;
    if ($uid == 0) {
        $uid = $mybb->user['uid'];
    }
    if (!$gid || $gid == 0) {
        if ($uid != 0 && $uid != $mybb->user['uid']) {
            if (!$usercache[$uid]) {
                $query = $db->simple_select("users", "*", "uid='{$uid}'");
                $usercache[$uid] = $db->fetch_array($query);
            }
            $gid = $usercache[$uid]['usergroup'] . "," . $usercache[$uid]['additionalgroups'];
            $groupperms = usergroup_permissions($gid);
        } else {
            $gid = $mybb->user['usergroup'];
            if (isset($mybb->user['additionalgroups'])) {
                $gid .= "," . $mybb->user['additionalgroups'];
            }
            $groupperms = $mybb->usergroup;
        }
    }
    if (!is_array($forum_cache)) {
        $forum_cache = cache_forums();
        if (!$forum_cache) {
            return false;
        }
    }
    if (!is_array($fpermcache)) {
        $fpermcache = $cache->read("forumpermissions");
    }
    if ($fid) {
        if (!$cached_forum_permissions_permissions[$gid][$fid]) {
            $cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);
        }
        return $cached_forum_permissions_permissions[$gid][$fid];
    } else {
        if (!$cached_forum_permissions[$gid]) {
            foreach ($forum_cache as $forum) {
                $cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
            }
        }
        return $cached_forum_permissions[$gid];
    }
}