@@ -50,17 +50,23 @@ discard block |
||
| 50 | 50 | include_once($autoloader); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | -if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true); |
|
| 53 | +if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) { |
|
| 54 | + $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true); |
|
| 55 | +} |
|
| 54 | 56 | |
| 55 | 57 | $base_path = str_replace('\\','/',dirname(__FILE__)) . '/'; |
| 56 | -if(is_file($base_path . 'assets/cache/siteManager.php')) |
|
| 58 | +if(is_file($base_path . 'assets/cache/siteManager.php')) { |
|
| 57 | 59 | include_once($base_path . 'assets/cache/siteManager.php'); |
| 58 | -if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) |
|
| 60 | +} |
|
| 61 | +if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) { |
|
| 59 | 62 | define('MGR_DIR', 'manager'); |
| 60 | -if(is_file($base_path . 'assets/cache/siteHostnames.php')) |
|
| 63 | +} |
|
| 64 | +if(is_file($base_path . 'assets/cache/siteHostnames.php')) { |
|
| 61 | 65 | include_once($base_path . 'assets/cache/siteHostnames.php'); |
| 62 | -if(!defined('MODX_SITE_HOSTNAMES')) |
|
| 66 | +} |
|
| 67 | +if(!defined('MODX_SITE_HOSTNAMES')) { |
|
| 63 | 68 | define('MODX_SITE_HOSTNAMES', ''); |
| 69 | +} |
|
| 64 | 70 | |
| 65 | 71 | // get start time |
| 66 | 72 | $mstart = memory_get_usage(); |
@@ -129,7 +135,7 @@ discard block |
||
| 129 | 135 | @ini_set("display_errors","0"); |
| 130 | 136 | } |
| 131 | 137 | |
| 132 | -if(MODX_CLI){ |
|
| 138 | +if(MODX_CLI) { |
|
| 133 | 139 | @set_time_limit(0); |
| 134 | 140 | @ini_set('max_execution_time',0); |
| 135 | 141 | } |
@@ -4,14 +4,14 @@ discard block |
||
| 4 | 4 | $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -if( ! function_exists('evolutionCMS')) {
|
|
| 7 | +if( ! function_exists('evolutionCMS')) { |
|
| 8 | 8 | /** |
| 9 | 9 | * @return DocumentParser |
| 10 | 10 | */ |
| 11 | - function evolutionCMS() |
|
| 12 | - {
|
|
| 13 | - if( ! defined('MODX_CLASS')) {
|
|
| 14 | - if( ! class_exists('DocumentParser')) {
|
|
| 11 | + function evolutionCMS() |
|
| 12 | + { |
|
| 13 | + if( ! defined('MODX_CLASS')) { |
|
| 14 | + if( ! class_exists('DocumentParser')) { |
|
| 15 | 15 | throw new RuntimeException('MODX_CLASS not defined and DocumentParser class not exists');
|
| 16 | 16 | } |
| 17 | 17 | define('MODX_CLASS', 'DocumentParser');
|
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | -function genEvoSessionName() |
|
| 28 | -{
|
|
| 27 | +function genEvoSessionName() |
|
| 28 | +{ |
|
| 29 | 29 | $_ = crc32(__FILE__); |
| 30 | 30 | $_ = sprintf('%u', $_);
|
| 31 | 31 | |
@@ -35,10 +35,12 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * @return void |
| 37 | 37 | */ |
| 38 | -function startCMSSession() |
|
| 39 | -{
|
|
| 38 | +function startCMSSession() |
|
| 39 | +{ |
|
| 40 | 40 | global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain; |
| 41 | - if(MODX_CLI) return; |
|
| 41 | + if(MODX_CLI) { |
|
| 42 | + return; |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | session_name($site_sessionname); |
| 44 | 46 | removeInvalidCmsSessionIds($site_sessionname); |
@@ -49,14 +51,14 @@ discard block |
||
| 49 | 51 | session_set_cookie_params($cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
| 50 | 52 | session_start(); |
| 51 | 53 | $key = "modx.mgr.session.cookie.lifetime"; |
| 52 | - if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
|
|
| 54 | + if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
|
| 53 | 55 | $cookieLifetime = (int)$_SESSION[$key]; |
| 54 | - if ($cookieLifetime) {
|
|
| 56 | + if ($cookieLifetime) { |
|
| 55 | 57 | $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime; |
| 56 | 58 | } |
| 57 | 59 | setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
| 58 | 60 | } |
| 59 | - if (!isset($_SESSION['modx.session.created.time'])) {
|
|
| 61 | + if (!isset($_SESSION['modx.session.created.time'])) { |
|
| 60 | 62 | $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME']; |
| 61 | 63 | } |
| 62 | 64 | } |
@@ -66,9 +68,9 @@ discard block |
||
| 66 | 68 | * @param $session_name |
| 67 | 69 | * @return void |
| 68 | 70 | */ |
| 69 | -function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
| 70 | -{
|
|
| 71 | - if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) {
|
|
| 71 | +function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
| 72 | +{ |
|
| 73 | + if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) { |
|
| 72 | 74 | unset($storage[$session_name]); |
| 73 | 75 | } |
| 74 | 76 | } |
@@ -77,9 +79,11 @@ discard block |
||
| 77 | 79 | * @param $session_name |
| 78 | 80 | * @return void |
| 79 | 81 | */ |
| 80 | -function removeInvalidCmsSessionIds($session_name) |
|
| 81 | -{
|
|
| 82 | - if(MODX_CLI) return; |
|
| 82 | +function removeInvalidCmsSessionIds($session_name) |
|
| 83 | +{ |
|
| 84 | + if(MODX_CLI) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 83 | 87 | // session ids is invalid iff it is empty string |
| 84 | 88 | // storage priorioty can see in PHP source ext/session/session.c |
| 85 | 89 | removeInvalidCmsSessionFromStorage($_COOKIE, $session_name); |