@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $autoloader = __DIR__.'/vendor/autoload.php'; |
49 | 49 | if (file_exists($autoloader) && is_readable($autoloader)) { |
50 | - include_once($autoloader); |
|
50 | + include_once($autoloader); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true); |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | if(is_file($base_path . 'assets/cache/siteManager.php')) |
57 | 57 | include_once($base_path . 'assets/cache/siteManager.php'); |
58 | 58 | if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) |
59 | - define('MGR_DIR','manager'); |
|
59 | + define('MGR_DIR','manager'); |
|
60 | 60 | if(is_file($base_path . 'assets/cache/siteHostnames.php')) |
61 | 61 | include_once($base_path . 'assets/cache/siteHostnames.php'); |
62 | 62 | if(!defined('MODX_SITE_HOSTNAMES')) |
63 | - define('MODX_SITE_HOSTNAMES',''); |
|
63 | + define('MODX_SITE_HOSTNAMES',''); |
|
64 | 64 | |
65 | 65 | // get start time |
66 | 66 | $mstart = memory_get_usage(); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | define("IN_PARSER_MODE", true); |
86 | 86 | if (!defined('IN_MANAGER_MODE')) { |
87 | - define("IN_MANAGER_MODE", false); |
|
87 | + define("IN_MANAGER_MODE", false); |
|
88 | 88 | } |
89 | 89 | if (!defined('MODX_API_MODE')) { |
90 | 90 | define('MODX_API_MODE', false); |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | |
93 | 93 | // get the required includes |
94 | 94 | if(!isset($database_user) || $database_user=="") { |
95 | - $rt = @include_once(dirname(__FILE__).'/'.MGR_DIR.'/includes/config.inc.php'); |
|
96 | - // Be sure config.inc.php is there and that it contains some important values |
|
97 | - if(!$rt || !$database_type || !$database_server || !$database_user || !$dbase) { |
|
98 | - readfile('install/not_installed.tpl'); |
|
99 | - exit; |
|
100 | - } |
|
95 | + $rt = @include_once(dirname(__FILE__).'/'.MGR_DIR.'/includes/config.inc.php'); |
|
96 | + // Be sure config.inc.php is there and that it contains some important values |
|
97 | + if(!$rt || !$database_type || !$database_server || !$database_user || !$dbase) { |
|
98 | + readfile('install/not_installed.tpl'); |
|
99 | + exit; |
|
100 | + } |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // start session |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | |
106 | 106 | // initiate a new document parser |
107 | 107 | if (isset($coreClass) && class_exists($coreClass)) { |
108 | - $modx = new $coreClass; |
|
108 | + $modx = new $coreClass; |
|
109 | 109 | } |
110 | 110 | if (!isset($modx) || !($modx instanceof \DocumentParser)) { |
111 | - include_once(MODX_MANAGER_PATH.'includes/document.parser.class.inc.php'); |
|
112 | - $modx = new \DocumentParser; |
|
111 | + include_once(MODX_MANAGER_PATH.'includes/document.parser.class.inc.php'); |
|
112 | + $modx = new \DocumentParser; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | // set some parser options |
@@ -4,138 +4,138 @@ |
||
4 | 4 | // SNUFFKIN/ Alex 2004 |
5 | 5 | |
6 | 6 | class SqlParser { |
7 | - public $host; |
|
8 | - public $dbname; |
|
9 | - public $prefix; |
|
10 | - public $user; |
|
11 | - public $password; |
|
12 | - public $mysqlErrors; |
|
13 | - public $conn; |
|
14 | - public $installFailed; |
|
15 | - public $sitename; |
|
16 | - public $adminname; |
|
17 | - public $adminemail; |
|
18 | - public $adminpass; |
|
19 | - public $managerlanguage; |
|
20 | - public $mode; |
|
21 | - public $fileManagerPath; |
|
22 | - public $imgPath; |
|
23 | - public $imgUrl; |
|
24 | - public $dbMODx; |
|
25 | - public $dbVersion; |
|
7 | + public $host; |
|
8 | + public $dbname; |
|
9 | + public $prefix; |
|
10 | + public $user; |
|
11 | + public $password; |
|
12 | + public $mysqlErrors; |
|
13 | + public $conn; |
|
14 | + public $installFailed; |
|
15 | + public $sitename; |
|
16 | + public $adminname; |
|
17 | + public $adminemail; |
|
18 | + public $adminpass; |
|
19 | + public $managerlanguage; |
|
20 | + public $mode; |
|
21 | + public $fileManagerPath; |
|
22 | + public $imgPath; |
|
23 | + public $imgUrl; |
|
24 | + public $dbMODx; |
|
25 | + public $dbVersion; |
|
26 | 26 | public $connection_charset; |
27 | 27 | public $connection_method; |
28 | 28 | public $ignoreDuplicateErrors; |
29 | 29 | |
30 | - public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
31 | - $this->host = $host; |
|
32 | - $this->dbname = $db; |
|
33 | - $this->prefix = $prefix; |
|
34 | - $this->user = $user; |
|
35 | - $this->password = $password; |
|
36 | - $this->adminpass = $adminpass; |
|
37 | - $this->adminname = $adminname; |
|
38 | - $this->adminemail = $adminemail; |
|
39 | - $this->connection_charset = $connection_charset; |
|
40 | - $this->connection_method = $connection_method; |
|
41 | - $this->ignoreDuplicateErrors = false; |
|
42 | - $this->managerlanguage = $managerlanguage; |
|
30 | + public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
31 | + $this->host = $host; |
|
32 | + $this->dbname = $db; |
|
33 | + $this->prefix = $prefix; |
|
34 | + $this->user = $user; |
|
35 | + $this->password = $password; |
|
36 | + $this->adminpass = $adminpass; |
|
37 | + $this->adminname = $adminname; |
|
38 | + $this->adminemail = $adminemail; |
|
39 | + $this->connection_charset = $connection_charset; |
|
40 | + $this->connection_method = $connection_method; |
|
41 | + $this->ignoreDuplicateErrors = false; |
|
42 | + $this->managerlanguage = $managerlanguage; |
|
43 | 43 | $this->autoTemplateLogic = $auto_template_logic; |
44 | - } |
|
44 | + } |
|
45 | 45 | |
46 | - public function connect() { |
|
47 | - $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
|
48 | - mysqli_select_db($this->conn, $this->dbname); |
|
49 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
46 | + public function connect() { |
|
47 | + $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
|
48 | + mysqli_select_db($this->conn, $this->dbname); |
|
49 | + if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
50 | 50 | |
51 | - $this->dbVersion = 3.23; // assume version 3.23 |
|
52 | - if(function_exists("mysqli_get_server_info")) { |
|
53 | - $ver = mysqli_get_server_info($this->conn); |
|
54 | - $this->dbMODx = version_compare($ver,"4.0.2"); |
|
55 | - $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
|
56 | - } |
|
51 | + $this->dbVersion = 3.23; // assume version 3.23 |
|
52 | + if(function_exists("mysqli_get_server_info")) { |
|
53 | + $ver = mysqli_get_server_info($this->conn); |
|
54 | + $this->dbMODx = version_compare($ver,"4.0.2"); |
|
55 | + $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
|
56 | + } |
|
57 | 57 | |
58 | 58 | mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}"); |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | 61 | public function process($filename) { |
62 | - global $custom_placeholders; |
|
63 | - |
|
64 | - // check to make sure file exists |
|
65 | - if (!file_exists($filename)) { |
|
66 | - $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
|
67 | - $this->installFailed = true ; |
|
68 | - return false; |
|
69 | - } |
|
70 | - |
|
71 | - $fh = fopen($filename, 'r'); |
|
72 | - $idata = ''; |
|
73 | - |
|
74 | - while (!feof($fh)) { |
|
75 | - $idata .= fread($fh, 1024); |
|
76 | - } |
|
77 | - |
|
78 | - fclose($fh); |
|
79 | - $idata = str_replace("\r", '', $idata); |
|
80 | - |
|
81 | - // check if in upgrade mode |
|
82 | - if ($this->mode=="upd") { |
|
83 | - // remove non-upgradeable parts |
|
84 | - $s = strpos($idata,"non-upgrade-able[["); |
|
85 | - $e = strpos($idata,"]]non-upgrade-able")+17; |
|
86 | - if($s && $e) $idata = str_replace(substr($idata,$s,$e-$s)," Removed non upgradeable items",$idata); |
|
87 | - } |
|
88 | - |
|
89 | - // replace {} tags |
|
90 | - $idata = str_replace('{PREFIX}', $this->prefix, $idata); |
|
91 | - $idata = str_replace('{ADMIN}', $this->adminname, $idata); |
|
92 | - $idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata); |
|
93 | - $idata = str_replace('{ADMINPASS}', $this->adminpass, $idata); |
|
94 | - $idata = str_replace('{IMAGEPATH}', $this->imgPath, $idata); |
|
95 | - $idata = str_replace('{IMAGEURL}', $this->imgUrl, $idata); |
|
96 | - $idata = str_replace('{FILEMANAGERPATH}', $this->fileManagerPath, $idata); |
|
97 | - $idata = str_replace('{MANAGERLANGUAGE}', $this->managerlanguage, $idata); |
|
98 | - $idata = str_replace('{AUTOTEMPLATELOGIC}', $this->autoTemplateLogic, $idata); |
|
99 | - /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
|
100 | - |
|
101 | - // Replace custom placeholders |
|
102 | - foreach($custom_placeholders as $key=>$val) { |
|
103 | - if (strpos($idata, '{'.$key.'}') !== false) { |
|
104 | - $idata = str_replace('{'.$key.'}', $val, $idata); |
|
105 | - } |
|
106 | - } |
|
107 | - |
|
108 | - $sql_array = explode("\n\n", $idata); |
|
109 | - |
|
110 | - $num = 0; |
|
111 | - foreach($sql_array as $sql_entry) { |
|
112 | - $sql_do = trim($sql_entry, "\r\n; "); |
|
113 | - |
|
114 | - if (preg_match('/^\#/', $sql_do)) continue; |
|
115 | - |
|
116 | - // strip out comments and \n for mysql 3.x |
|
117 | - if ($this->dbVersion <4.0) { |
|
118 | - $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
119 | - $sql_do = str_replace('\r', "", $sql_do); |
|
120 | - $sql_do = str_replace('\n', "", $sql_do); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - $num = $num + 1; |
|
125 | - if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
126 | - if(mysqli_error($this->conn)) { |
|
127 | - // Ignore duplicate and drop errors - Raymond |
|
128 | - if ($this->ignoreDuplicateErrors){ |
|
129 | - if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
130 | - } |
|
131 | - // End Ignore duplicate |
|
132 | - $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
|
133 | - $this->installFailed = true; |
|
134 | - } |
|
135 | - } |
|
136 | - } |
|
62 | + global $custom_placeholders; |
|
63 | + |
|
64 | + // check to make sure file exists |
|
65 | + if (!file_exists($filename)) { |
|
66 | + $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
|
67 | + $this->installFailed = true ; |
|
68 | + return false; |
|
69 | + } |
|
70 | + |
|
71 | + $fh = fopen($filename, 'r'); |
|
72 | + $idata = ''; |
|
73 | + |
|
74 | + while (!feof($fh)) { |
|
75 | + $idata .= fread($fh, 1024); |
|
76 | + } |
|
77 | + |
|
78 | + fclose($fh); |
|
79 | + $idata = str_replace("\r", '', $idata); |
|
80 | + |
|
81 | + // check if in upgrade mode |
|
82 | + if ($this->mode=="upd") { |
|
83 | + // remove non-upgradeable parts |
|
84 | + $s = strpos($idata,"non-upgrade-able[["); |
|
85 | + $e = strpos($idata,"]]non-upgrade-able")+17; |
|
86 | + if($s && $e) $idata = str_replace(substr($idata,$s,$e-$s)," Removed non upgradeable items",$idata); |
|
87 | + } |
|
88 | + |
|
89 | + // replace {} tags |
|
90 | + $idata = str_replace('{PREFIX}', $this->prefix, $idata); |
|
91 | + $idata = str_replace('{ADMIN}', $this->adminname, $idata); |
|
92 | + $idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata); |
|
93 | + $idata = str_replace('{ADMINPASS}', $this->adminpass, $idata); |
|
94 | + $idata = str_replace('{IMAGEPATH}', $this->imgPath, $idata); |
|
95 | + $idata = str_replace('{IMAGEURL}', $this->imgUrl, $idata); |
|
96 | + $idata = str_replace('{FILEMANAGERPATH}', $this->fileManagerPath, $idata); |
|
97 | + $idata = str_replace('{MANAGERLANGUAGE}', $this->managerlanguage, $idata); |
|
98 | + $idata = str_replace('{AUTOTEMPLATELOGIC}', $this->autoTemplateLogic, $idata); |
|
99 | + /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
|
100 | + |
|
101 | + // Replace custom placeholders |
|
102 | + foreach($custom_placeholders as $key=>$val) { |
|
103 | + if (strpos($idata, '{'.$key.'}') !== false) { |
|
104 | + $idata = str_replace('{'.$key.'}', $val, $idata); |
|
105 | + } |
|
106 | + } |
|
107 | + |
|
108 | + $sql_array = explode("\n\n", $idata); |
|
109 | + |
|
110 | + $num = 0; |
|
111 | + foreach($sql_array as $sql_entry) { |
|
112 | + $sql_do = trim($sql_entry, "\r\n; "); |
|
113 | + |
|
114 | + if (preg_match('/^\#/', $sql_do)) continue; |
|
115 | + |
|
116 | + // strip out comments and \n for mysql 3.x |
|
117 | + if ($this->dbVersion <4.0) { |
|
118 | + $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
119 | + $sql_do = str_replace('\r', "", $sql_do); |
|
120 | + $sql_do = str_replace('\n', "", $sql_do); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + $num = $num + 1; |
|
125 | + if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
126 | + if(mysqli_error($this->conn)) { |
|
127 | + // Ignore duplicate and drop errors - Raymond |
|
128 | + if ($this->ignoreDuplicateErrors){ |
|
129 | + if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
130 | + } |
|
131 | + // End Ignore duplicate |
|
132 | + $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
|
133 | + $this->installFailed = true; |
|
134 | + } |
|
135 | + } |
|
136 | + } |
|
137 | 137 | |
138 | 138 | public function close() { |
139 | - mysqli_close($this->conn); |
|
140 | - } |
|
139 | + mysqli_close($this->conn); |
|
140 | + } |
|
141 | 141 | } |