function resetCloudWind() { $GLOBALS['db']->query("DELETE FROM `pw_config` WHERE db_name = 'db_yunsearch_search'"); $GLOBALS['db']->query("DELETE FROM `pw_config` WHERE db_name = 'db_yunsearch_hook'"); $GLOBALS['db']->query("DELETE FROM `pw_config` WHERE db_name = 'db_yunsearch_search'"); $GLOBALS['db']->query("DELETE FROM `pw_config` WHERE db_name = 'db_yunsearch_domain'"); $GLOBALS['db']->query("DELETE FROM `pw_config` WHERE db_name = 'db_yunsearch_isopen'"); $GLOBALS['db']->query("DELETE FROM `pw_config` WHERE db_name = 'db_yunsearch_unique'"); $GLOBALS['db']->query("DELETE FROM `pw_config` WHERE db_name = 'db_yundefend_shield'"); $GLOBALS['db']->query("DELETE FROM `pw_config` WHERE db_name = 'db_yundefend_shielduser'"); $GLOBALS['db']->query("DELETE FROM `pw_config` WHERE db_name = 'db_yundefend_shieldpost'"); $GLOBALS['db']->query("DELETE FROM `pw_config` WHERE db_name = 'db_yun_model'"); $GLOBALS['db']->query("DELETE FROM `pw_config` WHERE db_name = 'db_yun_expand'"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_aggregate`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_attachs`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_colonys`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_diary`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_forums`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_members`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_postdefend`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_posts`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_postverify`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_setting`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_threads`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_userdefend`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_log_weibos`"); $GLOBALS['db']->query("TRUNCATE TABLE `pw_yun_setting`"); P_unlink(D_P . 'data/bbscache/cloudwind_logsettings.php'); P_unlink(D_P . 'data/bbscache/cloudwind_settings.php'); P_unlink(D_P . 'data/bbscache/cloudwind_postinfo.php'); require_once R_P . 'admin/cache.php'; updatecache_c(); return true; }
function updatesyncredit($syncredit) { require_once R_P . 'admin/cache.php'; setConfig('uc_syncredit', $syncredit); updatecache_c(); return new ApiResponse(1); }
function setConfig($key, $value) { if (!$key) { return true; } require_once R_P . 'admin/cache.php'; setConfig('db_' . $key, $value); updatecache_c(); }
/** * 插入站长中心id * @param int $siteId 站长中心id * @return bool */ function insertWebmasterKey($siteId) { if ($siteId <= 0) { return new ApiResponse(false); } require_once R_P . 'admin/cache.php'; setConfig('db_siteappkey', $siteId); updatecache_c(); return new ApiResponse(true); }
function appsUpdateCache($apps) { if ($apps && is_array($apps)) { require_once R_P . 'admin/cache.php'; setConfig('db_apps_list', $apps); updatecache_c(); return new ApiResponse(true); } else { return new ApiResponse(false); } }
function _saveBindInfo($options) { require_once R_P . 'admin/cache.php'; global ${$this->_config_key}; $bindInfo = ${$this->_config_key} ? ${$this->_config_key} : array(); foreach ($options as $key => $value) { $bindInfo[$key] = $value; } ${$this->_config_key} = $bindInfo; setConfig($this->_config_key, $bindInfo); updatecache_c(); return true; }
function resetWind() { $fields = array('db_yunsearch_search', 'db_yunsearch_hook', 'db_yun_hash', 'db_yunsearch_domain', 'db_yunsearch_isopen', 'db_yunsearch_unique', 'db_yundefend_shield', 'db_yundefend_shielduser', 'db_yundefend_shieldpost', 'db_yun_model', 'db_yun_expand'); foreach ($fields as $field) { $GLOBALS['db']->query("DELETE FROM `pw_config` WHERE db_name = '{$field}'"); } $tables = array('pw_log_aggregate', 'pw_log_attachs', 'pw_log_colonys', 'pw_log_diary', 'pw_log_forums', 'pw_log_members', 'pw_log_postdefend', 'pw_log_posts', 'pw_log_postverify', 'pw_log_setting', 'pw_log_threads', 'pw_log_userdefend', 'pw_log_weibos', 'pw_yun_setting'); foreach ($tables as $table) { $result = $GLOBALS['db']->get_one("SHOW TABLES LIKE '{$table}'"); if ($result) { $GLOBALS['db']->query("TRUNCATE TABLE `{$table}`"); } } P_unlink(D_P . 'data/bbscache/cloudwind_logsettings.php'); P_unlink(D_P . 'data/bbscache/cloudwind_settings.php'); P_unlink(D_P . 'data/bbscache/cloudwind_postinfo.php'); require_once R_P . 'admin/cache.php'; updatecache_c(); return true; }
function alertMusic($state) { //虾米音乐网编辑器开启/关闭 require_once R_P . 'admin/cache.php'; setConfig('db_xiami_music_open', $state); updatecache_c(); return new ApiResponse(true); }
function addConfigPower($powerData, $groupData) { setConfig('db_ratepower', serialize($powerData)); setConfig('db_rategroup', serialize($groupData)); updatecache_c(); }
function setScanCache() { global $db, $timestamp, $db_plist; # 获取回复表 if ($db_plist && is_array($db_plist)) { foreach ($db_plist as $key => $value) { if ($key > 0) { $postslist[] = 'pw_posts' . (int) $key; } else { $postslist[] = 'pw_posts'; } } } else { $postslist[] = 'pw_posts'; } if (file_exists(D_P . 'data/bbscache/wordsfb_progress.php')) { # 读取缓存 //* require_once pwCache::getPath(D_P.'data/bbscache/wordsfb_progress.php'); pwCache::getData(D_P . 'data/bbscache/wordsfb_progress.php'); $temp_threaddb = unserialize($threaddb); } else { $temp_threaddb = array(); } $forum = $catedb = $forumdb = $subdb1 = $subdb2 = $threaddb = array(); # 获取版块列表 $query = $db->query("SELECT fid,name,fup,type FROM pw_forums WHERE cms!='1' ORDER BY vieworder"); while ($forums = $db->fetch_array($query)) { $forums['name'] = Quot_cv(strip_tags($forums['name'])); if ($forums['type'] == 'category') { $catedb[] = $forums; } elseif ($forums['type'] == 'forum') { $forumdb[] = $forums; } elseif ($forums['type'] == 'sub') { $subdb1[] = $forums; } else { $subdb2[] = $forums; } } foreach ($catedb as $cate) { $threaddb[$cate['fid']] = array(); foreach ($forumdb as $key2 => $forumss) { if ($forumss['fup'] == $cate['fid']) { if (!array_key_exists($forumss['fid'], $temp_threaddb[$cate['fid']])) { # 读取版块帖子总数和表进度 $forumss['count'] = 0; $forumss['progress'] = 0; $forumss['result'] = 0; $forumss['table_progress']['pw_threads'] = 0; foreach ($postslist as $pw_posts) { $forumss['table_progress'][$pw_posts] = 0; } $threaddb[$cate['fid']][$forumss['fid']] = $forumss; } else { $threaddb[$cate['fid']][$forumss['fid']] = $temp_threaddb[$cate['fid']][$forumss['fid']]; unset($threaddb[$cate['fid']][$forumss['fid']]['table_progress']); $threaddb[$cate['fid']][$forumss['fid']]['table_progress']['pw_threads'] = $temp_threaddb[$cate['fid']][$forumss['fid']]['table_progress']['pw_threads']; foreach ($postslist as $pw_posts) { $threaddb[$cate['fid']][$forumss['fid']]['table_progress'][$pw_posts] = $temp_threaddb[$cate['fid']][$forumss['fid']]['table_progress'][$pw_posts]; } } unset($forumdb[$key2]); foreach ($subdb1 as $key3 => $sub1) { if ($sub1['fup'] == $forumss['fid']) { if (!array_key_exists($sub1['fid'], $temp_threaddb[$cate['fid']])) { # 读取版块帖子总数和表进度 $sub1['count'] = 0; $sub1['progress'] = 0; $sub1['result'] = 0; $sub1['table_progress']['pw_threads'] = 0; foreach ($postslist as $pw_posts) { $sub1['table_progress'][$pw_posts] = 0; } $threaddb[$cate['fid']][$sub1['fid']] = $sub1; } else { $threaddb[$cate['fid']][$sub1['fid']] = $temp_threaddb[$cate['fid']][$sub1['fid']]; unset($threaddb[$cate['fid']][$sub1['fid']]['table_progress']); $threaddb[$cate['fid']][$sub1['fid']]['table_progress']['pw_threads'] = $temp_threaddb[$cate['fid']][$sub1['fid']]['table_progress']['pw_threads']; foreach ($postslist as $pw_posts) { $threaddb[$cate['fid']][$sub1['fid']]['table_progress'][$pw_posts] = $temp_threaddb[$cate['fid']][$sub1['fid']]['table_progress'][$pw_posts]; } } unset($subdb1[$key3]); foreach ($subdb2 as $key4 => $sub2) { if ($sub2['fup'] == $sub1['fid']) { if (!array_key_exists($sub2['fid'], $temp_threaddb[$cate['fid']])) { # 读取版块帖子总数和表进度 $sub2['count'] = 0; $sub2['progress'] = 0; $sub2['result'] = 0; $sub2['table_progress']['pw_threads'] = 0; foreach ($postslist as $pw_posts) { $sub2['table_progress'][$pw_posts] = 0; } $threaddb[$cate['fid']][$sub2['fid']] = $sub2; } else { $threaddb[$cate['fid']][$sub2['fid']] = $temp_threaddb[$cate['fid']][$sub2['fid']]; unset($threaddb[$cate['fid']][$sub2['fid']]['table_progress']); $threaddb[$cate['fid']][$sub2['fid']]['table_progress']['pw_threads'] = $temp_threaddb[$cate['fid']][$sub2['fid']]['table_progress']['pw_threads']; foreach ($postslist as $pw_posts) { $threaddb[$cate['fid']][$sub2['fid']]['table_progress'][$pw_posts] = $temp_threaddb[$cate['fid']][$sub2['fid']]['table_progress'][$pw_posts]; } } unset($subdb2[$key4]); } } } } } } } $catedb = serialize($catedb); $threaddb = serialize($threaddb); # 写入文件 $filecontent = "<?php\r\n"; $filecontent .= "\$catedb=" . pw_var_export($catedb) . ";\r\n"; $filecontent .= "\$threaddb=" . pw_var_export($threaddb) . ";\r\n"; $filecontent .= "?>"; $cahce_file = D_P . 'data/bbscache/wordsfb_progress.php'; pwCache::setData($cahce_file, $filecontent); setConfig('db_wordsfb_cachetime', $timestamp); updatecache_c(); return array('catedb' => $catedb, 'threaddb' => $threaddb); }
/** * * @param PW_WeiboSiteBindConfig $config */ function _saveBindConfig($bindConfig) { require_once R_P . 'admin/cache.php'; setConfig($this->_config_key, $bindConfig->toArray()); updatecache_c(); }
function saveConfig() { global $db; $configdb = array(); $temppre = array('config' => 'db_', 'ftp' => 'ftp_', 'reg' => 'rg_', 'mail' => 'ml_'); foreach ($temppre as $key => $pre) { if (!isset($GLOBALS[$key])) { continue; } $key_a = $GLOBALS[$key]; if (is_array($key_a)) { foreach ($key_a as $k => $value) { $var = $pre . $k; $vtype = 'string'; if (is_array($value)) { $vtype = 'array'; $value = serialize($value); } $configdb[$var] = array($var, $vtype, $value); } } } if (!empty($configdb)) { $names = array_keys($configdb); $query = $db->query('SELECT db_name,vtype,db_value FROM pw_config WHERE db_name IN (' . S::sqlImplode($names, false) . ')'); while ($rt = $db->fetch_array($query)) { if (isset($configdb[$rt['db_name']])) { if ($rt['db_value'] != $configdb[$rt['db_name']]) { $db->update("UPDATE pw_config SET " . S::sqlSingle(array('db_value' => $configdb[$rt['db_name']][2], 'vtype' => $configdb[$rt['db_name']][1])) . ' WHERE db_name=' . S::sqlEscape($rt['db_name'])); } unset($configdb[$rt['db_name']]); } } $db->free_result($query); $pwSqlMulti = S::sqlMulti($configdb); $pwSqlMulti && $db->update('INSERT INTO pw_config (db_name,vtype,db_value) VALUES' . $pwSqlMulti); updatecache_c(); return true; } else { return false; } }
function cache() { $query = $this->db->query("SELECT * FROM pw_nav WHERE isshow=1 ORDER BY type,upid,view"); $nav_cache = $nav_other = $nav_main = $nav_head = $nav_foot = array(); while ($navdb = $this->db->fetch_array($query)) { list($navdb['color'], $navdb['b'], $navdb['i'], $navdb['u']) = explode('|', $navdb['style']); $key = $navdb['nkey'] ? 'KEY' . $navdb['nkey'] : 'ID' . $navdb['nid']; if ($navdb['type'] == "foot") { $nav_foot[$key] = array('html' => $this->_getHtmlText($navdb), 'pos' => $navdb['pos']); } elseif ($navdb['type'] == "head") { $nav_head[$key] = array('html' => $this->_getHtmlText($navdb), 'pos' => $navdb['pos']); } elseif ($navdb['type'] == "main") { $nav_main[$key] = array('html' => $this->_getHtmlText($navdb), 'pos' => $navdb['pos']); } else { $nav_other[$navdb['nid']] = $navdb; } } foreach ($nav_other as $value) { $key = $value['nkey'] ? 'KEY' . $value['nkey'] : 'ID' . $value['nid']; if (!$value['upid']) { $nav_cache[$value['type']][$key] = array('html' => $this->_getHtmlText($value)); } else { $upkey = $nav_other[$value['upid']]['nkey'] ? 'KEY' . $nav_other[$value['upid']]['nkey'] : 'ID' . $nav_other[$value['upid']]['nid']; $nav_cache[$value['type']][$upkey]['child'][$key] = array('html' => $this->_getHtmlText($value)); } } require_once R_P . 'admin/cache.php'; setConfig('db_headnav', $nav_head); setConfig('db_footnav', $nav_foot); setConfig('db_mainnav', $nav_main); foreach ($nav_cache as $key => $value) { if (strpos($key, 'bbs_') !== false) { $key = str_replace('bbs_', 'db_', $key); setConfig($key, $value); } else { $this->db->update("REPLACE INTO pw_hack SET hk_name=" . pwEscape($key, false) . ",vtype='array',hk_value=" . pwEscape(serialize($value), false)); } } foreach (array_keys($GLOBALS['db_modes']) as $value) { if ($value != 'bbs') { updatecache_conf($value, true); } } updatecache_c(); }
function updatecache_postcate() { global $db; $postcatedb = array(); $query = $db->query("SELECT pcid,name,ifable,vieworder,viewright,adminright FROM pw_postcate ORDER BY vieworder"); $configdb = "<?php\r\n"; while ($rt = $db->fetch_array($query)) { $postcatedb[$rt['pcid']] = $rt; $pcids[] = $rt['pcid']; } $configdb .= "\$postcatedb=" . pw_var_export($postcatedb) . ";\r\n"; $configdb .= "?>"; writeover(D_P . 'data/bbscache/postcate_config.php', $configdb); $pcids = implode(',', $pcids); setConfig('db_pcids', $pcids); updatecache_c(); }
function _updateAreaUserConfig() { require_once R_P . 'admin/cache.php'; $users = $this->getAllAreaUser(); $temp = array(); foreach ($users as $value) { $temp[] = $value['uid']; } setConfig('db_portal_admins', $temp); updatecache_c(); }
/** * 解封某个用户 * * @param int $uid 用户id * @param array $params * ifmsg 是否发送消息 1-是,0-否 * reason 操作原因 * fid 版块ID * tid */ function banfree($uid, $params = array()) { $uid = intval($uid); $tid = intval($params['tid']); $pid = intval($params['pid']); $ifmsg = intval($params['ifmsg']); $reason = $params['reason']; $banuserDb = $this->_getBanUserDB(); $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */ $userinfo = $userService->get($uid); if (!$userinfo) { return 'undefined_action'; } $GLOBALS['username'] = $userinfo['username']; if ($banuserDb->deleteByUserId($uid)) { //解除禁言 $userService->setUserStatus($uid, PW_USERSTATUS_BANUSER, false); //* $userinfo['groupid'] == 6 && $this->db->update("UPDATE `pw_members` SET groupid='-1' WHERE `uid`=".S::sqlEscape($uid)); $userinfo['groupid'] == 6 && pwQuery::update('pw_members', 'uid=:uid', array($uid), array('groupid' => -1)); $ifmsg && M::sendNotice(array($userinfo['username']), array('title' => getLangInfo('writemsg', 'banuser_free_title'), 'content' => getLangInfo('writemsg', 'banuser_free_content', array('reason' => stripslashes($reason), 'manager' => $GLOBALS['windid'])))); /*如果是版块禁言,获取帖子信息*/ if ($tid > 0) { $postInfo = $this->getPostInfo($tid, $pid); if ($postInfo === false) { return 'banuser_post_data_error'; } $fid = $postInfo['fid']; $userip = $postInfo['userip']; //解除禁止的IP/ require_once R_P . 'admin/cache.php'; $ipban = $this->db->get_one("SELECT db_value FROM pw_config WHERE db_name='db_ipban'"); $bannedIps = explode(',', $ipban['db_value']); if (in_array($userip, $bannedIps)) { $bannedIps = array_filter(str_replace($userip, '', $bannedIps)); setConfig('db_ipban', implode(',', $bannedIps)); updatecache_c(); } $fid && ($foruminfo = L::forum($fid)); if ($foruminfo) { //omit write log if ($foruminfo['allowhtm']) { $StaticPage = L::loadClass('StaticPage'); $StaticPage->update($tid); } } } $this->clearUserCache($uid); } else { //未被禁言 return 'banuser_notfound'; } return true; }
function updateMergeCreditlogTable() { global $db, $PW; $createTable = array(); $query = $db->query("SHOW TABLE STATUS LIKE 'pw_creditlog%'"); while ($rt = $db->fetch_array($query)) { $key = $PW ? substr(str_replace($GLOBALS['PW'], 'pw_', $rt['Name']), 12) : substr($rt['Name'], 5); if ($key && !is_numeric($key)) { continue; } $createTable[] = $rt['Name']; } $engineType = $db->server_info() > '4.1' ? 'ENGINE=MERGE' : 'TYPE=MERGE'; $creatTableStructure = $db->get_one("SHOW CREATE TABLE `pw_creditlog`"); preg_match('/\\(.+\\)/is', $creatTableStructure['Create Table'], $match); preg_match('/CHARSET=([^;\\s]+)/is', $creatTableStructure['Create Table'], $charsetMatch); $db->query('DROP TABLE IF EXISTS `pw_merge_creditlog`'); ksort($createTable); $createTableSql = 'CREATE TABLE `pw_merge_creditlog` ' . $match[0] . " {$engineType} UNION=(" . implode(',', $createTable) . ') DEFAULT CHARSET=' . $charsetMatch[1] . ' INSERT_METHOD=LAST'; $db->query($createTableSql); $success = $db->get_one("SHOW TABLE STATUS LIKE 'pw_merge_creditlog'"); $config = $success['Engine'] ? 1 : 0; setConfig("db_merge_creditlog", $config); updatecache_c(); return true; }
function updateMergePostsTable() { global $db_plist, $db, $PW; !$db_plist && ($postTableNames = array("{$PW}posts")); if (S::isArray($db_plist)) { foreach ($db_plist as $key => $val) { $postTableNames[$key] = $key == 0 ? "{$PW}posts" : "{$PW}posts" . $key; } } $engineType = $db->server_info() > '4.1' ? 'ENGINE=MERGE' : 'TYPE=MERGE'; $creatTable = $db->get_one("SHOW CREATE TABLE `pw_posts`"); preg_match('/\\(.+\\)/is', $creatTable['Create Table'], $match); preg_match('/CHARSET=([^;\\s]+)/is', $creatTable['Create Table'], $charsetMatch); $db->query("DROP TABLE IF EXISTS `pw_merge_posts`"); ksort($postTableNames); $createTableSql = 'CREATE TABLE `pw_merge_posts` ' . $match[0] . " {$engineType} UNION=(" . implode(',', $postTableNames) . ') DEFAULT CHARSET=' . $charsetMatch[1] . ' INSERT_METHOD=LAST'; $db->query($createTableSql); $success = $db->get_one("SHOW TABLE STATUS LIKE 'pw_merge_posts'"); $config = $success['Engine'] ? 1 : 0; setConfig("db_merge_posts", $config); updatecache_c(); return true; }
function _updateChannelDomain() { include_once R_P . 'admin/cache.php'; $channelDAO = $this->_getChannelDAO(); $channelDomain = $channelDAO->getSecendDomains(); setConfig('db_channeldomain', $channelDomain); updatecache_c(); }
function _updateCache($hotwords) { global $timestamp; require_once R_P . 'admin/cache.php'; if (!$hotwords) { setConfig('db_hotwords', ''); return updatecache_c(); } setConfig('db_hotwords', $hotwords); setConfig('db_hotwordlasttime', $timestamp); updatecache_c(); return true; }
function updateshortcut() { global $db, $db_shortcutforum; PwNewDB(); $array = array(); $query = $db->query("SELECT f.fid,f.name FROM pw_forums f LEFT JOIN pw_forumdata fd ON f.fid=fd.fid WHERE f.f_type='forum' AND f.password='' AND f.allowvisit='' ORDER BY fd.tpost DESC LIMIT 6"); while ($rt = $db->fetch_array($query)) { $array[$rt['fid']] = strip_tags($rt['name']); } empty($array) && ($array[0] = ''); if ($db_shortcutforum != $array) { require_once R_P . 'admin/cache.php'; setConfig('db_shortcutforum', $array); updatecache_c(); } return $array; }
/** * 确认帐号是否存在 */ function checkUsername($appid) { if (empty($appid)) { return false; } $siteappkey = $this->_checkUsername($appid); if (!empty($siteappkey['status'])) { setConfig('db_siteappkey', $siteappkey['siteid']); updatecache_c(); return true; } return false; }
if ($hackopen[$key] == 0) { $navMenu->setshow('hack_'.$key,0); $navMenu->setupnav('hack_'.$key,'hack'); } elseif ($hackopen[$key] == 1) { $navMenu->setshow('hack_'.$key,1); $navMenu->setupnav('hack_'.$key,'hack'); } elseif ($hackopen[$key] == 2) { $navMenu->setshow('hack_'.$key,1); $navMenu->setupnav('hack_'.$key); } */ $db_hackdb[$key] = array(stripslashes($value), $key); } } setConfig('db_hackdb', $db_hackdb); updatecache_c(); //$navMenu->cache(); adminmsg('operate_success'); } elseif ($action == 'delete') { InitGP(array('id')); empty($db_hackdb[$id]) && adminmsg('hackcenter_del'); unset($db_hackdb[$id]); $sqlarray = file_exists(R_P . "hack/{$id}/sql.txt") ? FileArray($id) : array(); !empty($sqlarray) && SQLDrop($sqlarray); setConfig('db_hackdb', $db_hackdb); $navMenu = L::loadClass('navmenu'); $navMenu->settype('bbs_navinfo'); $navMenu->del('hack_' . $id); $navMenu->cache(); adminmsg('operate_success'); } elseif ($action == 'add') {
function configThreads($params) { //生成帖子交换缓存 if ($params && is_array($params)) { require_once R_P . 'admin/cache.php'; setConfig('db_threadconfig', $params); updatecache_c(); return new ApiResponse(true); } return new ApiResponse(false); }