示例#1
2
function islogged()
{
    if (session_status() === PHP_SESSION_ACTIVE) {
        return;
    }
    redirect("login.php");
}
示例#2
1
 /**
  * Identical to the parent constructor, except that
  * we start a PHP session to store the user ID and
  * access token if during the course of execution
  * we discover them.
  *
  * @param array $config the application configuration. Additionally
  * accepts "sharedSession" as a boolean to turn on a secondary
  * cookie for environments with a shared session (that is, your app
  * shares the domain with other apps).
  *
  * @see BaseFacebook::__construct
  */
 public function __construct($config)
 {
     if (function_exists('session_status') && session_status() !== PHP_SESSION_ACTIVE || !session_id()) {
         session_start();
     }
     $_REQUEST += $_GET;
     if ($config == null) {
         $this->_ci =& get_instance();
         $this->_ci->load->config('facebook');
         $config = array('appId' => $this->_ci->config->item('appId'), 'secret' => $this->_ci->config->item('secret'));
     }
     if (!isset($config['appId']) || !isset($config['secret'])) {
         $this->_ci =& get_instance();
         $this->_ci->load->config('facebook');
         //            $config['appId'] = $this->_ci->config->item('appId');
         //            $config['secret'] = $this->_ci->config->item('secret');
         $config['appId'] = '446400522196773';
         $config['secret'] = '0bc289d56447f3ca090be62f4e593fde';
     }
     parent::__construct($config);
     if (!empty($config['sharedSession'])) {
         $this->initSharedSession();
         // re-load the persisted state, since parent
         // attempted to read out of non-shared cookie
         $state = $this->getPersistentData('state');
         if (!empty($state)) {
             $this->state = $state;
         } else {
             $this->state = null;
         }
     }
 }
示例#3
1
 /**
  * @param string $sessionKey
  */
 public function __construct($sessionKey = 'guardian')
 {
     $this->sessionKey = $sessionKey;
     if (session_status() !== PHP_SESSION_ACTIVE) {
         session_start();
     }
 }
示例#4
0
 public function __construct($timeLimit = 900)
 {
     if (session_status() !== PHP_SESSION_ACTIVE) {
         session_start();
     }
     $this->timeLimit = $timeLimit;
 }
示例#5
0
 public function detect()
 {
     if (session_status() === PHP_SESSION_ACTIVE && isset($_SESSION[self::$fieldName]) && !empty($_SESSION[self::$fieldName])) {
         return collator_create($_SESSION[self::$fieldName]);
     }
     return null;
 }
示例#6
0
 /**
  * 登出(移动端手机号登录用户)
  */
 public function submitLogoutAction()
 {
     WkUserService::getInstance()->logout($this->curToken);
     if (session_status() == PHP_SESSION_ACTIVE) {
         unset($_SESSION['appParam']);
     }
 }
示例#7
0
 public static function isUserLogged()
 {
     if (session_status() != PHP_SESSION_NONE && !empty($_SESSION['Auth'])) {
         return true;
     }
     return false;
 }
示例#8
0
 public function __construct()
 {
     if (session_status() !== PHP_SESSION_ACTIVE) {
         @session_start();
     }
     $this->keyServer = '*****@*****.**';
 }
示例#9
0
 public function verifySupport()
 {
     if (session_status() == PHP_SESSION_NONE) {
         return false;
     }
     return true;
 }
示例#10
0
 function __construct()
 {
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     $this->db = new medoo();
 }
 /**
  * Запуск программы, единая точка входа.
  */
 public static function run()
 {
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     $instance = new FrontController();
     try {
         $instance->init();
         $instance->handleRequest();
     } catch (\REXFramework\exceptions\AppException $e) {
         $e->process();
     } catch (\PDOException $e) {
         if (ob_get_length()) {
             ob_end_clean();
         }
         $myException = new \REXFramework\exceptions\AppException($e->getMessage());
         $myException->process();
     } catch (\Exception $e) {
         if (ob_get_length()) {
             ob_end_clean();
         }
         header('HTTP/1.0 404 Not Found');
         echo $e->getMessage();
     }
 }
function _eventorganiser_load_eo_confirmation_page_session()
{
    if (!defined('EVENT_ORGANISER_PRO_DIR') || version_compare('1.9', EVENT_ORGANISER_PRO_VER) > 0) {
        return;
    }
    // Include Eric Mann's WP Session Manager
    // This isn't working for now as requiring it directly like this produces a 'headers already sent' error in PHP, which doesn't happen if
    // the plugin is loaded as normal in WordPress (rather than included as a library here)
    // require(dirname(__FILE__) . '/inc/wp-session-manager/wp-session-manager.php');
    // require(dirname(__FILE__) . '/lib/confirmation-page-session.php');
    require dirname(__FILE__) . '/lib/class-confirmation-page-session.php';
    require dirname(__FILE__) . '/lib/shortcodes.php';
    // Check if wp_session_manager exists. If it does, use it. If it doesn't, fall back to $_SESSSION. If neither exist, display an error
    if (class_exists('WP_Session')) {
        //Don't use PHP sessions as WP_Session exists
        Confirmation_Page_Session::get_instance(false)->init();
    } elseif (session_status() === PHP_SESSION_NONE || session_status() === PHP_SESSION_ACTIVE) {
        // WP_Session doesn't exist, but we can use $_SESSION
        Confirmation_Page_Session::get_instance(true)->init();
    } else {
        //We have neither WP_Session or $_SESSION. Oh dear. Display an error
        add_action('admin_notices', array(Confirmation_Page_Session::get_instance(), 'display_no_session_error'));
    }
    // add_action( 'admin_notices', array(Confirmation_Page_Session::get_instance(), 'display_no_session_error') );
}
 private static function startSessionIfNecessary()
 {
     if (session_status() === PHP_SESSION_NONE) {
         date_default_timezone_set("America/New_York");
         session_start();
     }
 }
示例#14
0
 /**
  * Returns the ID of the user session.
  *
  * Automatically starts the session if necessary.
  *
  * @return string The session ID
  */
 protected function getSessionId()
 {
     if (PHP_SESSION_NONE === session_status()) {
         session_start();
     }
     return session_id();
 }
示例#15
0
 public static function isValid()
 {
     if (session_status() !== PHP_SESSION_ACTIVE) {
         session_start();
     }
     return $_SESSION['user']['time'] - time() < 1800 ? true : false;
 }
示例#16
0
 public function __construct()
 {
     if (session_status() != PHP_SESSION_ACTIVE) {
         session_start();
     }
     ob_start();
 }
示例#17
0
 /**
  * Application constructor. This is the entry point of Calmacil/Mf.
  * @param string $root
  * @param string $env
  */
 public function __construct($root, $env = 'prod')
 {
     parent::__construct($root);
     define('ROOT', $root);
     $this->env = $env;
     $this->cfile = "settings_" . $this->env;
     Config::init(ROOT . '/config/');
     // Loggers
     $rotateHandler = new RotatingFileHandler(ROOT . Config::get($this->cfile)->log->logfile, 10, Config::get($this->cfile)->log->loglevel);
     $processor = new PsrLogMessageProcessor();
     $this->loggers['core'] = new Logger('core');
     $this->loggers['app'] = new Logger('app');
     $this->loggers['core']->pushHandler($rotateHandler);
     $this->loggers['app']->pushHandler($rotateHandler);
     $this->loggers['core']->pushProcessor($processor);
     $this->loggers['app']->pushProcessor($processor);
     if (Config::get($this->cfile)->debug) {
         $browserHandler = new BrowserConsoleHandler();
         $this->loggers['core']->pushHandler($browserHandler);
         $this->loggers['app']->pushHandler($browserHandler);
     }
     $this->coreLogger()->addNotice("============================================================");
     // Session service handling
     if (session_status() !== PHP_SESSION_DISABLED) {
         $this["session"] = new SessionPlugin($this);
     }
     $this->router = Router::getInstance(ROOT . Config::get($this->cfile)->paths->routing_file, $this);
     $this->request = new Request($this, $_SERVER['REQUEST_URI']);
     $this->response = new Response($this);
     $this->coreLogger()->addNotice("------------------------------------------------------------");
     $this->coreLogger()->addNotice("Application initialized.");
 }
示例#18
0
 /**
  * Checks If Session Has Already Been Created
  * @return bool
  */
 public function getSessionStatus()
 {
     if (session_status() == PHP_SESSION_NONE) {
         return false;
     }
     return true;
 }
 function check_login()
 {
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     $fp = $this->fingerprint();
     $post = $_POST;
     // to sanitize ?
     // logout action
     if (isset($post['logout'])) {
         unset($_SESSION[$fp]);
         return;
     }
     // login action
     if (isset($post['login']) && isset($post['password'])) {
         return $this->login($post['login'], $post['password'], $fp);
     }
     // session login (already logged)
     if (!isset($_SESSION[$fp])) {
         return;
     }
     $name = $_SESSION[$fp]['name'];
     $pass = $_SESSION[$fp]['password'];
     $logged = $this->login($name, $pass, $fp);
     if ($logged) {
         return true;
     }
     unset($_SESSION[$fp]);
     return;
 }
示例#20
0
 public function __construct(DAL $dal)
 {
     if (\session_status() == PHP_SESSION_NONE) {
         assert("No session started");
     }
     $this->dal = $dal;
 }
示例#21
0
 public function __construct($name = null)
 {
     parent::__construct($name);
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
 }
示例#22
0
 public function startSession()
 {
     if (session_status() !== PHP_SESSION_ACTIVE) {
         session_cache_limiter(false);
         session_start();
     }
 }
示例#23
0
文件: Login.php 项目: baaslk/baas.lk
 public function __construct()
 {
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     //login with session data
     if (isset($_GET["logout"])) {
         $this->Logout();
     } else {
         if (isset($_COOKIE['rememberme'])) {
             $this->loginWithCookies();
         } else {
             if (!empty($_SESSION['username']) && $_SESSION['loginstatus'] == 1) {
                 //echo "session";
                 $this->loginWithSessionData();
             } else {
                 if (isset($_POST["login"])) {
                     if (!isset($_POST['user_rememberme'])) {
                         $_POST['user_rememberme'] = null;
                     }
                     $this->loginWithPostData($_POST['user_name'], $_POST['user_password'], $_POST['user_rememberme']);
                 }
             }
         }
     }
 }
 public function fixSession()
 {
     if ($this->isEnabled()) {
         return;
     }
     $sessionName = session_name();
     $arrays = [&$_GET, &$_POST, &$_COOKIE];
     foreach ($arrays as $k => $arr) {
         if (isset($arrays[$k][$sessionName]) && strlen($arrays[$k][$sessionName]) > 32) {
             switch ($this->actionOnCorruptedId) {
                 case self::ACTION_EXCEPTION:
                     throw new \Exception("Invalid session id");
                 case self::ACTION_HTTP_EXCEPTION:
                     unset($arrays[$k][$sessionName]);
                     throw new HttpException("Invalid session id. Recreated id.", 400, null, "Bad request");
                 default:
                     unset($arrays[$k][$sessionName]);
             }
         }
     }
     if (PHP_SESSION_NONE === session_status()) {
         try {
             session_start();
         } catch (\Exception $e) {
             switch ($this->actionOnCorruptedId) {
                 case self::ACTION_EXCEPTION:
                     throw new \Exception("Invalid session id");
                 case self::ACTION_HTTP_EXCEPTION:
                     throw new HttpException("Invalid session id. Recreated id.", 400, null, "Bad request");
                 default:
                     session_start();
             }
         }
     }
 }
示例#25
0
 /**
  * Class constructor. Gets the new prefix from the global settings.
  *
  */
 public function __construct()
 {
     $this->_sPrefix = Phpfox::getParam('core.session_prefix');
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
 }
示例#26
0
 /**
  * Init
  */
 public function start()
 {
     session_name('SESSID');
     if (session_status() === PHP_SESSION_NONE) {
         session_start();
     }
 }
示例#27
0
文件: User.php 项目: openclerk/users
 /**
  * Get the current logged in user instance, or {@code null} if
  * there is none, based on session variables.
  *
  * @return the {@link User} logged in or {@code null} if none
  */
 static function getInstance(\Db\Connection $db)
 {
     if (User::$instance === null) {
         if (session_status() === PHP_SESSION_NONE) {
             throw new UserStatusException("Session needs to be started before requesting User instance");
         }
         // try autologin if we don't have session variables set
         $used_auto_login = false;
         if (!isset($_SESSION['user_id']) && !isset($_SESSION['user_key']) && !isset($_SESSION['no_autologin'])) {
             User::tryAutoLogin();
             $used_auto_login = true;
         }
         // if the session variables are still not set after autologin, bail
         if (!isset($_SESSION['user_id']) && !isset($_SESSION['user_key'])) {
             return User::$instance;
         }
         // now try to find the valid user
         $q = $db->prepare("SELECT * FROM user_valid_keys WHERE user_id=? AND user_key=? LIMIT 1");
         $q->execute(array($_SESSION['user_id'], $_SESSION['user_key']));
         if ($user = $q->fetch()) {
             // find the associated user
             User::$instance = User::findUser($db, $user['user_id']);
             if (User::$instance) {
                 User::$instance->is_auto_logged_in = $used_auto_login;
             }
         }
     }
     return User::$instance;
 }
示例#28
0
 function __construct()
 {
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     /* session is started if you don't write this line can't use $_Session  global variable */
 }
示例#29
0
 /**
  * Destroy session
  *
  * @access public
  * @return void
  */
 public function destroy()
 {
     if (PHP_SESSION_ACTIVE === session_status()) {
         session_unset();
         session_destroy();
     }
 }
 function __construct()
 {
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     $this->session__status = isset($_SESSION['username']);
 }