private function _initInfo() { $this->uid = wekit::getLoginUser()->info['uid']; // dump($this->uid); $this->username = wekit::getLoginUser()->info['username']; $this->onlinetime = intval(intval(wekit::getLoginUser()->info['onlinetime']) / 3600); // $this->ip= wekit::getLoginUser()->info['lastloginip']; // $this->ip=$_SERVER["REMOTE_ADDR"]; $this->ip = $this->GetIP(); Wind::import('SRV:credit.bo.PwCreditBo'); $userBelongSrv = Wekit::load('SRV:user.PwUserBelong'); // dump($userBelongSrv->getUserBelongs(7)); $this->gid = wekit::getLoginUser()->info['groupid']; //$this->gid=8;//0 NULL 1会员2游客3管理员4总版主5论坛版主6禁止发言7未验证会员 if (($group = Wekit::cache()->get('group', $this->gid)) === false) { $group = Wekit::cache()->get('group', 1); } // dump(Wekit::$_app); // dump($this->gid); //2015.1.17关闭group if ($group) { $this->groupInfo = array('name' => $group['name'], 'type' => $group['type'], 'image' => $group['image'], 'points' => $group['points']); $this->permission = $group['permission']; } // dump($this->groupInfo); $this->avatarPath = str_replace('_middle', '', Pw::getAvatar($this->uid)); //获取头像 √ }
/** * 获取版块活跃用户 * * @param int $fid * @param int $day * @param int $num * @return array */ public function getActiveUser($fid, $day = 7, $num = 12) { $key = "active_user_{$fid}_{$day}_{$num}"; if (!($result = Wekit::cache()->get($key))) { $result = $this->_getActiveUser($fid, $day, $num); Wekit::cache()->set($key, $result, array(), 3600); } return $result; }
public function doFtpAction() { try { $config = $this->getInput(array('server', 'port', 'user', 'pwd', 'dir', 'sftp'), 'post', true); $ftp = $config['sftp'] ? new PwSftpSave($config) : new PwFtpSave($config); } catch (WindFtpException $e) { $this->showError(array('APPCENTER:upgrade.ftp.fail', array($e->getMessage()))); } $ftp->close(); Wekit::cache()->set('system_patch_ftp', $config); $this->showMessage('success', 'appcenter/fixup/run', true); }
protected function _setPreCache($m, $mc, $mca) { $precache = Wekit::V('precache'); if (isset($precache[$m])) { Wekit::cache()->preset($precache[$m]); } if (isset($precache[$mc])) { Wekit::cache()->preset($precache[$mc]); } if (isset($precache[$mca])) { Wekit::cache()->preset($precache[$mca]); } }
/** * do ---> go * * @return void boolean */ public function compile($force = false) { if (!$this->inDevMode1()) { return; } $manifests = $this->_read(); if (empty($manifests)) { return; } $logs = Wekit::cache()->get('app_debug'); $logs || ($logs = array()); foreach ($manifests as $alias => $manifest) { $this->_copyRes($alias, $manifest); if (!isset($logs[$alias]) || md5_file($manifest) != $logs[$alias] || $force) { $this->_upgrade($alias, $manifest); $logs[$alias] = md5_file($manifest); } } Wekit::cache()->set('app_debug', $logs); return true; }
/** * 获取全局配置 * * @return array */ public function getConfig() { return Wekit::cache()->get('config'); }
public function after($fileList, $useFtp, $oldList) { if (Wekit::cache()->get('system_upgrade_replace')) { return true; } $relativePath_1 = PwSystemHelper::resolveRelativePath(PUBLIC_PATH, Wind::getRealPath('SRC:wekit')); $relativePath_2 = PwSystemHelper::resolveRelativePath(PUBLIC_PATH . 'aCloud', Wind::getRealPath('SRC:wekit')); $strtr = $this->getMoveWay(); $move = array(); $entrance = array('index.php', 'read.php', 'install.php', 'windid.php', 'admin.php', 'alipay.php', 'pay99bill.php', 'paypal.php', 'tenpay.php'); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { foreach ($oldList as $v) { $v = trim($v, '/'); $v = str_replace('/', DIRECTORY_SEPARATOR, $v); $_v = ROOT_PATH . $v; $file = $v; foreach ($strtr as $search => $replace) { if (0 === strpos($_v, $search)) { $file = str_replace(ROOT_PATH, '', $replace . substr($_v, strlen($search))); $file = str_replace('//', '/', $file); break; } } $move[$file] = $_v; if (in_array(basename($_v), $entrance)) { $content = WindFile::read($_v); if (strpos($content, '../../src/wekit.php')) { $content = str_replace('../../src/wekit.php', $relativePath_2, $content); } else { $content = str_replace('../src/wekit.php', $relativePath_1, $content); } $tmp = tempnam($this->tmpPath, basename($_v) . WindUtility::generateRandStr(3)); WindFile::write($tmp, $content); $move[$file] = $tmp; } } } else { foreach ($fileList as $f => $hash) { $_v = ROOT_PATH . $f; if (in_array(basename($_v), $entrance)) { $content = WindFile::read($_v); if (strpos($content, '../../src/wekit.php')) { $content = str_replace('../../src/wekit.php', $relativePath_2, $content); } else { $content = str_replace('../src/wekit.php', $relativePath_1, $content); } $tmp = tempnam($this->tmpPath, basename($_v) . WindUtility::generateRandStr(3)); WindFile::write($tmp, $content); $move[$f] = $tmp; } } } // MD5SUM $md5File = WindFile::read(CONF_PATH . 'md5sum'); $sourceMd5 = PwSystemHelper::resolveMd5($md5File); $data = ''; foreach ($sourceMd5 as $v => $md5) { $v = trim($v, '/'); $v = str_replace('/', DIRECTORY_SEPARATOR, $v); $_v = ROOT_PATH . $v; $file = $v; foreach ($strtr as $search => $replace) { if (0 === strpos($_v, $search)) { $file = str_replace(ROOT_PATH, '', $replace . substr($_v, strlen($search))); $file = str_replace('//', '/', $file); break; } } $data .= PwSystemHelper::md5content($md5, $file); } $tmp = tempnam($this->tmpPath, 'md5temp'); WindFile::write($tmp, $data); $move[str_replace(ROOT_PATH, '', CONF_PATH . 'md5sum')] = $tmp; // 入口文件 if ($useFtp) { try { $ftp = $useFtp['sftp'] ? new PwSftpSave($useFtp) : new PwFtpSave($useFtp); } catch (WindFtpException $e) { return new PwError(array('APPCENTER:upgrade.ftp.fail', array($e->getMessage()))); } } foreach ($move as $k => $v) { if ($useFtp) { try { $r = $ftp->upload($v, $k); if ($useFtp['sftp'] && !$r && ($e = $ftp->getError())) { return new PwError('APPCENTER:upgrade.upload.fail', array($v . var_export($e, true))); } } catch (WindFtpException $e) { return new PwError(array('APPCENTER:upgrade.ftp.fail', array($e->getMessage()))); } } else { copy($v, ROOT_PATH . $k); } } $useFtp && $ftp->close(); return true; }
/** * 更新全局配置 config */ public function updateConfig() { Wekit::cache()->set('config', $this->getConfigCacheValue()); }
/** * 准备用户显示信息 * * @param array $uids 用户id序列 * @return array */ public function bulidUsers($uids) { $groupRight = Wekit::cache()->get('group_right'); $uids = array_unique($uids); $users = Wekit::load('user.PwUser')->fetchUserByUid($uids, PwUser::FETCH_ALL); in_array('0', $uids) && ($users['0'] = $this->_getGuestInfo()); foreach ($users as $key => $value) { $value['groupid'] == '0' && ($value['groupid'] = $value['memberid']); if ($value['bbs_sign']) { $value['bbs_sign'] = $this->_bulidBbsSign($value['bbs_sign'], $groupRight[$value['groupid']], $value['status']); } $users[$key] = $value; } $this->users = $this->runWithFilters('bulidUsers', $users); }
public function __construct() { Wekit::cache()->mergeKeys($this->keys); }
public function clear() { if ($this->ftp) { $this->ftp->close(); } WindFolder::clearRecur($this->tmpPath, true); Wekit::cache()->delete('system_patch_ftp'); }
/** * 生成表情html标签 * * @param int $key 表情序号 * @return string 表情html */ public static function createEmotion($length, $key) { is_null(self::$_emotion) && (self::$_emotion = Wekit::cache()->get('all_emotions')); isset(self::$_emotion['name'][$key]) && ($key = self::$_emotion['name'][$key]); $emotion = isset(self::$_emotion['emotion'][$key]) ? self::$_emotion['emotion'][$key] : current(self::$_emotion['emotion']); $html = "<img src=\"" . Wekit::url()->images . "/emotion/" . $emotion['emotion_folder'] . '/' . $emotion['emotion_icon'] . "\" />"; return array($html, 1); }
public function batchDeleteUser($uids) { Wekit::cache()->batchDelete($this->fetchKeysByUid($uids)); return $this->_getDao()->batchDeleteUser($uids); }
/** * 回复 */ public function doreplyAction() { $tid = $this->getInput('tid'); list($title, $content, $hide, $rpid) = $this->getInput(array('atc_title', 'atc_content', 'hide', 'pid'), 'post'); $_getHtml = $this->getInput('_getHtml', 'get'); $pwPost = $this->post; $this->runHook('c_post_doreply', $pwPost); $info = $pwPost->getInfo(); $title == 'Re:' . $info['subject'] && ($title = ''); if ($rpid) { $post = Wekit::load('thread.PwThread')->getPost($rpid); if ($post && $post['tid'] == $tid && $post['ischeck']) { $post['content'] = $post['ifshield'] ? '此帖已被屏蔽' : trim(Pw::stripWindCode(preg_replace('/\\[quote(=.+?\\,\\d+)?\\].*?\\[\\/quote\\]/is', '', $post['content']))); $post['content'] && ($content = '[quote=' . $post['created_username'] . ',' . $rpid . ']' . Pw::substrs($post['content'], 120) . '[/quote] ' . $content); } else { $rpid = 0; } } $postDm = $pwPost->getDm(); $postDm->setTitle($title)->setContent($content)->setHide($hide)->setReplyPid($rpid); if (($result = $pwPost->execute($postDm)) !== true) { $data = $result->getData(); $data && $this->addMessage($data, 'data'); $this->showError($result->getError()); } $pid = $pwPost->getNewId(); if ($_getHtml == 1) { Wind::import('SRV:forum.srv.threadDisplay.PwReplyRead'); Wind::import('SRV:forum.srv.PwThreadDisplay'); $threadDisplay = new PwThreadDisplay($tid, $this->loginUser); $this->runHook('c_post_replyread', $threadDisplay); $dataSource = new PwReplyRead($tid, $pid); $threadDisplay->execute($dataSource); $_cache = Wekit::cache()->fetch(array('level', 'group_right')); $this->setOutput($threadDisplay, 'threadDisplay'); $this->setOutput($tid, 'tid'); $this->setOutput($threadDisplay->fid, 'fid'); $this->setOutput($threadDisplay->getThreadInfo(), 'threadInfo'); $this->setOutput(current($threadDisplay->getList()), 'read'); $this->setOutput($threadDisplay->getUsers(), 'users'); $this->setOutput($threadDisplay->getArea(), 'area'); $this->setOutput($threadDisplay->getForum(), 'pwforum'); $this->setOutput(PwCreditBo::getInstance(), 'creditBo'); $this->setOutput(Wekit::C('bbs', 'read.display_member_info'), 'displayMemberInfo'); $this->setOutput(Wekit::C('bbs', 'read.display_info'), 'displayInfo'); $this->setOutput($_cache['level']['ltitle'], 'ltitle'); $this->setOutput($_cache['level']['lpic'], 'lpic'); $this->setOutput($_cache['level']['lneed'], 'lneed'); $this->setOutput($_cache['group_right'], 'groupRight'); $this->setTemplate('read_floor'); } elseif ($_getHtml == 2) { $content = Wekit::load('forum.srv.PwThreadService')->displayContent($content, $postDm->getField('useubb'), $postDm->getField('reminds')); $this->setOutput($postDm->getField('ischeck'), 'ischeck'); $this->setOutput($content, 'content'); $this->setOutput($this->loginUser->uid, 'uid'); $this->setOutput($this->loginUser->username, 'username'); $this->setOutput($pid, 'pid'); $this->setOutput(Pw::getTime() - 1, 'time'); $this->setTemplate('read_reply_floor'); } else { $this->showMessage('success', 'bbs/read/run/?tid=' . $tid . '&fid=' . $pwPost->forum->fid . '&page=e#' . $pid, true); } }
/** * 清除一个版块的列表缓存缓存 * * @param int $fid */ public function clearThreadListCache($fid) { Wekit::cache()->increment('thread_fver', array($fid)); }
/** * 组装我参与的勋章及自动勋章列表 * * 非cahce:PwUserMedalBo->getMyAndAutoMedal() * Enter description here ... * @param int $uid */ public function getMyAndAutoMedal($uid) { if (!$uid) { return array(); } $_medals = $myMedalIds = $status = array(); $logs = Wekit::load('medal.PwMedalLog')->getInfoListByUid($uid); foreach ($logs as $log) { $myMedalIds[] = $log['medal_id']; $status[$log['medal_id']] = $log['award_status']; } $cacheDs = Wekit::cache(); $autoMedalIds = $cacheDs->get('medal_auto'); $medals = $cacheDs->get('medal_all'); $attachUrl = Pw::getPath('') . 'medal/'; $localUrl = WindUrlHelper::checkUrl(PUBLIC_RES . '/images/medal/', PUBLIC_URL) . '/'; $medalIds = array_merge($myMedalIds, $autoMedalIds); $medalIds = array_unique($medalIds); foreach ($medalIds as $id) { if (!isset($medals[$id])) { continue; } $medals[$id]['award_status'] = isset($status[$id]) ? $status[$id] : 0; $path = $medals[$id]['path'] ? $attachUrl : $localUrl; $_tmp = $medals[$id]; $_tmp['image'] = $path . $_tmp['image']; $_tmp['icon'] = $path . $_tmp['icon']; $_medals[] = $_tmp; } return $_medals; }
private function _updateAdcache() { $ads = $this->_getAdDs()->getAllAd(); Wekit::cache()->set('advertisement', $ads); }
/** * 获取全局配置 * * @return array */ public function getConfig() { return new PwConfigBo(Wekit::cache()->get('config')); }
public function updateReplaceWordCache($data) { Wekit::cache()->set(self::WORD_REPLACE_KEY, $data); return true; }
/** * 初始化当前用户组信息及权限 */ private function _initGroup() { if ($this->_groupInfo) { return; } if (($group = Wekit::cache()->get('group', $this->gid)) === false) { $group = Wekit::cache()->get('group', 1); } $this->_groupInfo = array('name' => $group['name'], 'type' => $group['type'], 'image' => $group['image'], 'points' => $group['points']); $this->_permission = $group['permission']; }
/** * 勋章缓存更新策略 * * @return void */ public function updateCache() { $cacheDs = Wekit::cache(); $cacheDs->set('medal_all', $this->getMedalAllCacheValue()); $cacheDs->set('medal_auto', $this->getMedalAutoCacheValue()); }
/** * 分享到其它平台使用的链接 * * @access public * @return void * @example * <pre> * /index.php?m=native&c=read&a=sharePage&tid=21 * </pre> */ public function sharePageAction() { $tid = intval($this->getInput('tid', 'get')); list($page, $uid, $desc) = $this->getInput(array('page', 'uid', 'desc'), 'get'); $threadDisplay = new PwThreadDisplay($tid, $this->loginUser); $this->runHook('c_read_run', $threadDisplay); if (($result = $threadDisplay->check()) !== true) { $this->showError($result->getError()); } $_cache = Wekit::cache()->fetch(array('level', 'group_right')); $pwforum = $threadDisplay->getForum(); if ($pwforum->foruminfo['password']) { if (!$this->uid) { $this->forwardAction('u/login/run', array('backurl' => WindUrlHelper::createUrl('bbs/cate/run', array('fid' => ${$pwforum}->fid)))); } elseif (Pw::getPwdCode($pwforum->foruminfo['password']) != Pw::getCookie('fp_' . $pwforum->fid)) { $this->forwardAction('bbs/forum/password', array('fid' => $pwforum->fid)); } } Wind::import('SRV:forum.srv.threadDisplay.PwCommonRead'); $dataSource = new PwCommonRead($threadDisplay->thread); //数据分页 $perpage = $pwforum->forumset['readperpage'] ? $pwforum->forumset['readperpage'] : Wekit::C('bbs', 'read.perpage'); $dataSource->setPage($page)->setPerpage($perpage)->setDesc($desc); $threadDisplay->setImgLazy(Wekit::C('bbs', 'read.image_lazy')); $threadDisplay->execute($dataSource); //主题的信息 $threadInfo = $threadDisplay->getThreadInfo(); $threadInfo['content'] = preg_replace('/onload="([^"]+)"/i', '', $threadInfo['content']); $threadInfo['content'] = preg_replace('/onclick="([^"]+)"/i', '', $threadInfo['content']); $threadInfo['content'] = str_replace('style="max-width:700px;"', '', $threadInfo['content']); preg_match_all('/<div class="J_video" data-url="(.+?\\.swf.*?)".*?><\\/div>/i', $threadInfo['content'], $matches); if (isset($matches[0]) && $matches[0]) { $count = count($matches[0]); for ($i = 0; $i < $count; $i++) { $vedio = '<embed src="' . $matches[1][$i] . '" allowFullScreen="true" quality="high" width="240" height="200" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed><br>'; // echo $vedio."<br>"; $threadInfo['content'] = str_replace($matches[0][$i], $vedio, $threadInfo['content']); } } //帖子内容音频资源 preg_match_all('/<div class="J_audio".*?data-url="(.+?)".*?><\\/div>/i', $threadInfo['content'], $matches); if (isset($matches[0]) && $matches[0]) { $count = count($matches[0]); for ($i = 0; $i < $count; $i++) { $audio = '<br><audio controls="controls" src="' . $matches[1][$i] . '">不支持音乐</audio><br>'; $threadInfo['content'] = str_replace($matches[0][$i], $audio, $threadInfo['content']); } } //帖子数据列表 $threadList = $threadDisplay->getList(); $threadList = array_slice($threadList, 1, 3); foreach ($threadList as $k => $v) { preg_match_all('/<div class="J_video" data-url="(.+?\\.swf.*?)".*?><\\/div>/i', $v['content'], $matches); if (isset($matches[0]) && $matches[0]) { $count = count($matches[0]); for ($i = 0; $i < $count; $i++) { $vedio = '<embed src="' . $matches[1][$i] . '" allowFullScreen="true" quality="high" width="240" height="200" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed><br>'; // echo $vedio."<br>"; $threadList[$k]['content'] = str_replace($matches[0][$i], $vedio, $v['content']); } } preg_match_all('/<div class="J_audio".*?data-url="(.+?)".*?><\\/div>/i', $v['content'], $matches); if (isset($matches[0]) && $matches[0]) { $count = count($matches[0]); for ($i = 0; $i < $count; $i++) { $audio = '<br><audio controls="controls" src="' . $matches[1][$i] . '">不支持音乐</audio><br>'; $threadList[$k]['content'] = str_replace($matches[0][$i], $audio, $v['content']); } } } //var_dump($threadList);exit; $this->setOutput(Wekit::getGlobal('url', 'res'), 'resPath'); $this->setOutput($threadInfo, 'threadInfo'); $this->setOutput($threadList, 'threadList'); $this->setOutput($threadDisplay, 'threadDisplay'); $this->setOutput(PwCreditBo::getInstance(), 'creditBo'); }
private function _deleteHotTagCache() { $allCategorys = $this->_getTagCateGoryDs()->getAllCategorys(); $keys = array('hot_tags_0'); foreach ($allCategorys as $v) { $keys[] = sprintf('hot_tags_%s', $v['category_id']); } Wekit::cache()->batchDelete($keys); }
/** * 检查是否合法请求 * * @param unknown_type $action * @param unknown_type $r */ private function _checkLegal($action, $r) { $step = Wekit::cache()->get('system_upgrade_step'); $status = Wekit::cache()->get('system_upgrade'); $legal = true; if (!$step || !$status) { $legal = false; } if ($action != $this->status[++$step]) { $legal = false; } if ($status['version'] != $r['version']) { $legal = false; } $this->version = $status['version']; if (!is_array($r['filelist'])) { $legal = false; } if (!$legal) { $this->_clear(); $this->showError('APPCENTER:upgrade.illegal.request', 'appcenter/upgrade/check'); } $this->installService->target = $this->version; $this->fileList = $r['filelist']; $this->localFileList = isset($r['newfilelist']) ? $r['newfilelist'] : array(); $this->md5FileList = $r['md5list']; $this->setOutput($this->version, 'version'); }
/** * 清除一个帖子的列表缓存 * * @param int $tid */ public function clearPostListCache($tid) { Wekit::cache()->increment('post_tver', array($tid)); }
/** * 批量更新用户组的权限缓存 * * @param array $gids 更新指定gid序列的权限缓存 * @return void */ public function updateGroupCache($gids = array()) { $group = $this->getGroupCacheValue($gids); foreach ($group as $key => $value) { Wekit::cache()->set('group', $value, array($key)); } }
/** * 积分首页--我的积分 */ public function run() { //支持积分转换的积分 $exchange = array(); $exchange_config = Wekit::C()->credit->get('exchange', array()); foreach ($exchange_config as $key => $value) { if ($value['ifopen']) { $exchange[$value['credit1']][] = $value; } } //用户积分升级进度 $totalCredit = Wekit::load('usergroup.srv.PwUserGroupsService')->getCredit($this->loginUser->info); $_cache = Wekit::cache()->get('level'); $lneed = $_cache['lneed']; arsort($lneed); reset($lneed); $memberid = $nextid = $cpoint = $npoint = 0; foreach ($lneed as $key => $value) { $memberid = $key; $cpoint = $value; if ($totalCredit >= $value) { break; } $nextid = $key; $npoint = $value; } if ($totalCredit < $cpoint) { $max = max(abs($totalCredit), abs($cpoint)) * 2; $rate = round(($max - abs($totalCredit - $cpoint)) / $max * 10); $nextid = $npoint = 0; } elseif ($nextid) { $rate = round(($totalCredit - $cpoint) / ($npoint - $cpoint) * 100); } else { $rate = round(($totalCredit - $cpoint) / ($totalCredit * 2) * 100); } //综合积分: 计算方案 $upgrade = Wekit::C('site', 'upgradestrategy'); $_upgrade = array(); if ($upgrade['postnum']) { $_upgrade[] = '发帖数X' . $upgrade['postnum']; } if ($upgrade['digest']) { $_upgrade[] = '精华X' . $upgrade['digest']; } /* @var $creditBo PwCreditBo */ $creditBo = PwCreditBo::getInstance(); foreach ($creditBo->cType as $k => $v) { if (!$upgrade['credit' . $k]) { continue; } $_upgrade[] = $v . 'X' . $upgrade['credit' . $k]; } if ($upgrade['onlinetime']) { $_upgrade[] = '会员历史在线时间X' . $upgrade['onlinetime']; } $_upgrade = implode(' + ', $_upgrade); $this->setOutput($_upgrade, '_upgrade'); $this->setOutput($creditBo, 'creditBo'); $this->setOutput(Wekit::C('credit', 'transfer'), 'transfer'); $this->setOutput($exchange, 'exchange'); $this->setOutput($totalCredit, 'totalCredit'); $this->setOutput($cpoint, 'cpoint'); $this->setOutput($npoint, 'npoint'); $this->setOutput($memberid, 'memberid'); $this->setOutput($nextid, 'nextid'); $this->setOutput($rate, 'rate'); $this->setOutput($_cache['ltitle'], 'ltitle'); $this->setTemplate('profile_credit'); // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $seoBo = PwSeoBo::getInstance(); $lang = Wind::getComponent('i18n'); $seoBo->setCustomSeo($lang->getMessage('SEO:profile.credit.run.title'), '', ''); Wekit::setV('seo', $seoBo); }
/** * 获得用户拥有的权限 //这个权限在读贴子详细内容时获取,此接口暂时不用 * * @access public * @return void * @example * <pre> * post: tid * </pre> */ private function permissionAction() { $tid = $this->getInput('tid'); $userBo = new PwUserBo($this->uid); Wind::import('SRV:forum.srv.PwThreadDisplay'); $threadDisplay = new PwThreadDisplay($tid, $userBo); $this->runHook('c_read_run', $threadDisplay); if (($result = $threadDisplay->check()) !== true) { $this->showError($result->getError()); } $_cache = Wekit::cache()->fetch(array('level', 'group_right')); $pwforum = $threadDisplay->getForum(); $isBM = $pwforum->isBM($userBo->username); if ($threadPermission = $userBo->getPermission('operate_thread', $isBM, array())) { $operateThread = Pw::subArray($threadPermission, array('delete', 'ban')); $operateReply = Pw::subArray($threadPermission, array('delete', 'ban')); } /** * if ($hasFirstPart || $hasSecondPart || $hasThirdPart) //只要是版主都可以推荐 * $operateThread['delete'] * $operateReply['ban'] */ // print_r($operateThread); // print_r($operateReply); }
public function getHotTags($categoryId = 0, $num = 100) { return Wekit::cache()->get('hot_tags', array($categoryId, $num)); }
/** * 帖子阅读页 */ public function run() { $tid = intval($this->getInput('tid')); list($page, $uid, $desc) = $this->getInput(array('page', 'uid', 'desc'), 'get'); $threadDisplay = new PwThreadDisplay($tid, $this->loginUser); $this->runHook('c_read_run', $threadDisplay); if (($result = $threadDisplay->check()) !== true) { $this->showError($result->getError()); } $_cache = Wekit::cache()->fetch(array('level', 'group_right')); $pwforum = $threadDisplay->getForum(); if ($pwforum->foruminfo['password']) { if (!$this->loginUser->isExists()) { $this->forwardAction('u/login/run', array('backurl' => WindUrlHelper::createUrl('bbs/cate/run', array('fid' => ${$pwforum}->fid)))); } elseif (Pw::getPwdCode($pwforum->foruminfo['password']) != Pw::getCookie('fp_' . $pwforum->fid)) { $this->forwardAction('bbs/forum/password', array('fid' => $pwforum->fid)); } } if ($uid) { Wind::import('SRV:forum.srv.threadDisplay.PwUserRead'); $dataSource = new PwUserRead($threadDisplay->thread, $uid); } else { Wind::import('SRV:forum.srv.threadDisplay.PwCommonRead'); $dataSource = new PwCommonRead($threadDisplay->thread); } $dataSource->setPage($page)->setPerpage($pwforum->forumset['readperpage'] ? $pwforum->forumset['readperpage'] : Wekit::C('bbs', 'read.perpage'))->setDesc($desc); $threadDisplay->setImgLazy(Wekit::C('bbs', 'read.image_lazy')); $threadDisplay->execute($dataSource); $operateReply = $operateThread = array(); $isBM = $pwforum->isBM($this->loginUser->username); if ($threadPermission = $this->loginUser->getPermission('operate_thread', $isBM, array())) { $operateReply = Pw::subArray($threadPermission, array('toppedreply', 'remind', 'shield', 'delete', 'ban', 'inspect', 'read')); $operateThread = Pw::subArray($threadPermission, array('digest', 'topped', 'up', 'highlight', 'copy', 'type', 'move', 'lock', 'down', 'delete', 'ban')); } $threadInfo = $threadDisplay->getThreadInfo(); $this->setOutput($threadDisplay, 'threadDisplay'); $this->setOutput($tid, 'tid'); $this->setOutput($threadDisplay->fid, 'fid'); $this->setOutput($threadInfo, 'threadInfo'); $this->setOutput($threadDisplay->getList(), 'readdb'); $this->setOutput($threadDisplay->getUsers(), 'users'); $this->setOutput($pwforum, 'pwforum'); $this->setOutput(PwCreditBo::getInstance(), 'creditBo'); $this->setOutput($threadDisplay->getHeadguide(), 'headguide'); $this->setOutput(Wekit::C('bbs', 'read.display_member_info'), 'displayMemberInfo'); $this->setOutput(Wekit::C('bbs', 'read.display_info'), 'displayInfo'); $this->setOutput(Wekit::C('bbs', 'thread.hotthread_replies'), 'hotIcon'); $this->setOutput($threadPermission, 'threadPermission'); $this->setOutput($operateThread, 'operateThread'); $this->setOutput($operateReply, 'operateReply'); $this->setOutput(!$this->loginUser->uid && !$this->allowPost($pwforum) ? ' J_qlogin_trigger' : '', 'postNeedLogin'); $this->setOutput(!$this->loginUser->uid && !$this->allowReply($pwforum) ? ' J_qlogin_trigger' : '', 'replyNeedLogin'); $this->setOutput($_cache['level']['ltitle'], 'ltitle'); $this->setOutput($_cache['level']['lpic'], 'lpic'); $this->setOutput($_cache['level']['lneed'], 'lneed'); $this->setOutput($_cache['group_right'], 'groupRight'); $this->setOutput($threadDisplay->page, 'page'); $this->setOutput($threadDisplay->perpage, 'perpage'); $this->setOutput($threadDisplay->total, 'count'); $this->setOutput($threadDisplay->maxpage, 'totalpage'); $this->setOutput($threadDisplay->getUrlArgs(), 'urlargs'); $this->setOutput($threadDisplay->getUrlArgs('desc'), 'urlDescArgs'); $this->setOutput($this->loginUser->getPermission('look_thread_log', $isBM, array()), 'canLook'); $this->setOutput($this->_getFpage($threadDisplay->fid), 'fpage'); //版块风格 if ($pwforum->foruminfo['style']) { $this->setTheme('forum', $pwforum->foruminfo['style']); //$this->addCompileDir($pwforum->foruminfo['style']); } // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $seoBo = PwSeoBo::getInstance(); $lang = Wind::getComponent('i18n'); $threadDisplay->page <= 1 && $seoBo->setDefaultSeo($lang->getMessage('SEO:bbs.read.run.title'), '', $lang->getMessage('SEO:bbs.read.run.description')); $seoBo->init('bbs', 'read'); $seoBo->set(array('{forumname}' => $threadDisplay->forum->foruminfo['name'], '{title}' => $threadDisplay->thread->info['subject'], '{description}' => Pw::substrs($threadDisplay->thread->info['content'], 100, 0, false), '{classfication}' => $threadDisplay->thread->info['topic_type'], '{tags}' => $threadInfo['tags'], '{page}' => $threadDisplay->page)); Wekit::setV('seo', $seoBo); //是否显示回复 $showReply = true; //锁定时间 if ($pwforum->forumset['locktime'] && $threadInfo['created_time'] + $pwforum->forumset['locktime'] * 86400 < Pw::getTime()) { $showReply = false; } elseif (Pw::getstatus($threadInfo['tpcstatus'], PwThread::STATUS_LOCKED) && !$this->loginUser->getPermission('reply_locked_threads')) { $showReply = false; } $this->setOutput($showReply, 'showReply'); $this->runReadDesign($threadDisplay->fid); $this->updateReadOnline($threadDisplay->fid, $tid); }