function build_cache_admingroups() { $query = DB::query("SELECT * FROM " . DB::table('common_admingroup')); while ($data = DB::fetch($query)) { save_syscache('admingroup_' . $data['admingid'], $data); } }
function build_cache_plugin() { $data = array(); $query = DB::query("SELECT * FROM " . DB::table('common_plugin') . " WHERE available='1'"); $pluginsetting = array(); while ($plugin = DB::fetch($query)) { $queryvars = DB::query("SELECT * FROM " . DB::table('common_pluginvar') . " WHERE pluginid='{$plugin['pluginid']}'"); while ($var = DB::fetch($queryvars)) { $data[$plugin['identifier']][$var['variable']] = $var['value']; if (in_array(substr($var['type'], 0, 6), array('group_', 'forum_'))) { $stype = substr($var['type'], 0, 5) . 's'; $type = substr($var['type'], 6); if ($type == 'select') { foreach (explode("\n", $var['extra']) as $key => $option) { $option = trim($option); if (strpos($option, '=') === FALSE) { $key = $option; } else { $item = explode('=', $option); $key = trim($item[0]); $option = trim($item[1]); } $var['select'][] = array($key, $option); } } $pluginsetting[$stype][$plugin['identifier']]['name'] = $plugin['name']; $pluginsetting[$stype][$plugin['identifier']]['setting'][$var['pluginvarid']] = array('title' => $var['title'], 'description' => $var['description'], 'type' => $type, 'select' => $var['select']); } } } writetocache('pluginsetting', getcachevars(array('pluginsetting' => $pluginsetting))); save_syscache('plugin', $data); }
function build_cache_globalstick() { $data = array(); $query = DB::query("SELECT fid, type, fup FROM " . DB::table('forum_forum') . " WHERE status='1' AND type IN ('forum', 'sub') ORDER BY type"); $fuparray = $threadarray = array(); while ($forum = DB::fetch($query)) { switch ($forum['type']) { case 'forum': $fuparray[$forum['fid']] = $forum['fup']; break; case 'sub': $fuparray[$forum['fid']] = $fuparray[$forum['fup']]; break; } } $query = DB::query("SELECT tid, fid, displayorder FROM " . DB::table('forum_thread') . " WHERE fid>'0' AND displayorder IN (2, 3)"); while ($thread = DB::fetch($query)) { switch ($thread['displayorder']) { case 2: $threadarray[$fuparray[$thread['fid']]][] = $thread['tid']; break; case 3: $threadarray['global'][] = $thread['tid']; break; } } foreach (array_unique($fuparray) as $gid) { if (!empty($threadarray[$gid])) { $data['categories'][$gid] = array('tids' => dimplode($threadarray[$gid]), 'count' => intval(@count($threadarray[$gid]))); } } $data['global'] = array('tids' => empty($threadarray['global']) ? '' : dimplode($threadarray['global']), 'count' => intval(@count($threadarray['global']))); save_syscache('globalstick', $data); }
function build_cache_usergroups_single() { $pluginvalue = pluginsettingvalue('groups'); $allowthreadplugin = unserialize(DB::result_first("SELECT svalue FROM " . DB::table('common_setting') . " WHERE skey='allowthreadplugin'")); $query = DB::query("SELECT * FROM " . DB::table('common_usergroup') . " u\r\n\t\tLEFT JOIN " . DB::table('common_usergroup_field') . " uf ON u.groupid=uf.groupid\r\n\t\tLEFT JOIN " . DB::table('common_admingroup') . " a ON u.groupid=a.admingid"); while ($data = DB::fetch($query)) { $ratearray = array(); if ($data['raterange']) { foreach (explode("\n", $data['raterange']) as $rating) { $rating = explode("\t", $rating); $ratearray[$rating[0]] = array('isself' => $rating[1], 'min' => $rating[2], 'max' => $rating[3], 'mrpd' => $rating[4]); } } $data['raterange'] = $ratearray; $data['grouptitle'] = $data['color'] ? '<font color="' . $data['color'] . '">' . $data['grouptitle'] . '</font>' : $data['grouptitle']; $data['grouptype'] = $data['type']; $data['grouppublic'] = $data['system'] != 'private'; $data['groupcreditshigher'] = $data['creditshigher']; $data['groupcreditslower'] = $data['creditslower']; $data['maxspacesize'] = intval($data['maxspacesize']) * 1024 * 1024; $data['allowthreadplugin'] = !empty($allowthreadplugin[$data['groupid']]) ? $allowthreadplugin[$data['groupid']] : array(); $data['plugin'] = $pluginvalue[$data['groupid']]; unset($data['type'], $data['system'], $data['creditshigher'], $data['creditslower'], $data['groupavatar'], $data['admingid']); save_syscache('usergroup_' . $data['groupid'], $data); } }
function build_cache_advs() { $data = array(); $query = DB::query("SELECT * FROM " . DB::table('common_advertisement') . " WHERE available>'0' AND starttime<='" . TIMESTAMP . "' ORDER BY displayorder"); $data['code'] = $data['parameters'] = $data['evalcode'] = array(); $advlist = array(); while ($adv = DB::fetch($query)) { foreach (explode("\t", $adv['targets']) as $target) { $data['code'][$target][$adv['type']][$adv['advid']] = $adv['code']; } $advtype_class = libfile('adv/' . $adv['type'], 'class'); if (!file_exists($advtype_class)) { continue; } require_once $advtype_class; $advclass = 'adv_' . $adv['type']; $advclass = new $advclass(); $adv['parameters'] = unserialize($adv['parameters']); unset($adv['parameters']['style'], $adv['parameters']['html'], $adv['parameters']['displayorder']); $data['parameters'][$adv['type']][$adv['advid']] = $adv['parameters']; if ($adv['parameters']['extra']) { $data['parameters'][$adv['type']][$adv['advid']] = array_merge($data['parameters'][$adv['type']][$adv['advid']], $adv['parameters']['extra']); unset($data['parameters'][$adv['type']][$adv['advid']]['extra']); } $advlist[] = $adv; $data['evalcode'][$adv['type']] = $advclass->evalcode($adv); } updateadvtype(); save_syscache('advs', $data); }
function build_cache_stamps() { $data = array(); $query = DB::query("SELECT id, url, displayorder FROM " . DB::table('common_smiley') . " WHERE type IN ('stamp','stamplist') ORDER BY displayorder"); $fillarray = range(0, 99); $count = 0; $repeats = $stampicon = array(); while ($stamp = DB::fetch($query)) { if (isset($fillarray[$stamp['displayorder']])) { unset($fillarray[$stamp['displayorder']]); } else { $repeats[] = $stamp['id']; } $count++; } foreach ($repeats as $id) { reset($fillarray); $displayorder = current($fillarray); unset($fillarray[$displayorder]); DB::query("UPDATE " . DB::table('common_smiley') . " SET displayorder='{$displayorder}' WHERE id='{$id}'"); } $query = DB::query("SELECT typeid, displayorder FROM " . DB::table('common_smiley') . " WHERE type='stamplist' AND typeid>'0' ORDER BY displayorder"); while ($stamp = DB::fetch($query)) { $stamporder = DB::result_first("SELECT displayorder FROM " . DB::table('common_smiley') . " WHERE id='{$stamp['typeid']}' AND type='stamp'"); $stampicon[$stamporder] = $stamp['displayorder']; } $query = DB::query("SELECT * FROM " . DB::table('common_smiley') . " WHERE type IN ('stamp','stamplist') ORDER BY displayorder"); while ($stamp = DB::fetch($query)) { $icon = $stamp['type'] == 'stamp' ? isset($stampicon[$stamp['displayorder']]) ? $stampicon[$stamp['displayorder']] : 0 : ($stamp['type'] == 'stamplist' && !in_array($stamp['displayorder'], $stampicon) ? 1 : 0); $data[$stamp['displayorder']] = array('url' => $stamp['url'], 'text' => $stamp['code'], 'type' => $stamp['type'], 'icon' => $icon); } save_syscache('stamps', $data); }
function build_cache_heats() { global $_G; $data = array(); if ($_G['setting']['indexhot']['status']) { require_once libfile('function/post'); $_G['setting']['indexhot'] = array('status' => 1, 'limit' => intval($_G['setting']['indexhot']['limit'] ? $_G['setting']['indexhot']['limit'] : 10), 'days' => intval($_G['setting']['indexhot']['days'] ? $_G['setting']['indexhot']['days'] : 7), 'expiration' => intval($_G['setting']['indexhot']['expiration'] ? $_G['setting']['indexhot']['expiration'] : 900), 'messagecut' => intval($_G['setting']['indexhot']['messagecut'] ? $_G['setting']['indexhot']['messagecut'] : 200)); $heatdateline = TIMESTAMP - 86400 * $_G['setting']['indexhot']['days']; $query = DB::query("SELECT t.tid,t.posttableid,t.views,t.dateline,t.replies,t.author,t.authorid,t.subject,t.price\r\n\t\t\tFROM " . DB::table('forum_thread') . " t\r\n\t\t\tWHERE t.dateline>'{$heatdateline}' AND t.heats>'0' AND t.displayorder>='0' ORDER BY t.heats DESC LIMIT " . $_G['setting']['indexhot']['limit'] * 2); $messageitems = 2; $limit = $_G['setting']['indexhot']['limit']; while ($heat = DB::fetch($query)) { $posttable = $heat['posttableid'] ? "forum_post_{$heat['posttableid']}" : 'forum_post'; $post = DB::fetch_first("SELECT p.pid, p.message FROM " . DB::table($posttable) . " p WHERE p.tid='{$heat['tid']}' AND p.first='1'"); $heat = array_merge($heat, (array) $post); if ($limit == 0) { break; } if ($messageitems > 0) { $heat['message'] = !$heat['price'] ? messagecutstr($heat['message'], $_G['setting']['indexhot']['messagecut']) : ''; $data['message'][$heat['tid']] = $heat; } else { unset($heat['message']); $data['subject'][$heat['tid']] = $heat; } $messageitems--; $limit--; } $data['expiration'] = TIMESTAMP + $_G['setting']['indexhot']['expiration']; } save_syscache('heats', $data); }
function build_cache_fields_connect_register() { global $_G; $data = array(); $fields = array(); if ($_G['setting']['connect']['register_gender']) { $fields[] = 'gender'; } if ($_G['setting']['connect']['register_birthday']) { $fields[] = 'birthyear'; $fields[] = 'birthmonth'; $fields[] = 'birthday'; } if ($fields) { $query = DB::query("SELECT * FROM " . DB::table('common_member_profile_setting') . " WHERE fieldid IN (" . dimplode($fields) . ")"); while ($field = DB::fetch($query)) { $choices = array(); if ($field['selective']) { foreach (explode("\n", $field['choices']) as $item) { list($index, $choice) = explode('=', $item); $choices[trim($index)] = trim($choice); } $field['choices'] = $choices; } else { unset($field['choices']); } $field['showinregister'] = 1; $field['available'] = 1; $data['field_' . $field['fieldid']] = $field; } } save_syscache('fields_connect_register', $data); }
function poll_getcachearray($cachename, $script = '') { global $_G; $cols = '*'; $conditions = ''; $timestamp = TIMESTAMP; switch ($cachename) { case 'poll_setting': $table = 'poll_setting'; $conditions = ''; break; } $data = array(); if ($cols && $table) { $query = DB::query("SELECT {$cols} FROM " . DB::table($table) . " {$conditions}"); } switch ($cachename) { case 'poll_setting': while ($datarow = DB::fetch($query)) { $data[$datarow['skey']] = $datarow['svalue']; } default: while ($datarow = DB::fetch($query)) { $data[] = $datarow; } } save_syscache($cachename, $data); return true; }
function pdnovelcache($cachename, $identifier = "") { global $_G; $cachearray = array("pdnovelcategory", "pdnovelcreditrule"); $cachename = in_array($cachename, $cachearray) ? $cachename : ""; if ($cachename == "pdnovelcategory") { $data = array(); $query = DB::query("SELECT * FROM " . DB::table("pdnovel_category") . " ORDER BY displayorder,catid"); while ($value = DB::fetch($query)) { $value['catname'] = dhtmlspecialchars($value['catname']); $data[$value['catid']] = $value; } foreach ($data as $k => $v) { if (!$v['catid']) { continue; } elseif ($v['upid'] > 0) { $data[$k]['level'] = 1; continue; } foreach ($data as $ks => $vs) { if ($vs['upid'] == $v['catid']) { $data[$k]['children'][] = $vs['catid']; $data[$k]['level'] = 0; } } } save_syscache("pdnovelcategory", $data); } }
function build_cache_forumrecommend() { $data = array(); $query = DB::query("SELECT fid FROM " . DB::table('forum_forum') . " WHERE type<>'group' AND status<>3"); while ($row = DB::fetch($query)) { require_once libfile('function/group'); $squery = DB::query("SELECT f.fid, f.name, f.threads, f.lastpost, ff.icon, ff.membernum, ff.description FROM " . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff ON ff.fid=f.fid WHERE recommend='{$row['fid']}'"); while ($group = DB::fetch($squery)) { $group['icon'] = get_groupimg($group['icon'], 'icon'); $lastpost = array(0, 0, '', ''); $group['lastpost'] = is_string($group['lastpost']) ? explode("\t", $group['lastpost']) : $group['lastpost']; $group['lastpost'] = count($group['lastpost']) != 4 ? $lastpost : $group['lastpost']; list($lastpost['tid'], $lastpost['subject'], $lastpost['dateline'], $lastpost['author']) = $group['lastpost']; if ($lastpost['tid']) { $lastpost['dateline'] = dgmdate($lastpost['dateline'], 'Y-m-d H:i:s'); if ($lastpost['author']) { $lastpost['encode_author'] = rawurlencode($lastpost['author']); } $group['lastpost'] = $lastpost; } else { $group['lastpost'] = ''; } $data[$row['fid']][] = $group; } } save_syscache('forumrecommend', $data); }
function build_cache_forumlinks() { global $_G; $data = array(); $query = DB::query("SELECT * FROM " . DB::table('common_friendlink') . " ORDER BY displayorder"); if ($_G['setting']['forumlinkstatus']) { $tightlink_content = $tightlink_text = $tightlink_logo = $comma = ''; while ($flink = DB::fetch($query)) { if ($flink['description']) { if ($flink['logo']) { $tightlink_content .= '<li class="lk_logo mbm bbda cl"><img src="' . $flink['logo'] . '" border="0" alt="' . $flink['name'] . '" /><div class="lk_content z"><h5><a href="' . $flink['url'] . '" target="_blank">' . $flink['name'] . '</a></h5><p>' . $flink['description'] . '</p></div>'; } else { $tightlink_content .= '<li class="mbm bbda"><div class="lk_content"><h5><a href="' . $flink['url'] . '" target="_blank">' . $flink['name'] . '</a></h5><p>' . $flink['description'] . '</p></div>'; } } else { if ($flink['logo']) { $tightlink_logo .= '<a href="' . $flink['url'] . '" target="_blank"><img src="' . $flink['logo'] . '" border="0" alt="' . $flink['name'] . '" /></a> '; } else { $tightlink_text .= '<li><a href="' . $flink['url'] . '" target="_blank" title="' . $flink['name'] . '">' . $flink['name'] . '</a></li>'; } } } $data = array($tightlink_content, $tightlink_logo, $tightlink_text); } save_syscache('forumlinks', $data); }
function build_cache_groupreadaccess() { $data = array(); $query = DB::query("SELECT g.groupid, g.grouptitle, gf.readaccess FROM " . DB::table('common_usergroup') . " g\r\n\t\tLEFT JOIN " . DB::table('common_usergroup_field') . " gf ON gf.groupid=g.groupid WHERE gf.readaccess>'0' ORDER BY gf.readaccess"); while ($datarow = DB::fetch($query)) { $data[] = $datarow; } save_syscache('groupreadaccess', $data); }
function build_cache_modreasons() { $data = array(); $query = DB::query("SELECT svalue FROM " . DB::table('common_setting') . " WHERE skey='modreasons'"); $modreasons = DB::result($query, 0); $modreasons = str_replace(array("\r\n", "\r"), array("\n", "\n"), $modreasons); $data = explode("\n", trim($modreasons)); save_syscache('modreasons', $data); }
function build_cache_typetree() { global $root; global $data_array; $data = array(); $data['root'] = $root; $data['data_array'] = $data_array; save_syscache('typetree', $data); }
function build_cache_medals() { $data = array(); $query = DB::query("SELECT medalid, name, image FROM " . DB::table('forum_medal') . " WHERE available='1'"); while ($medal = DB::fetch($query)) { $data[$medal['medalid']] = array('name' => $medal['name'], 'image' => $medal['image']); } save_syscache('medals', $data); }
function build_cache_dsuMedalCenter() { $data = array(); $query = DB::query("SELECT m.*, mf.* FROM " . DB::table('forum_medal') . " m LEFT JOIN " . DB::table('dsu_medalfield') . " mf ON m.medalid = mf.medalid"); while ($medal = DB::fetch($query)) { $data[$medal['medalid']] = array('name' => $medal['name'], 'image' => $medal['image']); } save_syscache('dsuMedalCenter', $data); }
function build_cache_ipctrl() { $data = array(); $query = DB::query("SELECT * FROM " . DB::table('common_setting') . " WHERE skey IN ('ipregctrl', 'ipverifywhite')"); while ($setting = DB::fetch($query)) { $data[$setting['skey']] = $setting['svalue']; } save_syscache('ipctrl', $data); }
function build_cache_magics() { $data = array(); $query = DB::query("SELECT * FROM " . DB::table('common_magic') . " WHERE available='1'"); while ($magic = DB::fetch($query)) { $data[$magic['magicid']] = $magic; } save_syscache('magics', $data); }
function build_cache_stamptypeid() { $data = array(); $query = DB::query("SELECT displayorder, typeid FROM " . DB::table('common_smiley') . " WHERE type='stamp' AND typeid>'0'"); while ($stamp = DB::fetch($query)) { $data[$stamp['typeid']] = $stamp['displayorder']; } save_syscache('stamptypeid', $data); }
function build_cache_profilesetting() { $data = array(); $query = DB::query("SELECT * FROM " . DB::table('common_member_profile_setting') . " WHERE available='1' ORDER BY displayorder"); while ($field = DB::fetch($query)) { $data[$field['fieldid']] = $field; } save_syscache('profilesetting', $data); }
function build_cache_connect_blacklist() { global $_G; $data = array(); $query = DB::query("SELECT * FROM " . DB::table('common_uin_black'), 'SILENT'); while ($blacklist = DB::fetch($query)) { $data[] = $blacklist['uin']; } save_syscache('connect_blacklist', $data); }
function nextcron() { $nextrun = DB::result_first("SELECT nextrun FROM " . DB::table('common_cron') . " WHERE available>'0' ORDER BY nextrun LIMIT 1"); if ($nextrun !== FALSE) { save_syscache('cronnextrun', $nextrun); } else { save_syscache('cronnextrun', TIMESTAMP + 86400 * 365); } return true; }
function build_cache_userapp() { $data = array(); $query = DB::query("SELECT * FROM " . DB::table('common_myapp') . " WHERE flag='1' ORDER BY displayorder"); while ($myapp = DB::fetch($query)) { $myapp['icon'] = getmyappiconpath($myapp['appid'], $myapp['iconstatus']); $data[$myapp['appid']] = $myapp; } save_syscache('userapp', $data); }
function build_cache_modreasons() { foreach (array('modreasons', 'userreasons') as $key) { $data = array(); $reasons = DB::result_first("SELECT svalue FROM " . DB::table('common_setting') . " WHERE skey='{$key}'"); $reasons = str_replace(array("\r\n", "\r"), array("\n", "\n"), $reasons); $data = explode("\n", trim($reasons)); save_syscache($key, $data); } }
function build_cache_domainwhitelist() { $query = DB::query("SELECT svalue FROM " . DB::table('common_setting') . " WHERE skey='domainwhitelist'"); if ($result = DB::result($query, 0)) { $data = explode("\r\n", $result); } else { $data = array(); } save_syscache('domainwhitelist', $data); }
function build_cache_groupicon() { $data = array(); $query = DB::query("SELECT * FROM " . DB::table('forum_onlinelist') . " ORDER BY displayorder"); while ($list = DB::fetch($query)) { if ($list['url']) { $data[$list['groupid']] = STATICURL . 'image/common/' . $list['url']; } } save_syscache('groupicon', $data); }
function build_cache_forums() { $data = array(); /*vot*/ $query = DB::query("SELECT f.fid, f.type, f.name, f.fup, f.simple, f.status, f.allowpostspecial, ff.viewperm, ff.formulaperm, ff.viewperm, ff.postperm, ff.replyperm, ff.getattachperm, ff.postattachperm, ff.extra, ff.commentitem, a.uid FROM " . DB::table('forum_forum') . " f\r\n\t\tLEFT JOIN " . DB::table('forum_forumfield') . " ff ON ff.fid=f.fid LEFT JOIN " . DB::table('forum_access') . " a ON (a.fid=f.fid AND a.allowview>'0') WHERE f.status<>'3' ORDER BY f.type, f.displayorder"); $pluginvalue = $forumlist = array(); $nopermdefault = array('viewperm' => array(), 'getattachperm' => array(), 'postperm' => array(7), 'replyperm' => array(7), 'postattachperm' => array(7)); $pluginvalue = pluginsettingvalue('forums'); $forumnoperms = array(); while ($forum = DB::fetch($query)) { $forum['orderby'] = bindec(($forum['simple'] & 128 ? 1 : 0) . ($forum['simple'] & 64 ? 1 : 0)); $forum['ascdesc'] = $forum['simple'] & 32 ? 'ASC' : 'DESC'; $forum['extra'] = unserialize($forum['extra']); if (!is_array($forum['extra'])) { $forum['extra'] = array(); } if (!isset($forumlist[$forum['fid']])) { $forum['name'] = strip_tags($forum['name']); if ($forum['uid']) { $forum['users'] = "\t{$forum['uid']}\t"; } unset($forum['uid']); if ($forum['fup']) { $forumlist[$forum['fup']]['count']++; } $forumlist[$forum['fid']] = $forum; } elseif ($forum['uid']) { if (!$forumlist[$forum['fid']]['users']) { $forumlist[$forum['fid']]['users'] = "\t"; } $forumlist[$forum['fid']]['users'] .= "{$forum['uid']}\t"; } } $data = array(); if (!empty($forumlist)) { foreach ($forumlist as $fid1 => $forum1) { if ($forum1['type'] == 'group' && $forum1['count']) { $data[$fid1] = formatforumdata($forum1, $pluginvalue); unset($data[$fid1]['users'], $data[$fid1]['allowpostspecial'], $data[$fid1]['commentitem']); foreach ($forumlist as $fid2 => $forum2) { if ($forum2['fup'] == $fid1 && $forum2['type'] == 'forum') { $data[$fid2] = formatforumdata($forum2, $pluginvalue); foreach ($forumlist as $fid3 => $forum3) { if ($forum3['fup'] == $fid2 && $forum3['type'] == 'sub') { $data[$fid3] = formatforumdata($forum3, $pluginvalue); } } } } } } } save_syscache('forums', $data); }
function build_cache_diytemplatename() { $data = array(); $query = DB::query("SELECT * FROM " . DB::table('common_diy_data')); while ($datarow = DB::fetch($query)) { $langtplname = lang('portalcp', $datarow['targettplname'], '', lang('portalcp', 'diytemplate_name_null')); $datarow['name'] = $datarow['name'] ? $datarow['name'] : $langtplname; $data[$datarow['targettplname']] = dhtmlspecialchars($datarow['name']); } save_syscache('diytemplatename', $data); }
function build_cache_faqs() { $data = array(); $query = DB::query("SELECT fpid, id, identifier, keyword FROM " . DB::table('forum_faq') . " WHERE identifier!='' AND keyword!=''"); while ($faqs = DB::fetch($query)) { $data[$faqs['identifier']]['fpid'] = $faqs['fpid']; $data[$faqs['identifier']]['id'] = $faqs['id']; $data[$faqs['identifier']]['keyword'] = $faqs['keyword']; } save_syscache('faqs', $data); }