Example #1
0
File: set.php Project: anqqa/Anqh
 /**
  * Change country
  *
  * @param  string  $country
  */
 public function country($country)
 {
     if (in_array($country, Kohana::config('site.countries'))) {
         if ($this->session->get('country') == $country) {
             // Clear country if same as given
             $this->session->delete('country');
         } else {
             // Set country
             $this->session->set('country', $country);
         }
     }
     url::back();
 }
 public function logout()
 {
     // remove data from database
     $this->_db->delete('users_session', array('user_id', '=', $this->data()->id));
     Session::delete($this->_sessionName);
     Cookie::delete($this->_cookieName);
 }
 /**
  * Destroys the session, removing all data stored in this session and
  * removing any reference to this session.
  */
 public function session_destroy()
 {
     # Remove cookie
     remove_cookie($this->sign($this->session->id, $this->session->salt));
     # Remove session from database
     $this->session->delete();
 }
 public function action_profile()
 {
     $data = null;
     $data['user'] = Model_User::query()->related('user_providers')->where('id', static::$user_id)->get_one();
     $data['api_key'] = Auth::get('api_key');
     if (Input::Method() == 'POST') {
         $new_password = Input::Post('new_password');
         $current_password = Input::Post('current_password');
         if (empty($new_password) === false) {
             if (empty($current_password) === true) {
                 Session::set('error', 'You must enter your old password in first!');
                 $this->template->content = View::Forge('settings/profile', $data);
                 return;
             } else {
                 if (Auth::change_password($current_password, $new_password) === false) {
                     Session::set('error', 'Wrong Password');
                     $this->template->content = View::Forge('settings/profile', $data);
                     return;
                 } else {
                     Session::delete('current_password');
                 }
             }
         }
         // update the data for the current user
         try {
             Auth::update_user(array('email' => Input::Post('email'), 'fullname' => Input::Post('full_name')));
         } catch (Exception $e) {
             Session::set('error', $e->getMessage());
             $this->template->content = View::Forge('settings/profile', $data);
             return;
         }
         Session::set('success', 'Your profile has been updated');
     }
     $this->template->content = View::Forge('settings/profile', $data);
 }
Example #5
0
 function __construct()
 {
     if (isset($_COOKIE)) {
         Session::delete();
     }
     header('Location: /');
 }
Example #6
0
 public function action_index()
 {
     // clear redirect referrer
     \Session::delete('submitted_redirect');
     // load language
     \Lang::load('index');
     // read flash message for display errors.
     $form_status = \Session::get_flash('form_status');
     if (isset($form_status['form_status']) && isset($form_status['form_status_message'])) {
         $output['form_status'] = $form_status['form_status'];
         $output['form_status_message'] = $form_status['form_status_message'];
     }
     unset($form_status);
     // get total accounts
     $output['total_accounts'] = \Model_Accounts::count();
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('admin_administrator_dashbord'));
     // <head> output ----------------------------------------------------------------------------------------------
     // breadcrumb -------------------------------------------------------------------------------------------------
     $page_breadcrumb = [];
     $page_breadcrumb[0] = ['name' => \Lang::get('admin_admin_home'), 'url' => \Uri::create('admin')];
     $output['page_breadcrumb'] = $page_breadcrumb;
     unset($page_breadcrumb);
     // breadcrumb -------------------------------------------------------------------------------------------------
     // the admin views or theme should follow this structure. (admin/templates/controller/method) and follow with _v in the end.
     return $this->generatePage('admin/templates/index/index_v', $output, false);
 }
Example #7
0
 public function action_list()
 {
     $view = View::forge('admin/list');
     if (Session::get('status')) {
         $view->set_global('status', Session::get('status'));
         Session::delete('status');
     }
     if (\Input::post()) {
         if (Auth::delete_user(\Input::param('username'))) {
             Session::set('status', array('css' => 'success', 'msg' => 'ユーザ削除に成功しました'));
             Response::redirect('admin/list');
         } else {
             Session::set('status', array('css' => 'danger', 'msg' => 'ユーザ削除に失敗しました'));
             Response::redirect('admin/list');
         }
     }
     $list = DB::select('id', 'username', 'email', 'group')->from('users')->where('group', '!=', 100);
     $total = $list->execute()->count();
     $config = array('per_page' => 20, 'num_links' => 10, 'show_first' => true, 'show_last' => true, 'total_items' => $total, 'uri_segment' => 3);
     $pagination = Pagination::forge('mypagination', $config);
     $list->limit($pagination->per_page)->offset($pagination->offset);
     $result = $list->execute()->as_array();
     $view->set_global('list', $result);
     $view->set_global('pagination', $pagination);
     return $view;
 }
Example #8
0
 /**
  * Log out a user by removing the related session variables.
  *
  * @param   boolean  $destroy  completely destroy the session
  * @return  boolean
  */
 public function logout($destroy = false)
 {
     // Delete the autologin cookie to prevent re-login
     if (cookie::get($this->config['cookie_name'])) {
         cookie::delete($this->config['cookie_name']);
     }
     // Logout 3rd party?
     if (FB::enabled() && Visitor::instance()->get_provider()) {
         $this->session->delete($this->config['session_key'] . '_provider');
         try {
             FB::instance()->expire_session();
         } catch (Exception $e) {
         }
     }
     // Destroy the session completely?
     if ($destroy === true) {
         $this->session->destroy();
     } else {
         // Remove the user from the session
         $this->session->delete($this->config['session_key']);
         // Regenerate session_id
         $this->session->regenerate();
     }
     // Double check
     return !$this->logged_in();
 }
Example #9
0
 public static function deleteApplySeesion()
 {
     Session::delete('admission.unit');
     Session::delete('ssc.roll');
     Session::delete('ssc.session');
     Session::delete('ssc.res');
     Session::delete('ssc.py');
     Session::delete('ssc.board');
     Session::delete('ssc.group');
     Session::delete('ssc.gpa');
     Session::delete('hsc.roll');
     Session::delete('hsc.session');
     Session::delete('hsc.res');
     Session::delete('hsc.py');
     Session::delete('hsc.board');
     Session::delete('hsc.group');
     Session::delete('hsc.gpa');
     Session::delete('admission.name');
     Session::delete('admission.father.name');
     Session::delete('admission.mother.name');
     Session::delete('admission.gender');
     Session::delete('admission.nat');
     Session::delete('admission.preadress');
     Session::delete('admission.peradress');
     Session::delete('admission.contact');
     Session::delete('admission.dob');
     Session::delete('admission.photo');
 }
Example #10
0
    function delete()
    {
        $translator = new Translator();
        $user = new User();
        try {
            $id = array_shift($this->param);
            $user->disable($_SESSION['user_id']);
            Session::delete();
            echo <<<EOF
<div class="container">
   <div class="page-header">
        <h1>{$translator->User_updated}</h1>
      </div>
   <p class="lead">{$translator->User_updated_Desc}</p>
      <p >{$translator->Error_Backprofile}</p>
</div>
<script type="text/javascript">
window.location.href='/';
</script>

EOF;
        } catch (Exception $e) {
            echo <<<EOF
<div class="container">
   <div class="page-header">
        <h1>{$translator->User_error}</h1>
      </div>
   <p class="lead">{$translator->User_error_Desc}</p>
      <p >{$translator->Error_Backusers}</p>
</div>

EOF;
        }
    }
Example #11
0
 /**
  * Logout
  */
 public function logout($params)
 {
     Cookie::delete('login');
     Session::delete('username');
     header('Location: ' . $params['redirect']);
     exit;
 }
Example #12
0
 private function callLoginAction($module = 'default')
 {
     Session::delete('user');
     require_once MODULE_PATH . $module . DS . 'controllers' . DS . 'LoginController.php';
     $indexController = new LoginController($this->_params);
     $indexController->indexAction();
 }
Example #13
0
 function cerrar()
 {
     Auth::destroy_identity();
     Session::delete("usuario_id");
     Session::delete("usuario_nombrecompleto");
     Router::redirect("login/index");
 }
Example #14
0
 public function logout()
 {
     if (!is_null(Session::get('person'))) {
         Session::delete('person');
     }
     Router::redirect('/personal/');
 }
Example #15
0
 /**
  * Método para limpiar los mensajes almacenados
  */
 public static function clean()
 {
     //Reinicio la variable de los mensajes
     self::$_contentMsj = array();
     //Elimino los almacenados en sesión
     Session::delete('mkc-messages');
 }
Example #16
0
 public function action_index()
 {
     // clear redirect referrer
     \Session::delete('submitted_redirect');
     // read flash message for display errors.
     $form_status = \Session::get_flash('form_status');
     if (isset($form_status['form_status']) && isset($form_status['form_status_message'])) {
         $output['form_status'] = $form_status['form_status'];
         $output['form_status_message'] = $form_status['form_status_message'];
     }
     unset($form_status);
     // list tables
     $output['list_tables'] = \DB::list_tables();
     // if form submitted
     if (\Input::method() == 'POST') {
         $table_name = trim(\Input::post('table_name'));
         $output['table_name'] = $table_name;
         if (!\Extension\NoCsrf::check()) {
             // validate token failed
             $output['form_status'] = 'error';
             $output['form_status_message'] = \Lang::get('fslang_invalid_csrf_token');
         } elseif ($table_name == null) {
             $output['form_status'] = 'error';
             $output['form_status_message'] = \Lang::get('dbhelper_please_select_db_table');
         } else {
             $output['list_columns'] = \DB::list_columns(\DB::expr('`' . $table_name . '`'));
         }
     }
     // endif; form submitted
     // <head> output ---------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('dbhelper'));
     // <head> output ---------------------------------------------------------------------
     return $this->generatePage('admin/templates/index/index_v', $output, false);
 }
Example #17
0
 public function logout()
 {
     $this->user = null;
     $this->token = null;
     Cookie::delete(self::COOKIE_NAME);
     Session::delete(self::SESSION_NAME);
 }
Example #18
0
 /**
  * Initialize by loading config & starting default session
  */
 public static function _init()
 {
     \Config::load('session', true);
     if (\Config::get('session.auto_initialize', true)) {
         static::instance();
     }
     if (\Config::get('session.native_emulation', false)) {
         // emulate native PHP sessions
         session_set_save_handler(function ($savePath, $sessionName) {
         }, function () {
         }, function ($sessionId) {
             // copy all existing session vars into the PHP session store
             $_SESSION = \Session::get();
             $_SESSION['__org'] = $_SESSION;
         }, function ($sessionId, $data) {
             // get the original data
             $org = isset($_SESSION['__org']) ? $_SESSION['__org'] : array();
             unset($_SESSION['__org']);
             // do we need to remove stuff?
             if ($remove = array_diff_key($org, $_SESSION)) {
                 \Session::delete(array_keys($remove));
             }
             // add or update the remainder
             empty($_SESSION) or \Session::set($_SESSION);
         }, function ($sessionId) {
             \Session::destroy();
         }, function ($lifetime) {
         });
     }
 }
Example #19
0
 /**
  * Logout user
  *
  * @return bool
  */
 public function logout()
 {
     $this->user = null;
     \Session::delete('email');
     \Session::delete('login_hash');
     return true;
 }
Example #20
0
 public static function signin($login, $password)
 {
     $password = sha1(md5($password));
     $user = DB::toRow("SELECT users.* FROM users WHERE (email='{$login}' or login='******')");
     if (!$user->id) {
         Session::set('auth_error', 'USER_UNKNOWN');
     } elseif ($user->password != $password) {
         Session::set('auth_error', 'PASSWORD_WRONG');
     } elseif (!$user->status) {
         Session::set('auth_error', 'ACCESS_DENID');
     } else {
         $auth = new stdClass();
         foreach ($user as $f => $v) {
             $auth->{$f} = $v;
         }
         if (!empty($auth->src)) {
             $auth->src = LOCALHOST . "assets/avatar/" . $auth->src;
         } elseif (empty($auth->src) and !empty($auth->facebook_id)) {
             $auth->src = "https://graph.facebook.com/" . $auth->facebook_id . "/picture?height=128";
         } else {
             $auth->src = LOCALHOST . "files/avatar/dafault.jpg";
         }
         Session::setFixed('auth', $auth);
         Session::delete('auth_error');
         return $auth;
     }
     return false;
 }
Example #21
0
 public function action_logout()
 {
     if (\CMF\Auth::logout()) {
         \Session::delete('cmf.admin.language');
         \Response::redirect('/admin/login', 'location');
     }
 }
Example #22
0
 /**
  * セッションに保存されたファイルデータをファイルとして保存する
  * 
  * @param Model $model
  * @param string $fieldName
  * @return void
  * @access public
  */
 function moveFileSessionToTmp(&$model, $fieldName)
 {
     $sessionKey = $model->data[$model->alias][$fieldName . '_tmp'];
     $tmpName = $this->savePath . $sessionKey;
     $fileData = $this->Session->read('Upload.' . $sessionKey);
     $fileType = $this->Session->read('Upload.' . $sessionKey . '_type');
     $this->Session->delete('Upload.' . $sessionKey);
     $this->Session->delete('Upload.' . $sessionKey . '_type');
     // サイズを取得
     if (ini_get('mbstring.func_overload') & 2 && function_exists('mb_strlen')) {
         $fileSize = mb_strlen($fileData, 'ASCII');
     } else {
         $fileSize = strlen($fileData);
     }
     if ($fileSize == 0) {
         return false;
     }
     // ファイルを一時ファイルとして保存
     $file = new File($tmpName, true, 0666);
     $file->write($fileData);
     $file->close();
     // 元の名前を取得
     $pos = strpos($sessionKey, '_');
     $fileName = substr($sessionKey, $pos + 1, strlen($sessionKey));
     // アップロードされたデータとしてデータを復元する
     $uploadInfo['error'] = 0;
     $uploadInfo['name'] = $fileName;
     $uploadInfo['tmp_name'] = $tmpName;
     $uploadInfo['size'] = $fileSize;
     $uploadInfo['type'] = $fileType;
     $model->data[$model->alias][$fieldName] = $uploadInfo;
     unset($model->data[$model->alias][$fieldName . '_tmp']);
 }
 /**
  * @runInSeparateProcess
  */
 public function testExists()
 {
     Session::start();
     Session::set('test', 'testing');
     $this->assertTrue(Session::exists('test'));
     Session::delete('test');
     $this->assertFalse(Session::exists('test'));
 }
 public function success()
 {
     if (!Session::get('success')) {
         Router::redirect('/');
     } else {
         Session::delete('success');
     }
 }
Example #25
0
 public static function check($token)
 {
     if (Session::exists('token') && $token === Session::get('token')) {
         Session::delete('token');
         return true;
     }
     return false;
 }
Example #26
0
 public static function check($token)
 {
     $tokenName = config::get("session/token_name");
     if (Session::exist($tokenName) && $token === Session::get($tokenName)) {
         Session::delete($tokenName);
         return true;
     }
 }
Example #27
0
 /**
  * Loggt den User aus
  * @uses Smarty Als Template-System
  */
 public function logout()
 {
     $this->_session->delete();
     //Sektion der Sprachdatei weitergeben für die Texte im Template
     $this->_smarty->assign('section', 'Logout');
     $this->_smarty->assign('forward_link', "?");
     $this->_smarty->display('forward.tpl');
 }
Example #28
0
 public static function check($token)
 {
     if (Session::exists(self::$tokenName) && $token === Session::get(self::$tokenName)) {
         Session::delete(self::$tokenName);
         return true;
     }
     return false;
 }
Example #29
0
 public static function check($token)
 {
     $tokenName = Config::get('session/token_name');
     if (Session::exists($tokenName) && $token === Session::get($tokenName)) {
         Session::delete($tokenName);
         return true;
     }
     return false;
 }
Example #30
0
 public function after_save()
 {
     Session::delete('empresa', 'config');
     //Si no está habilitado para el manejo de sucursal
     //registro la ubicación de la empresa como sucursal
     if (!APP_OFFICE && Input::hasPost('sucursal')) {
         Sucursal::setSucursal('save', Input::post('sucursal'), array('sucursal' => 'Oficina Principal', 'ciudad' => Input::post('ciudad'), 'empresa_id' => $this->id));
     }
 }