function saveModesData($uid, $data, $conf) { $array = array(); foreach ($data as $key => $value) { $this->_cacheService->set($this->_getKeyForUserMode($uid, $key), array('num' => S::isArray($conf[$key]) ? S::int($conf[$key]['num']) : $conf[$key], 'value' => $value), S::isArray($conf[$key]) && isset($conf[$key]['expire']) ? S::int($conf[$key]['expire']) : 608400); } }
/** * 获取帖子基本信息和详细信息 * * @param int $threadId 帖子id * @return array */ function getThreadAndTmsgByThreadId($threadId) { $threadId = S::int($threadId); if ($threadId < 1) { return false; } if (!$this->checkMemcache()) { return $this->_getThreadAndTmsgByThreadIdNoCache($threadId); } $threadKey = $this->_getKeyForThread($threadId); $tmsgKey = $this->_getKeyForTmsg($threadId); //* $result = $this->_cacheService->get(array($threadKey, $tmsgKey)); //* $thread = isset($result[$threadKey]) ? $result[$threadKey] : false; //* $tmsg = isset($result[$tmsgKey]) ? $result[$tmsgKey] : false; $thread = $this->_cacheService->get($threadKey); $tmsg = $this->_cacheService->get($tmsgKey); if ($thread === false) { $thread = $this->_getThreadNoCache($threadId); $this->_cacheService->set($threadKey, $thread); } if ($tmsg === false) { $tmsg = $this->_getTmsgNoCache($threadId); $this->_cacheService->set($tmsgKey, $tmsg); } return $thread && $tmsg ? array_merge($thread, $tmsg) : array(); }
/** * 从缓存获取一条bbsinfo记录 * * @param int $id * @return array */ function getBbsInfoById($id) { $id = S::int($id); if ($id < 1) { return false; } $key = $this->_getBbsInfoKeyById($id); if (!($bbsInfo = $this->_cacheService->get($key))) { $bbsInfo = $this->_getBbsInfoByIdNoCache($id); $bbsInfo && $this->_cacheService->set($key, $bbsInfo); } return $bbsInfo; }
function getBbsInfoById($id) { $id = S::int($id); if ($id < 1) { return false; } if (perf::checkMemcache()) { $_cacheService = Perf::gatherCache('pw_bbsinfo'); return $_cacheService->getBbsInfoById($id); } $bbsInfoDb = $this->_getBbsInfoDB(); return $bbsInfoDb->get($id); }
/** * 获取用户模块缓存数据 * @param $uid int 用户id * @param $modes array 获取模块数据及数量 array('article' => 1, 'write' => 2, ...)或数组 array('aritcle' => array('num'=>1,'expire'=>1234)) * return array */ function getByModes($uid, $modes) { $array = array(); $query = $this->_db->query("SELECT type,num,value FROM " . $this->_tableName . " WHERE uid=" . S::sqlEscape($uid) . ' AND type IN(' . S::sqlImplode(array_keys($modes)) . ') AND expire>' . S::sqlEscape($this->now, false)); while ($rt = $this->_db->fetch_array($query)) { $num = S::isArray($modes[$rt['type']]) ? S::int($modes[$rt['type']]['num']) : $modes[$rt['type']]; if ($num < $rt['num']) { $array[$rt['type']] = PwArraySlice($this->_unserialize($rt['value']), 0, $num, true); } elseif ($num == $rt['num']) { $array[$rt['type']] = $this->_unserialize($rt['value']); } } return $array; }
/** * 获取评分基本信息 * * @param int $threadId 帖子id * @param array $ping_logs 积分日志数组 * @return array */ function getPingsByThreadId($threadId, $ping_logs, $pingpage = null) { $threadId = S::int($threadId); if ($threadId < 1 || !$this->checkMemcache()) { return false; } $pinglogKey = $this->_getPinglogKey($threadId); $pinglogSourceKey = $this->_getPinglogSourceKey($threadId); $result = $this->_cacheService->get($pinglogKey); if ($result === false || $this->_cacheService->get($pinglogSourceKey) != $ping_logs) { $pingService = L::loadClass("ping", 'forum'); $result = $pingService->getPingLogs($threadId, $ping_logs, $pingpage); $this->_cacheService->set($pinglogSourceKey, $ping_logs); $this->_cacheService->set($pinglogKey, $result); } return $result; }
function getFirstPostsByTid($postTable, $tid, $limit, $offset) { $tid = S::int($tid); if ($tid < 1) { return false; } if (!$this->checkMemcache()) { return $this->_getFirstPostNoCache($postTable, $tid, $limit, $offset); } $key = $this->_getPostsKey($tid, $limit); $result = $this->_cacheService->get($key); if ($result === false) { $result = $this->_getFirstPostNoCache($postTable, $tid, $limit, $offset); $this->_cacheService->set($key, $result); if (count($result) < $offset) { $this->_cacheService->set($this->_getPostsLastKey($tid), $limit, false); } } return $result; }
/** * 根据一个用户id获取用户标签 * * @param int $uid 用户id * @return array */ function getMemberTagsByUserid($userId) { $userId = S::int($userId); if ($userId < 1) { return false; } $key = $this->_getMemberTagsKey($userId); $result = $this->_cacheService->get($key); if ($result === false) { $memberTagsService = L::loadClass('memberTagsService', 'user'); $result = $memberTagsService->getMemberTagsByUidFromDB($userId); $result = $result ? $result : array(); $this->_cacheService->set($key, $result); } return $result; }
function gets($behavior, $num) { $query = $this->_db->query("SELECT * FROM " . $this->_tableName . " WHERE behavior =" . S::int($behavior) . $this->_Limit(0, $num)); return $this->_getAllResultFromQuery($query); }
/** * 私有解析分页语句 * @param $offset * @param $row_count */ function _parseLimit($limits) { $offset = S::int($limits[0]); $row_count = S::int($limits[1]); return $offset >= 0 && $row_count > 0 ? " LIMIT " . $offset . "," . $row_count : ''; }
/** * today fans order * * @param int $uid * @return */ function todayFansUpdate($uid) { global $tdtime, $timestamp; if (!$uid) { return false; } $eid = $this->db->get_value("SELECT eid FROM pw_elements WHERE type='todayfans' AND id=" . S::int($uid)); if ($eid) { $this->db->update("UPDATE pw_elements SET value=value+1 WHERE eid=" . S::int($eid)); } else { $count = $this->db->get_value("SELECT COUNT(*) AS count FROM pw_attention WHERE friendid=" . S::int($uid) . " AND joindate>" . S::int($tdtime)); $this->updatelist[] = array('todayfans', 'fans', $uid, $count, $timestamp, '0'); $this->updatetype['todayfans'] = 1; } return true; }
function setTpcStatusByThreadIds($tids, $mask) { $this->_db->update("UPDATE {$this->_tableName} SET tpcstatus=tpcstatus & " . S::int($mask) . " WHERE tid IN(" . S::sqlImplode($tids) . ")"); }
/** * 获取用户信息 * * @global DB $db * @param int $uid * @return array */ function getUserByUid($uid) { $uid = S::int($uid); if ($uid < 1) { return false; } if (perf::checkMemcache()) { $_cacheService = Perf::getCacheService(); $detail = $_cacheService->get('member_all_uid_' . $uid); if ($detail && in_array(SCR, array('index', 'read', 'thread', 'post'))) { $_singleRight = $_cacheService->get('member_singleright_uid_' . $uid); $detail = $_singleRight === false ? false : (array) $detail + (array) $_singleRight; } if ($detail) { return $detail && $detail['groupid'] != 0 && isset($detail['md.uid']) ? $detail : false; } $cache = perf::gatherCache('pw_members'); if (in_array(SCR, array('index', 'read', 'thread', 'post'))) { $detail = $cache->getMembersAndMemberDataAndSingleRightByUserId($uid); } else { $detail = $cache->getAllByUserId($uid, true, true); } return $detail && $detail['groupid'] != 0 && isset($detail['md.uid']) ? $detail : false; } else { global $db; $sqladd = $sqltab = ''; if (in_array(SCR, array('index', 'read', 'thread', 'post'))) { $sqladd = SCR == 'post' ? ',md.postcheck,sr.visit,sr.post,sr.reply' : (SCR == 'read' ? ',sr.visit,sr.reply' : ',sr.visit'); $sqltab = "LEFT JOIN pw_singleright sr ON m.uid=sr.uid"; } $detail = $db->get_one("SELECT m.uid,m.username,m.password,m.safecv,m.email,m.bday,m.oicq,m.groupid,m.memberid,m.groups,m.icon,m.regdate,m.honor,m.timedf,m.style,m.datefm,m.t_num,m.p_num,m.yz,m.newpm,m.userstatus,m.shortcut,m.medals,m.gender,md.lastmsg,md.postnum,md.rvrc,md.money,md.credit,md.currency,md.lastvisit,md.thisvisit,md.onlinetime,md.lastpost,md.todaypost,md.monthpost,md.onlineip,md.uploadtime,md.uploadnum,md.starttime,md.pwdctime,md.monoltime,md.digests,md.f_num,md.creditpop,md.jobnum,md.lastgrab,md.follows,md.fans,md.newfans,md.newreferto,md.newcomment,md.punch,md.bubble,md.newnotice,md.newrequest,md.shafa {$sqladd} FROM pw_members m LEFT JOIN pw_memberdata md ON m.uid=md.uid {$sqltab} WHERE m.uid=" . S::sqlEscape($uid) . " AND m.groupid<>'0' AND md.uid IS NOT NULL"); return $detail; } }
if ($_POST['step'] == 2) { S::gp(array('host', 'port', 'isopen', 'rank', 'group', 'tindex', 'tcindex', 'pindex', 'dindex', 'dcindex', 'cmsindex', 'weiboindex', 'wordsegment_mode', 'sync_data')); empty($host) && adminmsg("抱歉,服务器主机不能为空"); empty($port) && adminmsg("抱歉,服务器端口不能为空"); $isopen = isset($isopen) ? $isopen : 0; if ($isopen) { $errormsg = testSockopen($host, $port); if ($errormsg[0] != 1) { adminmsg($errormsg[1]); } } $sync_data = (array) $sync_data; if ($sync_data && array_diff($sync_data, array('sync_threads', 'sync_posts', 'sync_diarys', 'sync_members'))) { showMsg("抱歉,实时操作记录类型不存在"); } $sphinxData = array('isopen' => $isopen, 'host' => $host, 'port' => $port, 'rank' => trim($rank), 'group' => trim($group), 'tindex' => trim($tindex), 'tcindex' => trim($tcindex), 'pindex' => trim($pindex), 'dindex' => trim($dindex), 'dcindex' => trim($dcindex), 'cmsindex' => trim($cmsindex), 'weiboindex' => trim($weiboindex), 'wordsegment_mode' => S::int($wordsegment_mode), 'sync' => $sync_data); setConfig('db_sphinx', $sphinxData); updatecache_c(); adminmsg("operate_success"); } else { $ajax = S::getGP('ajax'); if ($ajax == 1 && strtolower($pwServer['REQUEST_METHOD']) == 'post') { S::gp(array('host', 'port')); $errormsg = testSockopen($host, $port); showError($errormsg[1]); } $baseUrl = EncodeUrl($basename); $default = $sphinxSearch->_getSphinxDefaults(); $configure = $db_sphinx ? $db_sphinx : $default; /*兼容*/ foreach ($default as $k => $v) {
/** * 根据用户id获取用户名 * * @param int $userId 用户id * @return string|null */ function getUserNameByUserId($userId) { $userId = S::int($userId); if ($userId < 1) { return false; } if (perf::checkMemcache()) { $_cacheService = Perf::gatherCache('pw_members'); return $_cacheService->getUserNameByUserId($userId); } if (!($data = $this->get($userId))) { return null; } return $data['username']; }
$USCR = 'space_set'; !$winduid && Showmsg('not_login'); $isGM = S::inArray($windid, $manager); !$isGM && $groupid == 3 && ($isGM = 1); require_once R_P . 'u/lib/space.class.php'; $newSpace = new PwSpace($winduid); $newSpace->initSet(); $space = $newSpace->getInfo(); $isSpace = true; $spaceModel = $newSpace->models; $lang_model = array('friend' => array('朋友', '人', 'friend'), 'visitor' => array('最近访客', '人', 'visitor'), 'visit' => array('我访问过', '人', 'visit'), 'messageboard' => array('留言板', '条', 'messageboard'), 'diary' => array('日志', '篇', 'diary'), 'photos' => array('相册照片', '张', 'photos'), 'weibo' => array('新鲜事', '条', 'write'), 'article' => array('发表的帖子', '篇', 'article'), 'colony' => array('群组', '个', 'colony'), 'tags' => array('个人标签', '个', 'tags'), 'reply' => array('回复的帖子', '篇', 'article')); if (empty($_POST['step'])) { S::gp(array('tab')); $modeSel = $tab ? $tab : substr($_COOKIE['spacemodeset'], 4); !in_array($modeSel, array('basic', 'skin', 'model')) && ($modeSel = 'basic'); S::int($space['spacetype']) < 0 && ($space['spacetype'] = 3); !$space['spacestyle'] && ($space['spacestyle'] = 2); !$space['spacetype'] && ($space['spacetype'] = 0); $sel_basic = $sel_skin = $sel_model = $ifcheck_0 = $ifcheck_1 = $ifcheck_2 = $ifcheck_3 = $ifcheckstyle_2 = $ifcheckstyle_3 = ''; $style_basic = $style_skin = $style_model = 'none'; ${'sel_' . $modeSel} = ' class="current"'; ${'style_' . $modeSel} = ''; ${'ifcheck_' . $space['spacetype']} = ' checked'; ${'spacethemes_' . $space['spacetype']} = 'class="current"'; ${'ifcheckstyle_' . $space['spacestyle']} = ' checked'; ${'spacestyle_' . $space['spacestyle']} = 'class="current"'; $maxuploadsize = ini_get('upload_max_filesize'); //$privacy = $newSpace->getPrivacy(); !$o_uskin && ($o_uskin = array('default85' => 'default85')); $space['namelength'] = strlen($space['name']); $space['desclength'] = strlen($space['descript']);
/** * 根据作者id 删除帖子 * * @param int $authorId 作者id * @return int */ function deleteByAuthorId($authorId) { $authorId = S::int($authorId); if ($authorId < 1) { return false; } $_dbService = L::loadDB('threads', 'forum'); return $_dbService->deleteByAuthorId($authorId); }