Esempio n. 1
0
function loadforum($fid = null, $tid = null)
{
    global $_G;
    $tid = intval(isset($tid) ? $tid : getgpc('tid'));
    if (isset($fid)) {
        $fid = intval($fid);
    } else {
        $fid = getgpc('fid');
        if (!$fid && getgpc('gid')) {
            $fid = intval(getgpc('gid'));
        }
    }
    if (isset($_G['forum']['fid']) && $_G['forum']['fid'] == $fid || isset($_G['thread']['tid']) && $_G['thread']['tid'] == $tid) {
        return null;
    }
    if (!empty($_GET['archiver'])) {
        //X1.5的Archiver兼容
        if ($fid) {
            dheader('location: archiver/?fid-' . $fid . '.html');
        } elseif ($tid) {
            dheader('location: archiver/?tid-' . $tid . '.html');
        } else {
            dheader('location: archiver/');
        }
    }
    if (defined('IN_ARCHIVER') && $_G['setting']['archiverredirect'] && !IS_ROBOT) {
        dheader('location: ../forum.php' . ($_G['mod'] ? '?mod=' . $_G['mod'] . (!empty($_GET['fid']) ? '&fid=' . $_GET['fid'] : (!empty($_GET['tid']) ? '&tid=' . $_GET['tid'] : '')) : ''));
    }
    if ($_G['setting']['forumpicstyle']) {
        $_G['setting']['forumpicstyle'] = dunserialize($_G['setting']['forumpicstyle']);
        empty($_G['setting']['forumpicstyle']['thumbwidth']) && ($_G['setting']['forumpicstyle']['thumbwidth'] = 203);
        empty($_G['setting']['forumpicstyle']['thumbheight']) && ($_G['setting']['forumpicstyle']['thumbheight'] = 999);
    } else {
        $_G['setting']['forumpicstyle'] = array('thumbwidth' => 203, 'thumbheight' => 999);
    }
    if ($fid) {
        $fid = is_numeric($fid) ? intval($fid) : (!empty($_G['setting']['forumfids'][$fid]) ? $_G['setting']['forumfids'][$fid] : 0);
    }
    $modthreadkey = isset($_GET['modthreadkey']) && $_GET['modthreadkey'] == modauthkey($tid) ? $_GET['modthreadkey'] : '';
    $_G['forum_auditstatuson'] = $modthreadkey ? true : false;
    $metadescription = $hookscriptmessage = '';
    $adminid = $_G['adminid'];
    if (!empty($tid) || !empty($fid)) {
        if (!empty($tid)) {
            $archiveid = !empty($_GET['archiveid']) ? intval($_GET['archiveid']) : null;
            $_G['thread'] = get_thread_by_tid($tid, $archiveid);
            $_G['thread']['allreplies'] = $_G['thread']['replies'] + $_G['thread']['comments'];
            if (!$_G['forum_auditstatuson'] && !empty($_G['thread']) && !($_G['thread']['displayorder'] >= 0 || in_array($_G['thread']['displayorder'], array(-4, -3, -2)) && $_G['uid'] && $_G['thread']['authorid'] == $_G['uid'])) {
                $_G['thread'] = null;
            }
            $_G['forum_thread'] =& $_G['thread'];
            if (empty($_G['thread'])) {
                $fid = $tid = 0;
            } else {
                $fid = $_G['thread']['fid'];
                $tid = $_G['thread']['tid'];
            }
        }
        if ($fid) {
            $forum = C::t('forum_forum')->fetch_info_by_fid($fid);
        }
        if ($forum) {
            if ($_G['uid']) {
                if ($_G['member']['accessmasks']) {
                    $query = C::t('forum_access')->fetch_all_by_fid_uid($fid, $_G['uid']);
                    $forum['allowview'] = $query[0]['allowview'];
                    $forum['allowpost'] = $query[0]['allowpost'];
                    $forum['allowreply'] = $query[0]['allowreply'];
                    $forum['allowgetattach'] = $query[0]['allowgetattach'];
                    $forum['allowgetimage'] = $query[0]['allowgetimage'];
                    $forum['allowpostattach'] = $query[0]['allowpostattach'];
                    $forum['allowpostimage'] = $query[0]['allowpostimage'];
                }
                if ($adminid == 3) {
                    $forum['ismoderator'] = C::t('forum_moderator')->fetch_uid_by_fid_uid($fid, $_G['uid']);
                }
            }
            $forum['ismoderator'] = !empty($forum['ismoderator']) || $adminid == 1 || $adminid == 2 ? 1 : 0;
            $fid = $forum['fid'];
            $gorup_admingroupids = $_G['setting']['group_admingroupids'] ? dunserialize($_G['setting']['group_admingroupids']) : array('1' => '1');
            if ($forum['status'] == 3) {
                if (!empty($forum['moderators'])) {
                    $forum['moderators'] = dunserialize($forum['moderators']);
                } else {
                    require_once libfile('function/group');
                    $forum['moderators'] = update_groupmoderators($fid);
                }
                if ($_G['uid'] && $_G['adminid'] != 1) {
                    $forum['ismoderator'] = !empty($forum['moderators'][$_G['uid']]) ? 1 : 0;
                    $_G['adminid'] = 0;
                    if ($forum['ismoderator'] || $gorup_admingroupids[$_G['groupid']]) {
                        $_G['adminid'] = $_G['adminid'] ? $_G['adminid'] : 3;
                        if (!empty($gorup_admingroupids[$_G['groupid']])) {
                            $forum['ismoderator'] = 1;
                            $_G['adminid'] = 2;
                        }
                        $group_userperm = dunserialize($_G['setting']['group_userperm']);
                        if (is_array($group_userperm)) {
                            $_G['group'] = array_merge($_G['group'], $group_userperm);
                            $_G['group']['allowmovethread'] = $_G['group']['allowcopythread'] = $_G['group']['allowedittypethread'] = 0;
                        }
                    }
                }
            }
            foreach (array('threadtypes', 'threadsorts', 'creditspolicy', 'modrecommend') as $key) {
                $forum[$key] = !empty($forum[$key]) ? dunserialize($forum[$key]) : array();
                if (!is_array($forum[$key])) {
                    $forum[$key] = array();
                }
            }
            if ($forum['status'] == 3) {
                $_G['isgroupuser'] = 0;
                $_G['basescript'] = 'group';
                if ($forum['level'] == 0) {
                    $levelinfo = C::t('forum_grouplevel')->fetch_by_credits($forum['commoncredits']);
                    $levelid = $levelinfo['levelid'];
                    $forum['level'] = $levelid;
                    C::t('forum_forum')->update_group_level($levelid, $fid);
                }
                if ($forum['level'] != -1) {
                    loadcache('grouplevels');
                    $grouplevel = $_G['grouplevels'][$forum['level']];
                    if (!empty($grouplevel['icon'])) {
                        $valueparse = parse_url($grouplevel['icon']);
                        if (!isset($valueparse['host'])) {
                            $grouplevel['icon'] = $_G['setting']['attachurl'] . 'common/' . $grouplevel['icon'];
                        }
                    }
                }
                $group_postpolicy = $grouplevel['postpolicy'];
                if (is_array($group_postpolicy)) {
                    $forum = array_merge($forum, $group_postpolicy);
                }
                $forum['allowfeed'] = $_G['setting']['group_allowfeed'];
                if ($_G['uid']) {
                    if (!empty($forum['moderators'][$_G['uid']])) {
                        $_G['isgroupuser'] = 1;
                    } else {
                        $groupuserinfo = C::t('forum_groupuser')->fetch_userinfo($_G['uid'], $fid);
                        $_G['isgroupuser'] = $groupuserinfo['level'];
                        if ($_G['isgroupuser'] <= 0 && empty($forum['ismoderator'])) {
                            $_G['group']['allowrecommend'] = $_G['cache']['usergroup_' . $_G['groupid']]['allowrecommend'] = 0;
                            $_G['group']['allowcommentpost'] = $_G['cache']['usergroup_' . $_G['groupid']]['allowcommentpost'] = 0;
                            $_G['group']['allowcommentitem'] = $_G['cache']['usergroup_' . $_G['groupid']]['allowcommentitem'] = 0;
                            $_G['group']['raterange'] = $_G['cache']['usergroup_' . $_G['groupid']]['raterange'] = array();
                            $_G['group']['allowvote'] = $_G['cache']['usergroup_' . $_G['groupid']]['allowvote'] = 0;
                        } else {
                            $_G['isgroupuser'] = 1;
                        }
                    }
                }
            }
        } else {
            $fid = 0;
        }
    }
    $_G['fid'] = $fid;
    $_G['tid'] = $tid;
    $_G['forum'] =& $forum;
    $_G['current_grouplevel'] =& $grouplevel;
    if (empty($_G['uid'])) {
        $_G['group']['allowpostactivity'] = $_G['group']['allowpostpoll'] = $_G['group']['allowvote'] = $_G['group']['allowpostreward'] = $_G['group']['allowposttrade'] = $_G['group']['allowpostdebate'] = $_G['group']['allowpostrushreply'] = 0;
    }
    if (!empty($_G['forum']['widthauto'])) {
        $_G['widthauto'] = $_G['forum']['widthauto'];
    }
}
Esempio n. 2
0
                $ucresult = uc_user_login($_G['uid'], $_G['gp_grouppwd'], 1);
                if (!is_array($ucresult) || $ucresult[0] < 1) {
                    showmessage('group_demise_password_error');
                }
                $user = getuserbyuid($suid);
                loadcache('usergroup_' . $user['groupid']);
                $allowbuildgroup = $_G['cache']['usergroup_' . $user['groupid']]['allowbuildgroup'];
                if ($allowbuildgroup > 0) {
                    $groupnum = DB::result_first("SELECT COUNT(*) FROM " . DB::table('forum_forumfield') . " WHERE founderuid='{$suid}'");
                }
                if (empty($allowbuildgroup) || $allowbuildgroup - $groupnum < 1) {
                    showmessage('group_demise_receiver_cannot_do');
                }
                DB::query("UPDATE " . DB::table('forum_forumfield') . " SET founderuid='{$suid}', foundername='{$user['username']}' WHERE fid='{$_G['fid']}'");
                DB::query("UPDATE " . DB::table('forum_groupuser') . " SET level='1' WHERE fid='{$_G['fid']}' AND uid='{$suid}'");
                update_groupmoderators($_G['fid']);
                sendpm($suid, lang('group/misc', 'group_demise_message_title', array('forum' => $_G['forum']['name'])), lang('group/misc', 'group_demise_message_body', array('forum' => $_G['forum']['name'], 'siteurl' => $_G['siteurl'], 'fid' => $_G['fid'])), $_G['uid']);
                showmessage('group_demise_succeed', 'forum.php?mod=group&action=manage&fid=' . $_G['fid']);
            }
        } else {
            showmessage('group_demise_founder_only');
        }
    } else {
        showmessage('undefined_action');
    }
    include template('diy:group/group:' . $_G['fid']);
} elseif ($action == 'recommend') {
    if (!$_G['forum']['ismoderator'] || !in_array($_G['adminid'], array(1, 2))) {
        showmessage('group_admin_noallowed');
    }
    if (submitcheck('grouprecommend')) {
Esempio n. 3
0
function loadforum()
{
    global $_G;
    $tid = intval(getgpc('tid'));
    $fid = getgpc('fid');
    if ($fid) {
        $fid = is_numeric($fid) ? intval($fid) : (!empty($_G['setting']['forumfids'][$fid]) ? $_G['setting']['forumfids'][$fid] : 0);
    }
    $modthreadkey = isset($_G['gp_modthreadkey']) && $_G['gp_modthreadkey'] == modauthkey($tid) ? $_G['gp_modthreadkey'] : '';
    $_G['forum_auditstatuson'] = $modthreadkey ? true : false;
    $accessadd1 = $accessadd2 = $modadd1 = $modadd2 = $metadescription = $hookscriptmessage = '';
    $adminid = $_G['adminid'];
    if ($_G['uid']) {
        if ($_G['member']['accessmasks']) {
            $accessadd1 = ', a.allowview, a.allowpost, a.allowreply, a.allowgetattach, a.allowpostattach, a.allowpostimage';
            $accessadd2 = "LEFT JOIN " . DB::table('forum_access') . " a ON a.uid='{$_G['uid']}' AND a.fid=f.fid";
        }
        if ($adminid == 3) {
            $modadd1 = ', m.uid AS ismoderator';
            $modadd2 = "LEFT JOIN " . DB::table('forum_moderator') . " m ON m.uid='{$_G['uid']}' AND m.fid=f.fid";
        }
    }
    if (!empty($tid) || !empty($fid)) {
        if (empty($tid)) {
            $forum = DB::fetch_first("SELECT f.fid, f.*, ff.* {$accessadd1} {$modadd1}, f.fid AS fid\r\n\t\t\tFROM " . DB::table('forum_forum') . " f\r\n\t\t\tLEFT JOIN " . DB::table("forum_forumfield") . " ff ON ff.fid=f.fid {$accessadd2} {$modadd2}\r\n\t\t\tWHERE f.fid='{$fid}'");
        } else {
            loadcache('threadtableids');
            $threadtableids = array(0);
            if (!empty($_G['cache']['threadtableids'])) {
                $threadtableids = array_merge($threadtableids, $_G['cache']['threadtableids']);
            }
            $archiveid = intval($_REQUEST['archiveid']);
            if (!empty($archiveid) && in_array($archiveid, $threadtableids)) {
                $threadtable = $archiveid ? "forum_thread_{$archiveid}" : 'forum_thread';
                $forum = DB::fetch_first("SELECT t.tid, t.closed," . (defined('SQL_ADD_THREAD') ? SQL_ADD_THREAD : '') . " f.*, ff.* {$accessadd1} {$modadd1}, f.fid AS fid\r\n\t\t\t\t\tFROM " . DB::table($threadtable) . " t\r\n\t\t\t\t\tINNER JOIN " . DB::table('forum_forum') . " f ON f.fid=t.fid\r\n\t\t\t\t\tLEFT JOIN " . DB::table('forum_forumfield') . " ff ON ff.fid=f.fid {$accessadd2} {$modadd2}\r\n\t\t\t\t\tWHERE t.tid='{$tid}'" . ($_G['forum_auditstatuson'] ? '' : " AND (t.displayorder>='0' OR (t.displayorder IN ('-4', '-3', '-2') AND t.authorid='{$_G['uid']}'))") . " LIMIT 1");
                $forum['threadtableid'] = $archiveid;
            } else {
                foreach ($threadtableids as $tableid) {
                    $threadtable = $tableid ? "forum_thread_{$tableid}" : 'forum_thread';
                    $forum = DB::fetch_first("SELECT t.tid, t.closed," . (defined('SQL_ADD_THREAD') ? SQL_ADD_THREAD : '') . " f.*, ff.* {$accessadd1} {$modadd1}, f.fid AS fid\r\n\t\t\t\t\tFROM " . DB::table($threadtable) . " t\r\n\t\t\t\t\tINNER JOIN " . DB::table('forum_forum') . " f ON f.fid=t.fid\r\n\t\t\t\t\tLEFT JOIN " . DB::table('forum_forumfield') . " ff ON ff.fid=f.fid {$accessadd2} {$modadd2}\r\n\t\t\t\t\tWHERE t.tid='{$tid}'" . ($_G['forum_auditstatuson'] ? '' : " AND (t.displayorder>='0' OR (t.displayorder IN ('-4', '-3', '-2') AND t.authorid='{$_G['uid']}'))") . " LIMIT 1");
                    if (!empty($forum)) {
                        $forum['threadtableid'] = $tableid;
                        break;
                    }
                }
            }
            $tid = $forum['tid'];
        }
        if ($forum) {
            $forum['ismoderator'] = !empty($forum['ismoderator']) || $adminid == 1 || $adminid == 2 ? 1 : 0;
            $fid = $forum['fid'];
            $gorup_admingroupids = $_G['setting']['group_admingroupids'] ? unserialize($_G['setting']['group_admingroupids']) : array('1' => '1');
            if ($forum['status'] == 3) {
                if (!$_G['setting']['groupstatus']) {
                    showmessage('group_status_off');
                }
                if (!empty($forum['moderators'])) {
                    $forum['moderators'] = unserialize($forum['moderators']);
                } else {
                    require_once libfile('function/group');
                    $forum['moderators'] = update_groupmoderators($fid);
                }
                if ($_G['uid'] && $_G['adminid'] != 1) {
                    $forum['ismoderator'] = !empty($forum['moderators'][$_G['uid']]) ? 1 : 0;
                    $_G['adminid'] = 0;
                    if ($forum['ismoderator'] || $gorup_admingroupids[$_G['groupid']]) {
                        $_G['adminid'] = $_G['adminid'] ? $_G['adminid'] : 3;
                        if (!empty($gorup_admingroupids[$_G['groupid']])) {
                            $forum['ismoderator'] = 1;
                            $_G['adminid'] = 2;
                        }
                        $group_userperm = unserialize($_G['setting']['group_userperm']);
                        if (is_array($group_userperm)) {
                            $_G['group'] = array_merge($_G['group'], $group_userperm);
                            $_G['group']['allowmovethread'] = $_G['group']['allowcopythread'] = $_G['group']['allowedittypethread'] = 0;
                        }
                    }
                }
            }
            foreach (array('threadtypes', 'threadsorts', 'creditspolicy', 'modrecommend') as $key) {
                $forum[$key] = !empty($forum[$key]) ? unserialize($forum[$key]) : array();
            }
            if ($forum['status'] == 3) {
                $_G['isgroupuser'] = 0;
                $_G['basescript'] = 'group';
                $_G['group']['allowstickthread'] = 1;
                if (empty($forum['level'])) {
                    $levelid = DB::result_first("SELECT levelid FROM " . DB::table('forum_grouplevel') . " WHERE creditshigher<='{$forum['commoncredits']}' AND '{$forum['commoncredits']}'<creditslower LIMIT 1");
                    $forum['level'] = $levelid;
                    DB::query("UPDATE " . DB::table('forum_forum') . " SET level='{$levelid}' WHERE fid='{$fid}'");
                }
                loadcache('grouplevels');
                $grouplevel = $_G['grouplevels'][$forum['level']];
                if (!empty($grouplevel['icon'])) {
                    $valueparse = parse_url($grouplevel['icon']);
                    if (!isset($valueparse['host'])) {
                        $grouplevel['icon'] = $_G['setting']['attachurl'] . 'common/' . $grouplevel['icon'];
                    }
                }
                $group_postpolicy = $grouplevel['postpolicy'];
                if (is_array($group_postpolicy)) {
                    $forum = array_merge($forum, $group_postpolicy);
                }
                $forum['allowfeed'] = $_G['setting']['group_allowfeed'];
                if ($_G['uid']) {
                    if (!empty($forum['moderators'][$_G['uid']])) {
                        $_G['isgroupuser'] = 1;
                    } else {
                        $_G['isgroupuser'] = DB::result_first("SELECT level FROM " . DB::table('forum_groupuser') . " WHERE fid='{$fid}' AND uid='{$_G['uid']}' LIMIT 1");
                        if ($_G['isgroupuser'] <= 0 && empty($forum['ismoderator'])) {
                            $_G['group']['allowrecommend'] = $_G['cache']['usergroup_' . $_G['groupid']]['allowrecommend'] = 0;
                            $_G['group']['allowcommentpost'] = $_G['cache']['usergroup_' . $_G['groupid']]['allowcommentpost'] = 0;
                            $_G['group']['allowcommentitem'] = $_G['cache']['usergroup_' . $_G['groupid']]['allowcommentitem'] = 0;
                            $_G['group']['raterange'] = $_G['cache']['usergroup_' . $_G['groupid']]['raterange'] = array();
                            $_G['group']['allowvote'] = $_G['cache']['usergroup_' . $_G['groupid']]['allowvote'] = 0;
                        } else {
                            $_G['isgroupuser'] = 1;
                        }
                    }
                }
            }
        } else {
            $fid = 0;
        }
    }
    $_G['fid'] = $fid;
    $_G['tid'] = $tid;
    $_G['forum'] =& $forum;
    $_G['current_grouplevel'] =& $grouplevel;
}
Esempio n. 4
0
function loadforum()
{
    global $_G;
    $tid = intval(getgpc('tid'));
    $fid = getgpc('fid');
    if (!$fid && getgpc('gid')) {
        $fid = intval(getgpc('gid'));
    }
    /*vot*/
    if (!empty($_G['gp_archiver'])) {
        //Archiver X1.5 compatible
        if ($fid) {
            dheader('location: archiver/?fid-' . $fid . '.html');
        } elseif ($tid) {
            dheader('location: archiver/?tid-' . $tid . '.html');
        } else {
            dheader('location: archiver/');
        }
    }
    if (defined('IN_ARCHIVER') && $_G['setting']['archiverredirect'] && !IS_ROBOT) {
        dheader('location: ../forum.php' . ($_G['mod'] ? '?mod=' . $_G['mod'] . (!empty($_GET['fid']) ? '&fid=' . $_GET['fid'] : (!empty($_GET['tid']) ? '&tid=' . $_GET['tid'] : '')) : ''));
    }
    if ($_G['setting']['forumpicstyle']) {
        $_G['setting']['forumpicstyle'] = unserialize($_G['setting']['forumpicstyle']);
        empty($_G['setting']['forumpicstyle']['thumbwidth']) && ($_G['setting']['forumpicstyle']['thumbwidth'] = 214);
        empty($_G['setting']['forumpicstyle']['thumbheight']) && ($_G['setting']['forumpicstyle']['thumbheight'] = 160);
    } else {
        $_G['setting']['forumpicstyle'] = array('thumbwidth' => 214, 'thumbheight' => 160);
    }
    if ($fid) {
        $fid = is_numeric($fid) ? intval($fid) : (!empty($_G['setting']['forumfids'][$fid]) ? $_G['setting']['forumfids'][$fid] : 0);
    }
    $modthreadkey = isset($_G['gp_modthreadkey']) && $_G['gp_modthreadkey'] == modauthkey($tid) ? $_G['gp_modthreadkey'] : '';
    $_G['forum_auditstatuson'] = $modthreadkey ? true : false;
    $accessadd1 = $accessadd2 = $modadd1 = $modadd2 = $metadescription = $hookscriptmessage = '';
    $adminid = $_G['adminid'];
    if ($_G['uid']) {
        if ($_G['member']['accessmasks']) {
            $accessadd1 = ', a.allowview, a.allowpost, a.allowreply, a.allowgetattach, a.allowgetimage, a.allowpostattach, a.allowpostimage';
            /*vot*/
            $accessadd2 = "LEFT JOIN " . DB::table('forum_access') . " a ON (a.uid='{$_G['uid']}' AND a.fid=f.fid)";
        }
        if ($adminid == 3) {
            $modadd1 = ', m.uid AS ismoderator';
            /*vot*/
            $modadd2 = "LEFT JOIN " . DB::table('forum_moderator') . " m ON (m.uid='{$_G['uid']}' AND m.fid=f.fid)";
        }
    }
    if (!empty($tid) || !empty($fid)) {
        if (!empty($tid)) {
            $archiveid = !empty($_G['gp_archiveid']) ? intval($_G['gp_archiveid']) : null;
            $_G['thread'] = get_thread_by_tid($tid, '*', '', $archiveid);
            if (!$_G['forum_auditstatuson'] && !empty($_G['thread']) && !($_G['thread']['displayorder'] >= 0 || in_array($_G['thread']['displayorder'], array(-4, -3, -2)) && $_G['thread']['authorid'] == $_G['uid'])) {
                $_G['thread'] = null;
            }
            $_G['forum_thread'] =& $_G['thread'];
            if (empty($_G['thread'])) {
                $fid = $tid = 0;
            } else {
                $fid = $_G['thread']['fid'];
                $tid = $_G['thread']['tid'];
            }
        }
        if ($fid) {
            $forum = DB::fetch_first("SELECT f.fid, f.*, ff.* {$accessadd1} {$modadd1}, f.fid AS fid\r\n\t\t\tFROM " . DB::table('forum_forum') . " f\r\n\t\t\tLEFT JOIN " . DB::table("forum_forumfield") . " ff ON ff.fid=f.fid {$accessadd2} {$modadd2}\r\n\t\t\tWHERE f.fid='{$fid}'");
        }
        if ($forum) {
            $forum['ismoderator'] = !empty($forum['ismoderator']) || $adminid == 1 || $adminid == 2 ? 1 : 0;
            $fid = $forum['fid'];
            $gorup_admingroupids = $_G['setting']['group_admingroupids'] ? unserialize($_G['setting']['group_admingroupids']) : array('1' => '1');
            if ($forum['status'] == 3) {
                if (!$_G['setting']['groupstatus']) {
                    showmessage('group_status_off');
                }
                if (!empty($forum['moderators'])) {
                    $forum['moderators'] = unserialize($forum['moderators']);
                } else {
                    require_once libfile('function/group');
                    $forum['moderators'] = update_groupmoderators($fid);
                }
                if ($_G['uid'] && $_G['adminid'] != 1) {
                    $forum['ismoderator'] = !empty($forum['moderators'][$_G['uid']]) ? 1 : 0;
                    $_G['adminid'] = 0;
                    if ($forum['ismoderator'] || $gorup_admingroupids[$_G['groupid']]) {
                        $_G['adminid'] = $_G['adminid'] ? $_G['adminid'] : 3;
                        if (!empty($gorup_admingroupids[$_G['groupid']])) {
                            $forum['ismoderator'] = 1;
                            $_G['adminid'] = 2;
                        }
                        $group_userperm = unserialize($_G['setting']['group_userperm']);
                        if (is_array($group_userperm)) {
                            $_G['group'] = array_merge($_G['group'], $group_userperm);
                            $_G['group']['allowmovethread'] = $_G['group']['allowcopythread'] = $_G['group']['allowedittypethread'] = 0;
                        }
                    }
                }
            }
            foreach (array('threadtypes', 'threadsorts', 'creditspolicy', 'modrecommend') as $key) {
                $forum[$key] = !empty($forum[$key]) ? unserialize($forum[$key]) : array();
                if (!is_array($forum[$key])) {
                    $forum[$key] = array();
                }
            }
            if ($forum['status'] == 3) {
                $_G['isgroupuser'] = 0;
                $_G['basescript'] = 'group';
                if (empty($forum['level'])) {
                    $levelid = DB::result_first("SELECT levelid FROM " . DB::table('forum_grouplevel') . " WHERE creditshigher<='{$forum['commoncredits']}' AND '{$forum['commoncredits']}'<creditslower LIMIT 1");
                    $forum['level'] = $levelid;
                    DB::query("UPDATE " . DB::table('forum_forum') . " SET level='{$levelid}' WHERE fid='{$fid}'");
                }
                loadcache('grouplevels');
                $grouplevel = $_G['grouplevels'][$forum['level']];
                if (!empty($grouplevel['icon'])) {
                    $valueparse = parse_url($grouplevel['icon']);
                    if (!isset($valueparse['host'])) {
                        $grouplevel['icon'] = $_G['setting']['attachurl'] . 'common/' . $grouplevel['icon'];
                    }
                }
                $group_postpolicy = $grouplevel['postpolicy'];
                if (is_array($group_postpolicy)) {
                    $forum = array_merge($forum, $group_postpolicy);
                }
                $forum['allowfeed'] = $_G['setting']['group_allowfeed'];
                if ($_G['uid']) {
                    if (!empty($forum['moderators'][$_G['uid']])) {
                        $_G['isgroupuser'] = 1;
                    } else {
                        $_G['isgroupuser'] = DB::result_first("SELECT level FROM " . DB::table('forum_groupuser') . " WHERE fid='{$fid}' AND uid='{$_G['uid']}' LIMIT 1");
                        if ($_G['isgroupuser'] <= 0 && empty($forum['ismoderator'])) {
                            $_G['group']['allowrecommend'] = $_G['cache']['usergroup_' . $_G['groupid']]['allowrecommend'] = 0;
                            $_G['group']['allowcommentpost'] = $_G['cache']['usergroup_' . $_G['groupid']]['allowcommentpost'] = 0;
                            $_G['group']['allowcommentitem'] = $_G['cache']['usergroup_' . $_G['groupid']]['allowcommentitem'] = 0;
                            $_G['group']['raterange'] = $_G['cache']['usergroup_' . $_G['groupid']]['raterange'] = array();
                            $_G['group']['allowvote'] = $_G['cache']['usergroup_' . $_G['groupid']]['allowvote'] = 0;
                        } else {
                            $_G['isgroupuser'] = 1;
                        }
                    }
                }
            }
        } else {
            $fid = 0;
        }
    }
    $_G['fid'] = $fid;
    $_G['tid'] = $tid;
    $_G['forum'] =& $forum;
    $_G['current_grouplevel'] =& $grouplevel;
    if (isset($_G['cookie']['widthauto']) && $_G['setting']['switchwidthauto'] && empty($_G['forum']['widthauto'])) {
        $_G['forum_widthauto'] = $_G['cookie']['widthauto'] > 0;
    } else {
        $_G['forum_widthauto'] = empty($_G['forum']['widthauto']) ? !$_G['setting']['allowwidthauto'] : $_G['forum']['widthauto'] > 0;
        if (!empty($_G['forum']['widthauto'])) {
            $_G['setting']['switchwidthauto'] = 0;
        }
    }
}