예제 #1
0
 public function beforeAction($handlerAdapter)
 {
     parent::beforeAction($handlerAdapter);
     $action = $handlerAdapter->getAction();
     if (in_array($action, array('fastreply', 'replylist'))) {
         return;
     }
     $this->post = $this->_getPost($action);
     if (($result = $this->post->check()) !== true) {
         $error = $result->getError();
         if (is_array($error) && $error[0] == 'BBS:post.forum.allow.ttype' && ($allow = $this->post->forum->getThreadType($this->post->user))) {
             $special = key($allow);
             $this->forwardAction('bbs/post/run?fid=' . $this->post->forum->fid . ($special ? '&special=' . $special : ''));
         }
         $this->showError($error);
     }
     //版块风格
     $pwforum = $this->post->forum;
     if ($pwforum->foruminfo['password']) {
         if (!$this->loginUser->isExists()) {
             $this->forwardAction('u/login/run', array('backurl' => WindUrlHelper::createUrl('bbs/post/' . $action, 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 ($pwforum->foruminfo['style']) {
         $this->setTheme('forum', $pwforum->foruminfo['style']);
     }
     $this->setOutput($action, 'action');
 }
예제 #2
0
 protected function _getUser()
 {
     $authkey = 'winduser';
     $pre = Wekit::C('site', 'cookie.pre');
     $pre && ($authkey = $pre . '_' . $authkey);
     $winduser = $this->getInput($authkey, 'post');
     list($uid, $password) = explode("\t", Pw::decrypt(urldecode($winduser)));
     $user = new PwUserBo($uid);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         return null;
     }
     unset($user->info['password']);
     return $user;
 }
예제 #3
0
 public function isLogin($uid, $password)
 {
     $user = $this->loadUserService()->getUserByUid($uid);
     if (!$user) {
         return array();
     }
     if (Pw::getPwdCode($user['password']) != $password) {
         return array();
     }
     $auth = Wekit::load('ADMIN:service.AdminAuth');
     if (!$auth->findByUid($user['uid'])) {
         return array();
     }
     return $user;
 }
예제 #4
0
 public function isLogin($username, $password)
 {
     if (!$this->isFounder($username)) {
         return array();
     }
     $founder = $this->getFounders();
     list($md5pwd) = explode('|', $founder[$username], 2);
     if (Pw::getPwdCode($md5pwd) != $password) {
         return array();
     }
     if (!($user = $this->loadUserService()->getUserByName($username))) {
         $user = array('uid' => 0, 'username' => $username, 'groupid' => 3);
     }
     return $user;
 }
예제 #5
0
 /**
  * 本地安装 - 上传
  */
 public function uploadAction()
 {
     $authkey = 'AdminUser';
     $pre = Wekit::C('site', 'cookie.pre');
     $pre && ($authkey = $pre . '_' . $authkey);
     $winduser = $this->getInput($authkey, 'post');
     if (!$winduser) {
         $this->showError('login.not');
     }
     list($type, $u, $pwd) = explode("\t", Pw::decrypt(urldecode($winduser)));
     if ($type == 'founder') {
         $founders = Wekit::load('ADMIN:service.srv.AdminFounderService')->getFounders();
         if (!isset($founders[$u])) {
             $this->showError('login.not');
         }
         list($md5pwd, $salt) = explode('|', $founders[$u], 2);
         if (Pw::getPwdCode($md5pwd) != $pwd) {
             $this->showError('login.not');
         }
     } else {
         $r = Wekit::load('user.PwUser')->getUserByUid($u);
         if (!$r) {
             $this->showError('login.not');
         }
         if (Pw::getPwdCode($r['password']) != $pwd) {
             $this->showError('login.not');
         }
     }
     Wind::import('SRC:applications.appcenter.service.srv.helper.PwApplicationUpload');
     $upload = new PwApplicationUpload();
     $upload->dir = Wind::getRealDir($this->_installService()->getConfig('tmp_dir'), true) . '/';
     $uploaddb = $upload->execute();
     if ($uploaddb instanceof PwError) {
         $this->showError($uploaddb->getError());
     }
     if (empty($uploaddb)) {
         $this->showError('upload.fail');
     }
     $this->setOutput(array('filename' => $uploaddb[0]['name'], 'file' => $uploaddb[0]['fileuploadurl']), 'data');
     $this->showMessage('success');
 }
예제 #6
0
 /**
  * 获得大概年前登录用户对象
  *
  * @return PwUserBo
  */
 protected function _getLoginUser()
 {
     if (!($userCookie = Pw::getCookie('winduser'))) {
         $uid = $password = '';
     } else {
         list($uid, $password) = explode("\t", Pw::decrypt($userCookie));
     }
     $user = new PwUserBo($uid);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         $user->reset();
     } else {
         unset($user->info['password']);
     }
     return $user;
 }
예제 #7
0
 /**
  * 后台用户登录服务
  *
  * 后台用户登录服务,并返回用户对象.参数信息:<code>
  * $loginInfo: AdminUser
  * </code>
  *
  * @param string $username 用户名
  * @param string $password 密码
  * @return boolean
  */
 public function login($username, $password)
 {
     $conf = $this->loadFounderService()->getFounders();
     if (isset($conf[$username])) {
         $r = $this->loadFounderService()->checkPwd($conf[$username], $password);
         if (!$r) {
             return new PwError('ADMIN:login.fail.user.illegal');
         }
         $cookie = Pw::encrypt(self::FOUNDER . "\t" . $username . "\t" . Pw::getPwdCode($r));
     } else {
         if (!$this->loadSafeService()->ipLegal(Wekit::app()->clientIp)) {
             return new PwError('ADMIN:login.fail.ip');
         }
         $user = $this->loadUserService()->verifyUser($username, $password);
         if ($user instanceof PwError) {
             return new PwError('ADMIN:login.fail.user.illegal');
         }
         /* @var $auth AdminAuth */
         $auth = Wekit::load('ADMIN:service.AdminAuth');
         if (!$auth->findByUid($user['uid'])) {
             return new PwError('ADMIN:login.fail.allow');
         }
         $u = $this->loadUserService()->getUserByUid($user['uid']);
         $cookie = Pw::encrypt(self::USER . "\t" . $user['uid'] . "\t" . Pw::getPwdCode($u['password']));
     }
     Pw::setCookie($this->cookieName, $cookie, 1800);
     return true;
 }
예제 #8
0
 /**
  * 验证版块密码
  */
 public function verifyAction()
 {
     $fid = $this->getInput('fid');
     $password = $this->getInput('password', 'post');
     Wind::import('SRV:forum.bo.PwForumBo');
     $forum = new PwForumBo($fid);
     if (!$forum->isForum(true)) {
         $this->showError('BBS:forum.exists.not');
     }
     if (md5($password) != $forum->foruminfo['password']) {
         $this->showError('BBS:forum.password.error');
     }
     Pw::setCookie('fp_' . $fid, Pw::getPwdCode(md5($password)), 86400);
     $this->showMessage('success');
 }
예제 #9
0
 /** 
  * 创建登录用户标识
  *
  * @param int $uid 用户ID
  * @param string $password 用户密码
  * @return boolean
  */
 public function createIdentity($uid, $password)
 {
     $identity = Pw::encrypt($uid . "\t" . Pw::getPwdCode($password));
     return Pw::setCookie('winduser', $identity, 31536000);
 }
예제 #10
0
 /**
  * 帖子阅读页
  */
 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);
 }
예제 #11
0
 /** 
  * 构造用户标志
  *
  * @param int $uid  用户ID
  * @param string $pwd 用户密码
  * @return string
  */
 public static function createRegistIdentify($uid, $pwd)
 {
     $code = Pw::encrypt($uid . "\t" . Pw::getPwdCode($pwd));
     return rawurlencode($code);
 }
예제 #12
0
 protected function _getLoginUser()
 {
     $userCookie = Pw::getCookie('AdminUser');
     /* @var $adminUserService AdminUserService */
     $adminUserService = Wekit::load('ADMIN:service.srv.AdminUserService');
     if ($userCookie) {
         list($type, $uid, $password) = explode("\t", Pw::decrypt($userCookie));
         /* @var $founderService AdminFounderService */
         $founderService = Wekit::load('ADMIN:service.srv.AdminFounderService');
         if ($founderService->isFounder($uid)) {
             $founders = $founderService->getFounders();
             list($md5pwd) = explode('|', $founders[$uid], 2);
             $userinfo = $adminUserService->verifyUserByUsername($uid);
             $userinfo['password'] = $md5pwd;
         } else {
             $userinfo = $adminUserService->loadUserService()->getUserByUid($uid);
         }
     } else {
         $password = '';
         $userinfo = array();
     }
     Wind::import('ADMIN:service.bo.AdminDefaultUserBo');
     $user = new AdminDefaultUserBo($userinfo);
     if (!$user->isExists() || Pw::getPwdCode($userinfo['password']) != $password) {
         $user->reset();
     }
     return $user;
 }
예제 #13
0
 /**
  * 创建登录标识
  *
  * @param array $userInfo 用户信息
  * @return string
  */
 public static function createLoginIdentify($userInfo)
 {
     $code = Pw::encrypt($userInfo['uid'] . "\t" . Pw::getPwdCode($userInfo['password']) . "\t" . Pw::getTime());
     return rawurlencode($code);
 }
예제 #14
0
 /**
  * 分享到其它平台使用的链接 
  * 
  * @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');
 }
예제 #15
0
 /** 
  * 创建登录用户标识
  *
  * @param int $uid 用户ID
  * @param string $password 用户密码
  * @param int $rememberme 是否采用记住当前用户,记住则保存1年
  * @return boolean
  */
 public function createIdentity($uid, $password, $rememberme = 0)
 {
     $identity = Pw::encrypt($uid . "\t" . Pw::getPwdCode($password));
     return Pw::setCookie('winduser', $identity, $rememberme ? 31536000 : NULL);
 }
예제 #16
0
 /**
  * 验证用户标识
  *
  * @return string
  */
 private function checkRegisterUser()
 {
     $identify = $this->getInput('_statu', 'get');
     !$identify && ($identify = $this->getInput('_statu', 'post'));
     if (!$identify) {
         $this->showError('USER:illegal.request');
     }
     list($uid, $password) = PwRegisterService::parserRegistIdentify($identify);
     $info = $this->_getUserDs()->getUserByUid($uid, PwUser::FETCH_MAIN);
     if (Pw::getPwdCode($info['password']) != $password) {
         $this->showError('USER:illegal.request');
     }
     $this->loginUser = new PwUserBo($uid);
     return $identify;
 }
예제 #17
0
 /**
  * 检查用户信息合法性
  *
  * @return string
  */
 private function checkUserInfo()
 {
     $identify = $this->getInput('_statu', 'get');
     !$identify && ($identify = $this->getInput('_statu', 'post'));
     if (!$identify) {
         $this->showError('USER:illegal.request');
     }
     list($identify, $url, $rememberme) = explode('|', base64_decode($identify) . '|');
     list($uid, $password) = PwLoginService::parseLoginIdentify(rawurldecode($identify));
     // 		$info = $this->_getUserDs()->getUserByUid($uid, PwUser::FETCH_MAIN);
     $this->loginUser = new PwUserBo($uid);
     if (!$this->loginUser->isExists() || Pw::getPwdCode($this->loginUser->info['password']) != $password) {
         $this->showError('USER:illegal.request');
     }
     return base64_encode($identify . '|' . $url . '|' . $rememberme);
 }
예제 #18
0
 /**
  * 帖子列表页
  */
 public function run()
 {
     $tab = $this->getInput('tab');
     $fid = intval($this->getInput('fid'));
     $type = intval($this->getInput('type', 'get'));
     //主题分类ID
     $page = $this->getInput('page', 'get');
     $orderby = $this->getInput('orderby', 'get');
     $pwforum = new PwForumBo($fid, true);
     if (!$pwforum->isForum()) {
         $this->showError('BBS:forum.exists.not');
     }
     if ($pwforum->allowVisit($this->loginUser) !== true) {
         $this->showError(array('BBS:forum.permissions.visit.allow', array('{grouptitle}' => $this->loginUser->getGroupInfo('name'))));
     }
     if ($pwforum->forumset['jumpurl']) {
         $this->forwardRedirect($pwforum->forumset['jumpurl']);
     }
     if ($pwforum->foruminfo['password']) {
         if (!$this->loginUser->isExists()) {
             $this->forwardAction('u/login/run', array('backurl' => WindUrlHelper::createUrl('bbs/cate/run', array('fid' => $fid))));
         } elseif (Pw::getPwdCode($pwforum->foruminfo['password']) != Pw::getCookie('fp_' . $fid)) {
             $this->forwardAction('bbs/forum/password', array('fid' => $fid));
         }
     }
     $isBM = $pwforum->isBM($this->loginUser->username);
     if ($operateThread = $this->loginUser->getPermission('operate_thread', $isBM, array())) {
         $operateThread = Pw::subArray($operateThread, array('topped', 'digest', 'highlight', 'up', 'copy', 'type', 'move', 'lock', 'down', 'delete', 'ban'));
     }
     $this->_initTopictypes($fid, $type);
     $threadList = new PwThreadList();
     $this->runHook('c_thread_run', $threadList);
     $threadList->setPage($page)->setPerpage($pwforum->forumset['threadperpage'] ? $pwforum->forumset['threadperpage'] : Wekit::C('bbs', 'thread.perpage'))->setIconNew($pwforum->foruminfo['newtime']);
     $defaultOrderby = $pwforum->forumset['threadorderby'] ? 'postdate' : 'lastpost';
     !$orderby && ($orderby = $defaultOrderby);
     if ($tab == 'digest') {
         Wind::import('SRV:forum.srv.threadList.PwDigestThread');
         $dataSource = new PwDigestThread($pwforum->fid, $type, $orderby);
     } elseif ($type) {
         Wind::import('SRV:forum.srv.threadList.PwSearchThread');
         $dataSource = new PwSearchThread($pwforum);
         $dataSource->setOrderby($orderby);
         $dataSource->setType($type, $this->_getSubTopictype($type));
     } elseif ($orderby == 'postdate') {
         Wind::import('SRV:forum.srv.threadList.PwNewForumThread');
         $dataSource = new PwNewForumThread($pwforum);
     } else {
         Wind::import('SRV:forum.srv.threadList.PwCommonThread');
         $dataSource = new PwCommonThread($pwforum);
     }
     $orderby != $defaultOrderby && $dataSource->setUrlArg('orderby', $orderby);
     $threadList->execute($dataSource);
     $this->setOutput($threadList, 'threadList');
     $this->setOutput($threadList->getList(), 'threaddb');
     $this->setOutput($fid, 'fid');
     $this->setOutput($type ? $type : null, 'type');
     $this->setOutput($tab, 'tab');
     $this->setOutput($pwforum, 'pwforum');
     $this->setOutput($pwforum->headguide(), 'headguide');
     $this->setOutput($threadList->icon, 'icon');
     $this->setOutput($threadList->uploadIcon, 'uploadIcon');
     $this->setOutput($operateThread, 'operateThread');
     $this->setOutput($pwforum->forumset['numofthreadtitle'] ? $pwforum->forumset['numofthreadtitle'] : 26, 'numofthreadtitle');
     $this->setOutput(!$this->loginUser->uid && !$this->allowPost($pwforum) ? ' J_qlogin_trigger' : '', 'postNeedLogin');
     $this->setOutput($threadList->page, 'page');
     $this->setOutput($threadList->perpage, 'perpage');
     $this->setOutput($threadList->total, 'count');
     $this->setOutput($threadList->maxPage, 'totalpage');
     $this->setOutput($defaultOrderby, 'defaultOrderby');
     $this->setOutput($orderby, 'orderby');
     $this->setOutput($threadList->getUrlArgs(), 'urlargs');
     $this->setOutput($this->_formatTopictype($type), 'topictypes');
     //版块风格
     if ($pwforum->foruminfo['style']) {
         $this->setTheme('forum', $pwforum->foruminfo['style']);
         //$this->addCompileDir($pwforum->foruminfo['style']);
     }
     //seo设置
     Wind::import('SRV:seo.bo.PwSeoBo');
     $lang = Wind::getComponent('i18n');
     if ($threadList->page <= 1) {
         if ($type) {
             PwSeoBo::setDefaultSeo($lang->getMessage('SEO:bbs.thread.run.type.title'), '', $lang->getMessage('SEO:bbs.thread.run.type.description'));
         } else {
             PwSeoBo::setDefaultSeo($lang->getMessage('SEO:bbs.thread.run.title'), '', $lang->getMessage('SEO:bbs.thread.run.description'));
         }
     }
     PwSeoBo::init('bbs', 'thread', $fid);
     PwSeoBo::set(array('{forumname}' => $pwforum->foruminfo['name'], '{forumdescription}' => Pw::substrs($pwforum->foruminfo['descrip'], 100, 0, false), '{classification}' => $this->_getSubTopictypeName($type), '{page}' => $threadList->page));
     Pw::setCookie('visit_referer', 'fid_' . $fid . '_page_' . $threadList->page, 300);
 }
예제 #19
0
 public function run()
 {
     $fid = intval($this->getInput('fid'));
     $pwforum = new PwForumBo($fid, true);
     if (!$pwforum->isForum(true)) {
         $this->showError('BBS:forum.exists.not');
     }
     if ($pwforum->allowVisit($this->loginUser) !== true) {
         $this->showError(array('BBS:forum.permissions.visit.allow', array('{grouptitle}' => $this->loginUser->getGroupInfo('name'))));
     }
     if ($pwforum->forumset['jumpurl']) {
         $this->forwardRedirect($pwforum->forumset['jumpurl']);
     }
     if ($pwforum->foruminfo['password']) {
         if (!$this->loginUser->isExists()) {
             $this->forwardAction('u/login/run', array('backurl' => WindUrlHelper::createUrl('bbs/cate/run', array('fid' => $fid))));
         } elseif (Pw::getPwdCode($pwforum->foruminfo['password']) != Pw::getCookie('fp_' . $fid)) {
             $this->forwardAction('bbs/forum/password', array('fid' => $fid));
         }
     }
     $isBM = $pwforum->isBM($this->loginUser->username);
     if ($operateThread = $this->loginUser->getPermission('operate_thread', $isBM, array())) {
         $operateThread = Pw::subArray($operateThread, array('delete'));
     }
     $pwforum->foruminfo['threads'] = $pwforum->foruminfo['subthreads'];
     $this->setOutput($operateThread, 'operateThread');
     $tab = $this->getInput('tab');
     //tab标签
     $page = intval($this->getInput('page', 'get'));
     $orderby = $this->getInput('orderby', 'get');
     $threadList = new PwThreadList();
     $this->runHook('c_cate_run', $threadList);
     $threadList->setPage($page)->setPerpage($pwforum->forumset['threadperpage'] ? $pwforum->forumset['threadperpage'] : Wekit::C('bbs', 'thread.perpage'))->setIconNew($pwforum->foruminfo['newtime']);
     $defaultOrderby = $pwforum->forumset['threadorderby'] ? 'postdate' : 'lastpost';
     !$orderby && ($orderby = $defaultOrderby);
     $isCommon = 0;
     if ($tab == 'digest') {
         Wind::import('SRV:forum.srv.threadList.PwCateDigestThread');
         $dataSource = new PwCateDigestThread($pwforum->fid, $orderby);
     } else {
         Wind::import('SRV:forum.srv.threadList.PwCateThread');
         $srv = Wekit::load('forum.srv.PwForumService');
         $forbidFids = $srv->getForbidVisitForum($this->loginUser, $srv->getForumsByLevel($fid, $srv->getForumMap()), true);
         $dataSource = new PwCateThread($pwforum, $forbidFids);
         $dataSource->setOrderby($orderby);
         $isCommon = 1;
     }
     $orderby != $defaultOrderby && $dataSource->setUrlArg('orderby', $orderby);
     $threadList->execute($dataSource);
     if ($isCommon && $threadList->total > 12000) {
         Wekit::load('forum.PwThreadCateIndex')->deleteOver($fid, $threadList->total - 10000);
     }
     $this->setOutput($threadList, 'threadList');
     $this->setOutput($threadList->getList(), 'threaddb');
     $this->setOutput($tab, 'tab');
     $this->setOutput($defaultOrderby, 'defaultOrderby');
     $this->setOutput($orderby, 'orderby');
     $this->setOutput($pwforum->fid, 'fid');
     $this->setOutput($pwforum, 'pwforum');
     $this->setOutput($pwforum->headguide(), 'headguide');
     $this->setOutput($threadList->icon, 'icon');
     $this->setOutput($threadList->uploadIcon, 'uploadIcon');
     $this->setOutput($pwforum->forumset['numofthreadtitle'] ? $pwforum->forumset['numofthreadtitle'] : 26, 'numofthreadtitle');
     $this->setOutput($threadList->page, 'page');
     $this->setOutput($threadList->perpage, 'perpage');
     $this->setOutput($threadList->total, 'count');
     $this->setOutput($threadList->maxPage, 'totalpage');
     $this->setOutput($threadList->getUrlArgs(), 'urlargs');
     //版块风格
     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');
     if ($threadList->page <= 1) {
         $seoBo->setDefaultSeo($lang->getMessage('SEO:bbs.thread.run.title'), '', $lang->getMessage('SEO:bbs.thread.run.description'));
     }
     $seoBo->init('bbs', 'thread', $fid);
     $seoBo->set(array('{forumname}' => $pwforum->foruminfo['name'], '{forumdescription}' => Pw::substrs($pwforum->foruminfo['descrip'], 100, 0, false), '{classification}' => '', '{page}' => $threadList->page));
     Wekit::setV('seo', $seoBo);
 }
 public function checkCookie($cookie)
 {
     if (empty($cookie)) {
         $uid = $password = '';
     } else {
         list($uid, $password) = explode("\t", Pw::decrypt($cookie));
     }
     Wind::import('SRV:user.bo.PwUserBo');
     $user = new PwUserBo($uid);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         return $this->buildResponse(-1, 'cookie非法');
     } else {
         return $this->buildResponse(0, array('uid' => $uid, 'username' => $user->username));
     }
 }
예제 #21
0
 protected function _getLoginUser()
 {
     if (!($userCookie = Pw::getCookie('AdminUser'))) {
         $password = '';
         $us = new AdminUserSourceDb(0);
     } else {
         list($type, $uid, $password) = explode("\t", Pw::decrypt($userCookie));
         if ($type == AdminUserService::FOUNDER) {
             $us = new AdminUserSourceFounder($uid);
         } else {
             $us = new AdminUserSourceDb($uid);
         }
     }
     Pw::setCookie('AdminUser', $userCookie, 1800);
     $user = new AdminUserBo($us);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         $user->reset();
     } else {
         unset($user->info['password']);
     }
     return $user;
 }
예제 #22
0
 private function _checkForumRight(PwForumBo $pwforum)
 {
     if (!$pwforum->isForum()) {
         $this->showError('BBS:forum.exists.not');
     }
     if ($pwforum->allowVisit($this->loginUser) !== true) {
         $this->showError(array('BBS:forum.permissions.visit.allow', array('{grouptitle}' => $this->loginUser->getGroupInfo('name'))));
     }
     if ($pwforum->forumset['jumpurl']) {
         $this->forwardRedirect($pwforum->forumset['jumpurl']);
     }
     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));
         }
     }
 }