@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * @param $className |
| 17 | 17 | */ |
| 18 | 18 | spl_autoload_register( |
| 19 | - function ($className) {
|
|
| 19 | + function($className) {
|
|
| 20 | 20 | if ($className === 'O2System\Session') {
|
| 21 | 21 | require __DIR__ . DIRECTORY_SEPARATOR . 'Session.php'; |
| 22 | 22 | } elseif (strpos($className, 'O2System\Session\\') === false) {
|
@@ -89,26 +89,26 @@ discard block |
||
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if (isset($this->config[ 'servers' ])) { |
|
| 93 | - foreach ($this->config[ 'servers' ] as $server => $setup) { |
|
| 94 | - isset($setup[ 'port' ]) OR $setup[ 'port' ] = 11211; |
|
| 95 | - isset($setup[ 'weight' ]) OR $setup[ 'weight' ] = 1; |
|
| 92 | + if (isset($this->config['servers'])) { |
|
| 93 | + foreach ($this->config['servers'] as $server => $setup) { |
|
| 94 | + isset($setup['port']) OR $setup['port'] = 11211; |
|
| 95 | + isset($setup['weight']) OR $setup['weight'] = 1; |
|
| 96 | 96 | |
| 97 | 97 | // Third parameter is persistance and defaults to TRUE. |
| 98 | 98 | $this->memcache->addServer( |
| 99 | - $setup[ 'host' ], |
|
| 100 | - $setup[ 'port' ], |
|
| 99 | + $setup['host'], |
|
| 100 | + $setup['port'], |
|
| 101 | 101 | true, |
| 102 | - $setup[ 'weight' ] |
|
| 102 | + $setup['weight'] |
|
| 103 | 103 | ); |
| 104 | 104 | } |
| 105 | 105 | } else { |
| 106 | 106 | // Third parameter is persistance and defaults to TRUE. |
| 107 | 107 | $this->memcache->addServer( |
| 108 | - $this->config[ 'host' ], |
|
| 109 | - $this->config[ 'port' ], |
|
| 108 | + $this->config['host'], |
|
| 109 | + $this->config['port'], |
|
| 110 | 110 | true, |
| 111 | - $this->config[ 'weight' ] |
|
| 111 | + $this->config['weight'] |
|
| 112 | 112 | ); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | $this->prefixKey . $session_id, |
| 342 | 342 | $session_data, |
| 343 | 343 | false, |
| 344 | - $this->config[ 'lifetime' ] |
|
| 344 | + $this->config['lifetime'] |
|
| 345 | 345 | ) |
| 346 | 346 | ) { |
| 347 | 347 | $this->fingerprint = $fingerprint; |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | return $this->memcache->replace($this->prefixKey . $session_id, $session_data, false, |
| 356 | - $this->config[ 'lifetime' ]); |
|
| 356 | + $this->config['lifetime']); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | return false; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | apcu_store($this->lockKey, time(), 300); |
| 284 | 284 | |
| 285 | 285 | if ($this->fingerprint !== ($fingerprint = md5($sessionData))) { |
| 286 | - if (apcu_store($this->prefixKey . $session_id, $sessionData, $this->config[ 'lifetime' ])) { |
|
| 286 | + if (apcu_store($this->prefixKey . $session_id, $sessionData, $this->config['lifetime'])) { |
|
| 287 | 287 | $this->fingerprint = $fingerprint; |
| 288 | 288 | |
| 289 | 289 | return true; |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | return false; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - return apcu_store($this->prefixKey . $session_id, $sessionData, $this->config[ 'lifetime' ]); |
|
| 295 | + return apcu_store($this->prefixKey . $session_id, $sessionData, $this->config['lifetime']); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | return false; |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | if (wincache_ucache_set( |
| 287 | 287 | $this->prefixKey . $session_id, |
| 288 | 288 | $session_data, |
| 289 | - $this->config[ 'lifetime' ] |
|
| 289 | + $this->config['lifetime'] |
|
| 290 | 290 | )) {
|
| 291 | 291 | $this->fingerprint = $fingerprint; |
| 292 | 292 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | return false; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - return wincache_ucache_set($this->prefixKey . $session_id, $session_data, $this->config[ 'lifetime' ]); |
|
| 299 | + return wincache_ucache_set($this->prefixKey . $session_id, $session_data, $this->config['lifetime']); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | return false; |
@@ -90,22 +90,22 @@ discard block |
||
| 90 | 90 | return false; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if (isset($this->config[ 'servers' ])) {
|
|
| 94 | - foreach ($this->config[ 'servers' ] as $server => $setup) {
|
|
| 95 | - isset($setup[ 'port' ]) OR $setup[ 'port' ] = 11211; |
|
| 96 | - isset($setup[ 'weight' ]) OR $setup[ 'weight' ] = 1; |
|
| 93 | + if (isset($this->config['servers'])) {
|
|
| 94 | + foreach ($this->config['servers'] as $server => $setup) {
|
|
| 95 | + isset($setup['port']) OR $setup['port'] = 11211; |
|
| 96 | + isset($setup['weight']) OR $setup['weight'] = 1; |
|
| 97 | 97 | |
| 98 | 98 | $this->memcached->addServer( |
| 99 | - $setup[ 'host' ], |
|
| 100 | - $setup[ 'port' ], |
|
| 101 | - $setup[ 'weight' ] |
|
| 99 | + $setup['host'], |
|
| 100 | + $setup['port'], |
|
| 101 | + $setup['weight'] |
|
| 102 | 102 | ); |
| 103 | 103 | } |
| 104 | 104 | } else {
|
| 105 | 105 | $this->memcached->addServer( |
| 106 | - $this->config[ 'host' ], |
|
| 107 | - $this->config[ 'port' ], |
|
| 108 | - $this->config[ 'weight' ] |
|
| 106 | + $this->config['host'], |
|
| 107 | + $this->config['port'], |
|
| 108 | + $this->config['weight'] |
|
| 109 | 109 | ); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | if ($this->memcached->set( |
| 338 | 338 | $this->prefixKey . $session_id, |
| 339 | 339 | $session_data, |
| 340 | - $this->config[ 'lifetime' ] |
|
| 340 | + $this->config['lifetime'] |
|
| 341 | 341 | ) |
| 342 | 342 | ) {
|
| 343 | 343 | $this->fingerprint = $fingerprint; |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | return false; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - return $this->memcached->touch($this->prefixKey . $session_id, $this->config[ 'lifetime' ]); |
|
| 351 | + return $this->memcached->touch($this->prefixKey . $session_id, $this->config['lifetime']); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | return false; |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | try {
|
| 95 | 95 | if ( ! $this->redis->connect( |
| 96 | - $this->config[ 'host' ], |
|
| 97 | - ($this->config[ 'host' ][ 0 ] === '/' ? 0 |
|
| 98 | - : $this->config[ 'port' ]), |
|
| 99 | - $this->config[ 'timeout' ] |
|
| 96 | + $this->config['host'], |
|
| 97 | + ($this->config['host'][0] === '/' ? 0 |
|
| 98 | + : $this->config['port']), |
|
| 99 | + $this->config['timeout'] |
|
| 100 | 100 | ) |
| 101 | 101 | ) {
|
| 102 | 102 | if ($this->logger instanceof LoggerInterface) {
|
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | return false; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if (isset($this->config[ 'password' ]) AND ! $this->redis->auth($this->config[ 'password' ])) {
|
|
| 109 | + if (isset($this->config['password']) AND ! $this->redis->auth($this->config['password'])) {
|
|
| 110 | 110 | if ($this->logger instanceof LoggerInterface) {
|
| 111 | 111 | $this->logger->error('SESSION_E_REDIS_AUTHENTICATION_FAILED', ['Redis']);
|
| 112 | 112 | } |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | $this->redis->setTimeout($this->lockKey, 300); |
| 351 | 351 | |
| 352 | 352 | if ($this->fingerprint !== ($fingerprint = md5($session_data))) {
|
| 353 | - if ($this->redis->set($this->prefixKey . $session_id, $session_data, $this->config[ 'lifetime' ])) {
|
|
| 353 | + if ($this->redis->set($this->prefixKey . $session_id, $session_data, $this->config['lifetime'])) {
|
|
| 354 | 354 | $this->fingerprint = $fingerprint; |
| 355 | 355 | |
| 356 | 356 | return true; |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | return false; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - return $this->redis->setTimeout($this->prefixKey . $session_id, $this->config[ 'lifetime' ]); |
|
| 362 | + return $this->redis->setTimeout($this->prefixKey . $session_id, $this->config['lifetime']); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | return false; |
@@ -88,7 +88,7 @@ |
||
| 88 | 88 | $this->logger->error('SESSION_E_PLATFORM_UNSUPPORTED', ['Redis']);
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - z |
|
| 91 | + z |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | try {
|
@@ -32,33 +32,33 @@ discard block |
||
| 32 | 32 | public function __construct(array $config) |
| 33 | 33 | {
|
| 34 | 34 | // Define Session Name |
| 35 | - $config[ 'name' ] = isset($config[ 'name' ]) ? $config[ 'name' ] : 'o2session'; |
|
| 35 | + $config['name'] = isset($config['name']) ? $config['name'] : 'o2session'; |
|
| 36 | 36 | |
| 37 | 37 | // Define Session Match IP |
| 38 | - $config[ 'match' ][ 'ip' ] = isset($config[ 'match' ][ 'ip' ]) ? $config[ 'match' ][ 'ip' ] : false; |
|
| 38 | + $config['match']['ip'] = isset($config['match']['ip']) ? $config['match']['ip'] : false; |
|
| 39 | 39 | |
| 40 | 40 | // Re-Define Session Name base on Match IP |
| 41 | - $config[ 'name' ] = $config[ 'name' ] . ':' . ($config[ 'match' ][ 'ip' ] ? $_SERVER[ 'REMOTE_ADDR' ] . ':' : ''); |
|
| 42 | - $config[ 'name' ] = rtrim($config[ 'name' ], ':'); |
|
| 41 | + $config['name'] = $config['name'] . ':' . ($config['match']['ip'] ? $_SERVER['REMOTE_ADDR'] . ':' : ''); |
|
| 42 | + $config['name'] = rtrim($config['name'], ':'); |
|
| 43 | 43 | |
| 44 | - if (isset($config[ 'handler' ])) {
|
|
| 45 | - $config[ 'handler' ] = $config[ 'handler' ] === 'files' ? 'file' : $config[ 'handler' ]; |
|
| 44 | + if (isset($config['handler'])) {
|
|
| 45 | + $config['handler'] = $config['handler'] === 'files' ? 'file' : $config['handler']; |
|
| 46 | 46 | // $config[ 'handler' ] = $config[ 'handler' ] === 'memcache' ? 'memcached' : $config[ 'handler' ]; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if ($config[ 'handler' ] === 'file') {
|
|
| 50 | - if (isset($config[ 'filePath' ])) {
|
|
| 51 | - $config[ 'filePath' ] = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $config[ 'filePath' ]); |
|
| 49 | + if ($config['handler'] === 'file') {
|
|
| 50 | + if (isset($config['filePath'])) {
|
|
| 51 | + $config['filePath'] = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $config['filePath']); |
|
| 52 | 52 | |
| 53 | - if ( ! is_dir($config[ 'filePath' ])) {
|
|
| 53 | + if ( ! is_dir($config['filePath'])) {
|
|
| 54 | 54 | if (defined('PATH_CACHE')) {
|
| 55 | - $config[ 'filePath' ] = PATH_CACHE . $config[ 'filePath' ]; |
|
| 55 | + $config['filePath'] = PATH_CACHE . $config['filePath']; |
|
| 56 | 56 | } else {
|
| 57 | - $config[ 'filePath' ] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $config[ 'filePath' ]; |
|
| 57 | + $config['filePath'] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $config['filePath']; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | } elseif (defined('PATH_CACHE')) {
|
| 61 | - $config[ 'filePath' ] = PATH_CACHE . 'sessions'; |
|
| 61 | + $config['filePath'] = PATH_CACHE . 'sessions'; |
|
| 62 | 62 | } else {
|
| 63 | 63 | $this->path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . implode( |
| 64 | 64 | DIRECTORY_SEPARATOR, |
@@ -66,37 +66,37 @@ discard block |
||
| 66 | 66 | ); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $config[ 'filePath' ] = rtrim($config[ 'filePath' ], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
| 69 | + $config['filePath'] = rtrim($config['filePath'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
| 70 | 70 | |
| 71 | - if ( ! is_writable($config[ 'filePath' ])) {
|
|
| 72 | - if ( ! file_exists($config[ 'filePath' ])) {
|
|
| 73 | - @mkdir($config[ 'filePath' ], 0777, true); |
|
| 71 | + if ( ! is_writable($config['filePath'])) {
|
|
| 72 | + if ( ! file_exists($config['filePath'])) {
|
|
| 73 | + @mkdir($config['filePath'], 0777, true); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if (empty($config[ 'cookie' ]) AND php_sapi_name() !== 'cli') {
|
|
| 79 | - $config[ 'cookie' ] = [ |
|
| 78 | + if (empty($config['cookie']) AND php_sapi_name() !== 'cli') {
|
|
| 79 | + $config['cookie'] = [ |
|
| 80 | 80 | 'name' => 'o2session', |
| 81 | 81 | 'lifetime' => 7200, |
| 82 | - 'domain' => isset($_SERVER[ 'HTTP_HOST' ]) ? $_SERVER[ 'HTTP_HOST' ] : $_SERVER[ 'SERVER_NAME' ], |
|
| 82 | + 'domain' => isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'], |
|
| 83 | 83 | 'path' => '/', |
| 84 | 84 | 'secure' => false, |
| 85 | 85 | 'httpOnly' => false, |
| 86 | 86 | ]; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if ( ! isset($config[ 'regenerate' ])) {
|
|
| 90 | - $config[ 'regenerate' ][ 'destroy' ] = false; |
|
| 91 | - $config[ 'regenerate' ][ 'lifetime' ] = 600; |
|
| 89 | + if ( ! isset($config['regenerate'])) {
|
|
| 90 | + $config['regenerate']['destroy'] = false; |
|
| 91 | + $config['regenerate']['lifetime'] = 600; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ( ! isset($config[ 'lifetime' ])) {
|
|
| 95 | - $config[ 'lifetime' ] = $config[ 'cookie' ][ 'lifetime' ]; |
|
| 94 | + if ( ! isset($config['lifetime'])) {
|
|
| 95 | + $config['lifetime'] = $config['cookie']['lifetime']; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( ! isset($config[ 'path' ])) {
|
|
| 99 | - $config[ 'path' ] = '/'; |
|
| 98 | + if ( ! isset($config['path'])) {
|
|
| 99 | + $config['path'] = '/'; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | parent::__construct($config, Config::CAMELCASE_OFFSET); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function open($save_path, $name) |
| 82 | 82 | {
|
| 83 | - $this->path = $this->config[ 'filePath' ]; |
|
| 83 | + $this->path = $this->config['filePath']; |
|
| 84 | 84 | |
| 85 | 85 | if ($this->isSupported() === false) {
|
| 86 | 86 | if ($this->logger instanceof LoggerInterface) {
|
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | $this->filePath = $this->path |
| 94 | 94 | . $name . '-' // we'll use the session cookie name as a prefix to avoid collisions |
| 95 | - . ($this->config[ 'match' ]->ip ? md5($_SERVER[ 'REMOTE_ADDR' ]) . '-' : ''); |
|
| 95 | + . ($this->config['match']->ip ? md5($_SERVER['REMOTE_ADDR']) . '-' : ''); |
|
| 96 | 96 | |
| 97 | 97 | return $this->success; |
| 98 | 98 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | while (($file = readdir($directory)) !== false) {
|
| 213 | 213 | // If the filename doesn't match this pattern, it's either not a session file or is not ours |
| 214 | - if ( ! preg_match('/[' . $this->config[ 'name' ] . '-]+[0-9-a-f]+/', $file)
|
|
| 214 | + if ( ! preg_match('/[' . $this->config['name'] . '-]+[0-9-a-f]+/', $file)
|
|
| 215 | 215 | || ! is_file($this->path . '/' . $file) |
| 216 | 216 | || ($mtime = filemtime($this->path . '/' . $file)) === false |
| 217 | 217 | || $mtime > $ts |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function setLogger(LoggerInterface $logger) |
| 114 | 114 | {
|
| 115 | - $this->logger =& $logger; |
|
| 115 | + $this->logger = & $logger; |
|
| 116 | 116 | |
| 117 | 117 | // Load Session Language |
| 118 | 118 | language()->loadFile('session');
|
@@ -156,12 +156,12 @@ discard block |
||
| 156 | 156 | session_set_save_handler($this->handler, true); |
| 157 | 157 | |
| 158 | 158 | // Sanitize the cookie, because apparently PHP doesn't do that for userspace handlers |
| 159 | - if (isset($_COOKIE[ $this->config[ 'name' ] ]) && ( |
|
| 160 | - ! is_string($_COOKIE[ $this->config[ 'name' ] ]) || ! preg_match('#\A' . $this->sidRegexp . '\z#',
|
|
| 161 | - $_COOKIE[ $this->config[ 'name' ] ]) |
|
| 159 | + if (isset($_COOKIE[$this->config['name']]) && ( |
|
| 160 | + ! is_string($_COOKIE[$this->config['name']]) || ! preg_match('#\A' . $this->sidRegexp . '\z#',
|
|
| 161 | + $_COOKIE[$this->config['name']]) |
|
| 162 | 162 | ) |
| 163 | 163 | ) {
|
| 164 | - unset($_COOKIE[ $this->config[ 'name' ] ]); |
|
| 164 | + unset($_COOKIE[$this->config['name']]); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -176,37 +176,37 @@ discard block |
||
| 176 | 176 | $this->initializeVariables(); |
| 177 | 177 | |
| 178 | 178 | // Sanitize the cookie, because apparently PHP doesn't do that for userspace handlers |
| 179 | - if (isset($_COOKIE[ $this->config[ 'name' ] ]) && ( |
|
| 180 | - ! is_string($this->config[ 'name' ]) || |
|
| 181 | - ! preg_match('#\A' . $this->sidRegexp . '\z#', $_COOKIE[ $this->config[ 'name' ] ]
|
|
| 179 | + if (isset($_COOKIE[$this->config['name']]) && ( |
|
| 180 | + ! is_string($this->config['name']) || |
|
| 181 | + ! preg_match('#\A' . $this->sidRegexp . '\z#', $_COOKIE[$this->config['name']]
|
|
| 182 | 182 | ) |
| 183 | 183 | ) |
| 184 | 184 | ) {
|
| 185 | - unset($_COOKIE[ $this->config[ 'name' ] ]); |
|
| 185 | + unset($_COOKIE[$this->config['name']]); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // Is session ID auto-regeneration configured? (ignoring ajax requests) |
| 189 | - if ((empty($_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) || |
|
| 190 | - strtolower($_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) !== 'xmlhttprequest') && |
|
| 191 | - ($regenerateTime = $this->config[ 'regenerate' ]->lifetime) > 0 |
|
| 189 | + if ((empty($_SERVER['HTTP_X_REQUESTED_WITH']) || |
|
| 190 | + strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest') && |
|
| 191 | + ($regenerateTime = $this->config['regenerate']->lifetime) > 0 |
|
| 192 | 192 | ) {
|
| 193 | - if ( ! isset($_SESSION[ 'last_regenerate' ])) {
|
|
| 194 | - $_SESSION[ 'last_regenerate' ] = time(); |
|
| 195 | - } elseif ($_SESSION[ 'last_regenerate' ] < (time() - $regenerateTime)) {
|
|
| 193 | + if ( ! isset($_SESSION['last_regenerate'])) {
|
|
| 194 | + $_SESSION['last_regenerate'] = time(); |
|
| 195 | + } elseif ($_SESSION['last_regenerate'] < (time() - $regenerateTime)) {
|
|
| 196 | 196 | $this->regenerate(); |
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | // Another work-around ... PHP doesn't seem to send the session cookie |
| 200 | 200 | // unless it is being currently created or regenerated |
| 201 | - elseif (isset($_COOKIE[ $this->config[ 'name' ] ]) && $_COOKIE[ $this->config[ 'name' ] ] === session_id() |
|
| 201 | + elseif (isset($_COOKIE[$this->config['name']]) && $_COOKIE[$this->config['name']] === session_id() |
|
| 202 | 202 | ) {
|
| 203 | 203 | setcookie( |
| 204 | - $this->config[ 'name' ], |
|
| 204 | + $this->config['name'], |
|
| 205 | 205 | session_id(), |
| 206 | - (empty($this->config[ 'lifetime' ]) ? 0 : time() + $this->config[ 'lifetime' ]), |
|
| 207 | - $this->config[ 'cookie' ]->path, |
|
| 208 | - '.' . ltrim($this->config[ 'cookie' ]->domain, '.'), |
|
| 209 | - $this->config[ 'cookie' ]->secure, |
|
| 206 | + (empty($this->config['lifetime']) ? 0 : time() + $this->config['lifetime']), |
|
| 207 | + $this->config['cookie']->path, |
|
| 208 | + '.' . ltrim($this->config['cookie']->domain, '.'), |
|
| 209 | + $this->config['cookie']->secure, |
|
| 210 | 210 | true |
| 211 | 211 | ); |
| 212 | 212 | } |
@@ -227,23 +227,23 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | private function setConfiguration() |
| 229 | 229 | {
|
| 230 | - ini_set('session.name', $this->config[ 'name' ]);
|
|
| 230 | + ini_set('session.name', $this->config['name']);
|
|
| 231 | 231 | |
| 232 | - if (empty($this->config[ 'lifetime' ])) {
|
|
| 233 | - $this->config[ 'lifetime' ] = (int)ini_get('session.gc_maxlifetime');
|
|
| 232 | + if (empty($this->config['lifetime'])) {
|
|
| 233 | + $this->config['lifetime'] = (int)ini_get('session.gc_maxlifetime');
|
|
| 234 | 234 | } else {
|
| 235 | - ini_set('session.gc_maxlifetime', (int)$this->config[ 'lifetime' ]);
|
|
| 235 | + ini_set('session.gc_maxlifetime', (int)$this->config['lifetime']);
|
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - if (empty($this->config[ 'cookie' ]->domain)) {
|
|
| 239 | - $this->config[ 'cookie' ]->domain = (isset($_SERVER[ 'HTTP_HOST' ]) ? $_SERVER[ 'HTTP_HOST' ] |
|
| 240 | - : (isset($_SERVER[ 'SERVER_NAME' ]) ? $_SERVER[ 'SERVER_NAME' ] : null)); |
|
| 238 | + if (empty($this->config['cookie']->domain)) {
|
|
| 239 | + $this->config['cookie']->domain = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] |
|
| 240 | + : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null)); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - $this->config[ 'cookie' ]->domain = ltrim($this->config[ 'cookie' ]->domain, '.'); |
|
| 243 | + $this->config['cookie']->domain = ltrim($this->config['cookie']->domain, '.'); |
|
| 244 | 244 | |
| 245 | - ini_set('session.cookie_domain', '.' . $this->config[ 'cookie' ]->domain);
|
|
| 246 | - ini_set('session.cookie_path', $this->config[ 'cookie' ]->path);
|
|
| 245 | + ini_set('session.cookie_domain', '.' . $this->config['cookie']->domain);
|
|
| 246 | + ini_set('session.cookie_path', $this->config['cookie']->path);
|
|
| 247 | 247 | |
| 248 | 248 | // Security is king |
| 249 | 249 | ini_set('session.cookie_lifetime', 0);
|
@@ -330,25 +330,25 @@ discard block |
||
| 330 | 330 | */ |
| 331 | 331 | private function initializeVariables() |
| 332 | 332 | {
|
| 333 | - if (empty($_SESSION[ 'system_variables' ])) {
|
|
| 333 | + if (empty($_SESSION['system_variables'])) {
|
|
| 334 | 334 | return; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | $currentTime = time(); |
| 338 | 338 | |
| 339 | - foreach ($_SESSION[ 'system_variables' ] as $key => &$value) {
|
|
| 339 | + foreach ($_SESSION['system_variables'] as $key => &$value) {
|
|
| 340 | 340 | if ($value === 'new') {
|
| 341 | - $_SESSION[ 'system_variables' ][ $key ] = 'old'; |
|
| 341 | + $_SESSION['system_variables'][$key] = 'old'; |
|
| 342 | 342 | } |
| 343 | 343 | // Hacky, but 'old' will (implicitly) always be less than time() ;) |
| 344 | 344 | // DO NOT move this above the 'new' check! |
| 345 | 345 | elseif ($value < $currentTime) {
|
| 346 | - unset($_SESSION[ $key ], $_SESSION[ 'system_variables' ][ $key ]); |
|
| 346 | + unset($_SESSION[$key], $_SESSION['system_variables'][$key]); |
|
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - if (empty($_SESSION[ 'system_variables' ])) {
|
|
| 351 | - unset($_SESSION[ 'system_variables' ]); |
|
| 350 | + if (empty($_SESSION['system_variables'])) {
|
|
| 351 | + unset($_SESSION['system_variables']); |
|
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | |
@@ -361,8 +361,8 @@ discard block |
||
| 361 | 361 | */ |
| 362 | 362 | public function regenerate() |
| 363 | 363 | {
|
| 364 | - $_SESSION[ 'last_regenerate' ] = time(); |
|
| 365 | - session_regenerate_id($this->config[ 'regenerate' ]->destroy); |
|
| 364 | + $_SESSION['last_regenerate'] = time(); |
|
| 365 | + session_regenerate_id($this->config['regenerate']->destroy); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | //-------------------------------------------------------------------- |
@@ -396,12 +396,12 @@ discard block |
||
| 396 | 396 | public function stop() |
| 397 | 397 | {
|
| 398 | 398 | setcookie( |
| 399 | - $this->config[ 'name' ], |
|
| 399 | + $this->config['name'], |
|
| 400 | 400 | session_id(), |
| 401 | 401 | 1, |
| 402 | - $this->config[ 'cookie' ]->path, |
|
| 403 | - '.' . ltrim($this->config[ 'cookie' ]->domain, '.'), |
|
| 404 | - $this->config[ 'cookie' ]->secure, |
|
| 402 | + $this->config['cookie']->path, |
|
| 403 | + '.' . ltrim($this->config['cookie']->domain, '.'), |
|
| 404 | + $this->config['cookie']->secure, |
|
| 405 | 405 | true |
| 406 | 406 | ); |
| 407 | 407 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | */ |
| 461 | 461 | public function offsetExists($offset) |
| 462 | 462 | {
|
| 463 | - return (bool)isset($_SESSION[ $offset ]); |
|
| 463 | + return (bool)isset($_SESSION[$offset]); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | // ------------------------------------------------------------------------ |
@@ -495,14 +495,14 @@ discard block |
||
| 495 | 495 | public function &__get($offset) |
| 496 | 496 | {
|
| 497 | 497 | if ($offset === 'id') {
|
| 498 | - $_SESSION[ 'id' ] = session_id(); |
|
| 498 | + $_SESSION['id'] = session_id(); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | - if ( ! isset($_SESSION[ $offset ])) {
|
|
| 502 | - $_SESSION[ $offset ] = null; |
|
| 501 | + if ( ! isset($_SESSION[$offset])) {
|
|
| 502 | + $_SESSION[$offset] = null; |
|
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - return $_SESSION[ $offset ]; |
|
| 505 | + return $_SESSION[$offset]; |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | // ------------------------------------------------------------------------ |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | */ |
| 543 | 543 | public function offsetSet($offset, $value) |
| 544 | 544 | {
|
| 545 | - $_SESSION[ $offset ] =& $value; |
|
| 545 | + $_SESSION[$offset] = & $value; |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | // ------------------------------------------------------------------------ |
@@ -580,8 +580,8 @@ discard block |
||
| 580 | 580 | */ |
| 581 | 581 | public function offsetUnset($offset) |
| 582 | 582 | {
|
| 583 | - if (isset($_SESSION[ $offset ])) {
|
|
| 584 | - unset($_SESSION[ $offset ]); |
|
| 583 | + if (isset($_SESSION[$offset])) {
|
|
| 584 | + unset($_SESSION[$offset]); |
|
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | 587 | |
@@ -644,13 +644,13 @@ discard block |
||
| 644 | 644 | {
|
| 645 | 645 | if (is_array($offset)) {
|
| 646 | 646 | foreach ($offset as $key => &$value) {
|
| 647 | - $_SESSION[ $key ] = $value; |
|
| 647 | + $_SESSION[$key] = $value; |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | return; |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - $_SESSION[ $offset ] =& $value; |
|
| 653 | + $_SESSION[$offset] = & $value; |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | //-------------------------------------------------------------------- |
@@ -668,26 +668,26 @@ discard block |
||
| 668 | 668 | {
|
| 669 | 669 | if (is_array($offset)) {
|
| 670 | 670 | for ($i = 0, $c = count($offset); $i < $c; $i++) {
|
| 671 | - if ( ! isset($_SESSION[ $offset[ $i ] ])) {
|
|
| 671 | + if ( ! isset($_SESSION[$offset[$i]])) {
|
|
| 672 | 672 | return false; |
| 673 | 673 | } |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | $new = array_fill_keys($offset, 'new'); |
| 677 | 677 | |
| 678 | - $_SESSION[ 'system_variables' ] = isset($_SESSION[ 'system_variables' ]) ? array_merge( |
|
| 679 | - $_SESSION[ 'system_variables' ], |
|
| 678 | + $_SESSION['system_variables'] = isset($_SESSION['system_variables']) ? array_merge( |
|
| 679 | + $_SESSION['system_variables'], |
|
| 680 | 680 | $new |
| 681 | 681 | ) : $new; |
| 682 | 682 | |
| 683 | 683 | return true; |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - if ( ! isset($_SESSION[ $offset ])) {
|
|
| 686 | + if ( ! isset($_SESSION[$offset])) {
|
|
| 687 | 687 | return false; |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | - $_SESSION[ 'system_variables' ][ $offset ] = 'new'; |
|
| 690 | + $_SESSION['system_variables'][$offset] = 'new'; |
|
| 691 | 691 | |
| 692 | 692 | return true; |
| 693 | 693 | } |
@@ -725,10 +725,10 @@ discard block |
||
| 725 | 725 | public function offsetGet($offset) |
| 726 | 726 | {
|
| 727 | 727 | if ($offset === 'id') {
|
| 728 | - $_SESSION[ 'id' ] = session_id(); |
|
| 728 | + $_SESSION['id'] = session_id(); |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | - return (isset($_SESSION[ $offset ])) ? $_SESSION[ $offset ] : false; |
|
| 731 | + return (isset($_SESSION[$offset])) ? $_SESSION[$offset] : false; |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | //-------------------------------------------------------------------- |
@@ -746,15 +746,15 @@ discard block |
||
| 746 | 746 | public function getFlash($offset = null) |
| 747 | 747 | {
|
| 748 | 748 | if (isset($offset)) {
|
| 749 | - return (isset($_SESSION[ 'system_variables' ], $_SESSION[ 'system_variables' ][ $offset ], $_SESSION[ $offset ]) && |
|
| 750 | - ! is_int($_SESSION[ 'system_variables' ][ $offset ])) ? $_SESSION[ $offset ] : null; |
|
| 749 | + return (isset($_SESSION['system_variables'], $_SESSION['system_variables'][$offset], $_SESSION[$offset]) && |
|
| 750 | + ! is_int($_SESSION['system_variables'][$offset])) ? $_SESSION[$offset] : null; |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | $flashVariables = []; |
| 754 | 754 | |
| 755 | - if ( ! empty($_SESSION[ 'system_variables' ])) {
|
|
| 756 | - foreach ($_SESSION[ 'system_variables' ] as $offset => &$value) {
|
|
| 757 | - is_int($value) OR $flashVariables[ $offset ] = $_SESSION[ $offset ]; |
|
| 755 | + if ( ! empty($_SESSION['system_variables'])) {
|
|
| 756 | + foreach ($_SESSION['system_variables'] as $offset => &$value) {
|
|
| 757 | + is_int($value) OR $flashVariables[$offset] = $_SESSION[$offset]; |
|
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | |
@@ -786,23 +786,23 @@ discard block |
||
| 786 | 786 | */ |
| 787 | 787 | public function unsetFlash($offset) |
| 788 | 788 | {
|
| 789 | - if (empty($_SESSION[ 'system_variables' ])) {
|
|
| 789 | + if (empty($_SESSION['system_variables'])) {
|
|
| 790 | 790 | return; |
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | is_array($offset) OR $offset = [$offset]; |
| 794 | 794 | |
| 795 | 795 | foreach ($offset as $key) {
|
| 796 | - if (isset($_SESSION[ 'system_variables' ][ $key ]) && ! is_int( |
|
| 797 | - $_SESSION[ 'system_variables' ][ $key ] |
|
| 796 | + if (isset($_SESSION['system_variables'][$key]) && ! is_int( |
|
| 797 | + $_SESSION['system_variables'][$key] |
|
| 798 | 798 | ) |
| 799 | 799 | ) {
|
| 800 | - unset($_SESSION[ 'system_variables' ][ $key ]); |
|
| 800 | + unset($_SESSION['system_variables'][$key]); |
|
| 801 | 801 | } |
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - if (empty($_SESSION[ 'system_variables' ])) {
|
|
| 805 | - unset($_SESSION[ 'system_variables' ]); |
|
| 804 | + if (empty($_SESSION['system_variables'])) {
|
|
| 805 | + unset($_SESSION['system_variables']); |
|
| 806 | 806 | } |
| 807 | 807 | } |
| 808 | 808 | |
@@ -817,13 +817,13 @@ discard block |
||
| 817 | 817 | */ |
| 818 | 818 | public function getFlashOffsets() |
| 819 | 819 | {
|
| 820 | - if ( ! isset($_SESSION[ 'system_variables' ])) {
|
|
| 820 | + if ( ! isset($_SESSION['system_variables'])) {
|
|
| 821 | 821 | return []; |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | $offsets = []; |
| 825 | - foreach (array_keys($_SESSION[ 'system_variables' ]) as $offset) {
|
|
| 826 | - is_int($_SESSION[ 'system_variables' ][ $offset ]) OR $offsets[] = $offset; |
|
| 825 | + foreach (array_keys($_SESSION['system_variables']) as $offset) {
|
|
| 826 | + is_int($_SESSION['system_variables'][$offset]) OR $offsets[] = $offset; |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | return $offsets; |
@@ -875,26 +875,26 @@ discard block |
||
| 875 | 875 | $value += time(); |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | - if ( ! isset($_SESSION[ $key ])) {
|
|
| 878 | + if ( ! isset($_SESSION[$key])) {
|
|
| 879 | 879 | return false; |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | - $temp[ $key ] = $value; |
|
| 882 | + $temp[$key] = $value; |
|
| 883 | 883 | } |
| 884 | 884 | |
| 885 | - $_SESSION[ 'system_variables' ] = isset($_SESSION[ 'system_variables' ]) ? array_merge( |
|
| 886 | - $_SESSION[ 'system_variables' ], |
|
| 885 | + $_SESSION['system_variables'] = isset($_SESSION['system_variables']) ? array_merge( |
|
| 886 | + $_SESSION['system_variables'], |
|
| 887 | 887 | $temp |
| 888 | 888 | ) : $temp; |
| 889 | 889 | |
| 890 | 890 | return true; |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - if ( ! isset($_SESSION[ $offset ])) {
|
|
| 893 | + if ( ! isset($_SESSION[$offset])) {
|
|
| 894 | 894 | return false; |
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - $_SESSION[ 'system_variables' ][ $offset ] = $ttl; |
|
| 897 | + $_SESSION['system_variables'][$offset] = $ttl; |
|
| 898 | 898 | |
| 899 | 899 | return true; |
| 900 | 900 | } |
@@ -913,15 +913,15 @@ discard block |
||
| 913 | 913 | public function getTemp($offset = null) |
| 914 | 914 | {
|
| 915 | 915 | if (isset($offset)) {
|
| 916 | - return (isset($_SESSION[ 'system_variables' ], $_SESSION[ 'system_variables' ][ $offset ], $_SESSION[ $offset ]) && |
|
| 917 | - is_int($_SESSION[ 'system_variables' ][ $offset ])) ? $_SESSION[ $offset ] : null; |
|
| 916 | + return (isset($_SESSION['system_variables'], $_SESSION['system_variables'][$offset], $_SESSION[$offset]) && |
|
| 917 | + is_int($_SESSION['system_variables'][$offset])) ? $_SESSION[$offset] : null; |
|
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | $tempVariables = []; |
| 921 | 921 | |
| 922 | - if ( ! empty($_SESSION[ 'system_variables' ])) {
|
|
| 923 | - foreach ($_SESSION[ 'system_variables' ] as $offset => &$value) {
|
|
| 924 | - is_int($value) && $tempVariables[ $offset ] = $_SESSION[ $offset ]; |
|
| 922 | + if ( ! empty($_SESSION['system_variables'])) {
|
|
| 923 | + foreach ($_SESSION['system_variables'] as $offset => &$value) {
|
|
| 924 | + is_int($value) && $tempVariables[$offset] = $_SESSION[$offset]; |
|
| 925 | 925 | } |
| 926 | 926 | } |
| 927 | 927 | |
@@ -939,23 +939,23 @@ discard block |
||
| 939 | 939 | */ |
| 940 | 940 | public function unsetTemp($offset) |
| 941 | 941 | {
|
| 942 | - if (empty($_SESSION[ 'system_variables' ])) {
|
|
| 942 | + if (empty($_SESSION['system_variables'])) {
|
|
| 943 | 943 | return; |
| 944 | 944 | } |
| 945 | 945 | |
| 946 | 946 | is_array($offset) OR $offset = [$offset]; |
| 947 | 947 | |
| 948 | 948 | foreach ($offset as $key) {
|
| 949 | - if (isset($_SESSION[ 'system_variables' ][ $key ]) && is_int( |
|
| 950 | - $_SESSION[ 'system_variables' ][ $key ] |
|
| 949 | + if (isset($_SESSION['system_variables'][$key]) && is_int( |
|
| 950 | + $_SESSION['system_variables'][$key] |
|
| 951 | 951 | ) |
| 952 | 952 | ) {
|
| 953 | - unset($_SESSION[ 'system_variables' ][ $key ]); |
|
| 953 | + unset($_SESSION['system_variables'][$key]); |
|
| 954 | 954 | } |
| 955 | 955 | } |
| 956 | 956 | |
| 957 | - if (empty($_SESSION[ 'system_variables' ])) {
|
|
| 958 | - unset($_SESSION[ 'system_variables' ]); |
|
| 957 | + if (empty($_SESSION['system_variables'])) {
|
|
| 958 | + unset($_SESSION['system_variables']); |
|
| 959 | 959 | } |
| 960 | 960 | } |
| 961 | 961 | |
@@ -970,13 +970,13 @@ discard block |
||
| 970 | 970 | */ |
| 971 | 971 | public function getTempOffsets() |
| 972 | 972 | {
|
| 973 | - if ( ! isset($_SESSION[ 'system_variables' ])) {
|
|
| 973 | + if ( ! isset($_SESSION['system_variables'])) {
|
|
| 974 | 974 | return []; |
| 975 | 975 | } |
| 976 | 976 | |
| 977 | 977 | $offsets = []; |
| 978 | - foreach (array_keys($_SESSION[ 'system_variables' ]) as $offset) {
|
|
| 979 | - is_int($_SESSION[ 'system_variables' ][ $offset ]) && $offsets[] = $offset; |
|
| 978 | + foreach (array_keys($_SESSION['system_variables']) as $offset) {
|
|
| 979 | + is_int($_SESSION['system_variables'][$offset]) && $offsets[] = $offset; |
|
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | return $offsets; |