Example #1
0
 /**
  * Fetch a cookie value, using the Input library.
  *
  * @param   string   cookie name
  * @param   mixed    default value
  * @param   boolean  use XSS cleaning on the value
  * @return  string
  */
 public static function get($name = NULL, $default = NULL, $xss_clean = FALSE)
 {
     // Return an array of all the cookies if we don't have a name
     if ($name === NULL) {
         $cookies = array();
         foreach ($_COOKIE as $key => $value) {
             $cookies[$key] = cookie::get($key, $default, $xss_clean);
         }
         return $cookies;
     }
     if (!isset($_COOKIE[$name])) {
         return $default;
     }
     // Get the cookie value
     $cookie = $_COOKIE[$name];
     // Find the position of the split between salt and contents
     $split = strlen(cookie::salt($name, NULL));
     if (isset($cookie[$split]) and $cookie[$split] === '~') {
         // Separate the salt and the value
         list($hash, $value) = explode('~', $cookie, 2);
         if (cookie::salt($name, $value) === $hash) {
             if ($xss_clean === TRUE and Kohana::config('core.global_xss_filtering') === FALSE) {
                 return Input::instance()->xss_clean($value);
             }
             // Cookie signature is valid
             return $value;
         }
         // The cookie signature is invalid, delete it
         cookie::delete($name);
     }
     return $default;
 }
 public function _before_index()
 {
     $model = D("MisSystemRecursion");
     $MisSystemCompanyDao = M("mis_system_company");
     $where = array();
     $where['status'] = 1;
     $companylist = $MisSystemCompanyDao->where($where)->select();
     $this->assign("companylist", $companylist);
     //构造结构树
     $param['url'] = "__URL__/index/jump/jump/parentid/#id#/id/#id#";
     $param['rel'] = "MisSystemCompanyZtree";
     $param['open'] = "true";
     $param['isParent'] = "true";
     if ($companylist) {
         $companyztree = $this->getTree($companylist, $param);
     }
     //高亮默认选中节点
     $parentid = $_REQUEST['parentid'];
     if (empty($parentid)) {
         $parentid = cookie::get("missystemcompanyid");
         cookie::delete("missystemcompanyid");
         if (empty($parentid)) {
             $parentid = $companylist[0]['id'];
         }
     }
     $this->assign('valid', $parentid);
     //赋值用于boolbar
     $this->assign('parentid', $parentid);
     $this->assign("companyztree", $companyztree);
 }
Example #3
0
 public function __construct(Request $request)
 {
     // Delete the authorization
     cookie::delete('authorized');
     // Redirect to the login page
     $request->redirect(url::site($request->uri(array('controller' => NULL))));
     // Do not call anything here, redirect has already halted execution.
 }
Example #4
0
 /**
  * Log a user out and remove any auto-login cookies.
  *
  * @param   boolean  completely destroy the session
  * @return  boolean
  */
 public function logout($destroy)
 {
     if (cookie::get('authautologin')) {
         // Delete the autologin cookie to prevent re-login
         cookie::delete('authautologin');
     }
     return parent::logout($destroy);
 }
Example #5
0
 function index()
 {
     //判断用户是否是已经登录状态
     $data = role::get_manager();
     if ($data['id'] > 0) {
         $data['success'] = 'true';
         $data['msg'] = 1;
     } else {
         $data['success'] = 'false';
         $data['msg'] = 1;
     }
     $username = $this->input->post('username');
     $password = $this->input->post('password');
     $secode = $this->input->post('secode');
     $remember = $this->input->post('remember');
     $data['success'] = 'false';
     //验证登录
     $manager = role::log_in($username, $password);
     if (isset($manager['username'])) {
         //判断普通账号的状态、权限
         if (!role::is_root($manager['username'])) {
             if ($manager['active'] != 1) {
                 ulog::login($manager['id'], 1);
                 $data['msg'] = Kohana::lang('o_global.account_was_locked');
             }
             $actions = role::manager_actions($manager['id'], TRUE);
             if (count($actions) < 1) {
                 ulog::login($manager['id'], 2);
                 $data['msg'] = Kohana::lang('o_global.account_permission_enough');
             }
         }
         //是否记录用户名
         if ($remember == 1) {
             cookie::set('opococ_username', $username);
         } else {
             cookie::delete('opococ_username');
         }
         //清除记录登录错误记录
         //Session::instance()->delete('login_error_count');
         //记入SESSION
         role::set_manager_session($manager);
         //记录日志
         ulog::login($manager['id']);
         $data['success'] = 'true';
         $data['msg'] = 1;
         /*if(empty($request_url))
         		{
         			remind::set(Kohana::lang('o_global.login_success'), '/index', 'success');
         		}
                    else
                    {
         			$request_url = url::base() . urldecode($request_url);
         			remind::set(Kohana::lang('o_global.login_success'), $request_url, 'success');
         		}*/
     }
     die(json_encode($data));
 }
Example #6
0
 /**
  * Logout un utilisateur.
  *
  * @return  void
  */
 public function logout()
 {
     $this->auto_render = FALSE;
     $authentic = Auth::instance();
     if ($authentic->logged_in()) {
         $authentic->logout(TRUE);
     }
     cookie::delete('urlAdminUrl');
     return self::redirection(Kohana::lang('logger.disconnect'));
 }
Example #7
0
 public function after()
 {
     if ($this->auto_render === TRUE and !$this->_ajax) {
         $this->template->content = View::factory('template/admin')->set('content', $this->template->content)->bind('menu', $menu);
         if ($this->_current_user) {
             // Display these menu items as controller
             $menu = array('projects', 'users', 'logout');
         }
     }
     parent::after();
     // Delete any existing message cookie
     cookie::delete('message');
 }
Example #8
0
 /**
  * Setup the test case
  * - Create MySQL users table
  * - Clear any set cookies
  */
 protected function setUp()
 {
     // Use unit test database
     Kohana::config('database')->default['connection']['database'] = "unit_test";
     // Import schema file
     $users_schema = Kohana::find_file('queries/schemas', 'users', 'sql');
     $users_sql = file_get_contents($users_schema);
     try {
         DB::query(Database::INSERT, $users_sql)->execute();
     } catch (Database_Exception $e) {
         echo $e->getMessage();
     }
     cookie::delete('a1_a1_autologin');
 }
Example #9
0
 public function getReferer()
 {
     $chkCookie = cookie::exists(COOKIE_SPONSOR_NAME);
     if ($chkCookie) {
         $refID = cookie::get(COOKIE_SPONSOR_NAME);
         $validRef = $this->db->count("user_accounts", "agent_id = '{$refID}'");
         if ($validRef != 0) {
             $return = $refID;
         } else {
             cookie::delete(COOKIE_SPONSOR_NAME);
             $return = FALSE;
         }
         return cookie::get(COOKIE_SPONSOR_NAME);
     } else {
         $return = FALSE;
     }
     return $return;
 }
Example #10
0
 public function s($sponsor)
 {
     $userData = user::checkExist("user_accounts", "agent_id = '{$sponsor}' or username = '******'");
     if ($userData == 1) {
         $getUserData = $this->db->select("user_accounts", "agent_id, username", "agent_id = '{$sponsor}' or username = '******'", "fetch");
         $chkCookie = cookie::exists(COOKIE_SPONSOR_NAME);
         if ($chkCookie) {
             $cookieName = cookie::get(COOKIE_SPONSOR_NAME);
             if ($cookieName != $getUserData['agent_id']) {
                 cookie::delete(COOKIE_SPONSOR_NAME);
                 cookie::set(COOKIE_SPONSOR_NAME, $getUserData['agent_id'], COOKIE_EXPIRY);
             }
         } else {
             cookie::set(COOKIE_SPONSOR_NAME, $getUserData['agent_id'], COOKIE_EXPIRY);
         }
     } else {
         cookie::delete(COOKIE_SPONSOR_NAME);
     }
     redirect::to(BASE_PATH, TRUE);
 }
Example #11
0
 /**
  * Gets the value of a signed cookie. Unsigned cookies will not be returned.
  *
  * @param   string  cookie name
  * @param   mixed   default value to return
  * @return  string
  */
 public static function get($key, $default = NULL)
 {
     if (!isset($_COOKIE[$key])) {
         // The cookie does not exist
         return $default;
     }
     // Get the cookie value
     $cookie = $_COOKIE[$key];
     // Find the position of the split between salt and contents
     $split = strlen(cookie::salt($key, NULL));
     if (isset($cookie[$split]) and $cookie[$split] === '~') {
         // Separate the salt and the value
         list($hash, $value) = explode('~', $cookie, 2);
         if (cookie::salt($key, $value) === $hash) {
             // Cookie signature is valid
             return $value;
         }
         // The cookie signature is invalid, delete it
         cookie::delete($key);
     }
     return $default;
 }
Example #12
0
 public function logout($destroy)
 {
     // Delete the autologin cookie if it exists
     cookie::get('authautologin') and cookie::delete('authautologin');
     if ($destroy === TRUE) {
         // Destroy the session completely
         Session::instance()->destroy();
     } else {
         // Remove the user object from the session
         unset($_SESSION['auth_user']);
         // Regenerate session_id
         $this->session->regenerate();
     }
     // Double check
     return !isset($_SESSION['auth_user']);
 }
Example #13
0
 /**
  * Log a owner out and remove any auto-login cookies.
  *
  * @param   boolean  completely destroy the session
  * @return  boolean
  */
 public function logout($destroy)
 {
     if ($token = cookie::get('authautologin')) {
         // Delete the autologin cookie to prevent re-login
         cookie::delete('authautologin');
         // Clear the autologin token from the database
         $token = ORM::factory('owner_token', $token);
         if ($token->loaded) {
             $token->delete();
         }
     }
     return parent::logout($destroy);
 }
Example #14
0
 public function logout($destroy = FALSE, $logout_all = FALSE)
 {
     if ($token = cookie::get('authautologin')) {
         echo 999;
         // Delete the autologin cookie to prevent re-login
         cookie::delete('authautologin');
         // Clear the autologin token from the database
         $token = Sprig::factory('token', array('token' => $token))->load();
         if ($token->loaded() and $logout_all) {
             Sprig::factory('token', array('user_id' => $token->user->id))->delete();
         } elseif ($token->loaded()) {
             $token->delete();
         }
     }
     return parent::logout($destroy);
 }
Example #15
0
 /**
  * 登出
  */
 public function logout()
 {
     cookie::delete(COOKIE_KEY);
     redirect('./');
 }
Example #16
0
 /**
  * Log a user out and remove any auto-login cookies.
  *
  * @param   boolean  completely destroy the session
  * @param	boolean  remove all tokens for user
  * @return  boolean
  */
 public function logout($destroy = FALSE, $logout_all = FALSE)
 {
     if ($token = cookie::get('authautologin')) {
         // Delete the autologin cookie to prevent re-login
         cookie::delete('authautologin');
         // Clear the autologin token from the database
         $token = ORM::factory('user_token', $token);
         if ($token->loaded() and $logout_all) {
             ORM::factory('user_token')->where('user_id', '=', $token->user_id)->delete_all();
         } elseif ($token->loaded()) {
             $token->delete();
         }
     }
     return parent::logout($destroy);
 }
Example #17
0
 public function logout()
 {
     $this->_db->delete('users_session', array('user_id', '=', $this->data()->id));
     session::delete($this->_sessionName);
     cookie::delete($this->_cookieName);
 }
Example #18
0
 /**
  * Tests cookie::delete()
  *
  * @test
  * @dataProvider provider_delete
  * @covers cookie::delete
  * @param mixed   $key      key to use
  * @param boolean $expected Output for cookie::delete()
  */
 public function test_delete($key, $expected)
 {
     if (headers_sent()) {
         $this->markTestSkipped('Cannot test setting cookies as headers have already been sent');
     }
     $this->assertSame($expected, cookie::delete($key));
 }
Example #19
0
 /**
  * Log out a user by removing the related session variables.
  *
  * @param   boolean  completely destroy the session
  * @param   boolean  remove all tokens for user
  * @return  boolean
  */
 public function logout($destroy = FALSE, $logout_all = FALSE)
 {
     if ($destroy === TRUE) {
         // Destroy the session completely
         $this->_session->destroy();
     } else {
         // Remove the user from the session
         $this->_session->delete($this->_config['session_key']);
         // Regenerate session_id
         $this->_session->regenerate();
     }
     cookie::delete('authautologin');
     // Double check
     return !$this->logged_in();
 }
 public function checkpassword()
 {
     // Check that a password is valid, then store in a browser cookie.
     // Prevent Cross Site Request Forgery
     access::verify_csrf();
     // Convert submitted data to local variables.
     $album_password = strtolower(Input::instance()->post("albumpassword_password"));
     // See if the submitted password matches any in the database.
     $existing_password = ORM::factory("items_albumpassword")->where("password", "=", $album_password)->find_all();
     if (count($existing_password) > 0) {
         // If the password if valid, then store it, and display a success message.
         // If not, close the dialog and display a rejected message.
         cookie::delete("g3_albumpassword_id");
         cookie::set("g3_albumpassword", $album_password);
         message::success(t("Password Accepted."));
         json::reply(array("result" => "success"));
     } else {
         message::error(t("Password Rejected."));
         json::reply(array("result" => "success"));
     }
 }
Example #21
0
 public static function logout()
 {
     session::destroy();
     $tokenExist = cookie::exists(TOKEN_NAME);
     if ($tokenExist) {
         $token = cookie::get(TOKEN_NAME);
         try {
             $db = new database(DBTYPE, DBHOST, DBNAME, DBUSER, DBPASS);
             $data = $db->select("users_session", "*", "token = '{$token}'", "fetch");
             $agent_id = $data['agent_id'];
             $db->delete("users_session", "token = '{$agent_id}'");
             cookie::delete(TOKEN_NAME);
         } catch (Exception $ex) {
             cookie::delete(TOKEN_NAME);
         }
     }
     redirect::to("login");
 }
Example #22
0
 /**
  * Destroys the current session.
  *
  * @return  void
  */
 public function destroy()
 {
     if (session_id() !== '') {
         // Get the session name
         $name = session_name();
         // Destroy the session
         session_destroy();
         // Re-initialize the array
         $_SESSION = array();
         // Delete the session cookie
         cookie::delete($name);
     }
 }
Example #23
0
 /**
  * Method: destroy
  *  Destroys the current session.
  *
  * Returns:
  *  TRUE or FALSE (or NULL if called before session_start())
  */
 public function destroy()
 {
     if (isset($_SESSION)) {
         // Remove all session data
         session_unset();
         // Delete the session cookie
         cookie::delete(session_name());
         // Destroy the session
         return session_destroy();
     }
 }
Example #24
0
	/**
	 * Tests cookie::delete()
	 *
	 * @test
	 * @dataProvider provider_delete
	 * @covers cookie::delete
	 * @param mixed   $key      key to use
	 * @param boolean $expected Output for cookie::delete()
	 */
	public function test_delete($key, $expected)
	{
		$this->assertSame($expected, cookie::delete($key));
	}
Example #25
0
 /**
  * Log a user out and remove any auto-login cookies.
  *
  * @param   boolean  completely destroy the session
  * @return  boolean
  */
 public function logout($destroy)
 {
     if (cookie::get('authautologin')) {
         // Delete the autologin cookie to prevent re-login
         cookie::delete('authautologin');
     }
     if (session::get('riverid')) {
         // Delete the riverid object in case it's set
         session::delete('riverid');
     }
     return parent::logout($destroy);
 }
Example #26
0
 public function logout()
 {
     $this->_database->delete('User_session', array('UserID', '=', $this->data()->UserID));
     session::delete($this->_sessionName);
     cookie::delete($this->_cookieName);
 }
Example #27
0
File: sprig.php Project: azuya/Wi3
 /**
  * Log a user out and remove any auto-login cookies.
  *
  * @param   boolean  completely destroy the session
  * @param	boolean  remove all tokens for user
  * @return  boolean
  */
 public function logout($destroy = FALSE, $logout_all = FALSE)
 {
     if ($token = cookie::get('authautologin')) {
         // Delete the autologin cookie to prevent re-login
         cookie::delete('authautologin');
         // Clear the autologin token from the database
         $token = Sprig::factory($this->token_model(), array('token' => $token))->delete();
     }
     // Delete all the User's Tokens
     if (isset($this->_user_auth) and $logout_all) {
         Sprig::factory($this->token_model(), array('user' => $this->_user_auth->id))->delete();
     }
     // Removed the cached user
     $this->_user_auth = NULL;
     return parent::logout($destroy);
 }
 public function logout()
 {
     // Delete a stored password cookie.
     cookie::delete("g3_albumpassword");
     url::redirect(url::abs_site("albums/1"));
 }
Example #29
0
 public function destroy($id)
 {
     return cookie::delete($this->cookie_name);
 }
Example #30
0
 /**
  * Log out a user by removing the related session variables.
  *
  * @param   boolean  completely destroy the session
  * @return  boolean
  */
 public function logout($destroy = FALSE)
 {
     if (cookie::get('a1_' . $this->config_name . '_autologin')) {
         cookie::delete('a1_' . $this->config_name . '_autologin');
     }
     if ($destroy === TRUE) {
         // Destroy the session completely
         $this->session->destroy();
     } else {
         // Remove the user from the session
         $this->session->delete($this->config['session_key']);
         // Regenerate session_id
         $this->session->regenerate();
     }
     return !$this->logged_in();
 }