@@ -3,51 +3,51 @@ discard block |
||
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | if(!$modx->hasPermission('exec_module')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
10 | 10 | if($id==0) { |
11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | // check if user has access permission, except admins |
15 | 15 | if($_SESSION['mgrRole']!=1){ |
16 | - $rs = $modx->db->select( |
|
17 | - 'sma.usergroup,mg.member', |
|
18 | - $modx->getFullTableName("site_module_access")." sma |
|
16 | + $rs = $modx->db->select( |
|
17 | + 'sma.usergroup,mg.member', |
|
18 | + $modx->getFullTableName("site_module_access")." sma |
|
19 | 19 | LEFT JOIN ".$modx->getFullTableName("member_groups")." mg ON mg.user_group = sma.usergroup AND member='".$modx->getLoginUserID()."'", |
20 | - "sma.module = '{$id}'" |
|
21 | - ); |
|
22 | - //initialize permission to -1, if it stays -1 no permissions |
|
23 | - //attached so permission granted |
|
24 | - $permissionAccessInt = -1; |
|
20 | + "sma.module = '{$id}'" |
|
21 | + ); |
|
22 | + //initialize permission to -1, if it stays -1 no permissions |
|
23 | + //attached so permission granted |
|
24 | + $permissionAccessInt = -1; |
|
25 | 25 | |
26 | - while ($row = $modx->db->getRow($rs)) { |
|
27 | - if($row["usergroup"] && $row["member"]) { |
|
28 | - //if there are permissions and this member has permission, ofcourse |
|
29 | - //this is granted |
|
30 | - $permissionAccessInt = 1; |
|
31 | - } elseif ($permissionAccessInt==-1) { |
|
32 | - //if there are permissions but this member has no permission and the |
|
33 | - //variable was still in init state we set permission to 0; no permissions |
|
34 | - $permissionAccessInt = 0; |
|
35 | - } |
|
36 | - } |
|
26 | + while ($row = $modx->db->getRow($rs)) { |
|
27 | + if($row["usergroup"] && $row["member"]) { |
|
28 | + //if there are permissions and this member has permission, ofcourse |
|
29 | + //this is granted |
|
30 | + $permissionAccessInt = 1; |
|
31 | + } elseif ($permissionAccessInt==-1) { |
|
32 | + //if there are permissions but this member has no permission and the |
|
33 | + //variable was still in init state we set permission to 0; no permissions |
|
34 | + $permissionAccessInt = 0; |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | - if($permissionAccessInt==0) { |
|
39 | - $modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106"); |
|
40 | - } |
|
38 | + if($permissionAccessInt==0) { |
|
39 | + $modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106"); |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // get module data |
44 | 44 | $rs = $modx->db->select('*', $modx->getFullTableName("site_modules"), "id='{$id}'"); |
45 | 45 | $content = $modx->db->getRow($rs); |
46 | 46 | if(!$content) { |
47 | - $modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106"); |
|
47 | + $modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106"); |
|
48 | 48 | } |
49 | 49 | if($content['disabled']) { |
50 | - $modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106"); |
|
50 | + $modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106"); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // Set the item name for logger |
@@ -71,38 +71,38 @@ discard block |
||
71 | 71 | * @return string |
72 | 72 | */ |
73 | 73 | function evalModule($moduleCode,$params){ |
74 | - $modx = evolutionCMS(); |
|
75 | - $modx->event->params = &$params; // store params inside event object |
|
76 | - if(is_array($params)) { |
|
77 | - extract($params, EXTR_SKIP); |
|
78 | - } |
|
79 | - ob_start(); |
|
80 | - $mod = eval($moduleCode); |
|
81 | - $msg = ob_get_contents(); |
|
82 | - ob_end_clean(); |
|
83 | - if (isset($php_errormsg)) |
|
84 | - { |
|
85 | - $error_info = error_get_last(); |
|
74 | + $modx = evolutionCMS(); |
|
75 | + $modx->event->params = &$params; // store params inside event object |
|
76 | + if(is_array($params)) { |
|
77 | + extract($params, EXTR_SKIP); |
|
78 | + } |
|
79 | + ob_start(); |
|
80 | + $mod = eval($moduleCode); |
|
81 | + $msg = ob_get_contents(); |
|
82 | + ob_end_clean(); |
|
83 | + if (isset($php_errormsg)) |
|
84 | + { |
|
85 | + $error_info = error_get_last(); |
|
86 | 86 | switch($error_info['type']) |
87 | 87 | { |
88 | - case E_NOTICE : |
|
89 | - $error_level = 1; |
|
90 | - case E_USER_NOTICE : |
|
91 | - break; |
|
92 | - case E_DEPRECATED : |
|
93 | - case E_USER_DEPRECATED : |
|
94 | - case E_STRICT : |
|
95 | - $error_level = 2; |
|
96 | - break; |
|
97 | - default: |
|
98 | - $error_level = 99; |
|
88 | + case E_NOTICE : |
|
89 | + $error_level = 1; |
|
90 | + case E_USER_NOTICE : |
|
91 | + break; |
|
92 | + case E_DEPRECATED : |
|
93 | + case E_USER_DEPRECATED : |
|
94 | + case E_STRICT : |
|
95 | + $error_level = 2; |
|
96 | + break; |
|
97 | + default: |
|
98 | + $error_level = 99; |
|
99 | + } |
|
100 | + if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
101 | + { |
|
102 | + $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
|
103 | + $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
|
99 | 104 | } |
100 | - if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
101 | - { |
|
102 | - $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
|
103 | - $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
|
104 | - } |
|
105 | - } |
|
106 | - unset($modx->event->params); |
|
107 | - return $mod.$msg; |
|
105 | + } |
|
106 | + unset($modx->event->params); |
|
107 | + return $mod.$msg; |
|
108 | 108 | } |
@@ -1,18 +1,18 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('exec_module')) { |
|
5 | +if (!$modx->hasPermission('exec_module')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | // check if user has access permission, except admins |
15 | -if($_SESSION['mgrRole']!=1){ |
|
15 | +if ($_SESSION['mgrRole'] != 1) { |
|
16 | 16 | $rs = $modx->db->select( |
17 | 17 | 'sma.usergroup,mg.member', |
18 | 18 | $modx->getFullTableName("site_module_access")." sma |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | $permissionAccessInt = -1; |
25 | 25 | |
26 | 26 | while ($row = $modx->db->getRow($rs)) { |
27 | - if($row["usergroup"] && $row["member"]) { |
|
27 | + if ($row["usergroup"] && $row["member"]) { |
|
28 | 28 | //if there are permissions and this member has permission, ofcourse |
29 | 29 | //this is granted |
30 | 30 | $permissionAccessInt = 1; |
31 | - } elseif ($permissionAccessInt==-1) { |
|
31 | + } elseif ($permissionAccessInt == -1) { |
|
32 | 32 | //if there are permissions but this member has no permission and the |
33 | 33 | //variable was still in init state we set permission to 0; no permissions |
34 | 34 | $permissionAccessInt = 0; |
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | - if($permissionAccessInt==0) { |
|
38 | + if ($permissionAccessInt == 0) { |
|
39 | 39 | $modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106"); |
40 | 40 | } |
41 | 41 | } |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | // get module data |
44 | 44 | $rs = $modx->db->select('*', $modx->getFullTableName("site_modules"), "id='{$id}'"); |
45 | 45 | $content = $modx->db->getRow($rs); |
46 | -if(!$content) { |
|
46 | +if (!$content) { |
|
47 | 47 | $modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106"); |
48 | 48 | } |
49 | -if($content['disabled']) { |
|
49 | +if ($content['disabled']) { |
|
50 | 50 | $modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106"); |
51 | 51 | } |
52 | 52 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // Set the item name for logger |
60 | 60 | $_SESSION['itemname'] = $content['name']; |
61 | 61 | |
62 | -$output = evalModule($content["modulecode"],$parameter); |
|
62 | +$output = evalModule($content["modulecode"], $parameter); |
|
63 | 63 | echo $output; |
64 | 64 | include MODX_MANAGER_PATH."includes/sysalert.display.inc.php"; |
65 | 65 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | * @param array $params |
71 | 71 | * @return string |
72 | 72 | */ |
73 | -function evalModule($moduleCode,$params){ |
|
73 | +function evalModule($moduleCode, $params){ |
|
74 | 74 | $modx = evolutionCMS(); |
75 | 75 | $modx->event->params = &$params; // store params inside event object |
76 | - if(is_array($params)) { |
|
76 | + if (is_array($params)) { |
|
77 | 77 | extract($params, EXTR_SKIP); |
78 | 78 | } |
79 | 79 | ob_start(); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | if (isset($php_errormsg)) |
84 | 84 | { |
85 | 85 | $error_info = error_get_last(); |
86 | - switch($error_info['type']) |
|
86 | + switch ($error_info['type']) |
|
87 | 87 | { |
88 | 88 | case E_NOTICE : |
89 | 89 | $error_level = 1; |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | default: |
98 | 98 | $error_level = 99; |
99 | 99 | } |
100 | - if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
100 | + if ($modx->config['error_reporting'] === '99' || 2 < $error_level) |
|
101 | 101 | { |
102 | - $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
|
102 | + $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'].' - Module', $error_info['message'], $error_info['line'], $msg); |
|
103 | 103 | $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
104 | 104 | } |
105 | 105 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | // check if user has access permission, except admins |
15 | -if($_SESSION['mgrRole']!=1){ |
|
15 | +if($_SESSION['mgrRole']!=1) { |
|
16 | 16 | $rs = $modx->db->select( |
17 | 17 | 'sma.usergroup,mg.member', |
18 | 18 | $modx->getFullTableName("site_module_access")." sma |
@@ -70,7 +70,8 @@ discard block |
||
70 | 70 | * @param array $params |
71 | 71 | * @return string |
72 | 72 | */ |
73 | -function evalModule($moduleCode,$params){ |
|
73 | +function evalModule($moduleCode,$params) |
|
74 | +{ |
|
74 | 75 | $modx = evolutionCMS(); |
75 | 76 | $modx->event->params = &$params; // store params inside event object |
76 | 77 | if(is_array($params)) { |
@@ -80,11 +81,9 @@ discard block |
||
80 | 81 | $mod = eval($moduleCode); |
81 | 82 | $msg = ob_get_contents(); |
82 | 83 | ob_end_clean(); |
83 | - if (isset($php_errormsg)) |
|
84 | - { |
|
84 | + if (isset($php_errormsg)) { |
|
85 | 85 | $error_info = error_get_last(); |
86 | - switch($error_info['type']) |
|
87 | - { |
|
86 | + switch($error_info['type']) { |
|
88 | 87 | case E_NOTICE : |
89 | 88 | $error_level = 1; |
90 | 89 | case E_USER_NOTICE : |
@@ -97,8 +96,7 @@ discard block |
||
97 | 96 | default: |
98 | 97 | $error_level = 99; |
99 | 98 | } |
100 | - if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
101 | - { |
|
99 | + if($modx->config['error_reporting']==='99' || 2<$error_level) { |
|
102 | 100 | $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
103 | 101 | $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
104 | 102 | } |
@@ -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 | 11 | function evolutionCMS() |
12 | 12 | { |
13 | - if( ! defined('MODX_CLASS')) { |
|
14 | - if( ! class_exists('DocumentParser')) { |
|
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'); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $_ = crc32(__FILE__); |
30 | 30 | $_ = sprintf('%u', $_); |
31 | 31 | |
32 | - return 'evo' . base_convert($_, 10, 36); |
|
32 | + return 'evo'.base_convert($_, 10, 36); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | function startCMSSession() |
39 | 39 | { |
40 | 40 | global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain; |
41 | - if(MODX_CLI) return; |
|
41 | + if (MODX_CLI) return; |
|
42 | 42 | |
43 | 43 | session_name($site_sessionname); |
44 | 44 | removeInvalidCmsSessionIds($site_sessionname); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | session_start(); |
51 | 51 | $key = "modx.mgr.session.cookie.lifetime"; |
52 | 52 | if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
53 | - $cookieLifetime = (int)$_SESSION[$key]; |
|
53 | + $cookieLifetime = (int) $_SESSION[$key]; |
|
54 | 54 | if ($cookieLifetime) { |
55 | 55 | $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime; |
56 | 56 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | function removeInvalidCmsSessionIds($session_name) |
81 | 81 | { |
82 | - if(MODX_CLI) return; |
|
82 | + if (MODX_CLI) return; |
|
83 | 83 | // session ids is invalid iff it is empty string |
84 | 84 | // storage priorioty can see in PHP source ext/session/session.c |
85 | 85 | removeInvalidCmsSessionFromStorage($_COOKIE, $session_name); |
@@ -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); |