예제 #1
0
파일: Index.php 프로젝트: chaoyanjie/HiBlog
 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();
     }
 }
예제 #2
0
파일: Edit.php 프로젝트: chaoyanjie/HiBlog
 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));
 }
예제 #3
0
파일: Db.php 프로젝트: chaoyanjie/HiBlog
 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;
 }
예제 #4
0
파일: Oauth.php 프로젝트: chaoyanjie/HiBlog
 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账号后再进行操作。');
     }
 }
예제 #5
0
 /**
  * 兼容 Windows
  *
  * @param Yaf_Dispatcher $dispatcher
  */
 public function _initWindows(Yaf_Dispatcher $dispatcher)
 {
     if (stripos(\Comm\Arg::server('SERVER_SOFTWARE'), 'IIS') !== false) {
         $dispatcher->registerPlugin(new \IisPlugin());
     }
 }
예제 #6
0
파일: Abs.php 프로젝트: chaoyanjie/HiBlog
 /**
  * 获取AccessToken
  * 
  * @return \mixed
  */
 public static function showAccessToken()
 {
     return \Comm\Arg::session('github-access-token');
 }