Esempio n. 1
0
                $plugin['modules'] = addslashes(serialize($plugin['modules']));
                DB::query("UPDATE " . DB::table('common_plugin') . " SET modules='" . $plugin['modules'] . "' WHERE pluginid='{$plugin['pluginid']}'");
            }
        }
        updatecache(array('plugin', 'setting', 'styles'));
        cpmsg('plugins_edit_succeed', 'action=plugins', 'succeed');
    }
} elseif ($operation == 'enable' || $operation == 'disable') {
    $conflictplugins = '';
    if ($operation == 'enable') {
        $plugin = DB::fetch_first("SELECT * FROM " . DB::table('common_plugin') . " WHERE pluginid='{$_G['gp_pluginid']}'");
        if (!$plugin) {
            cpmsg('plugin_not_found', '', 'error');
        }
        require_once libfile('cache/setting', 'function');
        list(, , $hookscript) = get_cachedata_setting_plugin($plugin['identifier']);
        $exists = array();
        foreach ($hookscript as $script => $modules) {
            foreach ($modules as $module => $data) {
                foreach (array('funcs' => '', 'outputfuncs' => '_output', 'messagefuncs' => '_message') as $functype => $funcname) {
                    /*vot*/
                    if (isset($data[$functype])) {
                        foreach ($data[$functype] as $k => $funcs) {
                            $pluginids = array();
                            foreach ($funcs as $func) {
                                $pluginids[$func[0]] = $func[0];
                            }
                            if (in_array($plugin['identifier'], $pluginids) && count($pluginids) > 1) {
                                unset($pluginids[$plugin['identifier']]);
                                foreach ($pluginids as $pluginid) {
                                    $exists[$pluginid][$k . $funcname] = $k . $funcname;
Esempio n. 2
0
function build_cache_setting()
{
    global $_G;
    $table = 'common_setting';
    $skipkeys = array('posttableids', 'siteuniqueid', 'mastermobile', 'closedreason', 'creditsnotify', 'backupdir', 'custombackup', 'jswizard', 'maxonlines', 'modreasons', 'newsletter', 'postno', 'postnocustom', 'customauthorinfo', 'domainwhitelist', 'ipregctrl', 'ipverifywhite', 'fastsmiley', 'defaultdoing', 'profilegroup');
    $serialized = array('reginput', 'memory', 'search', 'creditspolicy', 'ftp', 'secqaa', 'ec_credit', 'qihoo', 'spacedata', 'infosidestatus', 'uc', 'indexhot', 'relatedtag', 'sitemessage', 'uchome', 'heatthread', 'recommendthread', 'disallowfloat', 'allowviewuserthread', 'advtype', 'click', 'card', 'rewritestatus', 'rewriterule', 'privacy', 'focus', 'forumkeys', 'article_tags', 'verify', 'seotitle', 'seodescription', 'seokeywords', 'domain', 'ranklist', 'seccodedata', 'inviteconfig', 'advexpiration', 'allowpostcomment', 'mobile', 'connect');
    $data = array();
    $query = DB::query("SELECT * FROM " . DB::table($table) . " WHERE skey NOT IN(" . dimplode($skipkeys) . ')');
    while ($setting = DB::fetch($query)) {
        if ($setting['skey'] == 'extcredits') {
            if (is_array($setting['svalue'] = unserialize($setting['svalue']))) {
                foreach ($setting['svalue'] as $key => $value) {
                    if ($value['available']) {
                        unset($setting['svalue'][$key]['available']);
                    } else {
                        unset($setting['svalue'][$key]);
                    }
                }
            }
        } elseif ($setting['skey'] == 'creditsformula') {
            if (!checkformulacredits($setting['svalue'])) {
                $setting['svalue'] = '$member[\'extcredits1\']';
            } else {
                $setting['svalue'] = preg_replace("/(friends|doings|blogs|albums|polls|sharings|digestposts|posts|threads|oltime|extcredits[1-8])/", "\$member['\\1']", $setting['svalue']);
            }
        } elseif ($setting['skey'] == 'maxsmilies') {
            $setting['svalue'] = $setting['svalue'] <= 0 ? -1 : $setting['svalue'];
        } elseif ($setting['skey'] == 'threadsticky') {
            $setting['svalue'] = explode(',', $setting['svalue']);
        } elseif ($setting['skey'] == 'attachdir') {
            $setting['svalue'] = preg_replace("/\\.asp|\\0/i", '0', $setting['svalue']);
            $setting['svalue'] = str_replace('\\', '/', substr($setting['svalue'], 0, 2) == './' ? DISCUZ_ROOT . $setting['svalue'] : $setting['svalue']);
            $setting['svalue'] .= substr($setting['svalue'], -1, 1) != '/' ? '/' : '';
        } elseif ($setting['skey'] == 'attachurl') {
            $setting['svalue'] .= substr($setting['svalue'], -1, 1) != '/' ? '/' : '';
        } elseif ($setting['skey'] == 'onlinehold') {
            $setting['svalue'] = $setting['svalue'] * 60;
        } elseif (in_array($setting['skey'], $serialized)) {
            $setting['svalue'] = @unserialize($setting['svalue']);
            if ($setting['skey'] == 'search') {
                foreach ($setting['svalue'] as $key => $val) {
                    foreach ($val as $k => $v) {
                        $setting['svalue'][$key][$k] = max(0, intval($v));
                    }
                }
            }
            if ($setting['skey'] == 'ftp') {
                $setting['svalue']['attachurl'] .= substr($setting['svalue']['attachurl'], -1, 1) != '/' ? '/' : '';
            }
        }
        $_G['setting'][$setting['skey']] = $data[$setting['skey']] = $setting['svalue'];
    }
    DB::free_result($query);
    $data['newusergroupid'] = DB::result_first("SELECT groupid FROM " . DB::table('common_usergroup') . " WHERE creditshigher<=" . intval($data['initcredits']) . " AND " . intval($data['initcredits']) . "<creditslower LIMIT 1");
    if ($data['srchhotkeywords']) {
        $data['srchhotkeywords'] = explode("\n", $data['srchhotkeywords']);
    }
    if ($data['search']) {
        $searchstatus = 0;
        foreach ($data['search'] as $item) {
            if ($item['status']) {
                $searchstatus = 1;
                break;
            }
        }
        if (!$searchstatus) {
            $data['search'] = array();
        }
    }
    $data['creditspolicy'] = array_merge($data['creditspolicy'], get_cachedata_setting_creditspolicy());
    if ($data['heatthread']['iconlevels']) {
        $data['heatthread']['iconlevels'] = explode(',', $data['heatthread']['iconlevels']);
        arsort($data['heatthread']['iconlevels']);
    } else {
        $data['heatthread']['iconlevels'] = array();
    }
    if ($data['verify']) {
        foreach ($data['verify'] as $key => $value) {
            if ($value['available'] && !empty($value['icon'])) {
                $icourl = parse_url($value['icon']);
                if (!$icourl['host'] && !file_exists($value['icon'])) {
                    $data['verify'][$key]['icon'] = $data['attachurl'] . 'common/' . $value['icon'];
                }
            }
        }
    }
    if ($data['recommendthread']['status']) {
        if ($data['recommendthread']['iconlevels']) {
            $data['recommendthread']['iconlevels'] = explode(',', $data['recommendthread']['iconlevels']);
            arsort($data['recommendthread']['iconlevels']);
        } else {
            $data['recommendthread']['iconlevels'] = array();
        }
    } else {
        $data['recommendthread'] = array('allow' => 0);
    }
    if ($data['commentnumber'] && !$data['allowpostcomment']) {
        $data['commentnumber'] = 0;
    }
    if (!empty($data['ftp'])) {
        if (!empty($data['ftp']['allowedexts'])) {
            $data['ftp']['allowedexts'] = str_replace(array("\r\n", "\r"), array("\n", "\n"), $data['ftp']['allowedexts']);
            $data['ftp']['allowedexts'] = explode("\n", strtolower($data['ftp']['allowedexts']));
            array_walk($data['ftp']['allowedexts'], 'trim');
        }
        if (!empty($data['ftp']['disallowedexts'])) {
            $data['ftp']['disallowedexts'] = str_replace(array("\r\n", "\r"), array("\n", "\n"), $data['ftp']['disallowedexts']);
            $data['ftp']['disallowedexts'] = explode("\n", strtolower($data['ftp']['disallowedexts']));
            array_walk($data['ftp']['disallowedexts'], 'trim');
        }
        $data['ftp']['connid'] = 0;
    }
    if (!empty($data['forumkeys'])) {
        $data['forumfids'] = array_flip($data['forumkeys']);
    } else {
        $data['forumfids'] = array();
    }
    $data['commentitem'] = explode("\t", $data['commentitem']);
    $commentitem = array();
    foreach ($data['commentitem'] as $k => $v) {
        $tmp = explode(chr(0) . chr(0) . chr(0), $v);
        if (count($tmp) > 1) {
            $commentitem[$tmp[0]] = $tmp[1];
        } else {
            $commentitem[$k] = $v;
        }
    }
    $data['commentitem'] = $commentitem;
    if ($data['allowviewuserthread']['allow']) {
        $data['allowviewuserthread'] = is_array($data['allowviewuserthread']['fids']) && $data['allowviewuserthread']['fids'] && !in_array('', $data['allowviewuserthread']['fids']) ? dimplode($data['allowviewuserthread']['fids']) : '';
    } else {
        $data['allowviewuserthread'] = false;
    }
    include_once DISCUZ_ROOT . './source/discuz_version.php';
    $_G['setting']['version'] = $data['version'] = DISCUZ_VERSION;
    $data['sitemessage']['time'] = !empty($data['sitemessage']['time']) ? $data['sitemessage']['time'] * 1000 : 0;
    foreach (array('register', 'login', 'newthread', 'reply') as $type) {
        $data['sitemessage'][$type] = !empty($data['sitemessage'][$type]) ? explode("\n", $data['sitemessage'][$type]) : array();
    }
    $data['cachethreadon'] = DB::result_first("SELECT COUNT(*) FROM " . DB::table('forum_forum') . " WHERE status='1' AND threadcaches>0") ? 1 : 0;
    $data['disallowfloat'] = is_array($data['disallowfloat']) ? implode('|', $data['disallowfloat']) : '';
    if (!$data['imagelib']) {
        unset($data['imageimpath']);
    }
    if (is_array($data['relatedtag']['order'])) {
        asort($data['relatedtag']['order']);
        $relatedtag = array();
        foreach ($data['relatedtag']['order'] as $k => $v) {
            $relatedtag['status'][$k] = $data['relatedtag']['status'][$k];
            $relatedtag['name'][$k] = $data['relatedtag']['name'][$k];
            $relatedtag['limit'][$k] = $data['relatedtag']['limit'][$k];
            $relatedtag['template'][$k] = $data['relatedtag']['template'][$k];
        }
        $data['relatedtag'] = $relatedtag;
        foreach ((array) $data['relatedtag']['status'] as $appid => $status) {
            if (!$status) {
                unset($data['relatedtag']['limit'][$appid]);
            }
        }
        unset($data['relatedtag']['status'], $data['relatedtag']['order'], $relatedtag);
    }
    $data['domain']['defaultindex'] = isset($data['defaultindex']) && $data['defaultindex'] != '#' ? $data['defaultindex'] : '';
    $data['domain']['holddomain'] = isset($data['holddomain']) ? $data['holddomain'] : '';
    $data['domain']['list'] = array();
    $query = DB::query("SELECT * FROM " . DB::table('common_domain') . " WHERE idtype IN('subarea', 'forum', 'topic', 'channel')");
    while ($value = DB::fetch($query)) {
        $data['domain']['list'][$value['domain'] . '.' . $value['domainroot']] = array('id' => $value['id'], 'idtype' => $value['idtype']);
    }
    writetocache('domain', getcachevars(array('domain' => $data['domain'])));
    $data['seccodedata'] = is_array($data['seccodedata']) ? $data['seccodedata'] : array();
    if ($data['seccodedata']['type'] == 2) {
        if (extension_loaded('ming')) {
            unset($data['seccodedata']['background'], $data['seccodedata']['adulterate'], $data['seccodedata']['ttf'], $data['seccodedata']['angle'], $data['seccodedata']['color'], $data['seccodedata']['size'], $data['seccodedata']['animator']);
        } else {
            $data['seccodedata']['animator'] = 0;
        }
    } elseif ($data['seccodedata']['type'] == 99) {
        $data['seccodedata']['width'] = 32;
        $data['seccodedata']['height'] = 24;
    }
    $data['watermarktype'] = !empty($data['watermarktype']) ? unserialize($data['watermarktype']) : array();
    $data['watermarktext'] = !empty($data['watermarktext']) ? unserialize($data['watermarktext']) : array();
    foreach ($data['watermarktype'] as $k => $v) {
        if ($data['watermarktype'][$k] == 'text' && $data['watermarktext']['text'][$k]) {
            if ($data['watermarktext']['text'][$k] && strtoupper(CHARSET) != 'UTF-8') {
                $data['watermarktext']['text'][$k] = diconv($data['watermarktext']['text'][$k], CHARSET, 'UTF-8', true);
            }
            $data['watermarktext']['text'][$k] = bin2hex($data['watermarktext']['text'][$k]);
            if (file_exists('static/image/seccode/font/en/' . $data['watermarktext']['fontpath'][$k])) {
                $data['watermarktext']['fontpath'][$k] = 'static/image/seccode/font/en/' . $data['watermarktext']['fontpath'][$k];
            } elseif (file_exists('static/image/seccode/font/ch/' . $data['watermarktext']['fontpath'][$k])) {
                $data['watermarktext']['fontpath'][$k] = 'static/image/seccode/font/ch/' . $data['watermarktext']['fontpath'][$k];
            } else {
                $data['watermarktext']['fontpath'][$k] = 'static/image/seccode/font/' . $data['watermarktext']['fontpath'][$k];
            }
            $data['watermarktext']['color'][$k] = preg_replace('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/e', "hexdec('\\1').','.hexdec('\\2').','.hexdec('\\3')", $data['watermarktext']['color'][$k]);
            $data['watermarktext']['shadowcolor'][$k] = preg_replace('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/e', "hexdec('\\1').','.hexdec('\\2').','.hexdec('\\3')", $data['watermarktext']['shadowcolor'][$k]);
        } else {
            $data['watermarktext']['text'][$k] = '';
            $data['watermarktext']['fontpath'][$k] = '';
            $data['watermarktext']['color'][$k] = '';
            $data['watermarktext']['shadowcolor'][$k] = '';
        }
    }
    $data['styles'] = array();
    $query = DB::query("SELECT s.styleid, s.name, s.extstyle, t.directory FROM " . DB::table('common_style') . " s\n\t\t\t\tLEFT JOIN " . DB::table('common_template') . " t ON s.templateid=t.templateid\n\t\t\t\tWHERE s.available='1'");
    while ($style = DB::fetch($query)) {
        $data['styles'][$style['styleid']] = dhtmlspecialchars($style['name']);
    }
    $exchcredits = array();
    $allowexchangein = $allowexchangeout = FALSE;
    foreach ((array) $data['extcredits'] as $id => $credit) {
        $data['extcredits'][$id]['img'] = $credit['img'] ? '<img style="vertical-align:middle" src="' . $credit['img'] . '" />' : '';
        if (!empty($credit['ratio'])) {
            $exchcredits[$id] = $credit;
            $credit['allowexchangein'] && ($allowexchangein = TRUE);
            $credit['allowexchangeout'] && ($allowexchangeout = TRUE);
        }
        $data['creditnotice'] && ($data['creditnames'][] = str_replace("'", "\\'", htmlspecialchars($id . '|' . $credit['title'] . '|' . $credit['unit'])));
    }
    $data['creditnames'] = $data['creditnotice'] ? @implode(',', $data['creditnames']) : '';
    $creditstranssi = explode(',', $data['creditstrans']);
    $data['creditstrans'] = $creditstranssi[0];
    unset($creditstranssi[0]);
    $data['creditstransextra'] = $creditstranssi;
    for ($i = 1; $i < 11; $i++) {
        $data['creditstransextra'][$i] = $data['creditstrans'] ? !$data['creditstransextra'][$i] ? $data['creditstrans'] : $data['creditstransextra'][$i] : 0;
    }
    $data['exchangestatus'] = $allowexchangein && $allowexchangeout;
    $data['transferstatus'] = isset($data['extcredits'][$data['creditstrans']]);
    list($data['zoomstatus'], $data['imagemaxwidth']) = explode("\t", $data['zoomstatus']);
    $data['imagemaxwidth'] = intval($data['imagemaxwidth']);
    require_once DISCUZ_ROOT . './config/config_ucenter.php';
    $data['ucenterurl'] = UC_API;
    $query = DB::query("SELECT identifier, name FROM " . DB::table('common_magic') . " WHERE available='1'");
    while ($magic = DB::fetch($query)) {
        $data['magics'][$magic['identifier']] = $magic['name'];
    }
    $data['tradeopen'] = DB::result_first("SELECT count(*) FROM " . DB::table('common_usergroup_field') . " WHERE allowposttrade='1'") ? 1 : 0;
    $data['medalstatus'] = intval(DB::result_first("SELECT count(*) FROM " . DB::table('forum_medal') . " WHERE available='1'"));
    $focus = array();
    if ($data['focus']['data']) {
        foreach ($data['focus']['data'] as $k => $v) {
            if ($v['available'] && $v['position']) {
                foreach ($v['position'] as $position) {
                    $focus[$position][$k] = $k;
                }
            }
        }
    }
    $data['focus'] = $focus;
    list($data['plugins'], $data['pluginlinks'], $data['hookscript'], $data['hookscriptmobile'], $data['threadplugins'], $data['specialicon']) = get_cachedata_setting_plugin();
    if (empty($data['defaultindex'])) {
        $data['defaultindex'] = array();
    }
    list($data['navs'], $data['subnavs'], $data['menunavs'], $data['navmns'], $data['navmn'], $data['navdms'], $data['navlogos']) = get_cachedata_mainnav();
    $data['footernavs'] = get_cachedata_footernav();
    $data['spacenavs'] = get_cachedata_spacenavs();
    $data['mynavs'] = get_cachedata_mynavs();
    $data['topnavs'] = get_cachedata_topnav();
    require_once DISCUZ_ROOT . './uc_client/client.php';
    $ucapparray = uc_app_ls();
    $data['allowsynlogin'] = isset($ucapparray[UC_APPID]['synlogin']) ? $ucapparray[UC_APPID]['synlogin'] : 1;
    $appnamearray = array('UCHOME', 'XSPACE', 'DISCUZ', 'SUPESITE', 'SUPEV', 'ECSHOP', 'ECMALL', 'OTHER');
    $data['ucapp'] = $data['ucappopen'] = array();
    $data['uchomeurl'] = '';
    $data['discuzurl'] = $_G['siteurl'];
    $appsynlogins = 0;
    foreach ($ucapparray as $apparray) {
        if ($apparray['appid'] != UC_APPID) {
            if (!empty($apparray['synlogin'])) {
                $appsynlogins = 1;
            }
            if ($data['uc']['navlist'][$apparray['appid']] && $data['uc']['navopen']) {
                $data['ucapp'][$apparray['appid']]['name'] = $apparray['name'];
                $data['ucapp'][$apparray['appid']]['url'] = $apparray['url'];
            }
        } else {
            $data['discuzurl'] = $apparray['url'];
        }
        if (!empty($apparray['viewprourl'])) {
            $data['ucapp'][$apparray['appid']]['viewprourl'] = $apparray['url'] . $apparray['viewprourl'];
        }
        foreach ($appnamearray as $name) {
            if ($apparray['type'] == $name && $apparray['appid'] != UC_APPID) {
                $data['ucappopen'][$name] = 1;
                if ($name == 'UCHOME') {
                    $data['uchomeurl'] = $apparray['url'];
                } elseif ($name == 'XSPACE') {
                    $data['xspaceurl'] = $apparray['url'];
                }
            }
        }
    }
    $data['allowsynlogin'] = $data['allowsynlogin'] && $appsynlogins ? 1 : 0;
    $data['homeshow'] = $data['uchomeurl'] && $data['uchome']['homeshow'] ? $data['uchome']['homeshow'] : '0';
    unset($data['allowthreadplugin']);
    if ($data['jspath'] == 'data/cache/') {
        writetojscache();
    } elseif (!$data['jspath']) {
        $data['jspath'] = 'static/js/';
    }
    if ($data['cacheindexlife']) {
        $cachedir = DISCUZ_ROOT . './' . $data['cachethreaddir'];
        $tidmd5 = substr(md5(0), 3);
        @unlink($cachedir . '/' . $tidmd5[0] . '/' . $tidmd5[1] . '/' . $tidmd5[2] . '/0.htm');
    }
    $reginputbwords = array('username', 'password', 'password2', 'email');
    if (in_array($data['reginput']['username'], $reginputbwords) || !preg_match('/^[A-z]\\w+?$/', $data['reginput']['username'])) {
        $data['reginput']['username'] = random(6);
    }
    if (in_array($data['reginput']['password'], $reginputbwords) || !preg_match('/^[A-z]\\w+?$/', $data['reginput']['password'])) {
        $data['reginput']['password'] = random(6);
    }
    if (in_array($data['reginput']['password2'], $reginputbwords) || !preg_match('/^[A-z]\\w+?$/', $data['reginput']['password2'])) {
        $data['reginput']['password2'] = random(6);
    }
    if (in_array($data['reginput']['email'], $reginputbwords) || !preg_match('/^[A-z]\\w+?$/', $data['reginput']['email'])) {
        $data['reginput']['email'] = random(6);
    }
    $defaultcurhost = empty($_G['setting']['domain']['app']['default']) ? '{CURHOST}' : $_G['setting']['domain']['app']['default'];
    $output = array('str' => array(), 'preg' => array());
    //str為二級域名的查找和替換,preg為rewrite和默認域名的查找和替換
    $_G['domain'] = array();
    if (is_array($_G['setting']['domain']['app'])) {
        $apps = $_G['setting']['domain']['app'];
        $repflag = $apps['portal'] || $apps['forum'] || $apps['group'] || $apps['home'] || $apps['default'];
        foreach ($apps as $app => $domain) {
            if (in_array($app, array('default', 'mobile'))) {
                continue;
            }
            $appphp = "{$app}.php";
            if (!$domain) {
                $domain = $defaultcurhost;
            }
            if ($domain != '{CURHOST}') {
                $domain = 'http://' . $domain . $_G['siteport'] . '/';
            }
            if ($repflag) {
                $output['str']['search'][$app] = "<a href=\"{$app}.php";
                $output['str']['replace'][$app] = '<a href="' . $domain . $appphp;
                $_G['domain']['pregxprw'][$app] = '<a href\\="(' . preg_quote($domain, '/') . ')' . $appphp;
            } else {
                $_G['domain']['pregxprw'][$app] = '<a href\\="()' . $appphp;
            }
        }
    }
    if ($_G['setting']['rewritestatus'] || $output['str']['search']) {
        if ($_G['setting']['rewritestatus']) {
            require_once libfile('function/admincp');
            $output['preg'] = rewritedata(0);
        }
        if ($repflag) {
            if ($defaultcurhost != '{CURHOST}') {
                $defaultcurhost = 'http://' . $defaultcurhost . $_G['siteport'] . '/';
            }
            $output['preg']['search'][] = "/<a href=\"(\\w+\\.php)/";
            $output['preg']['replace'][] = '<a href="' . $defaultcurhost . "\$1";
        }
    }
    $data['output'] = $output;
    save_syscache('setting', $data);
    $_G['setting'] = $data;
}
Esempio n. 3
0
function build_cache_setting() {
	global $_G;

	$skipkeys = array('posttableids', 'mastermobile', 'masterqq', 'masteremail', 'closedreason',
		'creditsnotify', 'backupdir', 'custombackup', 'jswizard', 'maxonlines', 'modreasons', 'newsletter',
		'postno', 'postnocustom', 'customauthorinfo', 'domainwhitelist', 'ipregctrl',
		'ipverifywhite', 'fastsmiley', 'defaultdoing', 'antitheftsetting',
		);
	$serialized = array('reginput', 'memory', 'search', 'creditspolicy', 'ftp', 'secqaa', 'ec_credit', 'qihoo', 'spacedata',
		'infosidestatus', 'uc', 'indexhot', 'relatedtag', 'sitemessage', 'uchome', 'heatthread', 'recommendthread',
		'disallowfloat', 'allowviewuserthread', 'advtype', 'click', 'card', 'rewritestatus', 'rewriterule', 'privacy', 'focus',
		'forumkeys', 'article_tags', 'verify', 'seotitle', 'seodescription', 'seokeywords', 'domain', 'ranklist', 'my_search_data',
		'seccodedata', 'inviteconfig', 'advexpiration', 'allowpostcomment', /*(IN_MOBILE)*/ 'mobile', 'connect', 'upgrade', 'patch', 'strongpw',
		'posttable_info', 'threadtable_info', 'profilegroup', 'antitheft', 'makehtml', 'guestviewthumb', 'grid', 'guesttipsinthread'
		);

	$data = array();

	foreach(C::t('common_setting')->fetch_all_not_key($skipkeys) as $setting) {
		if($setting['skey'] == 'extcredits') {
			if(is_array($setting['svalue'] = dunserialize($setting['svalue']))) {
				foreach($setting['svalue'] as $key => $value) {
					if($value['available']) {
						unset($setting['svalue'][$key]['available']);
					} else {
						unset($setting['svalue'][$key]);
					}
				}
			}
		} elseif($setting['skey'] == 'creditsformula') {
			if(!checkformulacredits($setting['svalue'])) {
				$setting['svalue'] = '$member[\'extcredits1\']';
			} else {
				$setting['svalue'] = preg_replace("/(friends|doings|blogs|albums|polls|sharings|digestposts|posts|threads|oltime|extcredits[1-8])/", "\$member['\\1']", $setting['svalue']);
			}
		} elseif($setting['skey'] == 'maxsmilies') {
			$setting['svalue'] = $setting['svalue'] <= 0 ? -1 : $setting['svalue'];
		} elseif($setting['skey'] == 'threadsticky') {
			$setting['svalue'] = explode(',', $setting['svalue']);
		} elseif($setting['skey'] == 'attachdir') {
			$setting['svalue'] = preg_replace("/\.asp|\\0/i", '0', $setting['svalue']);
			$setting['svalue'] = str_replace('\\', '/', substr($setting['svalue'], 0, 2) == './' ? DISCUZ_ROOT.$setting['svalue'] : $setting['svalue']);
			$setting['svalue'] .= substr($setting['svalue'], -1, 1) != '/' ? '/' : '';
		} elseif($setting['skey'] == 'attachurl') {
			$setting['svalue'] .= substr($setting['svalue'], -1, 1) != '/' ? '/' : '';
		} elseif($setting['skey'] == 'onlinehold') {
			$setting['svalue'] = $setting['svalue'] * 60;
		} elseif(in_array($setting['skey'], $serialized)) {
			$setting['svalue'] = @dunserialize($setting['svalue'], $setting['skey']);
			if($setting['skey'] == 'search') {
				foreach($setting['svalue'] as $key => $val) {
					foreach($val as $k => $v) {
						$setting['svalue'][$key][$k] = max(0, intval($v));
					}
				}
			} elseif($setting['skey'] == 'ftp') {
				$setting['svalue']['attachurl'] .= substr($setting['svalue']['attachurl'], -1, 1) != '/' ? '/' : '';
			} elseif($setting['skey'] == 'inviteconfig') {
				$setting['svalue']['invitecodeprompt'] = stripslashes($setting['svalue']['invitecodeprompt']);
			} elseif($setting['skey'] == 'profilegroup') {
				$profile_settings = C::t('common_member_profile_setting')->fetch_all_by_available(1);
				foreach($setting['svalue'] as $key => $val) {
					$temp = array();
					foreach($profile_settings as $pval) {
						if(in_array($pval['fieldid'], $val['field'])) {
							$temp[$pval['fieldid']] = $pval['fieldid'];
						}
					}
					foreach($val['field'] as $fieldid) {
						if(!in_array($fieldid, $temp)) {
							$temp[$fieldid] = $fieldid;
						}
					}
					$setting['svalue'][$key]['field'] = $temp;
				}
				C::t('common_setting')->update('profilegroup', $setting['svalue']);
			}
		}
		$_G['setting'][$setting['skey']] = $data[$setting['skey']] = $setting['svalue'];
	}

	$usergroup = C::t('common_usergroup')->fetch_by_credits($data['initcredits'], '');
	$data['newusergroupid'] = $usergroup['groupid'];
	$data['buyusergroupexists'] = C::t('common_usergroup')->buyusergroup_exists();

	if($data['srchhotkeywords']) {
		$data['srchhotkeywords'] = explode("\n", $data['srchhotkeywords']);
	}

	if($data['search']) {
		$searchstatus = 0;
		foreach($data['search'] as $item) {
			if($item['status']) {
				$searchstatus = 1;
				break;
			}
		}
		if(!$searchstatus) {
			$data['search'] = array();
		}
	}

	$data['creditspolicy'] = array_merge($data['creditspolicy'], get_cachedata_setting_creditspolicy());

	if($data['heatthread']['iconlevels']) {
		$data['heatthread']['iconlevels'] = explode(',', $data['heatthread']['iconlevels']);
		arsort($data['heatthread']['iconlevels']);
	} else {
		$data['heatthread']['iconlevels'] = array();
	}
	if($data['verify']) {
		foreach($data['verify'] as $key => $value) {
			if($value['available']) {
				if(!empty($value['unverifyicon'])) {
					$icourl = parse_url($value['unverifyicon']);
					if(!$icourl['host'] && !file_exists($value['unverifyicon'])) {
						$data['verify'][$key]['unverifyicon'] = $data['attachurl'].'common/'.$value['unverifyicon'];
					}
				}
				if(!empty($value['icon'])) {
					$icourl = parse_url($value['icon']);
					if(!$icourl['host'] && !file_exists($value['icon'])) {
						$data['verify'][$key]['icon'] = $data['attachurl'].'common/'.$value['icon'];
					}
				}
			}
		}
	}

	if($data['recommendthread']['status']) {
		if($data['recommendthread']['iconlevels']) {
			$data['recommendthread']['iconlevels'] = explode(',', $data['recommendthread']['iconlevels']);
			arsort($data['recommendthread']['iconlevels']);
		} else {
			$data['recommendthread']['iconlevels'] = array();
		}
	} else {
		$data['recommendthread'] = array('allow' => 0);
	}

	if($data['commentnumber'] && !$data['allowpostcomment']) {
		$data['commentnumber'] = 0;
	}

	if(!empty($data['ftp'])) {
		if(!empty($data['ftp']['allowedexts'])) {
			$data['ftp']['allowedexts'] = str_replace(array("\r\n", "\r"), array("\n", "\n"), $data['ftp']['allowedexts']);
			$data['ftp']['allowedexts'] = explode("\n", strtolower($data['ftp']['allowedexts']));
			array_walk($data['ftp']['allowedexts'], 'trim');
		}
		if(!empty($data['ftp']['disallowedexts'])) {
			$data['ftp']['disallowedexts'] = str_replace(array("\r\n", "\r"), array("\n", "\n"), $data['ftp']['disallowedexts']);
			$data['ftp']['disallowedexts'] = explode("\n", strtolower($data['ftp']['disallowedexts']));
			array_walk($data['ftp']['disallowedexts'], 'trim');
		}
		$data['ftp']['connid'] = 0;
	}

	if(!empty($data['forumkeys'])) {
		$data['forumfids'] = array_flip($data['forumkeys']);
	} else {
		$data['forumfids'] = array();
	}

	$data['commentitem'] = explode("\t", $data['commentitem']);
	$commentitem = array();
	foreach($data['commentitem'] as $k => $v) {
		$tmp = explode(chr(0).chr(0).chr(0), $v);
		if(count($tmp) > 1) {
			$commentitem[$tmp[0]] = $tmp[1];
		} else {
			$commentitem[$k] = $v;
		}
	}
	$data['commentitem'] = $commentitem;

	if($data['allowviewuserthread']['allow']) {
		$data['allowviewuserthread'] = is_array($data['allowviewuserthread']['fids']) && $data['allowviewuserthread']['fids'] && !in_array('', $data['allowviewuserthread']['fids']) ? dimplode($data['allowviewuserthread']['fids']) : '';
	} else {
		$data['allowviewuserthread'] = -1;
	}

	include_once DISCUZ_ROOT.'./source/discuz_version.php';
	$_G['setting']['version'] = $data['version'] = DISCUZ_VERSION;
/*vot*/	$_G['setting']['release'] = $data['release'] = DISCUZ_RELEASE;
/*vot*/	$_G['setting']['ml_revision'] = $data['ml_revision'] = DISCUZ_ML_REVISION;

	$data['sitemessage']['time'] = !empty($data['sitemessage']['time']) ? $data['sitemessage']['time'] * 1000 : 0;
	foreach (array('register', 'login', 'newthread', 'reply') as $type) {
		$data['sitemessage'][$type] = !empty($data['sitemessage'][$type]) ? explode("\n", $data['sitemessage'][$type]) : array();
	}

	$data['cachethreadon'] = C::t('forum_forum')->fetch_threadcacheon_num() ? 1 : 0;
	$data['disallowfloat'] = is_array($data['disallowfloat']) ? implode('|', $data['disallowfloat']) : '';

	if(!$data['imagelib']) unset($data['imageimpath']);

	if(is_array($data['relatedtag']['order'])) {
		asort($data['relatedtag']['order']);
		$relatedtag = array();
		foreach($data['relatedtag']['order'] AS $k => $v) {
			$relatedtag['status'][$k] = $data['relatedtag']['status'][$k];
			$relatedtag['name'][$k] = $data['relatedtag']['name'][$k];
			$relatedtag['limit'][$k] = $data['relatedtag']['limit'][$k];
			$relatedtag['template'][$k] = $data['relatedtag']['template'][$k];
		}
		$data['relatedtag'] = $relatedtag;

		foreach((array)$data['relatedtag']['status'] AS $appid => $status) {
			if(!$status) {
				unset($data['relatedtag']['limit'][$appid]);
			}
		}
		unset($data['relatedtag']['status'], $data['relatedtag']['order'], $relatedtag);
	}

	$data['domain']['defaultindex'] = isset($data['defaultindex']) && $data['defaultindex'] != '#' ? $data['defaultindex'] : '';
	$data['domain']['holddomain'] = isset($data['holddomain']) ? $data['holddomain'] : '';
	$data['domain']['list'] = array();
	foreach(C::t('common_domain')->fetch_all_by_idtype(array('subarea', 'forum', 'topic', 'channel')) as $value) {
		$data['domain']['list'][$value['domain'].'.'.$value['domainroot']] = array('id' => $value['id'], 'idtype' => $value['idtype']);
	}
	writetocache('domain', getcachevars(array('domain' => $data['domain'])));

	$data['seccodedata'] = is_array($data['seccodedata']) ? $data['seccodedata'] : array();
	if($data['seccodedata']['type'] == 2) {
		if(extension_loaded('ming')) {
			unset($data['seccodedata']['background'], $data['seccodedata']['adulterate'],
			$data['seccodedata']['ttf'], $data['seccodedata']['angle'],
			$data['seccodedata']['color'], $data['seccodedata']['size'],
			$data['seccodedata']['animator']);
		} else {
			$data['seccodedata']['animator'] = 0;
		}
	} elseif($data['seccodedata']['type'] == 99) {
		$data['seccodedata']['width'] = 32;
		$data['seccodedata']['height'] = 24;
	}

	$data['watermarktype'] = !empty($data['watermarktype']) ? dunserialize($data['watermarktype']) : array();
	$data['watermarktext'] = !empty($data['watermarktext']) ? dunserialize($data['watermarktext']) : array();
	foreach($data['watermarktype'] as $k => $v) {
		if($data['watermarktype'][$k] == 'text' && $data['watermarktext']['text'][$k]) {
			if($data['watermarktext']['text'][$k] && strtoupper(CHARSET) != 'UTF-8') {
				$data['watermarktext']['text'][$k] = diconv($data['watermarktext']['text'][$k], CHARSET, 'UTF-8', true);
			}
			$data['watermarktext']['text'][$k] = bin2hex($data['watermarktext']['text'][$k]);
			if(file_exists('static/image/seccode/font/en/'.$data['watermarktext']['fontpath'][$k])) {
				$data['watermarktext']['fontpath'][$k] = 'static/image/seccode/font/en/'.$data['watermarktext']['fontpath'][$k];
			} elseif(file_exists('static/image/seccode/font/ch/'.$data['watermarktext']['fontpath'][$k])) {
				$data['watermarktext']['fontpath'][$k] = 'static/image/seccode/font/ch/'.$data['watermarktext']['fontpath'][$k];
			} else {
				$data['watermarktext']['fontpath'][$k] = 'static/image/seccode/font/'.$data['watermarktext']['fontpath'][$k];
			}
			$data['watermarktext']['color'][$k] = preg_replace('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/e', "hexdec('\\1').','.hexdec('\\2').','.hexdec('\\3')", $data['watermarktext']['color'][$k]);
			$data['watermarktext']['shadowcolor'][$k] = preg_replace('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/e', "hexdec('\\1').','.hexdec('\\2').','.hexdec('\\3')", $data['watermarktext']['shadowcolor'][$k]);
		} else {
			$data['watermarktext']['text'][$k] = '';
			$data['watermarktext']['fontpath'][$k] = '';
			$data['watermarktext']['color'][$k] = '';
			$data['watermarktext']['shadowcolor'][$k] = '';
		}
	}

	$data['styles'] = array();
	foreach(C::t('common_style')->fetch_all_data(false, 1) as $style) {
		$data['styles'][$style['styleid']] = dhtmlspecialchars($style['name']);
	}

	$exchcredits = array();
	$allowexchangein = $allowexchangeout = FALSE;
	foreach((array)$data['extcredits'] as $id => $credit) {
		$data['extcredits'][$id]['img'] = $credit['img'] ? '<img style="vertical-align:middle" src="'.$credit['img'].'" />' : '';
		if(!empty($credit['ratio'])) {
			$exchcredits[$id] = $credit;
			$credit['allowexchangein'] && $allowexchangein = TRUE;
			$credit['allowexchangeout'] && $allowexchangeout = TRUE;
		}
		$data['creditnotice'] && $data['creditnames'][] = str_replace("'", "\'", dhtmlspecialchars($id.'|'.$credit['title'].'|'.$credit['unit']));
	}
	$data['creditnames'] = $data['creditnotice'] ? @implode(',', $data['creditnames']) : '';

	$creditstranssi = explode(',', $data['creditstrans']);
	$data['creditstrans'] = $creditstranssi[0];
	unset($creditstranssi[0]);
	$data['creditstransextra'] = $creditstranssi;
	for($i = 1;$i < 11;$i++) {
		$data['creditstransextra'][$i] = $data['creditstrans'] ? (!$data['creditstransextra'][$i] ? $data['creditstrans'] : $data['creditstransextra'][$i]) : 0;
	}
	$data['exchangestatus'] = $allowexchangein && $allowexchangeout;
	$data['transferstatus'] = isset($data['extcredits'][$data['creditstrans']]);

	list($data['zoomstatus'], $data['imagemaxwidth']) = explode("\t", $data['zoomstatus']);
	$data['imagemaxwidth'] = intval($data['imagemaxwidth']);

	require_once DISCUZ_ROOT.'./config/config_ucenter.php';
	$data['ucenterurl'] = UC_API;

	foreach(C::t('common_magic')->fetch_all_data(1) as $magic) {
		$magic['identifier'] = str_replace(':', '_', $magic['identifier']);
		$data['magics'][$magic['identifier']] = $magic['name'];
	}

	$data['tradeopen'] = C::t('common_usergroup_field')->count_by_field('allowposttrade', 1) ? 1 : 0;
	$data['medalstatus'] = intval(C::t('forum_medal')->count_by_available());

	$focus = array();
	if($data['focus']['data']) {
		foreach($data['focus']['data'] as $k => $v) {
			if($v['available'] && $v['position']) {
				foreach($v['position'] as $position) {
					$focus[$position][$k] = $k;
				}
			}
		}
	}
	$data['focus'] = $focus;

	list($data['plugins'], $data['pluginlinks'], $data['hookscript'], $data['hookscriptmobile'], $data['threadplugins'], $data['specialicon']) = get_cachedata_setting_plugin();

	if(empty($data['defaultindex'])) $data['defaultindex'] = array();
	list($data['navs'], $data['subnavs'], $data['menunavs'], $data['navmns'], $data['navmn'], $data['navdms'], $data['navlogos']) = get_cachedata_mainnav();

	$data['footernavs'] = get_cachedata_footernav();
	$data['spacenavs'] = get_cachedata_spacenavs();
	$data['mynavs'] = get_cachedata_mynavs();
	$data['topnavs'] = get_cachedata_topnav();
	$data['profilenode'] = get_cachedata_threadprofile();

	require_once DISCUZ_ROOT.'./uc_client/client.php';
	$ucapparray = uc_app_ls();
	$data['allowsynlogin'] = isset($ucapparray[UC_APPID]['synlogin']) ? $ucapparray[UC_APPID]['synlogin'] : 1;
	$appnamearray = array('UCHOME','XSPACE','DISCUZ','SUPESITE','SUPEV','ECSHOP','ECMALL','OTHER');
	$data['ucapp'] = $data['ucappopen'] = array();
	$data['uchomeurl'] = '';
	$data['discuzurl'] = $_G['siteurl'];
	$appsynlogins = 0;
	foreach($ucapparray as $apparray) {
		if($apparray['appid'] != UC_APPID) {
			if(!empty($apparray['synlogin'])) {
				$appsynlogins = 1;
			}
			if($data['uc']['navlist'][$apparray['appid']] && $data['uc']['navopen']) {
				$data['ucapp'][$apparray['appid']]['name'] = $apparray['name'];
				$data['ucapp'][$apparray['appid']]['url'] = $apparray['url'];
			}
		} else {
			$data['discuzurl'] = $apparray['url'];
		}
		if(!empty($apparray['viewprourl'])) {
			$data['ucapp'][$apparray['appid']]['viewprourl'] = $apparray['url'].$apparray['viewprourl'];
		}
		foreach($appnamearray as $name) {
			if($apparray['type'] == $name && $apparray['appid'] != UC_APPID) {
				$data['ucappopen'][$name] = 1;
				if($name == 'UCHOME') {
					$data['uchomeurl'] = $apparray['url'];
				} elseif($name == 'XSPACE') {
					$data['xspaceurl'] = $apparray['url'];
				}
			}
		}
	}
	$data['allowsynlogin'] = $data['allowsynlogin'] && $appsynlogins ? 1 : 0;
	$data['homeshow'] = $data['uchomeurl'] && $data['uchome']['homeshow'] ? $data['uchome']['homeshow'] : '0';

	unset($data['allowthreadplugin']);
	if($data['jspath'] == 'data/cache/') {
		writetojscache();
	} elseif(!$data['jspath']) {
		$data['jspath'] = 'static/js/';
	}

	if($data['cacheindexlife']) {
		$cachedir = DISCUZ_ROOT.'./'.$data['cachethreaddir'];
		$tidmd5 = substr(md5(0), 3);
		@unlink($cachedir.'/'.$tidmd5[0].'/'.$tidmd5[1].'/'.$tidmd5[2].'/0.htm');
	}

	$reginputbwords = array('username', 'password', 'password2', 'email');
	if(in_array($data['reginput']['username'], $reginputbwords) || !preg_match('/^[A-z]\w+?$/', $data['reginput']['username'])) {
		$data['reginput']['username'] = random(6);
	}
	if(in_array($data['reginput']['password'], $reginputbwords) || !preg_match('/^[A-z]\w+?$/', $data['reginput']['password'])) {
		$data['reginput']['password'] = random(6);
	}
	if(in_array($data['reginput']['password2'], $reginputbwords) || !preg_match('/^[A-z]\w+?$/', $data['reginput']['password2'])) {
		$data['reginput']['password2'] = random(6);
	}
	if(in_array($data['reginput']['email'], $reginputbwords) || !preg_match('/^[A-z]\w+?$/', $data['reginput']['email'])) {
		$data['reginput']['email'] = random(6);
	}

	$defaultcurhost = empty($_G['setting']['domain']['app']['default']) ? '{CURHOST}' : $_G['setting']['domain']['app']['default'];
	$output = array('str'=>array(), 'preg' => array()); //str为二级域名的查找和替换,preg为rewrite和默认域名的查找和替换
	$_G['domain'] = array();
	if(is_array($_G['setting']['domain']['app'])) {
		$apps = $_G['setting']['domain']['app'];
		$repflag = $apps['portal'] || $apps['forum'] || $apps['group'] || $apps['home'] || $apps['default'];
		foreach($apps as $app => $domain) {
			if(in_array($app, array('default', 'mobile'))) {
				continue;
			}
			$appphp = "{$app}.php";
			if(!$domain) {
				$domain = $defaultcurhost;
			}
			if($domain != '{CURHOST}') {
				$domain = 'http://'.$domain.$_G['siteport'].'/';
			}
			if($repflag) {
				$output['str']['search'][$app] = "<a href=\"{$app}.php";
				$output['str']['replace'][$app] = '<a href="'.$domain.$appphp;
				$_G['domain']['pregxprw'][$app] = '<a href\="('.preg_quote($domain, '/').')'.$appphp;
			} else {
				$_G['domain']['pregxprw'][$app] = '<a href\="()'.$appphp;
			}
		}
	}
	if($_G['setting']['rewritestatus'] || $output['str']['search']) {
		if($_G['setting']['rewritestatus']) {
			require_once libfile('function/admincp');
			$output['preg'] = rewritedata(0);
		}
		if($output['preg']) {
			foreach($data['footernavs'] as $id => $nav) {
				$data['footernavs'][$id]['code'] = preg_replace($output['preg']['search'], $output['preg']['replace'], $nav['code']);
			}
			foreach($data['spacenavs'] as $id => $nav) {
				$data['spacenavs'][$id]['code'] = preg_replace($output['preg']['search'], $output['preg']['replace'], $nav['code']);
			}
			foreach($data['mynavs'] as $id => $nav) {
				$data['mynavs'][$id]['code'] = preg_replace($output['preg']['search'], $output['preg']['replace'], $nav['code']);
			}
			foreach($data['topnavs'] as $id => $nav) {
				$data['topnavs'][$id]['code'] = preg_replace($output['preg']['search'], $output['preg']['replace'], $nav['code']);
			}
			foreach($data['plugins']['jsmenu'] as $key => $nav) {
				$data['plugins']['jsmenu'][$key]['url'] = preg_replace($output['preg']['search'], $output['preg']['replace'], $nav['url']);
			}
		}
	}
	$data['output'] = $output;
	$data['connect'] = in_array('qqconnect', $data['plugins']['available']) ? $data['connect'] : array();

	savecache('setting', $data);
	$_G['setting'] = $data;
}