示例#1
0
文件: lang.php 项目: s-kalaus/ekernel
 public function set($lang)
 {
     if (application::get_instance()->config->resource->lang->type != 'session') {
         return false;
     }
     if ($lang) {
         session::set('lang', $lang);
     } else {
         session::remove('lang');
     }
     setcookie($this->_key, $lang, time() + 86400 * 30, '/');
 }
示例#2
0
文件: lang.php 项目: s-kalaus/ekernel
 public function controller_before()
 {
     $ml = new model_lang();
     $ids = $ml->fetch_col('stitle', array('show_it' => 1));
     if (@application::get_instance()->config->resource->lang->type == 'session') {
         if ($ids) {
             $lang_session = session::get('lang');
             $lang_cookie = @$_COOKIE['lang'];
             if ($lang_session && !in_array($lang_session, $ids)) {
                 session::remove('lang');
                 $lang_session = null;
             }
             if ($lang_cookie && !in_array($lang_cookie, $ids) || $lang_cookie && $lang_session && $lang_session != $lang_cookie) {
                 setcookie('lang', null, time() + 86400 * 30, '/');
             }
             if ($lang_cookie && !$lang_session) {
                 session::set('lang', $lang_cookie);
                 $lang_session = $lang_cookie;
             }
             if (application::get_instance()->config->resource->lang->detect && !$lang_session) {
                 $lang_detected = $this->prefered_language($ids, @$_SERVER['HTTP_ACCEPT_LANGUAGE']);
                 if ($lang_detected) {
                     session::set('lang', $lang_detected);
                 }
             }
         }
     } else {
         if ($ids && !in_array(application::get_instance()->controller->request->param->lang, $ids)) {
             unset(application::get_instance()->controller->request->param->lang);
         }
         if (!application::get_instance()->controller->request->param->lang) {
             application::get_instance()->controller->request->param->lang = application::get_instance()->controller->view->lang()->default->stitle;
         }
         if (application::get_instance()->request->url == '/control') {
             header('Location: /' . application::get_instance()->controller->view->lang()->default->stitle . '/control');
             exit;
         } else {
             if (application::get_instance()->request->url == '/error') {
                 header('Location: /' . application::get_instance()->controller->view->lang('stitle') . '/error');
                 exit;
             }
         }
     }
 }
示例#3
0
 public function callback()
 {
     // $oauth_verifier = filter_input(INPUT_GET, 'oauth_verifier');
     //
     // if (empty($oauth_verifier) || empty(session::get('tw_oauth_token')) || empty(session::get('tw_oauth_secret'))) {
     //     // something's missing, go and login again
     //     header('Location: ' . tw_url_login);
     // }
     session::init();
     $request_token = array();
     $request_token['oauth_token'] = session::get('tw_oauth_token');
     $request_token['oauth_token_secret'] = session::get('tw_oauth_token_secret');
     // connect with application token
     $connection = new TwitterOAuth(tw_consumer_key, tw_consumer_secret, $request_token['oauth_token'], $request_token['oauth_token_secret']);
     // request user token
     $token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $_REQUEST['oauth_verifier']));
     // session::set('tw_token',$token);
     auth::setLogin($token, true, $db = $this->db);
     session::remove('tw_oauth_token');
     session::remove('tw_oauth_token_secret');
     header('Location: /');
     //
     //
     // $twitter = new TwitterOAuth(
     //   tw_consumer_key,
     //   tw_consumer_secret,
     //   $token['oauth_token'],
     //   $token['oauth_token_secret']
     // );
     //
     // print_r($token);
     //
     // $result = $twitter->get('users/show', array('user_id'=>$token['user_id']));
     //
     // print_r($result);
     //
     // $status = $twitter->post(
     //   "statuses/update", [
     //     "status" => "m2m dene".date("Y-m-d h:i:sa")
     //   ]
     // );
     //
     // echo ('Created new status with #' . $status->id . PHP_EOL);
 }
示例#4
0
文件: user.php 项目: s-kalaus/ekernel
 function logout()
 {
     if (session::get($this->_key)) {
         session::remove($this->_key);
         if (isset($_COOKIE[$this->_key])) {
             unset($_COOKIE[$this->_key]);
             setcookie($this->_key, '', 0, '/');
         }
         $this->_data = null;
         return true;
     }
     return false;
 }
示例#5
0
 public function update_clink()
 {
     if ($this->config->field) {
         foreach ($this->config->field as $k => $v) {
             if ($v->type != 'clink') {
                 continue;
             }
             $class = 'model_' . $v->controller;
             $s = (int) session::get($v->controller . '_clink');
             if (!class_exists($class) || !$s) {
                 continue;
             }
             $m = new $class();
             $m->update(array($this->config->field_map->parentid => $this->config->ok), array($this->config->field_map->parentid => $s));
             session::remove($v->controller . '_clink');
         }
     }
 }
示例#6
0
 public function kill()
 {
     session::remove('auth');
     return false;
 }