@@ -8,8 +8,8 @@ |
||
| 8 | 8 | ******************************************************* |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -use PHPMailer\PHPMailer\PHPMailer; |
|
| 12 | 11 | use PHPMailer\PHPMailer\Exception; |
| 12 | +use PHPMailer\PHPMailer\PHPMailer; |
|
| 13 | 13 | |
| 14 | 14 | require MODX_MANAGER_PATH . 'includes/controls/phpmailer/Exception.php'; |
| 15 | 15 | require MODX_MANAGER_PATH . 'includes/controls/phpmailer/PHPMailer.php'; |
@@ -276,14 +276,16 @@ discard block |
||
| 276 | 276 | /** |
| 277 | 277 | * @return string |
| 278 | 278 | */ |
| 279 | - public function getMIMEHeader() { |
|
| 279 | + public function getMIMEHeader() |
|
| 280 | + { |
|
| 280 | 281 | return $this->MIMEHeader; |
| 281 | 282 | } |
| 282 | 283 | |
| 283 | 284 | /** |
| 284 | 285 | * @return string |
| 285 | 286 | */ |
| 286 | - public function getMIMEBody() { |
|
| 287 | + public function getMIMEBody() |
|
| 288 | + { |
|
| 287 | 289 | return $this->MIMEBody; |
| 288 | 290 | } |
| 289 | 291 | |
@@ -292,7 +294,8 @@ discard block |
||
| 292 | 294 | * |
| 293 | 295 | * @return $this |
| 294 | 296 | */ |
| 295 | - public function setMIMEHeader($header = '') { |
|
| 297 | + public function setMIMEHeader($header = '') |
|
| 298 | + { |
|
| 296 | 299 | $this->MIMEHeader = $header; |
| 297 | 300 | |
| 298 | 301 | return $this; |
@@ -303,7 +306,8 @@ discard block |
||
| 303 | 306 | * |
| 304 | 307 | * @return $this |
| 305 | 308 | */ |
| 306 | - public function setMIMEBody($body = '') { |
|
| 309 | + public function setMIMEBody($body = '') |
|
| 310 | + { |
|
| 307 | 311 | $this->MIMEBody = $body; |
| 308 | 312 | |
| 309 | 313 | return $this; |
@@ -314,7 +318,8 @@ discard block |
||
| 314 | 318 | * |
| 315 | 319 | * @return $this |
| 316 | 320 | */ |
| 317 | - public function setMailHeader($header = '') { |
|
| 321 | + public function setMailHeader($header = '') |
|
| 322 | + { |
|
| 318 | 323 | $this->mailHeader = $header; |
| 319 | 324 | |
| 320 | 325 | return $this; |
@@ -323,7 +328,8 @@ discard block |
||
| 323 | 328 | /** |
| 324 | 329 | * @return string |
| 325 | 330 | */ |
| 326 | - public function getMessageID() { |
|
| 331 | + public function getMessageID() |
|
| 332 | + { |
|
| 327 | 333 | return trim($this->lastMessageID,'<>'); |
| 328 | 334 | } |
| 329 | 335 | } |
@@ -4,7 +4,9 @@ discard block |
||
| 4 | 4 | if (is_file($base_path . 'assets/cache/siteManager.php')) { |
| 5 | 5 | include_once($base_path . 'assets/cache/siteManager.php'); |
| 6 | 6 | } |
| 7 | -if(!defined('MGR_DIR')) define('MGR_DIR', 'manager'); |
|
| 7 | +if(!defined('MGR_DIR')) { |
|
| 8 | + define('MGR_DIR', 'manager'); |
|
| 9 | +} |
|
| 8 | 10 | |
| 9 | 11 | require_once('../'.MGR_DIR.'/includes/version.inc.php'); |
| 10 | 12 | |
@@ -19,12 +21,12 @@ discard block |
||
| 19 | 21 | $mt = &$moduleTemplates; |
| 20 | 22 | if(is_dir($templatePath) && is_readable($templatePath)) { |
| 21 | 23 | $d = dir($templatePath); |
| 22 | - while (false !== ($tplfile = $d->read())) |
|
| 23 | - { |
|
| 24 | - if(substr($tplfile, -4) != '.tpl') continue; |
|
| 24 | + while (false !== ($tplfile = $d->read())) { |
|
| 25 | + if(substr($tplfile, -4) != '.tpl') { |
|
| 26 | + continue; |
|
| 27 | + } |
|
| 25 | 28 | $params = parse_docblock($templatePath, $tplfile); |
| 26 | - if(is_array($params) && (count($params)>0)) |
|
| 27 | - { |
|
| 29 | + if(is_array($params) && (count($params)>0)) { |
|
| 28 | 30 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
| 29 | 31 | $mt[] = array |
| 30 | 32 | ( |
@@ -48,7 +50,9 @@ discard block |
||
| 48 | 50 | if(is_dir($tvPath) && is_readable($tvPath)) { |
| 49 | 51 | $d = dir($tvPath); |
| 50 | 52 | while (false !== ($tplfile = $d->read())) { |
| 51 | - if(substr($tplfile, -4) != '.tpl') continue; |
|
| 53 | + if(substr($tplfile, -4) != '.tpl') { |
|
| 54 | + continue; |
|
| 55 | + } |
|
| 52 | 56 | $params = parse_docblock($tvPath, $tplfile); |
| 53 | 57 | if(is_array($params) && (count($params)>0)) { |
| 54 | 58 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
@@ -241,7 +245,8 @@ discard block |
||
| 241 | 245 | // setup callback function |
| 242 | 246 | $callBackFnc = "clean_up"; |
| 243 | 247 | |
| 244 | -function clean_up($sqlParser) { |
|
| 248 | +function clean_up($sqlParser) |
|
| 249 | +{ |
|
| 245 | 250 | $ids = array(); |
| 246 | 251 | $mysqlVerOk = -1; |
| 247 | 252 | |
@@ -259,9 +264,10 @@ discard block |
||
| 259 | 264 | $ds = mysqli_query($sqlParser->conn,$sql); |
| 260 | 265 | if(!$ds) { |
| 261 | 266 | echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); |
| 262 | - } |
|
| 263 | - else { |
|
| 264 | - while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; |
|
| 267 | + } else { |
|
| 268 | + while($r = mysqli_fetch_assoc($ds)) { |
|
| 269 | + $ids[]=$r["id"]; |
|
| 270 | + } |
|
| 265 | 271 | if(count($ids)>0) { |
| 266 | 272 | mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")"); |
| 267 | 273 | unset($ids); |
@@ -278,9 +284,10 @@ discard block |
||
| 278 | 284 | $ds = mysqli_query($sqlParser->conn,$sql); |
| 279 | 285 | if(!$ds) { |
| 280 | 286 | echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); |
| 281 | - } |
|
| 282 | - else { |
|
| 283 | - while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; |
|
| 287 | + } else { |
|
| 288 | + while($r = mysqli_fetch_assoc($ds)) { |
|
| 289 | + $ids[]=$r["id"]; |
|
| 290 | + } |
|
| 284 | 291 | if(count($ids)>0) { |
| 285 | 292 | mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")"); |
| 286 | 293 | unset($ids); |
@@ -288,7 +295,8 @@ discard block |
||
| 288 | 295 | } |
| 289 | 296 | } |
| 290 | 297 | |
| 291 | -function parse_docblock($element_dir, $filename) { |
|
| 298 | +function parse_docblock($element_dir, $filename) |
|
| 299 | +{ |
|
| 292 | 300 | $params = array(); |
| 293 | 301 | $fullpath = $element_dir . '/' . $filename; |
| 294 | 302 | if(is_readable($fullpath)) { |
@@ -18,8 +18,7 @@ discard block |
||
| 18 | 18 | $output = $_lang["status_checking_database"]; |
| 19 | 19 | if (!$conn = mysqli_connect($host, $uid, $pwd)) { |
| 20 | 20 | $output .= '<span id="database_fail" style="color:#FF0000;">'.$_lang['status_failed'].'</span>'; |
| 21 | -} |
|
| 22 | -else { |
|
| 21 | +} else { |
|
| 23 | 22 | $database_name = mysqli_real_escape_string($conn, $_POST['database_name']); |
| 24 | 23 | $database_name = str_replace("`", "", $database_name); |
| 25 | 24 | $tableprefix = mysqli_real_escape_string($conn, $_POST['tableprefix']); |
@@ -31,20 +30,16 @@ discard block |
||
| 31 | 30 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
| 32 | 31 | $query = "CREATE DATABASE `".$database_name."` CHARACTER SET ".$database_charset." COLLATE ".$database_collation.";"; |
| 33 | 32 | |
| 34 | - if (! mysqli_query($conn, $query)){ |
|
| 33 | + if (! mysqli_query($conn, $query)) { |
|
| 35 | 34 | $output .= '<span id="database_fail" style="color:#FF0000;">'.$_lang['status_failed_could_not_create_database'].'</span>'; |
| 36 | - } |
|
| 37 | - else { |
|
| 35 | + } else { |
|
| 38 | 36 | $output .= '<span id="database_pass" style="color:#80c000;">'.$_lang['status_passed_database_created'].'</span>'; |
| 39 | 37 | } |
| 40 | - } |
|
| 41 | - elseif (($installMode == 0) && (mysqli_query($conn, "SELECT COUNT(*) FROM {$database_name}.`{$tableprefix}site_content`"))) { |
|
| 38 | + } elseif (($installMode == 0) && (mysqli_query($conn, "SELECT COUNT(*) FROM {$database_name}.`{$tableprefix}site_content`"))) { |
|
| 42 | 39 | $output .= '<span id="database_fail" style="color:#FF0000;">'.$_lang['status_failed_table_prefix_already_in_use'].'</span>'; |
| 43 | - } |
|
| 44 | - elseif (($database_connection_method != 'SET NAMES') && ($rs = mysqli_query($conn, "show variables like 'collation_database'")) && ($row = mysqli_fetch_row($rs)) && ($row[1] != $database_collation)) { |
|
| 40 | + } elseif (($database_connection_method != 'SET NAMES') && ($rs = mysqli_query($conn, "show variables like 'collation_database'")) && ($row = mysqli_fetch_row($rs)) && ($row[1] != $database_collation)) { |
|
| 45 | 41 | $output .= '<span id="database_fail" style="color:#FF0000;">'.sprintf($_lang['status_failed_database_collation_does_not_match'], $row[1]).'</span>'; |
| 46 | - } |
|
| 47 | - else { |
|
| 42 | + } else { |
|
| 48 | 43 | $output .= '<span id="database_pass" style="color:#80c000;">'.$_lang['status_passed'].'</span>'; |
| 49 | 44 | } |
| 50 | 45 | } |
@@ -4,10 +4,8 @@ discard block |
||
| 4 | 4 | global $_lang; |
| 5 | 5 | |
| 6 | 6 | // session loop-back tester |
| 7 | - if(!isset($_GET['action']) || $_GET['action']!=='mode') |
|
| 8 | - { |
|
| 9 | - if(!isset($_SESSION['test']) || $_SESSION['test']!=1) |
|
| 10 | - { |
|
| 7 | + if(!isset($_GET['action']) || $_GET['action']!=='mode') { |
|
| 8 | + if(!isset($_SESSION['test']) || $_SESSION['test']!=1) { |
|
| 11 | 9 | echo ' |
| 12 | 10 | <html> |
| 13 | 11 | <head> |
@@ -34,8 +32,7 @@ discard block |
||
| 34 | 32 | |
| 35 | 33 | function parse($src,$ph,$left='[+',$right='+]') |
| 36 | 34 | { |
| 37 | - foreach($ph as $k=>$v) |
|
| 38 | - { |
|
| 35 | + foreach($ph as $k=>$v) { |
|
| 39 | 36 | $k = $left . $k . $right; |
| 40 | 37 | $src = str_replace($k,$v,$src); |
| 41 | 38 | } |
@@ -46,8 +43,11 @@ discard block |
||
| 46 | 43 | { |
| 47 | 44 | global $_lang,$moduleName,$moduleVersion,$modx_textdir,$modx_release_date; |
| 48 | 45 | |
| 49 | - if(isset($_SESSION['installmode'])) $installmode = $_SESSION['installmode']; |
|
| 50 | - else $installmode = get_installmode(); |
|
| 46 | + if(isset($_SESSION['installmode'])) { |
|
| 47 | + $installmode = $_SESSION['installmode']; |
|
| 48 | + } else { |
|
| 49 | + $installmode = get_installmode(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | $ph['pagetitle'] = $_lang['modx_install']; |
| 53 | 53 | $ph['textdir'] = $modx_textdir ? ' id="rtl"':''; |
@@ -65,29 +65,29 @@ discard block |
||
| 65 | 65 | global $base_path,$database_server, $database_user, $database_password, $dbase, $table_prefix; |
| 66 | 66 | |
| 67 | 67 | $conf_path = "{$base_path}manager/includes/config.inc.php"; |
| 68 | - if (!is_file($conf_path)) $installmode = 0; |
|
| 69 | - elseif(isset($_POST['installmode'])) $installmode = $_POST['installmode']; |
|
| 70 | - else |
|
| 71 | - { |
|
| 68 | + if (!is_file($conf_path)) { |
|
| 69 | + $installmode = 0; |
|
| 70 | + } elseif(isset($_POST['installmode'])) { |
|
| 71 | + $installmode = $_POST['installmode']; |
|
| 72 | + } else { |
|
| 72 | 73 | include_once("{$base_path}manager/includes/config.inc.php"); |
| 73 | 74 | |
| 74 | - if(!isset($dbase) || empty($dbase)) $installmode = 0; |
|
| 75 | - else |
|
| 76 | - { |
|
| 75 | + if(!isset($dbase) || empty($dbase)) { |
|
| 76 | + $installmode = 0; |
|
| 77 | + } else { |
|
| 77 | 78 | $conn = mysqli_connect($database_server, $database_user, $database_password); |
| 78 | - if($conn) |
|
| 79 | - { |
|
| 79 | + if($conn) { |
|
| 80 | 80 | $_SESSION['database_server'] = $database_server; |
| 81 | 81 | $_SESSION['database_user'] = $database_user; |
| 82 | 82 | $_SESSION['database_password'] = $database_password; |
| 83 | 83 | |
| 84 | 84 | $dbase = trim($dbase, '`'); |
| 85 | 85 | $rs = mysqli_select_db($conn, $dbase); |
| 86 | + } else { |
|
| 87 | + $rs = false; |
|
| 86 | 88 | } |
| 87 | - else $rs = false; |
|
| 88 | 89 | |
| 89 | - if($rs) |
|
| 90 | - { |
|
| 90 | + if($rs) { |
|
| 91 | 91 | $_SESSION['dbase'] = $dbase; |
| 92 | 92 | $_SESSION['table_prefix'] = $table_prefix; |
| 93 | 93 | $_SESSION['database_collation'] = 'utf8_general_ci'; |
@@ -95,17 +95,21 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | $tbl_system_settings = "`{$dbase}`.`{$table_prefix}system_settings`"; |
| 97 | 97 | $rs = mysqli_query($conn, "SELECT setting_value FROM {$tbl_system_settings} WHERE setting_name='settings_version'"); |
| 98 | - if($rs) |
|
| 99 | - { |
|
| 98 | + if($rs) { |
|
| 100 | 99 | $row = mysqli_fetch_assoc($rs); |
| 101 | 100 | $settings_version = $row['setting_value']; |
| 101 | + } else { |
|
| 102 | + $settings_version = ''; |
|
| 102 | 103 | } |
| 103 | - else $settings_version = ''; |
|
| 104 | 104 | |
| 105 | - if (empty($settings_version)) $installmode = 0; |
|
| 106 | - else $installmode = 1; |
|
| 105 | + if (empty($settings_version)) { |
|
| 106 | + $installmode = 0; |
|
| 107 | + } else { |
|
| 108 | + $installmode = 1; |
|
| 109 | + } |
|
| 110 | + } else { |
|
| 111 | + $installmode = 1; |
|
| 107 | 112 | } |
| 108 | - else $installmode = 1; |
|
| 109 | 113 | } |
| 110 | 114 | } |
| 111 | 115 | return $installmode; |
@@ -17,8 +17,7 @@ discard block |
||
| 17 | 17 | $output = $_lang["status_connecting"]; |
| 18 | 18 | if (!$conn = @mysqli_connect($host, $uid, $pwd)) { |
| 19 | 19 | $output .= '<span id="server_fail" style="color:#FF0000;"> '.$_lang['status_failed'].'</span>'; |
| 20 | -} |
|
| 21 | -else { |
|
| 20 | +} else { |
|
| 22 | 21 | $output .= '<span id="server_pass" style="color:#80c000;"> '.$_lang['status_passed_server'].'</span>'; |
| 23 | 22 | |
| 24 | 23 | // Mysql version check |
@@ -27,13 +26,17 @@ discard block |
||
| 27 | 26 | } |
| 28 | 27 | // Mode check |
| 29 | 28 | $mysqlmode = mysqli_query($conn, "SELECT @@session.sql_mode"); |
| 30 | - if (@mysqli_num_rows($mysqlmode) > 0){ |
|
| 29 | + if (@mysqli_num_rows($mysqlmode) > 0) { |
|
| 31 | 30 | $modes = mysqli_fetch_array($mysqlmode, MYSQLI_NUM); |
| 32 | 31 | $strictMode = false; |
| 33 | 32 | foreach ($modes as $mode) { |
| 34 | - if (stristr($mode, "STRICT_TRANS_TABLES") !== false || stristr($mode, "STRICT_ALL_TABLES") !== false) $strictMode = true; |
|
| 33 | + if (stristr($mode, "STRICT_TRANS_TABLES") !== false || stristr($mode, "STRICT_ALL_TABLES") !== false) { |
|
| 34 | + $strictMode = true; |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | + if ($strictMode) { |
|
| 38 | + $output .= '<br /><span style="color:#FF0000;"> '.$_lang['strict_mode'].'</span>'; |
|
| 35 | 39 | } |
| 36 | - if ($strictMode) $output .= '<br /><span style="color:#FF0000;"> '.$_lang['strict_mode'].'</span>'; |
|
| 37 | 40 | } |
| 38 | 41 | } |
| 39 | 42 | echo $output; |
@@ -15,7 +15,9 @@ discard block |
||
| 15 | 15 | require_once('lang.php'); |
| 16 | 16 | |
| 17 | 17 | $conn = mysqli_connect($host, $uid, $pwd); |
| 18 | -if(!$conn) exit('can not connect'); |
|
| 18 | +if(!$conn) { |
|
| 19 | + exit('can not connect'); |
|
| 20 | +} |
|
| 19 | 21 | |
| 20 | 22 | // get collation |
| 21 | 23 | $rs = mysqli_query($conn, "SHOW COLLATION"); |
@@ -29,23 +31,31 @@ discard block |
||
| 29 | 31 | $database_collation = htmlentities($_POST['database_collation']); |
| 30 | 32 | $recommend_collation = $_lang['recommend_collation']; |
| 31 | 33 | |
| 32 | - if (isset($_[$recommend_collation])) $_[$recommend_collation] = ' selected'; |
|
| 33 | - elseif(isset($_['utf8mb4_general_ci'])) $_['utf8mb4_general_ci'] = ' selected'; |
|
| 34 | - elseif(isset($_['utf8_general_ci'])) $_['utf8_general_ci'] = ' selected'; |
|
| 35 | - elseif(isset($_[$database_collation])) $_[$database_collation] = ' selected'; |
|
| 34 | + if (isset($_[$recommend_collation])) { |
|
| 35 | + $_[$recommend_collation] = ' selected'; |
|
| 36 | + } elseif(isset($_['utf8mb4_general_ci'])) { |
|
| 37 | + $_['utf8mb4_general_ci'] = ' selected'; |
|
| 38 | + } elseif(isset($_['utf8_general_ci'])) { |
|
| 39 | + $_['utf8_general_ci'] = ' selected'; |
|
| 40 | + } elseif(isset($_[$database_collation])) { |
|
| 41 | + $_[$database_collation] = ' selected'; |
|
| 42 | + } |
|
| 36 | 43 | |
| 37 | 44 | $_ = sortItem($_,$_lang['recommend_collations_order']); |
| 38 | 45 | |
| 39 | 46 | foreach($_ as $collation=>$selected) { |
| 40 | 47 | $collation = htmlentities($collation); |
| 41 | 48 | // if(substr($collation,0,4)!=='utf8') continue; |
| 42 | - if(strpos($collation,'sjis')===0) continue; |
|
| 43 | - if($collation=='recommend') |
|
| 44 | - $output .= '<optgroup label="recommend">'; |
|
| 45 | - elseif($collation=='unrecommend') |
|
| 46 | - $output .= '</optgroup><optgroup label="unrecommend">'; |
|
| 47 | - else |
|
| 48 | - $output .= sprintf('<option value="%s" %s>%s</option>', $collation, $selected, $collation); |
|
| 49 | + if(strpos($collation,'sjis')===0) { |
|
| 50 | + continue; |
|
| 51 | + } |
|
| 52 | + if($collation=='recommend') { |
|
| 53 | + $output .= '<optgroup label="recommend">'; |
|
| 54 | + } elseif($collation=='unrecommend') { |
|
| 55 | + $output .= '</optgroup><optgroup label="unrecommend">'; |
|
| 56 | + } else { |
|
| 57 | + $output .= sprintf('<option value="%s" %s>%s</option>', $collation, $selected, $collation); |
|
| 58 | + } |
|
| 49 | 59 | } |
| 50 | 60 | $output .= '</optgroup></select>'; |
| 51 | 61 | } |
@@ -55,7 +65,8 @@ discard block |
||
| 55 | 65 | |
| 56 | 66 | |
| 57 | 67 | |
| 58 | -function sortItem($array=array(),$order='utf8mb4,utf8') { |
|
| 68 | +function sortItem($array=array(),$order='utf8mb4,utf8') |
|
| 69 | +{ |
|
| 59 | 70 | $rs = array('recommend'=>''); |
| 60 | 71 | $order = explode(',', $order); |
| 61 | 72 | foreach($order as $v) { |
@@ -37,15 +37,18 @@ discard block |
||
| 37 | 37 | "sv" => "svenska" |
| 38 | 38 | ); |
| 39 | 39 | $_langISO6391 = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2); |
| 40 | -if (!empty($_langFiles[$_langISO6391])) $install_language = $_langFiles[$_langISO6391]; |
|
| 40 | +if (!empty($_langFiles[$_langISO6391])) { |
|
| 41 | + $install_language = $_langFiles[$_langISO6391]; |
|
| 42 | +} |
|
| 41 | 43 | |
| 42 | 44 | |
| 43 | 45 | if (isset($_POST['language']) && !stristr($_POST['language'],"..")) { |
| 44 | 46 | $install_language = $_POST['language']; |
| 45 | 47 | } else { |
| 46 | - if (isset($_GET['language']) && !stristr($_GET['language'],"..")) |
|
| 47 | - $install_language = $_GET['language']; |
|
| 48 | -} |
|
| 48 | + if (isset($_GET['language']) && !stristr($_GET['language'],"..")) { |
|
| 49 | + $install_language = $_GET['language']; |
|
| 50 | + } |
|
| 51 | + } |
|
| 49 | 52 | # load language file |
| 50 | 53 | require_once("lang/english.inc.php"); // As fallback |
| 51 | 54 | require_once("lang/".$install_language.".inc.php"); |
@@ -55,13 +58,14 @@ discard block |
||
| 55 | 58 | if (isset($_POST['managerlanguage']) && !stristr($_POST['managerlanguage'],"..")) { |
| 56 | 59 | $manager_language = $_POST['managerlanguage']; |
| 57 | 60 | } else { |
| 58 | - if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],"..")) |
|
| 59 | - $manager_language = $_GET['managerlanguage']; |
|
| 60 | -} |
|
| 61 | + if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],"..")) { |
|
| 62 | + $manager_language = $_GET['managerlanguage']; |
|
| 63 | + } |
|
| 64 | + } |
|
| 61 | 65 | |
| 62 | -foreach($_lang as $k=>$v) |
|
| 63 | -{ |
|
| 64 | - if(strpos($v,'[+MGR_DIR+]')!==false) |
|
| 65 | - $_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v); |
|
| 66 | -} |
|
| 66 | +foreach($_lang as $k=>$v) { |
|
| 67 | + if(strpos($v,'[+MGR_DIR+]')!==false) { |
|
| 68 | + $_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v); |
|
| 69 | + } |
|
| 70 | + } |
|
| 67 | 71 | ?> |
| 68 | 72 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) { |
| 3 | 3 | include_once(dirname(__FILE__)."/../assets/cache/siteManager.php"); |
| 4 | -}else{ |
|
| 4 | +} else { |
|
| 5 | 5 | define('MGR_DIR', 'manager'); |
| 6 | 6 | } |
| 7 | 7 | |
@@ -58,13 +58,15 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | // get base path and url |
| 60 | 60 | $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"]))); |
| 61 | -if (count($a) > 1) |
|
| 61 | +if (count($a) > 1) { |
|
| 62 | 62 | array_pop($a); |
| 63 | +} |
|
| 63 | 64 | $url = implode("install", $a); |
| 64 | 65 | reset($a); |
| 65 | 66 | $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__)))); |
| 66 | -if (count($a) > 1) |
|
| 67 | +if (count($a) > 1) { |
|
| 67 | 68 | array_pop($a); |
| 69 | +} |
|
| 68 | 70 | $pth = implode("install", $a); |
| 69 | 71 | unset ($a); |
| 70 | 72 | $base_url = $url . (substr($url, -1) != "/" ? "/" : ""); |
@@ -85,7 +87,9 @@ discard block |
||
| 85 | 87 | echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>"; |
| 86 | 88 | $create = true; |
| 87 | 89 | } else { |
| 88 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset); |
|
| 90 | + if (function_exists('mysqli_set_charset')) { |
|
| 91 | + mysqli_set_charset($conn, $database_charset); |
|
| 92 | + } |
|
| 89 | 93 | mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); |
| 90 | 94 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
| 91 | 95 | } |
@@ -127,7 +131,8 @@ discard block |
||
| 127 | 131 | if(!function_exists('parseProperties')) { |
| 128 | 132 | // parses a resource property string and returns the result as an array |
| 129 | 133 | // duplicate of method in documentParser class |
| 130 | - function parseProperties($propertyString) { |
|
| 134 | + function parseProperties($propertyString) |
|
| 135 | + { |
|
| 131 | 136 | $parameter= array (); |
| 132 | 137 | if (!empty ($propertyString)) { |
| 133 | 138 | $tmpParams= explode("&", $propertyString); |
@@ -135,11 +140,14 @@ discard block |
||
| 135 | 140 | if (strpos($tmpParams[$x], '=', 0)) { |
| 136 | 141 | $pTmp= explode("=", $tmpParams[$x]); |
| 137 | 142 | $pvTmp= explode(";", trim($pTmp[1])); |
| 138 | - if ($pvTmp[1] == 'list' && $pvTmp[3] != "") |
|
| 139 | - $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default |
|
| 143 | + if ($pvTmp[1] == 'list' && $pvTmp[3] != "") { |
|
| 144 | + $parameter[trim($pTmp[0])]= $pvTmp[3]; |
|
| 145 | + } |
|
| 146 | + //list default |
|
| 140 | 147 | else |
| 141 | - if ($pvTmp[1] != 'list' && $pvTmp[2] != "") |
|
| 142 | - $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 148 | + if ($pvTmp[1] != 'list' && $pvTmp[2] != "") { |
|
| 149 | + $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 150 | + } |
|
| 143 | 151 | } |
| 144 | 152 | } |
| 145 | 153 | } |
@@ -210,7 +218,7 @@ discard block |
||
| 210 | 218 | // custom or not |
| 211 | 219 | if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) { |
| 212 | 220 | $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");'; |
| 213 | -}else{ |
|
| 221 | +} else { |
|
| 214 | 222 | $mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
| 215 | 223 | } |
| 216 | 224 | |
@@ -346,7 +354,9 @@ discard block |
||
| 346 | 354 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 347 | 355 | return; |
| 348 | 356 | } |
| 349 | - if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 357 | + if(!is_null($save_sql_id_as)) { |
|
| 358 | + $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 359 | + } |
|
| 350 | 360 | echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
| 351 | 361 | } |
| 352 | 362 | } |
@@ -440,9 +450,9 @@ discard block |
||
| 440 | 450 | $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]); |
| 441 | 451 | $filecontent = $moduleChunk[2]; |
| 442 | 452 | |
| 443 | - if (!file_exists($filecontent)) |
|
| 444 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 445 | - else { |
|
| 453 | + if (!file_exists($filecontent)) { |
|
| 454 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 455 | + } else { |
|
| 446 | 456 | |
| 447 | 457 | // Create the category if it does not already exist |
| 448 | 458 | $category_id = getCreateDbCategory($category, $sqlParser); |
@@ -494,9 +504,9 @@ discard block |
||
| 494 | 504 | $guid = mysqli_real_escape_string($conn, $moduleModule[4]); |
| 495 | 505 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
| 496 | 506 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
| 497 | - if (!file_exists($filecontent)) |
|
| 498 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 499 | - else { |
|
| 507 | + if (!file_exists($filecontent)) { |
|
| 508 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 509 | + } else { |
|
| 500 | 510 | |
| 501 | 511 | // Create the category if it does not already exist |
| 502 | 512 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -546,9 +556,9 @@ discard block |
||
| 546 | 556 | // parse comma-separated legacy names and prepare them for sql IN clause |
| 547 | 557 | $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
| 548 | 558 | } |
| 549 | - if (!file_exists($filecontent)) |
|
| 550 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 551 | - else { |
|
| 559 | + if (!file_exists($filecontent)) { |
|
| 560 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 561 | + } else { |
|
| 552 | 562 | |
| 553 | 563 | // disable legacy versions based on legacy_names provided |
| 554 | 564 | if(!empty($leg_names)) { |
@@ -567,7 +577,7 @@ discard block |
||
| 567 | 577 | $insert = true; |
| 568 | 578 | while($row = mysqli_fetch_assoc($rs)) { |
| 569 | 579 | $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
| 570 | - if($row['description'] == $desc){ |
|
| 580 | + if($row['description'] == $desc) { |
|
| 571 | 581 | if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
| 572 | 582 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 573 | 583 | return; |
@@ -625,9 +635,9 @@ discard block |
||
| 625 | 635 | $filecontent = $moduleSnippet[2]; |
| 626 | 636 | $properties = $moduleSnippet[3]; |
| 627 | 637 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
| 628 | - if (!file_exists($filecontent)) |
|
| 629 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 630 | - else { |
|
| 638 | + if (!file_exists($filecontent)) { |
|
| 639 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 640 | + } else { |
|
| 631 | 641 | |
| 632 | 642 | // Create the category if it does not already exist |
| 633 | 643 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -735,13 +745,16 @@ discard block |
||
| 735 | 745 | } |
| 736 | 746 | |
| 737 | 747 | // call back function |
| 738 | -if ($callBackFnc != "") |
|
| 748 | +if ($callBackFnc != "") { |
|
| 739 | 749 | $callBackFnc ($sqlParser); |
| 750 | +} |
|
| 740 | 751 | |
| 741 | 752 | // Setup the MODX API -- needed for the cache processor |
| 742 | 753 | define('MODX_API_MODE', true); |
| 743 | 754 | define('MODX_BASE_PATH', $base_path); |
| 744 | -if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
| 755 | +if (!defined('MODX_MANAGER_PATH')) { |
|
| 756 | + define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
| 757 | +} |
|
| 745 | 758 | $database_type = 'mysqli'; |
| 746 | 759 | // initiate a new document parser |
| 747 | 760 | include_once('../'.MGR_DIR.'/includes/document.parser.class.inc.php'); |
@@ -780,11 +793,12 @@ discard block |
||
| 780 | 793 | } |
| 781 | 794 | |
| 782 | 795 | // Property Update function |
| 783 | -function propUpdate($new,$old){ |
|
| 796 | +function propUpdate($new,$old) |
|
| 797 | +{ |
|
| 784 | 798 | $newArr = parseProperties($new); |
| 785 | 799 | $oldArr = parseProperties($old); |
| 786 | - foreach ($oldArr as $k => $v){ |
|
| 787 | - if (isset($v['0']['options'])){ |
|
| 800 | + foreach ($oldArr as $k => $v) { |
|
| 801 | + if (isset($v['0']['options'])) { |
|
| 788 | 802 | $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options']; |
| 789 | 803 | } |
| 790 | 804 | } |
@@ -794,12 +808,17 @@ discard block |
||
| 794 | 808 | return $return; |
| 795 | 809 | } |
| 796 | 810 | |
| 797 | -function parseProperties($propertyString, $json=false) { |
|
| 811 | +function parseProperties($propertyString, $json=false) |
|
| 812 | +{ |
|
| 798 | 813 | $propertyString = str_replace('{}', '', $propertyString ); |
| 799 | 814 | $propertyString = str_replace('} {', ',', $propertyString ); |
| 800 | 815 | |
| 801 | - if(empty($propertyString)) return array(); |
|
| 802 | - if($propertyString=='{}' || $propertyString=='[]') return array(); |
|
| 816 | + if(empty($propertyString)) { |
|
| 817 | + return array(); |
|
| 818 | + } |
|
| 819 | + if($propertyString=='{}' || $propertyString=='[]') { |
|
| 820 | + return array(); |
|
| 821 | + } |
|
| 803 | 822 | |
| 804 | 823 | $jsonFormat = isJson($propertyString, true); |
| 805 | 824 | $property = array(); |
@@ -809,7 +828,7 @@ discard block |
||
| 809 | 828 | $arr = array(); |
| 810 | 829 | $key = array(); |
| 811 | 830 | foreach ($props as $prop) { |
| 812 | - if ($prop != ''){ |
|
| 831 | + if ($prop != '') { |
|
| 813 | 832 | $arr = explode(';', $prop); |
| 814 | 833 | $key = explode('=', $arr['0']); |
| 815 | 834 | $property[$key['0']]['0']['label'] = trim($key['1']); |
@@ -833,7 +852,7 @@ discard block |
||
| 833 | 852 | |
| 834 | 853 | } |
| 835 | 854 | // new json-format |
| 836 | - } else if(!empty($jsonFormat)){ |
|
| 855 | + } else if(!empty($jsonFormat)) { |
|
| 837 | 856 | $property = $jsonFormat; |
| 838 | 857 | } |
| 839 | 858 | if ($json) { |
@@ -843,12 +862,14 @@ discard block |
||
| 843 | 862 | return $property; |
| 844 | 863 | } |
| 845 | 864 | |
| 846 | -function isJson($string, $returnData=false) { |
|
| 865 | +function isJson($string, $returnData=false) |
|
| 866 | +{ |
|
| 847 | 867 | $data = json_decode($string, true); |
| 848 | 868 | return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false; |
| 849 | 869 | } |
| 850 | 870 | |
| 851 | -function getCreateDbCategory($category, $sqlParser) { |
|
| 871 | +function getCreateDbCategory($category, $sqlParser) |
|
| 872 | +{ |
|
| 852 | 873 | $dbase = $sqlParser->dbname; |
| 853 | 874 | $dbase = '`' . trim($dbase,'`') . '`'; |
| 854 | 875 | $table_prefix = $sqlParser->prefix; |
@@ -870,7 +891,8 @@ discard block |
||
| 870 | 891 | } |
| 871 | 892 | |
| 872 | 893 | // Remove installer Docblock only from components using plugin FileSource / fileBinding |
| 873 | -function removeDocblock($code, $type) { |
|
| 894 | +function removeDocblock($code, $type) |
|
| 895 | +{ |
|
| 874 | 896 | |
| 875 | 897 | $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1); |
| 876 | 898 | |
@@ -891,8 +913,9 @@ discard block |
||
| 891 | 913 | default: |
| 892 | 914 | return $cleaned; |
| 893 | 915 | }; |
| 894 | - if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
| 895 | - return $cleaned; |
|
| 916 | + if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') { |
|
| 917 | + return $cleaned; |
|
| 918 | + } |
|
| 896 | 919 | |
| 897 | 920 | // fileBinding not found - return code incl docblock |
| 898 | 921 | return $code; |
@@ -3,14 +3,16 @@ discard block |
||
| 3 | 3 | // MySQL Dump Parser |
| 4 | 4 | // SNUFFKIN/ Alex 2004 |
| 5 | 5 | |
| 6 | -class SqlParser { |
|
| 6 | +class SqlParser |
|
| 7 | +{ |
|
| 7 | 8 | var $host, $dbname, $prefix, $user, $password, $mysqlErrors; |
| 8 | 9 | var $conn, $installFailed, $sitename, $adminname, $adminemail, $adminpass, $managerlanguage; |
| 9 | 10 | var $mode, $fileManagerPath, $imgPath, $imgUrl; |
| 10 | 11 | var $dbMODx, $dbVersion; |
| 11 | 12 | var $connection_charset, $connection_method; |
| 12 | 13 | |
| 13 | - function SqlParser($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
| 14 | + function SqlParser($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') |
|
| 15 | + { |
|
| 14 | 16 | $this->host = $host; |
| 15 | 17 | $this->dbname = $db; |
| 16 | 18 | $this->prefix = $prefix; |
@@ -26,10 +28,13 @@ discard block |
||
| 26 | 28 | $this->autoTemplateLogic = $auto_template_logic; |
| 27 | 29 | } |
| 28 | 30 | |
| 29 | - function connect() { |
|
| 31 | + function connect() |
|
| 32 | + { |
|
| 30 | 33 | $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
| 31 | 34 | mysqli_select_db($this->conn, $this->dbname); |
| 32 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
| 35 | + if (function_exists('mysqli_set_charset')) { |
|
| 36 | + mysqli_set_charset($this->conn, $this->connection_charset); |
|
| 37 | + } |
|
| 33 | 38 | |
| 34 | 39 | $this->dbVersion = 3.23; // assume version 3.23 |
| 35 | 40 | if(function_exists("mysqli_get_server_info")) { |
@@ -41,7 +46,8 @@ discard block |
||
| 41 | 46 | mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}"); |
| 42 | 47 | } |
| 43 | 48 | |
| 44 | - function process($filename) { |
|
| 49 | + function process($filename) |
|
| 50 | + { |
|
| 45 | 51 | global $custom_placeholders; |
| 46 | 52 | |
| 47 | 53 | // check to make sure file exists |
@@ -66,7 +72,9 @@ discard block |
||
| 66 | 72 | // remove non-upgradeable parts |
| 67 | 73 | $s = strpos($idata,"non-upgrade-able[["); |
| 68 | 74 | $e = strpos($idata,"]]non-upgrade-able")+17; |
| 69 | - if($s && $e) $idata = str_replace(substr($idata,$s,$e-$s)," Removed non upgradeable items",$idata); |
|
| 75 | + if($s && $e) { |
|
| 76 | + $idata = str_replace(substr($idata,$s,$e-$s)," Removed non upgradeable items",$idata); |
|
| 77 | + } |
|
| 70 | 78 | } |
| 71 | 79 | |
| 72 | 80 | // replace {} tags |
@@ -94,7 +102,9 @@ discard block |
||
| 94 | 102 | foreach($sql_array as $sql_entry) { |
| 95 | 103 | $sql_do = trim($sql_entry, "\r\n; "); |
| 96 | 104 | |
| 97 | - if (preg_match('/^\#/', $sql_do)) continue; |
|
| 105 | + if (preg_match('/^\#/', $sql_do)) { |
|
| 106 | + continue; |
|
| 107 | + } |
|
| 98 | 108 | |
| 99 | 109 | // strip out comments and \n for mysql 3.x |
| 100 | 110 | if ($this->dbVersion <4.0) { |
@@ -105,11 +115,15 @@ discard block |
||
| 105 | 115 | |
| 106 | 116 | |
| 107 | 117 | $num = $num + 1; |
| 108 | - if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
| 118 | + if ($sql_do) { |
|
| 119 | + mysqli_query($this->conn, $sql_do); |
|
| 120 | + } |
|
| 109 | 121 | if(mysqli_error($this->conn)) { |
| 110 | 122 | // Ignore duplicate and drop errors - Raymond |
| 111 | - if ($this->ignoreDuplicateErrors){ |
|
| 112 | - if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
| 123 | + if ($this->ignoreDuplicateErrors) { |
|
| 124 | + if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) { |
|
| 125 | + continue; |
|
| 126 | + } |
|
| 113 | 127 | } |
| 114 | 128 | // End Ignore duplicate |
| 115 | 129 | $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
@@ -118,7 +132,8 @@ discard block |
||
| 118 | 132 | } |
| 119 | 133 | } |
| 120 | 134 | |
| 121 | - function close() { |
|
| 135 | + function close() |
|
| 136 | + { |
|
| 122 | 137 | mysqli_close($this->conn); |
| 123 | 138 | } |
| 124 | 139 | } |