public function _templateAction() { $config = isset($_GET['__config__']) ? $_GET['__config__'] : null; if (!isset($config)) { throw new Wk_Exception("", -1); } if (!empty($config['redirect'])) { Wk_Request::redirect($config['redirect']); } $needLogin = isset($config['needLogin']) ? $config['needLogin'] : 0; if (isset($needLogin) && $needLogin == 1 && !$this->isLogin()) { $this->redirectLogin(); } $needLogout = isset($config['needLogout']) ? $config['needLogout'] : 0; if (isset($needLogout) && $needLogout == 1 && $this->isLogin()) { // throw new K_Exception('', TErrorConstants::E_LOGIN); Wk_Request::redirect("/"); } $path = $config['path']; if (!empty($path)) { unset($_GET['__config__']); $content = $this->renderReleaseTemplate($path, true); echo $content; } Wk::app()->stop(); }
private function route($controllerName, $actionName) { $controllerClass = ucfirst($controllerName . 'Controller'); if (class_exists($controllerClass)) { /** @var K_Controller $runC */ $runC = new $controllerClass($actionName); $this->controller = $runC; $runC->run($actionName); } else { if (Wk_Request::isAjax()) { } else { Wk_Request::redirect('/'); } } $this->stop(); }
public function _templateAction() { if ($this->isGuest() && strpos($_SERVER['REQUEST_URI'], '/admin/login') !== 0) { Wk_Request::redirect('/admin/login'); } if ($this->isLogin() && strpos($_SERVER['REQUEST_URI'], '/admin/login') === 0) { Wk_Request::redirect('/admin'); } $config = isset($_GET['__config__']) ? $_GET['__config__'] : null; if (!isset($config)) { throw new Wk_Exception("", -1); } $path = $config['path']; if (!empty($path)) { unset($_GET['__config__']); $content = $this->renderReleaseTemplate($path, true); echo $content; } Wk::app()->stop(); }
/** * 通过跳转方式获得微信基本授权,可获得用户信息,但是会在微信里弹授权确认框 * @apiMethod get|post * @apiParam string retUrl 微信回调URL * @apiParam string [state=userinfo] 获取的信息 */ public function getWxOAuth2Redirect_UserInfoAction() { $returl = Wk_Request::getRequestString("retUrl"); // state可以传openId, 防止用户不通过授权,这样依然可以拿到用户的一些信息。 $state = Wk_Request::getRequestString("state", "userinfo"); $redirectUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . Wk::$config['wechat']['WX_AKEY'] . "&redirect_uri=" . urlencode($returl) . "&response_type=code&scope=snsapi_userinfo&state=" . $state . "#wechat_redirect"; Wk_Request::redirect($redirectUrl); }