Completed
Push — develop ( 0b7a4b...0c91f3 )
by Agel_Nash
06:09
created
manager/includes/preload.functions.inc.php 1 patch
Braces   +24 added lines, -20 removed lines patch added patch discarded remove patch
@@ -4,21 +4,21 @@  discard block
 block discarded – undo
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');
18 18
         }
19 19
         
20 20
         global $modx;
21
-        if ($modx === null) {
21
+        if ($modx === null) {
22 22
             $obj = new ReflectionClass(MODX_CLASS);
23 23
             $modx = $obj->newInstanceWithoutConstructor()->getInstance();
24 24
         }
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 /**
30 30
  * @return string
31 31
  */
32
-function genEvoSessionName()
33
-{
32
+function genEvoSessionName()
33
+{
34 34
     $_ = crc32(__FILE__);
35 35
     $_ = sprintf('%u', $_);
36 36
 
@@ -40,10 +40,12 @@  discard block
 block discarded – undo
40 40
 /**
41 41
  * @return void
42 42
  */
43
-function startCMSSession()
44
-{
43
+function startCMSSession()
44
+{
45 45
     global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain;
46
-    if(MODX_CLI) return;
46
+    if(MODX_CLI) {
47
+        return;
48
+    }
47 49
 
48 50
     session_name($site_sessionname);
49 51
     removeInvalidCmsSessionIds($site_sessionname);
@@ -54,14 +56,14 @@  discard block
 block discarded – undo
54 56
     session_set_cookie_params($cookieExpiration, $cookiePath, $cookieDomain, $secure, true);
55 57
     session_start();
56 58
     $key = "modx.mgr.session.cookie.lifetime";
57
-    if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
59
+    if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
58 60
         $cookieLifetime = (int)$_SESSION[$key];
59
-        if ($cookieLifetime) {
61
+        if ($cookieLifetime) {
60 62
             $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime;
61 63
         }
62 64
         setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true);
63 65
     }
64
-    if (!isset($_SESSION['modx.session.created.time'])) {
66
+    if (!isset($_SESSION['modx.session.created.time'])) {
65 67
         $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME'];
66 68
     }
67 69
 }
@@ -71,9 +73,9 @@  discard block
 block discarded – undo
71 73
  * @param $session_name
72 74
  * @return void
73 75
  */
74
-function removeInvalidCmsSessionFromStorage(&$storage, $session_name)
75
-{
76
-    if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) {
76
+function removeInvalidCmsSessionFromStorage(&$storage, $session_name)
77
+{
78
+    if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) {
77 79
         unset($storage[$session_name]);
78 80
     }
79 81
 }
@@ -82,9 +84,11 @@  discard block
 block discarded – undo
82 84
  * @param $session_name
83 85
  * @return void
84 86
  */
85
-function removeInvalidCmsSessionIds($session_name)
86
-{
87
-    if(MODX_CLI) return;
87
+function removeInvalidCmsSessionIds($session_name)
88
+{
89
+    if(MODX_CLI) {
90
+        return;
91
+    }
88 92
     // session ids is invalid iff it is empty string
89 93
     // storage priorioty can see in PHP source ext/session/session.c
90 94
     removeInvalidCmsSessionFromStorage($_COOKIE, $session_name);
Please login to merge, or discard this patch.