@@ -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); |
@@ -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 | session_start(); |
@@ -169,37 +169,37 @@ discard block |
||
| 169 | 169 | $this->initializeVariables(); |
| 170 | 170 | |
| 171 | 171 | // Sanitize the cookie, because apparently PHP doesn't do that for userspace handlers |
| 172 | - if (isset($_COOKIE[ $this->config[ 'name' ] ]) && ( |
|
| 173 | - ! is_string($this->config[ 'name' ]) || |
|
| 174 | - ! preg_match('#\A' . $this->sidRegexp . '\z#', $_COOKIE[ $this->config[ 'name' ] ]
|
|
| 172 | + if (isset($_COOKIE[$this->config['name']]) && ( |
|
| 173 | + ! is_string($this->config['name']) || |
|
| 174 | + ! preg_match('#\A' . $this->sidRegexp . '\z#', $_COOKIE[$this->config['name']]
|
|
| 175 | 175 | ) |
| 176 | 176 | ) |
| 177 | 177 | ) {
|
| 178 | - unset($_COOKIE[ $this->config[ 'name' ] ]); |
|
| 178 | + unset($_COOKIE[$this->config['name']]); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Is session ID auto-regeneration configured? (ignoring ajax requests) |
| 182 | - if ((empty($_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) || |
|
| 183 | - strtolower($_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) !== 'xmlhttprequest') && |
|
| 184 | - ($regenerateTime = $this->config[ 'regenerate' ]->lifetime) > 0 |
|
| 182 | + if ((empty($_SERVER['HTTP_X_REQUESTED_WITH']) || |
|
| 183 | + strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest') && |
|
| 184 | + ($regenerateTime = $this->config['regenerate']->lifetime) > 0 |
|
| 185 | 185 | ) {
|
| 186 | - if ( ! isset($_SESSION[ 'last_regenerate' ])) {
|
|
| 187 | - $_SESSION[ 'last_regenerate' ] = time(); |
|
| 188 | - } elseif ($_SESSION[ 'last_regenerate' ] < (time() - $regenerateTime)) {
|
|
| 186 | + if ( ! isset($_SESSION['last_regenerate'])) {
|
|
| 187 | + $_SESSION['last_regenerate'] = time(); |
|
| 188 | + } elseif ($_SESSION['last_regenerate'] < (time() - $regenerateTime)) {
|
|
| 189 | 189 | $this->regenerate(); |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | // Another work-around ... PHP doesn't seem to send the session cookie |
| 193 | 193 | // unless it is being currently created or regenerated |
| 194 | - elseif (isset($_COOKIE[ $this->config[ 'name' ] ]) && $_COOKIE[ $this->config[ 'name' ] ] === session_id() |
|
| 194 | + elseif (isset($_COOKIE[$this->config['name']]) && $_COOKIE[$this->config['name']] === session_id() |
|
| 195 | 195 | ) {
|
| 196 | 196 | setcookie( |
| 197 | - $this->config[ 'name' ], |
|
| 197 | + $this->config['name'], |
|
| 198 | 198 | session_id(), |
| 199 | - (empty($this->config[ 'lifetime' ]) ? 0 : time() + $this->config[ 'lifetime' ]), |
|
| 200 | - $this->config[ 'cookie' ]->path, |
|
| 201 | - '.' . ltrim($this->config[ 'cookie' ]->domain, '.'), |
|
| 202 | - $this->config[ 'cookie' ]->secure, |
|
| 199 | + (empty($this->config['lifetime']) ? 0 : time() + $this->config['lifetime']), |
|
| 200 | + $this->config['cookie']->path, |
|
| 201 | + '.' . ltrim($this->config['cookie']->domain, '.'), |
|
| 202 | + $this->config['cookie']->secure, |
|
| 203 | 203 | true |
| 204 | 204 | ); |
| 205 | 205 | } |
@@ -220,23 +220,23 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | private function setConfiguration() |
| 222 | 222 | {
|
| 223 | - ini_set('session.name', $this->config[ 'name' ]);
|
|
| 223 | + ini_set('session.name', $this->config['name']);
|
|
| 224 | 224 | |
| 225 | - if (empty($this->config[ 'lifetime' ])) {
|
|
| 226 | - $this->config[ 'lifetime' ] = (int)ini_get('session.gc_maxlifetime');
|
|
| 225 | + if (empty($this->config['lifetime'])) {
|
|
| 226 | + $this->config['lifetime'] = (int)ini_get('session.gc_maxlifetime');
|
|
| 227 | 227 | } else {
|
| 228 | - ini_set('session.gc_maxlifetime', (int)$this->config[ 'lifetime' ]);
|
|
| 228 | + ini_set('session.gc_maxlifetime', (int)$this->config['lifetime']);
|
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if (empty($this->config[ 'cookie' ]->domain)) {
|
|
| 232 | - $this->config[ 'cookie' ]->domain = (isset($_SERVER[ 'HTTP_HOST' ]) ? $_SERVER[ 'HTTP_HOST' ] |
|
| 233 | - : (isset($_SERVER[ 'SERVER_NAME' ]) ? $_SERVER[ 'SERVER_NAME' ] : null)); |
|
| 231 | + if (empty($this->config['cookie']->domain)) {
|
|
| 232 | + $this->config['cookie']->domain = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] |
|
| 233 | + : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null)); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - $this->config[ 'cookie' ]->domain = ltrim($this->config[ 'cookie' ]->domain, '.'); |
|
| 236 | + $this->config['cookie']->domain = ltrim($this->config['cookie']->domain, '.'); |
|
| 237 | 237 | |
| 238 | - ini_set('session.cookie_domain', '.' . $this->config[ 'cookie' ]->domain);
|
|
| 239 | - ini_set('session.cookie_path', $this->config[ 'cookie' ]->path);
|
|
| 238 | + ini_set('session.cookie_domain', '.' . $this->config['cookie']->domain);
|
|
| 239 | + ini_set('session.cookie_path', $this->config['cookie']->path);
|
|
| 240 | 240 | |
| 241 | 241 | // Security is king |
| 242 | 242 | ini_set('session.cookie_lifetime', 0);
|
@@ -323,25 +323,25 @@ discard block |
||
| 323 | 323 | */ |
| 324 | 324 | private function initializeVariables() |
| 325 | 325 | {
|
| 326 | - if (empty($_SESSION[ 'system_variables' ])) {
|
|
| 326 | + if (empty($_SESSION['system_variables'])) {
|
|
| 327 | 327 | return; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | $currentTime = time(); |
| 331 | 331 | |
| 332 | - foreach ($_SESSION[ 'system_variables' ] as $key => &$value) {
|
|
| 332 | + foreach ($_SESSION['system_variables'] as $key => &$value) {
|
|
| 333 | 333 | if ($value === 'new') {
|
| 334 | - $_SESSION[ 'system_variables' ][ $key ] = 'old'; |
|
| 334 | + $_SESSION['system_variables'][$key] = 'old'; |
|
| 335 | 335 | } |
| 336 | 336 | // Hacky, but 'old' will (implicitly) always be less than time() ;) |
| 337 | 337 | // DO NOT move this above the 'new' check! |
| 338 | 338 | elseif ($value < $currentTime) {
|
| 339 | - unset($_SESSION[ $key ], $_SESSION[ 'system_variables' ][ $key ]); |
|
| 339 | + unset($_SESSION[$key], $_SESSION['system_variables'][$key]); |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if (empty($_SESSION[ 'system_variables' ])) {
|
|
| 344 | - unset($_SESSION[ 'system_variables' ]); |
|
| 343 | + if (empty($_SESSION['system_variables'])) {
|
|
| 344 | + unset($_SESSION['system_variables']); |
|
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | |
@@ -354,8 +354,8 @@ discard block |
||
| 354 | 354 | */ |
| 355 | 355 | public function regenerate() |
| 356 | 356 | {
|
| 357 | - $_SESSION[ 'last_regenerate' ] = time(); |
|
| 358 | - session_regenerate_id($this->config[ 'regenerate' ]->destroy); |
|
| 357 | + $_SESSION['last_regenerate'] = time(); |
|
| 358 | + session_regenerate_id($this->config['regenerate']->destroy); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | //-------------------------------------------------------------------- |
@@ -389,12 +389,12 @@ discard block |
||
| 389 | 389 | public function stop() |
| 390 | 390 | {
|
| 391 | 391 | setcookie( |
| 392 | - $this->config[ 'name' ], |
|
| 392 | + $this->config['name'], |
|
| 393 | 393 | session_id(), |
| 394 | 394 | 1, |
| 395 | - $this->config[ 'cookie' ]->path, |
|
| 396 | - '.' . ltrim($this->config[ 'cookie' ]->domain, '.'), |
|
| 397 | - $this->config[ 'cookie' ]->secure, |
|
| 395 | + $this->config['cookie']->path, |
|
| 396 | + '.' . ltrim($this->config['cookie']->domain, '.'), |
|
| 397 | + $this->config['cookie']->secure, |
|
| 398 | 398 | true |
| 399 | 399 | ); |
| 400 | 400 | |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | */ |
| 454 | 454 | public function offsetExists($offset) |
| 455 | 455 | {
|
| 456 | - return (bool)isset($_SESSION[ $offset ]); |
|
| 456 | + return (bool)isset($_SESSION[$offset]); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | // ------------------------------------------------------------------------ |
@@ -488,14 +488,14 @@ discard block |
||
| 488 | 488 | public function &__get($offset) |
| 489 | 489 | {
|
| 490 | 490 | if ($offset === 'id') {
|
| 491 | - $_SESSION[ 'id' ] = session_id(); |
|
| 491 | + $_SESSION['id'] = session_id(); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - if ( ! isset($_SESSION[ $offset ])) {
|
|
| 495 | - $_SESSION[ $offset ] = null; |
|
| 494 | + if ( ! isset($_SESSION[$offset])) {
|
|
| 495 | + $_SESSION[$offset] = null; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | - return $_SESSION[ $offset ]; |
|
| 498 | + return $_SESSION[$offset]; |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | // ------------------------------------------------------------------------ |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | */ |
| 536 | 536 | public function offsetSet($offset, $value) |
| 537 | 537 | {
|
| 538 | - $_SESSION[ $offset ] =& $value; |
|
| 538 | + $_SESSION[$offset] = & $value; |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | // ------------------------------------------------------------------------ |
@@ -573,8 +573,8 @@ discard block |
||
| 573 | 573 | */ |
| 574 | 574 | public function offsetUnset($offset) |
| 575 | 575 | {
|
| 576 | - if (isset($_SESSION[ $offset ])) {
|
|
| 577 | - unset($_SESSION[ $offset ]); |
|
| 576 | + if (isset($_SESSION[$offset])) {
|
|
| 577 | + unset($_SESSION[$offset]); |
|
| 578 | 578 | } |
| 579 | 579 | } |
| 580 | 580 | |
@@ -637,13 +637,13 @@ discard block |
||
| 637 | 637 | {
|
| 638 | 638 | if (is_array($offset)) {
|
| 639 | 639 | foreach ($offset as $key => &$value) {
|
| 640 | - $_SESSION[ $key ] = $value; |
|
| 640 | + $_SESSION[$key] = $value; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | return; |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - $_SESSION[ $offset ] =& $value; |
|
| 646 | + $_SESSION[$offset] = & $value; |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | //-------------------------------------------------------------------- |
@@ -661,26 +661,26 @@ discard block |
||
| 661 | 661 | {
|
| 662 | 662 | if (is_array($offset)) {
|
| 663 | 663 | for ($i = 0, $c = count($offset); $i < $c; $i++) {
|
| 664 | - if ( ! isset($_SESSION[ $offset[ $i ] ])) {
|
|
| 664 | + if ( ! isset($_SESSION[$offset[$i]])) {
|
|
| 665 | 665 | return false; |
| 666 | 666 | } |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | $new = array_fill_keys($offset, 'new'); |
| 670 | 670 | |
| 671 | - $_SESSION[ 'system_variables' ] = isset($_SESSION[ 'system_variables' ]) ? array_merge( |
|
| 672 | - $_SESSION[ 'system_variables' ], |
|
| 671 | + $_SESSION['system_variables'] = isset($_SESSION['system_variables']) ? array_merge( |
|
| 672 | + $_SESSION['system_variables'], |
|
| 673 | 673 | $new |
| 674 | 674 | ) : $new; |
| 675 | 675 | |
| 676 | 676 | return true; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - if ( ! isset($_SESSION[ $offset ])) {
|
|
| 679 | + if ( ! isset($_SESSION[$offset])) {
|
|
| 680 | 680 | return false; |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - $_SESSION[ 'system_variables' ][ $offset ] = 'new'; |
|
| 683 | + $_SESSION['system_variables'][$offset] = 'new'; |
|
| 684 | 684 | |
| 685 | 685 | return true; |
| 686 | 686 | } |
@@ -718,10 +718,10 @@ discard block |
||
| 718 | 718 | public function offsetGet($offset) |
| 719 | 719 | {
|
| 720 | 720 | if ($offset === 'id') {
|
| 721 | - $_SESSION[ 'id' ] = session_id(); |
|
| 721 | + $_SESSION['id'] = session_id(); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | - return (isset($_SESSION[ $offset ])) ? $_SESSION[ $offset ] : false; |
|
| 724 | + return (isset($_SESSION[$offset])) ? $_SESSION[$offset] : false; |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | //-------------------------------------------------------------------- |
@@ -739,15 +739,15 @@ discard block |
||
| 739 | 739 | public function getFlash($offset = null) |
| 740 | 740 | {
|
| 741 | 741 | if (isset($offset)) {
|
| 742 | - return (isset($_SESSION[ 'system_variables' ], $_SESSION[ 'system_variables' ][ $offset ], $_SESSION[ $offset ]) && |
|
| 743 | - ! is_int($_SESSION[ 'system_variables' ][ $offset ])) ? $_SESSION[ $offset ] : null; |
|
| 742 | + return (isset($_SESSION['system_variables'], $_SESSION['system_variables'][$offset], $_SESSION[$offset]) && |
|
| 743 | + ! is_int($_SESSION['system_variables'][$offset])) ? $_SESSION[$offset] : null; |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | $flashVariables = []; |
| 747 | 747 | |
| 748 | - if ( ! empty($_SESSION[ 'system_variables' ])) {
|
|
| 749 | - foreach ($_SESSION[ 'system_variables' ] as $offset => &$value) {
|
|
| 750 | - is_int($value) OR $flashVariables[ $offset ] = $_SESSION[ $offset ]; |
|
| 748 | + if ( ! empty($_SESSION['system_variables'])) {
|
|
| 749 | + foreach ($_SESSION['system_variables'] as $offset => &$value) {
|
|
| 750 | + is_int($value) OR $flashVariables[$offset] = $_SESSION[$offset]; |
|
| 751 | 751 | } |
| 752 | 752 | } |
| 753 | 753 | |
@@ -779,23 +779,23 @@ discard block |
||
| 779 | 779 | */ |
| 780 | 780 | public function unsetFlash($offset) |
| 781 | 781 | {
|
| 782 | - if (empty($_SESSION[ 'system_variables' ])) {
|
|
| 782 | + if (empty($_SESSION['system_variables'])) {
|
|
| 783 | 783 | return; |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | is_array($offset) OR $offset = [$offset]; |
| 787 | 787 | |
| 788 | 788 | foreach ($offset as $key) {
|
| 789 | - if (isset($_SESSION[ 'system_variables' ][ $key ]) && ! is_int( |
|
| 790 | - $_SESSION[ 'system_variables' ][ $key ] |
|
| 789 | + if (isset($_SESSION['system_variables'][$key]) && ! is_int( |
|
| 790 | + $_SESSION['system_variables'][$key] |
|
| 791 | 791 | ) |
| 792 | 792 | ) {
|
| 793 | - unset($_SESSION[ 'system_variables' ][ $key ]); |
|
| 793 | + unset($_SESSION['system_variables'][$key]); |
|
| 794 | 794 | } |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | - if (empty($_SESSION[ 'system_variables' ])) {
|
|
| 798 | - unset($_SESSION[ 'system_variables' ]); |
|
| 797 | + if (empty($_SESSION['system_variables'])) {
|
|
| 798 | + unset($_SESSION['system_variables']); |
|
| 799 | 799 | } |
| 800 | 800 | } |
| 801 | 801 | |
@@ -810,13 +810,13 @@ discard block |
||
| 810 | 810 | */ |
| 811 | 811 | public function getFlashOffsets() |
| 812 | 812 | {
|
| 813 | - if ( ! isset($_SESSION[ 'system_variables' ])) {
|
|
| 813 | + if ( ! isset($_SESSION['system_variables'])) {
|
|
| 814 | 814 | return []; |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | $offsets = []; |
| 818 | - foreach (array_keys($_SESSION[ 'system_variables' ]) as $offset) {
|
|
| 819 | - is_int($_SESSION[ 'system_variables' ][ $offset ]) OR $offsets[] = $offset; |
|
| 818 | + foreach (array_keys($_SESSION['system_variables']) as $offset) {
|
|
| 819 | + is_int($_SESSION['system_variables'][$offset]) OR $offsets[] = $offset; |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | return $offsets; |
@@ -868,26 +868,26 @@ discard block |
||
| 868 | 868 | $value += time(); |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if ( ! isset($_SESSION[ $key ])) {
|
|
| 871 | + if ( ! isset($_SESSION[$key])) {
|
|
| 872 | 872 | return false; |
| 873 | 873 | } |
| 874 | 874 | |
| 875 | - $temp[ $key ] = $value; |
|
| 875 | + $temp[$key] = $value; |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | - $_SESSION[ 'system_variables' ] = isset($_SESSION[ 'system_variables' ]) ? array_merge( |
|
| 879 | - $_SESSION[ 'system_variables' ], |
|
| 878 | + $_SESSION['system_variables'] = isset($_SESSION['system_variables']) ? array_merge( |
|
| 879 | + $_SESSION['system_variables'], |
|
| 880 | 880 | $temp |
| 881 | 881 | ) : $temp; |
| 882 | 882 | |
| 883 | 883 | return true; |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | - if ( ! isset($_SESSION[ $offset ])) {
|
|
| 886 | + if ( ! isset($_SESSION[$offset])) {
|
|
| 887 | 887 | return false; |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - $_SESSION[ 'system_variables' ][ $offset ] = $ttl; |
|
| 890 | + $_SESSION['system_variables'][$offset] = $ttl; |
|
| 891 | 891 | |
| 892 | 892 | return true; |
| 893 | 893 | } |
@@ -906,15 +906,15 @@ discard block |
||
| 906 | 906 | public function getTemp($offset = null) |
| 907 | 907 | {
|
| 908 | 908 | if (isset($offset)) {
|
| 909 | - return (isset($_SESSION[ 'system_variables' ], $_SESSION[ 'system_variables' ][ $offset ], $_SESSION[ $offset ]) && |
|
| 910 | - is_int($_SESSION[ 'system_variables' ][ $offset ])) ? $_SESSION[ $offset ] : null; |
|
| 909 | + return (isset($_SESSION['system_variables'], $_SESSION['system_variables'][$offset], $_SESSION[$offset]) && |
|
| 910 | + is_int($_SESSION['system_variables'][$offset])) ? $_SESSION[$offset] : null; |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | $tempVariables = []; |
| 914 | 914 | |
| 915 | - if ( ! empty($_SESSION[ 'system_variables' ])) {
|
|
| 916 | - foreach ($_SESSION[ 'system_variables' ] as $offset => &$value) {
|
|
| 917 | - is_int($value) && $tempVariables[ $offset ] = $_SESSION[ $offset ]; |
|
| 915 | + if ( ! empty($_SESSION['system_variables'])) {
|
|
| 916 | + foreach ($_SESSION['system_variables'] as $offset => &$value) {
|
|
| 917 | + is_int($value) && $tempVariables[$offset] = $_SESSION[$offset]; |
|
| 918 | 918 | } |
| 919 | 919 | } |
| 920 | 920 | |
@@ -932,23 +932,23 @@ discard block |
||
| 932 | 932 | */ |
| 933 | 933 | public function unsetTemp($offset) |
| 934 | 934 | {
|
| 935 | - if (empty($_SESSION[ 'system_variables' ])) {
|
|
| 935 | + if (empty($_SESSION['system_variables'])) {
|
|
| 936 | 936 | return; |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | is_array($offset) OR $offset = [$offset]; |
| 940 | 940 | |
| 941 | 941 | foreach ($offset as $key) {
|
| 942 | - if (isset($_SESSION[ 'system_variables' ][ $key ]) && is_int( |
|
| 943 | - $_SESSION[ 'system_variables' ][ $key ] |
|
| 942 | + if (isset($_SESSION['system_variables'][$key]) && is_int( |
|
| 943 | + $_SESSION['system_variables'][$key] |
|
| 944 | 944 | ) |
| 945 | 945 | ) {
|
| 946 | - unset($_SESSION[ 'system_variables' ][ $key ]); |
|
| 946 | + unset($_SESSION['system_variables'][$key]); |
|
| 947 | 947 | } |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | - if (empty($_SESSION[ 'system_variables' ])) {
|
|
| 951 | - unset($_SESSION[ 'system_variables' ]); |
|
| 950 | + if (empty($_SESSION['system_variables'])) {
|
|
| 951 | + unset($_SESSION['system_variables']); |
|
| 952 | 952 | } |
| 953 | 953 | } |
| 954 | 954 | |
@@ -963,13 +963,13 @@ discard block |
||
| 963 | 963 | */ |
| 964 | 964 | public function getTempOffsets() |
| 965 | 965 | {
|
| 966 | - if ( ! isset($_SESSION[ 'system_variables' ])) {
|
|
| 966 | + if ( ! isset($_SESSION['system_variables'])) {
|
|
| 967 | 967 | return []; |
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | $offsets = []; |
| 971 | - foreach (array_keys($_SESSION[ 'system_variables' ]) as $offset) {
|
|
| 972 | - is_int($_SESSION[ 'system_variables' ][ $offset ]) && $offsets[] = $offset; |
|
| 971 | + foreach (array_keys($_SESSION['system_variables']) as $offset) {
|
|
| 972 | + is_int($_SESSION['system_variables'][$offset]) && $offsets[] = $offset; |
|
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | return $offsets; |