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'); }
/** * 获取回调响应 */ public function getResponseInfo() { $result = $this->checkStatus(); if ($result !== true) { return new PwError($result); } $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName()); $sessionInfo = App_Account_LoginSessionBo::getInstance($sessionId)->getSession(); if (!$sessionId || !$sessionInfo) { return new PwError('验证会话失败,请重试'); } if ($_REQUEST['state'] == $sessionInfo['sessiondata']['state']) { //step 2 通过Authorization Code获取Access Token $token = $this->_getAccessToken(); if ($token === false) { return new PwError('验证会话失败,请重试'); } list($accessToken, $uid) = $token; //step 2 获取用户信息 $userInfo = $this->_getUserInfo($uid, $accessToken); if (!$userInfo) { return new PwError('获取用户信息失败,请重试'); } //更新数据库 $this->_updateDb($uid, $userInfo); //更新session $this->updateSession($uid, $userInfo['screen_name'], 'sinaweibo'); return true; } }
public function reset() { $this->uid = 0; $this->gid = 2; $this->username = '******'; $this->info = array('lastpost' => Pw::getCookie('guest_lastpost')); }
/** * 获取淘宝响应信息 如果oauth2正常流程,可以走curl_init */ public function getResponseInfo() { $result = $this->checkStatus(); if ($result !== true) { return new PwError($result); } $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName()); $sessionInfo = App_Account_LoginSessionBo::getInstance($sessionId)->getSession(); if (!$sessionId || !$sessionInfo) { return new PwError('验证会话失败,请重试'); } list($top_parameters, $top_sign) = array(trim($_REQUEST['top_parameters']), trim($_REQUEST['top_sign'])); if ($this->_checkSign() === false) { return new PwError('与淘宝通信失败,请重试'); } $userInfo = $this->_getUserInfo(); if ($userInfo === false) { return new PwError('获取用户信息失败,请重试'); } list($user_id, $nick) = $userInfo; //更新数据库 $info = $this->_getTaobaoUserInfoDs()->get($user_id); if (!$info) { $dm = new App_Account_TaobaoUserInfoDm(); $dm->setUserId($user_id)->setNick($nick)->setCreateAt(Pw::getTime()); $this->_getTaobaoUserInfoDs()->add($dm); } //更新session $this->updateSession($user_id, $nick, 'taobao'); return true; }
public function getResponseInfo() { $result = $this->checkStatus(); if ($result !== true) { return new PwError($result); } $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName()); $sessionInfo = App_Account_LoginSessionBo::getInstance($sessionId)->getSession(); if (!$sessionId || !$sessionInfo) { return new PwError('验证会话失败,请重试'); } //计算得出通知验证结果 if (!$this->_verifyReturn()) { return new PwError('验证会话失败,请重试'); } //支付宝用户号 $user_id = intval($_GET['user_id']); //授权令牌 $token = trim($_GET['token']); $real_name = trim($_GET['real_name']); if (!$user_id) { return new PwError('获取用户信息失败,请重试'); } //更新数据库 $dm = new App_Account_AlipayUserInfoDm(); $dm->setUserId($user_id)->setRealName($real_name)->setCreateAt(Pw::getTime()); $this->_getAlipayUserInfoDs()->replace($dm); //更新session $this->updateSession($user_id, $real_name, 'alipay'); return true; }
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; }
/** * 获取QQ回调响应 */ public function getResponseInfo() { $result = $this->checkStatus(); if ($result !== true) { return new PwError($result); } $params = array_merge($_GET, $_POST); $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName()); $sessionInfo = App_Account_LoginSessionBo::getInstance($sessionId)->getSession(); if (!$sessionId || !$sessionInfo) { return new PwError('验证会话失败,请重试'); } if ($params['state'] == $sessionInfo['sessiondata']['state']) { //step 2 通过Authorization Code获取Access Token $accessToken = $this->_getAccessToken(); if ($accessToken === false) { return new PwError('验证会话失败,请重试'); } /* * step3:使用Access Token来获取用户的OpenID * openid 用户唯一标识 */ $openId = $this->_getOpenIdByAccessToken($accessToken); if ($openId === false) { return new PwError('验证会话失败,请重试'); } //step4: 使用openid获取用户信息 $userInfo = $this->_getUserInfo($openId, $accessToken); if ($userInfo === false || !$userInfo) { return new PwError('获取用户信息失败,请重试'); } //更新数据库 $userId = $this->_updateDb($openId, $userInfo); if ($userId === false || $userId < 1) { return new PwError('更新数据库失败'); } //更新session $this->updateSession($userId, $userInfo['nickname'], 'qzone'); return true; } }
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; }
/** * 结果分析路由 */ public function routeAction() { $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName()); $sessionInfo = App_Account_LoginSessionBo::getInstance($sessionId)->getSession(); $sessionData = $sessionInfo['sessiondata']; $refer = $sessionData['httpReferer'] ? $sessionData['httpReferer'] : $this->hostInfo; if (!$this->_getAccountTypeService()->checkType($sessionData['type'])) { $this->showError('登录类型错误,请重试'); } if (!$sessionId || !$sessionInfo || !$sessionData['data']['user_id'] || !$sessionData['action']) { $this->showError('验证失败,请重试'); } $url = $refer ? $refer : $this->hostInfo . Wind::getComponent('request')->getScriptUrl(); $type_name = $this->_getAccountTypeService()->getTypeName($sessionData['type']); $msg_info = '使用' . $type_name . '账号认证通过(窗口将自动关闭)'; if ($sessionData['action'] == 'bind') { //绑定流程 $result = $this->_getAccountBindService()->bind($this->uid, $sessionData['data']['user_id'], $sessionData['type']); if ($result instanceof PwError) { $this->showError($result->getError()); } } elseif ($sessionData['data']['isBound'] == 0 && $sessionData['action'] == 'login') { $sign = $sessionData['data']['sign']; //没有绑定社区账号 注册或者绑定 $config = Wekit::C()->getValues('register'); if ($config['type'] == 0) { //关闭注册,跳转到绑定设置页面 $url = WindUrlHelper::createUrl('app/login/run', array('app' => 'account', 'sign' => $sign)); } else { $url = WindUrlHelper::createUrl('app/register/run', array('app' => 'account', 'sign' => $sign)); } } elseif ($sessionData['data']['isBound'] == 1 && $sessionData['action'] == 'login') { //进入登录 用户校验 $uid = intval($sessionData['data']['bbs_uid']); Wind::import('SRV:user.bo.PwUserBo'); $userBo = PwUserBo::getInstance($uid); if (!$userBo->isExists()) { //用户不存在 $this->_getAccountBindDs()->deleteByUid($uid); $this->showError('绑定用户在站点已删除,请重试'); } $pattern = '/m=u&c=login/i'; if (preg_match($pattern, $url)) { $url = $this->_getCommonService()->getHost(); } $userService = Wekit::load('user.srv.PwUserService'); $userService->createIdentity($userBo->uid, $userBo->info['password']); } $this->setOutput($msg_info, 'msg_info'); $this->setOutput($url, 'jumpurl'); $this->setOutput(Wekit::app()->charset, 'charset'); $this->setTemplate('login_notice'); }
/** * 风格设置 * * 设置当前页面风格,需要两个参数,$type风格类型,$theme该类型下风格 * * @see WindSimpleController::setTheme() * @param string $type 风格类型(site,space,area...) * @param string $theme 风格别名 */ protected function setTheme($type, $theme) { $config = Wekit::C('site'); $themePack = $config['theme.' . $type . '.pack']; $themePack = 'THEMES:' . $themePack; // 风格预览,管理员权限 if ($style = Pw::getCookie('style_preview')) { list($s_theme, $s_type) = explode('|', $style, 2); if ($s_type == $type) { $theme = $s_theme; Wekit::C()->site->set('theme.' . $type . '.default', $theme); } } if (!$theme) { $theme = $config['theme.' . $type . '.default']; } parent::setTheme($theme, $themePack); }
protected function _getUser() { $authkey = 'winduser'; $pre = Wekit::C('site', 'cookie.pre'); $pre && ($authkey = $pre . '_' . $authkey); $winduser = $this->getInput($authkey, 'post'); if (!$winduser) { $winduser = Pw::getCookie('winduser'); $winduser = urlencode($winduser); } 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; }
private function _readVerifyCode() { return Pw::getCookie('Pw_verify_code'); /*Wind::import('WIND:http.session.WindSession'); $session = new WindSession(); return $session->get('verifycode');*/ }
/** * 获取本地的访问标记 * * @param $isRefresh bool 是否强制刷新 * @return bool|array */ public function getVisitor($isRefresh = false) { $sign = Pw::getCookie('visitor'); if (empty($sign)) { return true; } $sign = Pw::decrypt($sign); $signs = explode('_', $sign); if ($isRefresh) { return $signs; } list($ip, $createdTime, $modifyTime) = $signs; $modifyTime = (int) $modifyTime; $createdTime = (int) $createdTime; if ($createdTime < 1 || $modifyTime < 1) { return true; } $onlineTime = $this->time - $modifyTime; if ($createdTime == $modifyTime && $onlineTime >= $this->isVisitorTime) { return $signs; } if ($onlineTime >= $this->spaceTime) { return $signs; } return false; }
/** * 钩子---用户退出触发 */ public function logout($loginUser) { return true; $uid = intval($loginUser->uid); if ($uid < 1) { return false; } $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName()); if (!$sessionId) { return false; } $sessionInfo = App_Account_LoginSessionBo::getInstance($sessionId)->getSession(); $sessionData = $sessionInfo['sessiondata']; $type = $sessionData['type']; if (!$sessionData || !$this->_getAccountTypeService()->checkType($type)) { return false; } if (!$this->_getAccountBindDs()->getByUidAndType($uid, $type)) { return false; } $host = $this->getHost(); return $this->_getAccountService($type)->logout($host); }
/** * 初始话当前用户 */ protected function _initUser() { $_cOnlinetime = Wekit::C('site', 'onlinetime') * 60; if (!($lastvisit = Pw::getCookie('lastvisit'))) { $this->onlinetime = 0; $this->lastvisit = WEKIT_TIMESTAMP; $this->lastRequestUri = ''; } else { list($this->onlinetime, $this->lastvisit, $this->lastRequestUri) = explode("\t", $lastvisit); ($onlinetime = WEKIT_TIMESTAMP - $this->lastvisit) < $_cOnlinetime && ($this->onlinetime += $onlinetime); } $user = $this->getLoginUser(); if ($user->isExists() && WEKIT_TIMESTAMP - $user->info['lastvisit'] > min(1800, $_cOnlinetime)) { Wind::import('SRV:user.dm.PwUserInfoDm'); $dm = new PwUserInfoDm($user->uid); $dm->setLastvisit(WEKIT_TIMESTAMP)->setLastActiveTime(WEKIT_TIMESTAMP); if ($this->onlinetime > 0) { $dm->addOnline($this->onlinetime > $_cOnlinetime * 1.2 ? $_cOnlinetime : $this->onlinetime); } Wekit::load('user.PwUser')->editUser($dm, PwUser::FETCH_DATA); $this->onlinetime = 0; } Pw::setCookie('lastvisit', $this->onlinetime . "\t" . WEKIT_TIMESTAMP . "\t" . $this->requestUri, 31536000); }
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); }
/** * 更新session */ protected function updateSession($user_id, $nick, $type) { $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName()); $bindInfo = $this->_getAccountBindDs()->getByAppUidAndType($user_id, $type); $isBound = $bindInfo ? 1 : 0; $bbsUid = intval($bindInfo['uid']) ? intval($bindInfo['uid']) : 0; if ($type != 'alipay') { $nick = Pw::convert(trim($nick), Wind::getApp()->getResponse()->getCharset(), 'UTF-8'); } $data = array('data' => array('nick' => $nick, 'user_id' => $user_id, 'isBound' => $isBound, 'bbs_uid' => $bbsUid, 'sign' => $this->getSignSting())); $this->_getLoginSessionService()->updateLoginSession($sessionId, $data); }
private function _saveVerifyCode() { Wind::import('LIB:utility.verifycode.PwBaseCode'); $code = WindConvert::convert(PwBaseCode::getCode(), Wekit::V('charset'), 'UTF-8'); $code = Pw::encrypt(strtolower($code), $this->_config['key']); // $verify_session_id = Pw::getCookie('Pw_verify_code'); if (!$verify_session_id) { $verify_session_id = md5($code); Pw::setCookie('Pw_verify_code', md5($code), 3600); } //session 保存验证码 Wind::import('WIND:http.session.WindSession'); $session = new WindSession(); $session->set('verifycode', $code); }
/** * 初始话当前用户 */ protected function _initUser() { $requestUri = Wind::getComponent('request')->getRequestUri(); $_cOnlinetime = Wekit::C('site', 'onlinetime') * 60; if (!($lastvisit = Pw::getCookie('lastvisit'))) { $onlinetime = 0; $lastvisit = WEKIT_TIMESTAMP; $lastRequestUri = ''; } else { list($onlinetime, $lastvisit, $lastRequestUri) = explode("\t", $lastvisit); ($thistime = WEKIT_TIMESTAMP - $lastvisit) < $_cOnlinetime && ($onlinetime += $thistime); } $user = $this->getLoginUser(); if ($user->isExists()) { $today = Pw::str2time(Pw::time2str(Pw::getTime(), 'Y-m-d')); if ($user->info['lastvisit'] && $today > $user->info['lastvisit']) { /* @var $loginSrv PwLoginService */ $loginSrv = Wekit::load('SRV:user.srv.PwLoginService'); $loginSrv->welcome($user, Wind::getComponent('request')->getClientIp()); } elseif (WEKIT_TIMESTAMP - $user->info['lastvisit'] > min(1800, $_cOnlinetime)) { Wind::import('SRV:user.dm.PwUserInfoDm'); $dm = new PwUserInfoDm($user->uid); $dm->setLastvisit(WEKIT_TIMESTAMP)->setLastActiveTime(WEKIT_TIMESTAMP); if ($onlinetime > 0) { $dm->addOnline($onlinetime > $_cOnlinetime * 1.2 ? $_cOnlinetime : $onlinetime); } Wekit::load('user.PwUser')->editUser($dm, PwUser::FETCH_DATA); $onlinetime = 0; } } Pw::setCookie('lastvisit', $onlinetime . "\t" . WEKIT_TIMESTAMP . "\t" . $requestUri, 31536000); $obj = new stdClass(); $obj->lastvisit = $lastvisit; $obj->requestUri = $requestUri; $obj->lastRequestUri = $lastRequestUri; Wekit::setV('lastvist', $obj); }
private function _getFpage($fid) { $fpage = 1; if ($referer = Pw::getCookie('visit_referer')) { $tmp = explode('_', $referer); if ($tmp[0] == 'fid' && $tmp[1] == $fid) { $fpage = intval($tmp[3]); } } return $fpage; }
/** * 执行用户注册 */ public function dorunAction() { //new add //验证 $sign = $this->getInput('sign', 'get'); $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName()); $sessionInfo = App_Account_LoginSessionBo::getInstance($sessionId)->getSession(); $sessionData = $sessionInfo['sessiondata']; $app_uid = $sessionData['data']['user_id']; $type = $sessionData['type']; if (!$sessionId || !$this->_getAccountTypeService()->checkType($type) || $sessionData['data']['sign'] != $sign || !$app_uid) { $this->showError("非法访问"); } $this->setOutput('注册', 'title'); $registerService = new PwRegisterService(); $registerService->setUserDm($this->_getUserDm()); /*[u_regsiter]:插件扩展*/ $this->runHook('c_register', $registerService); if (($info = $registerService->register()) instanceof PwError) { $this->showError($info->getError()); } else { $identity = PwRegisterService::createRegistIdentify($info['uid'], $info['password']); //绑定 new add Wekit::load('EXT:account.service.srv.App_Account_BindService')->bind($info['uid'], $app_uid, $type); if (1 == Wekit::C('register', 'active.mail')) { $this->forwardAction('u/register/sendActiveEmail', array('_statu' => $identity), true); } else { $this->forwardAction('u/register/welcome', array('_statu' => $identity), true); } } }
/** * 页面登录 */ public function dorunAction() { //new add $sign = $this->getInput('sign', 'get'); $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName()); $sessionInfo = App_Account_LoginSessionBo::getInstance($sessionId)->getSession(); $sessionData = $sessionInfo['sessiondata']; $app_uid = $sessionData['data']['user_id']; $type = $sessionData['type']; if (!$sessionId || !$this->_getAccountTypeService()->checkType($type) || $sessionData['data']['sign'] != $sign || !$app_uid) { $this->showError("非法访问"); } $refer = $sessionData['httpReferer']; $backUrl = $refer ? $refer : $this->getRequest()->getHostInfo(); $userForm = $this->_getLoginForm(); /* [验证验证码是否正确] */ if ($this->_showVerify()) { $veryfy = $this->_getVerifyService(); if ($veryfy->checkVerify($userForm['code']) !== true) { $this->showError('USER:verifycode.error'); } } $question = $userForm['question']; if ($question == -4) { $question = $this->getInput('myquestion', 'post'); } /* [验证用户名和密码是否正确] */ $login = new PwLoginService(); $this->runHook('c_login_dorun', $login); $isSuccess = $login->login($userForm['username'], $userForm['password'], $this->getRequest()->getClientIp(), $question, $userForm['answer']); if ($isSuccess instanceof PwError) { $this->showError($isSuccess->getError()); } $config = Wekit::C('site'); if ($config['windid'] != 'local') { $localUser = $this->_getUserDs()->getUserByUid($isSuccess['uid'], PwUser::FETCH_MAIN); if ($userForm['username'] != $localUser['username']) { $this->showError('USER:user.syn.error'); } } //绑定 new add Wekit::load('EXT:account.service.srv.App_Account_BindService')->bind($isSuccess['uid'], $app_uid, $type); Wind::import('SRV:user.srv.PwRegisterService'); $registerService = new PwRegisterService(); $info = $registerService->sysUser($isSuccess['uid']); $identity = PwLoginService::createLoginIdentify($info); //$identity = base64_encode($identity . '|' . $this->getInput('backurl')); $identity = base64_encode($identity . '|' . $backUrl); /* [是否需要设置安全问题] */ /* @var $userService PwUserService */ $userService = Wekit::load('user.srv.PwUserService'); if (empty($isSuccess['safecv']) && $userService->mustSettingSafeQuestion($info['uid'])) { $this->addMessage(array('url' => WindUrlHelper::createUrl('u/login/setquestion', array('v' => 1, '_statu' => $identity))), 'check'); } $this->showMessage('', 'u/login/welcome?_statu=' . $identity); }
/** * 分享到其它平台使用的链接 * * @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'); }
public function isLogin() { if (!($userCookie = Pw::getCookie('AdminUser'))) { return array(); } list($type, $uid, $password) = explode("\t", Pw::decrypt($userCookie)); if ($type == AdminUserService::FOUNDER) { $srv = $this->loadFounderService(); } else { $srv = $this->loadManagerService(); } Pw::setCookie('AdminUser', $userCookie, 1800); return $srv->isLogin($uid, $password); }
/** * 帖子列表页 */ 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); }
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)); } } }