public function indexAction() { $login = \Comm\Arg::get('login', FILTER_VALIDATE_BOOLEAN); if (Yaf_Registry::get('current_uid') && !$login) { //已登录,跳至管理页 return $this->redirect(\Comm\View::path('manage/basic')); } else { //未登录,展示介绍页 $this->viewDisplay(); } }
public function indexAction() { $id = \Comm\Arg::get('id', FILTER_VALIDATE_INT); //获取模板基础内容 $theme = Model\Theme\Main::show($id); if (empty($theme)) { throw new \Exception\Msg('指定模板不存在'); } //权限验证 Model\User::validateAuth($theme['user_id']); //获取资源内容 $resource = Model\Theme\Resource::showByTheme($theme); $this->viewDisplay(array('theme' => $theme, 'resource' => $resource)); }
public function indexAction() { //生产环境禁止回调 return false; $action = \Comm\Arg::get('action', FILTER_DEFAULT, null, true); switch ($action) { //测试查询 case 'select': $db = new \Comm\Db\Simple('test'); $result = $db->limit(10)->fetchAll(); print_r($result); break; case 'config': print_r(\Model\Config::showAll()); break; } return false; }
public function indexAction() { $code = \Comm\Arg::get('code', FILTER_DEFAULT, null, true); $config = \Model\Config::showBatch(['github_client_secret', 'github_client_id']); $api = \Api\Github\Oauth::init(); $oauth = $api->accessToken($config['github_client_id'], $config['github_client_secret'], $code); $access_token = empty($oauth->access_token) ? '' : $oauth->access_token; if ($access_token) { $_SESSION['github-access-token'] = $oauth->access_token; } //获取用户信息 $github_user = new \Api\Github\Users(); $user = $github_user->user(); if (!empty($user->id)) { //更新用户数据 $metadata = array('login' => $user->login, 'avatar_url' => $user->avatar_url, 'name' => $user->name); \Model\User::updateLogin($user->id, $access_token, $metadata); $_SESSION['uid'] = $user->id; return $this->redirect('/manage/basic'); } else { throw new \Exception\Msg('请授权Github账号后再进行操作。'); } }
/** * 兼容 Windows * * @param Yaf_Dispatcher $dispatcher */ public function _initWindows(Yaf_Dispatcher $dispatcher) { if (stripos(\Comm\Arg::server('SERVER_SOFTWARE'), 'IIS') !== false) { $dispatcher->registerPlugin(new \IisPlugin()); } }
/** * 获取AccessToken * * @return \mixed */ public static function showAccessToken() { return \Comm\Arg::session('github-access-token'); }