예제 #1
0
 public function logout()
 {
     $this->user = null;
     $this->token = null;
     Cookie::delete(self::COOKIE_NAME);
     Session::delete(self::SESSION_NAME);
 }
예제 #2
0
 public static function run()
 {
     header('Content-type: text/html; charset=utf-8');
     // debug
     Debug::p('PHP Begin');
     $htmlDebug = Request::getGET('htmldebug');
     $ajaxDebug = Request::getGET('ajaxdebug');
     if ($htmlDebug == 'on') {
         Cookie::set('htmldebug', 1);
     }
     if ($htmlDebug == 'off') {
         Cookie::delete('htmldebug');
     }
     if ($ajaxDebug == 'on') {
         Cookie::set('ajaxdebug', 1);
     }
     if ($ajaxDebug == 'off') {
         Cookie::delete('ajaxdebug');
     }
     self::parseUrl();
     $path = empty(self::$CLASS_DIR) ? PROJECT_PATH . '/controller/' . self::$CLASS_NAME . '.class.php' : PROJECT_PATH . '/controller/' . self::$CLASS_DIR . '/' . self::$CLASS_NAME . '.class.php';
     if (!is_file($path)) {
         $userAgent = Arr::get('HTTP_USER_AGENT', $_SERVER, '');
         throw new FrameworkException("控制器:{$path} 不存在!User Agent: {$userAgent}");
     }
     require_once $path;
     $obj = new self::$CLASS_NAME();
     $actionName = self::$ACTION . 'Action';
     $obj->{$actionName}();
     // debug
     Debug::p('PHP End');
     if (isset($_COOKIE['htmldebug']) && !self::$IS_AJAX || isset($_COOKIE['ajaxdebug']) && self::$IS_AJAX) {
         Debug::show();
     }
 }
예제 #3
0
 /**
  *	@fn logout
  *	@short Action method that logs out a user.
  */
 function logout()
 {
     Cookie::delete('_u');
     Cookie::delete('_uid');
     $this->flash(l('Logout was performed successfully'), 'message');
     $this->redirect_to(array('controller' => 'home'));
 }
예제 #4
0
파일: User.php 프로젝트: hugonicolas/Site
 /**
  * Logout
  */
 public function logout($params)
 {
     Cookie::delete('login');
     Session::delete('username');
     header('Location: ' . $params['redirect']);
     exit;
 }
예제 #5
0
 function login_out()
 {
     Cookie::delete('feifa_admin');
     if (empty($_COOKIE['feifa_admin'])) {
         $this->redirect('Admin-Login/index');
     }
 }
 function init($request)
 {
     parent::init($request);
     $ck = new Cookie(COOKIE_NAME_SESSION);
     $ck->delete();
     Request::redirectToModule('index');
 }
예제 #7
0
 public function logout()
 {
     import('ORG.Util.Cookie');
     //Cookie::set('authcookie', authcode("$user_name\t$user_id\t",'ENCODE'), 31536000);
     Cookie::delete('authcookie');
     return true;
 }
예제 #8
0
파일: User.php 프로젝트: korejwo/coc
 /**
  * Wylogowywanie
  */
 public function action_logout()
 {
     Auth::instance()->logout();
     Session::instance()->destroy();
     Cookie::delete('authautologin');
     exit;
 }
예제 #9
0
파일: cookie.php 프로젝트: nevermlnd/cv
	/**
	 * Gets the value of a signed cookie. Cookies without signatures will not
	 * be returned. If the cookie signature is present, but invalid, the cookie
	 * will be deleted.
	 *
	 *     // Get the "theme" cookie, or use "blue" if the cookie does not exist
	 *     $theme = Cookie::get('theme', 'blue');
	 *
	 * @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;
	}
예제 #10
0
 /**
  * Sets the currently logged in user.
  * @param User $user The user to set.
  * @param string $password The password of the user, just to be sure.
  */
 public static function setUser(User $user, $password)
 {
     // Let's first issue a new session token to null out any old forms
     Session::issueToken();
     // Make sure the user isn't a guest and the password works
     if ($user == null || $user->isGuest() || !$user->isPassword($password)) {
         // Delete the cookies
         Cookie::delete('userid');
         Cookie::delete('sid');
         // Set the user to a guest
         self::$user = User::guest();
         return;
     }
     // Make sure this isn't already the signed in user
     if (self::$user != null && self::$user->getUserId() == $user->getUserId()) {
         return;
     }
     // Set the cookies
     Cookie::set('userid', $user->getUserId());
     Cookie::set('sid', $user->getCookiePassword());
     // Update the user's visit times
     $user->updateVisitInfo();
     // Let's now set the local version
     self::$user = $user;
 }
예제 #11
0
파일: cookie.php 프로젝트: rhrn/apirn
 public function action_delete()
 {
     $name = $this->request->query('name');
     if (Cookie::delete($name)) {
         echo json_decode(array($name => 1));
     }
 }
 function process()
 {
     $siteAdmin = $this->needASiteAdminSelected();
     if ($siteAdmin) {
         $choice = $this->request->getConfirmedState();
         $cookieSet = false;
         // is the cookie already set or not?
         if (isset($_COOKIE[COOKIE_NAME_NO_STAT . $siteAdmin])) {
             $cookieSet = true;
         }
         if ($choice == 1) {
             $ck = new Cookie(COOKIE_NAME_NO_STAT . $siteAdmin);
             if ($cookieSet) {
                 $ck->delete();
             } else {
                 $ck->save();
             }
             $this->setMessage();
         } else {
             if ($cookieSet) {
                 $this->tpl->assign("cookie_no_stat", true);
             } else {
                 $this->tpl->assign("cookie_no_stat", false);
             }
         }
     }
 }
예제 #13
0
파일: oauth.php 프로젝트: badsyntax/2do
 public function action_authorize()
 {
     if ($this->token and $this->token->token !== Arr::get($_GET, 'oauth_token')) {
         // Delete the token, it is not valid
         Cookie::delete($this->cookie);
         // Send the user back to the beginning
         Request::instance()->redirect($this->request->uri(array('action' => 'index')));
     }
     // Get the verifier
     $verifier = Arr::get($_GET, 'oauth_verifier');
     // Store the verifier in the token
     $this->token->verifier($verifier);
     // Exchange the request token for an access token
     $this->token = $this->provider->access_token($this->consumer, $this->token);
     // Store the access token
     Cookie::set($this->cookie, serialize($this->token));
     // At this point, we need to retrieve a unique twitter id for the user.
     $response = OAuth_Request::factory('resource', 'GET', 'http://api.twitter.com/1/account/verify_credentials.json')->param('oauth_consumer_key', Kohana::config('oauth.twitter.key'))->param('oauth_token', $this->token)->sign(OAuth_Signature::factory('HMAC-SHA1'), $this->consumer, $this->token)->execute();
     $response = json_decode($response);
     $twitter_id = $response->screen_name;
     $user = ORM::factory('user')->where('username', '=', $twitter_id)->find();
     !$user->id and Request::instance()->redirect('/auth/confirm?id=' . $twitter_id);
     Auth::instance()->force_login($user);
     Session::instance()->set('notification', 'Succesfully logged in.');
     Request::instance()->redirect('/');
 }
예제 #14
0
 public function logout()
 {
     Cookie::delete('username');
     Cookie::delete('lastlogintime');
     $this->assign("jumpUrl", "__APP__/index/index");
     $this->success('您已经成功退出,欢迎您的下次登录!');
 }
예제 #15
0
 /**
  * Get cookie value(s)
  * 
  * @param string $name      Name of the cookie to get
  * @param mixed $default    [optional] Default value if cookie is not set. Default is false
  * @return mixed            Cookie stored datas
  */
 public static function get($name, $default = false)
 {
     // handling array notation
     if (preg_match('#^(.*?)\\[(.*?)\\]$#', $name, $m)) {
         if (!isset($_COOKIE[$m[1]][$m[2]])) {
             return $default;
         }
         $value = $_COOKIE[$m[1]][$m[2]];
     } else {
         if (!isset($_COOKIE[$name])) {
             return $default;
         }
         $value = $_COOKIE[$name];
     }
     // retrieve cookie content
     $cookieValue = explode('|', $value);
     // hash is not correct
     if (count($cookieValue) !== 3 || !Security::check($cookieValue[0] . $cookieValue[1], $cookieValue[2])) {
         Cookie::delete($name);
         return $default;
     }
     $value = $cookieValue[0];
     // if content is a serialized array
     if ($v = @unserialize($value)) {
         $value = $v;
     }
     return $value;
 }
예제 #16
0
 /**
  * destroy the current session
  *
  * @access public
  * @return Fuel\Core\Session_Driver
  */
 public function destroy()
 {
     // delete the session cookie
     \Cookie::delete($this->config['cookie_name']);
     // reset the stored session data
     $this->keys = $this->flash = $this->data = array();
     return $this;
 }
 public function loginout()
 {
     Cookie::delete('username');
     Cookie::delete('usertype');
     Cookie::delete('lastlogintime');
     $this->assign("jumpUrl", "__APP__/Index/index");
     $this->success("您已退出成功!");
 }
예제 #18
0
 /**
  * destroy the current session
  *
  * @access	public
  * @return	Fuel\Core\Session_Driver
  */
 public function destroy()
 {
     // delete the session cookie
     \Cookie::delete($this->config['cookie_name'], $this->config['cookie_path'], $this->config['cookie_domain'], null, $this->config['cookie_http_only']);
     // reset the stored session data
     $this->keys = $this->flash = $this->data = array();
     return $this;
 }
예제 #19
0
 function loginout()
 {
     foreach ($_COOKIE as $key => $value) {
         Cookie::delete($key);
         Cookie::clear();
     }
     $this->redirect('Index');
 }
예제 #20
0
	public function action_complete()
	{
		if ($this->token AND $this->token->token !== Arr::get($_GET, 'oauth_token'))
		{
			// Delete the token, it is not valid
			Cookie::delete($this->cookie);

			// Send the user back to the beginning
			$this->request->redirect($this->request->uri(array('action' => 'index')));
		}

		// Get the verifier
		$verifier = Arr::get($_GET, 'oauth_verifier');

		// Store the verifier in the token
		$this->token->verifier($verifier);

		// Exchange the request token for an access token
		$this->token = $this->provider->access_token($this->consumer, $this->token);

		// Store the access token
		Cookie::set($this->cookie, serialize($this->token));

		// At this point, we need to retrieve a unique twitter id for the user.
		// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-account%C2%A0verify_credentials
		// @todo try/catch?
		$response = OAuth_Request::factory('resource', 'GET', 'http://api.twitter.com/1/account/verify_credentials.json')
			->param('oauth_consumer_key', Kohana::config('oauth.twitter.key'))
			->param('oauth_token', $this->token)
			->sign(OAuth_Signature::factory('HMAC-SHA1'), $this->consumer, $this->token)
			->execute();
		$response = json_decode($response);
		if ( ! $twitter_id = (int) $response->id)
			exit('error');

		// Check whether that id exists in our users table (twitter_id field).
		$user = ORM::factory('user')->where('twitter_id', '=', $twitter_id)->find();

		// If not, store the new twitter_id (as a new user). Also ask for signup info like email?
		if ( ! $user->loaded())
		{
			// Add user
			$user->twitter_id = $twitter_id;
			$user->save();

			// Give user the "login" and "user" role
			$user->add('roles', ORM::factory('role', array('name' => 'login')));
			$user->add('roles', ORM::factory('role', array('name' => 'user')));
			// @todo postpone give "user" role until after user completes the email field in his profile?
		}

		// If yes, log the user in and give him a normal auth session.
		Auth::instance()->force_login($user);

		$this->request->redirect('');
	}
예제 #21
0
 public function before()
 {
     //remove all data from previus installation....
     Sentry::logout();
     Config::load('Sentry', true);
     Cookie::delete('sentry_rm');
     Session::delete(Config::get('sentry.session.user'));
     Session::delete(Config::get('sentry.session.provider'));
     parent::before();
 }
예제 #22
0
파일: Session.php 프로젝트: noikiy/kohana
 public function destroy()
 {
     if ($this->_destroyed === FALSE) {
         $this->_destroyed = Cookie::delete($this->_name);
         if ($this->_destroyed) {
             $this->_data = array();
         }
     }
     return $this->_destroyed;
 }
예제 #23
0
파일: logout.php 프로젝트: 25564/Resume
 public function create(array $Params = array())
 {
     if (\Session::exists("UserID")) {
         \Cookie::delete(\Config::get("remember/cookie_name"));
         \DB::getInstance()->table("Users")->where("user_id", \Session::get("UserID"));
         \Session::delete("UserID");
         \Session::flash('homeMessage', 'You were logged out successfully.');
     }
     \Redirect::to("home");
 }
예제 #24
0
파일: admin.php 프로젝트: kerkness/shindig
 public function action_logout()
 {
     $this->template->title = 'logout';
     $this->template->content = View::factory('shindig/admin/logout');
     if (isset($_POST['logout'])) {
         // Delete the user cookie
         Cookie::delete('authorized');
         // Redirect to the home page
         $this->request->redirect('');
     }
 }
예제 #25
0
파일: User.php 프로젝트: JavaTrain/train
 public function logout($id)
 {
     $db = Service::get('pdo');
     $sql = "UPDATE `user` SET\n                    `hash` = :hash\n                    WHERE `id` = :id";
     $stmt = $db->prepare($sql);
     $stmt->execute(array(':hash' => "", ':id' => $id));
     $config = Service::get('config');
     Cookie::delete($config->getVal('remember/cookie_name'));
     $session = Service::get('session');
     $session->delete($config->getVal('session/session_name'));
 }
예제 #26
0
 protected function _destroy()
 {
     if ($this->_update_id === NULL) {
         // Session has not been created yet
         return TRUE;
     }
     $this->_rd->del($this->_update_id);
     // Delete the cookie
     Cookie::delete($this->_name);
     return TRUE;
 }
예제 #27
0
파일: Native.php 프로젝트: Kapitonova/codex
 /**
  * @return  bool
  */
 protected function _destroy()
 {
     // Destroy the current session
     session_destroy();
     // Did destruction work?
     $status = !session_id();
     if ($status) {
         // Make sure the session cannot be restarted
         Cookie::delete($this->_name);
     }
     return $status;
 }
예제 #28
0
 public function action_sign_out()
 {
     $session = Session::instance();
     $user_session = $session->get('user');
     $user_cookie = Cookie::get('user');
     if (empty($user_session)) {
         throw new Exception('Login to logout!');
     }
     if (!empty($user_cookie)) {
         Cookie::delete('user');
     }
     $session->delete('user');
     $this->request->redirect('dashboard');
 }
예제 #29
0
파일: acp.php 프로젝트: raku/My-iShop
 public function action_sign_out()
 {
     $session = Session::instance();
     $user_session = $session->get('admin');
     if (empty($user_session)) {
         $this->request->redirect('acp');
     }
     $session->delete('admin');
     $cookie = Cookie::get('admin');
     if (!empty($cookie)) {
         Cookie::delete('admin');
     }
     $this->request->redirect('acp');
 }
예제 #30
0
파일: logout.php 프로젝트: raku/My-iShop
 public function action_index()
 {
     $session = Session::instance();
     $user_session = $session->get('email');
     $user_cookie = Cookie::get('email');
     if (empty($user_session)) {
         $this->request->redirect('/');
     }
     if (!empty($user_cookie)) {
         Cookie::delete('email');
     }
     $session->delete('email');
     $this->request->redirect('/');
 }