This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | if (file_exists(dirname(__DIR__, 3) . "/assets/cache/siteManager.php")) { |
||
3 | include_once dirname(__DIR__, 3) . "/assets/cache/siteManager.php"; |
||
4 | } else { |
||
5 | define('MGR_DIR', 'manager'); |
||
6 | } |
||
7 | |||
8 | global $moduleName; |
||
9 | global $moduleVersion; |
||
10 | global $moduleSQLBaseFile; |
||
11 | global $moduleSQLDataFile; |
||
12 | global $moduleSQLResetFile; |
||
13 | |||
14 | global $moduleChunks; |
||
15 | global $moduleTemplates; |
||
16 | global $moduleSnippets; |
||
17 | global $modulePlugins; |
||
18 | global $moduleModules; |
||
19 | global $moduleTVs; |
||
20 | global $moduleDependencies; |
||
21 | |||
22 | global $errors; |
||
23 | |||
24 | // set timout limit |
||
25 | @ set_time_limit(120); // used @ to prevent warning when using safe mode? |
||
26 | |||
27 | $installMode = (int)$_POST['installmode']; |
||
28 | $installData = (int)!empty($_POST['installdata']); |
||
29 | |||
30 | // get db info from post |
||
31 | $database_server = $_POST['databasehost']; |
||
32 | $database_user = $_SESSION['databaseloginname']; |
||
33 | $database_password = $_SESSION['databaseloginpassword']; |
||
34 | $database_collation = $_POST['database_collation']; |
||
35 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
||
36 | $database_connection_charset = $_POST['database_connection_charset']; |
||
37 | $database_connection_method = $_POST['database_connection_method']; |
||
38 | $dbase = "`" . $_POST['database_name'] . "`"; |
||
39 | $table_prefix = $_POST['tableprefix']; |
||
40 | $adminname = $_POST['cmsadmin']; |
||
41 | $adminemail = $_POST['cmsadminemail']; |
||
42 | $adminpass = $_POST['cmspassword']; |
||
43 | $managerlanguage = $_POST['managerlanguage']; |
||
44 | $custom_placeholders = array(); |
||
45 | |||
46 | // set session name variable |
||
47 | if (!isset ($site_sessionname)) { |
||
48 | $site_sessionname = 'SN' . uniqid(''); |
||
49 | } |
||
50 | |||
51 | // get base path and url |
||
52 | $a = explode('install', str_replace('\\', '/', dirname($_SERVER['PHP_SELF']))); |
||
53 | if (count($a) > 1) { |
||
54 | array_pop($a); |
||
55 | } |
||
56 | $url = implode('install', $a); |
||
57 | reset($a); |
||
58 | $a = explode('install', str_replace('\\', '/', realpath(__DIR__))); |
||
59 | if (count($a) > 1) { |
||
60 | array_pop($a); |
||
61 | } |
||
62 | $pth = implode('install', $a); |
||
63 | unset ($a); |
||
64 | $base_url = $url . (substr($url, -1) != '/' ? '/' : ''); |
||
65 | $base_path = $pth . (substr($pth, -1) != '/' ? '/' : ''); |
||
66 | |||
67 | // connect to the database |
||
68 | $host = explode(':', $database_server, 2); |
||
69 | $conn = @mysqli_connect($host[0], $database_user, $database_password,'', isset($host[1]) ? $host[1] : null); |
||
70 | $installLevel = 0; |
||
71 | if ($conn) { |
||
72 | $installLevel = 0; |
||
73 | // select database |
||
74 | $selectDatabase = mysqli_select_db($conn, str_replace('`', '', $dbase)); |
||
75 | if ($selectDatabase) { |
||
76 | if (function_exists('mysqli_set_charset')) { |
||
77 | mysqli_set_charset($conn, $database_charset); |
||
78 | } |
||
79 | mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); |
||
80 | $installLevel = 1; |
||
81 | } else { |
||
82 | // try to create the database |
||
83 | $query = "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation"; |
||
84 | $createDatabase = mysqli_query($conn, $query); |
||
85 | if ($createDatabase === false) { |
||
86 | $errors += 1; |
||
87 | } else { |
||
88 | $installLevel = 1; |
||
89 | } |
||
90 | } |
||
91 | |||
92 | if ($installLevel === 1) { |
||
93 | // check table prefix |
||
94 | if ($installMode === 0) { |
||
95 | $query = "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`"; |
||
96 | if (@mysqli_query($conn, $query)) { |
||
97 | $errors += 1; |
||
98 | } else { |
||
99 | $installLevel = 2; |
||
100 | } |
||
101 | } else { |
||
102 | $installLevel = 2; |
||
103 | } |
||
104 | } |
||
105 | |||
106 | if ($installLevel === 2) { |
||
107 | // check status of Inherit Parent Template plugin |
||
108 | $auto_template_logic = 'parent'; |
||
109 | if ($installMode !== 0) { |
||
110 | $query = "SELECT properties, disabled FROM " . $dbase . ".`" . $table_prefix . "site_plugins` WHERE name='Inherit Parent Template'"; |
||
111 | $rs = mysqli_query($conn, $query); |
||
112 | $row = mysqli_fetch_row($rs); |
||
113 | View Code Duplication | if (!$row) { |
|
114 | // not installed |
||
115 | $auto_template_logic = 'system'; |
||
116 | } else { |
||
117 | if ($row[1] == 1) { |
||
118 | // installed but disabled |
||
119 | $auto_template_logic = 'system'; |
||
120 | } else { |
||
121 | // installed, enabled .. see how it's configured |
||
122 | $properties = parseProperties($row[0]); |
||
123 | if (isset($properties['inheritTemplate'])) { |
||
124 | if ($properties['inheritTemplate'] === 'From First Sibling') { |
||
125 | $auto_template_logic = 'sibling'; |
||
126 | } |
||
127 | } |
||
128 | } |
||
129 | } |
||
130 | } |
||
131 | |||
132 | // open db connection |
||
133 | include dirname(__DIR__) . '/processor/result.php'; |
||
134 | include_once dirname(__DIR__) . '/sqlParser.class.php'; |
||
135 | $sqlParser = new SqlParser( |
||
136 | $database_server, |
||
137 | $database_user, |
||
138 | $database_password, |
||
139 | str_replace("`", "", $dbase), |
||
140 | $table_prefix, |
||
141 | $adminname, |
||
142 | $adminemail, |
||
143 | $adminpass, |
||
144 | $database_connection_charset, |
||
145 | $managerlanguage, |
||
146 | $database_connection_method, |
||
147 | $auto_template_logic |
||
148 | ); |
||
149 | $sqlParser->database_collation = $database_collation; |
||
0 ignored issues
–
show
|
|||
150 | $sqlParser->mode = ($installMode < 1) ? 'new' : 'upd'; |
||
151 | $sqlParser->ignoreDuplicateErrors = true; |
||
152 | $sqlParser->connect(); |
||
153 | |||
154 | // install/update database |
||
155 | if ($moduleSQLBaseFile) { |
||
156 | $sqlParser->process($moduleSQLBaseFile); |
||
157 | // display database results |
||
158 | if ($sqlParser->installFailed == true) { |
||
159 | $errors += 1; |
||
160 | } else { |
||
161 | $installLevel = 3; |
||
162 | } |
||
163 | } else { |
||
164 | $installLevel = 3; |
||
165 | } |
||
166 | } |
||
167 | |||
168 | if ($installLevel === 3) { |
||
169 | // write the config.inc.php file if new installation |
||
170 | $confph = array(); |
||
171 | $confph['database_server'] = $database_server; |
||
172 | $confph['user_name'] = mysqli_real_escape_string($conn, $database_user); |
||
173 | $confph['password'] = mysqli_real_escape_string($conn, $database_password); |
||
174 | $confph['connection_charset'] = $database_connection_charset; |
||
175 | $confph['connection_collation'] = $database_collation; |
||
176 | $confph['connection_method'] = $database_connection_method; |
||
177 | $confph['dbase'] = str_replace('`', '', $dbase); |
||
178 | $confph['table_prefix'] = $table_prefix; |
||
179 | $confph['lastInstallTime'] = time(); |
||
180 | $confph['site_sessionname'] = $site_sessionname; |
||
181 | |||
182 | $configString = file_get_contents(dirname(__DIR__, 2) . '/stubs/files/config/database/connections/default.tpl'); |
||
183 | $configString = parse($configString, $confph); |
||
184 | |||
185 | $filename = EVO_CORE_PATH . 'config/database/connections/default.php'; |
||
186 | $configFileFailed = false; |
||
187 | if (@ !$handle = fopen($filename, 'w')) { |
||
188 | $configFileFailed = true; |
||
189 | } |
||
190 | |||
191 | // write $somecontent to our opened file. |
||
192 | if (@ fwrite($handle, $configString) === false) { |
||
193 | $configFileFailed = true; |
||
194 | } |
||
195 | @ fclose($handle); |
||
196 | |||
197 | // try to chmod the config file go-rwx (for suexeced php) |
||
198 | @chmod($filename, 0404); |
||
199 | |||
200 | if ($configFileFailed === true) { |
||
201 | $errors += 1; |
||
202 | } else { |
||
203 | $installLevel = 4; |
||
204 | } |
||
205 | } |
||
206 | |||
207 | if ($installLevel === 4) { |
||
208 | // generate new site_id and set manager theme to default |
||
209 | View Code Duplication | if ($installMode == 0) { |
|
210 | $siteid = uniqid(''); |
||
211 | mysqli_query( |
||
212 | $sqlParser->conn, |
||
213 | "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')" |
||
214 | ); |
||
215 | } else { |
||
216 | // update site_id if missing |
||
217 | $ds = mysqli_query( |
||
218 | $sqlParser->conn, |
||
219 | "SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'" |
||
220 | ); |
||
221 | if ($ds) { |
||
222 | $r = mysqli_fetch_assoc($ds); |
||
223 | $siteid = $r['setting_value']; |
||
224 | if ($siteid == '' || $siteid === 'MzGeQ2faT4Dw06+U49x3') { |
||
225 | $siteid = uniqid(''); |
||
226 | mysqli_query( |
||
227 | $sqlParser->conn, |
||
228 | "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')" |
||
229 | ); |
||
230 | } |
||
231 | } |
||
232 | } |
||
233 | |||
234 | // Reset database for installation of demo-site |
||
235 | if ($installData && $moduleSQLDataFile && $moduleSQLResetFile) { |
||
236 | $sqlParser->process($moduleSQLResetFile); |
||
237 | // display database results |
||
238 | if ($sqlParser->installFailed === true) { |
||
239 | $errors += 1; |
||
240 | } else { |
||
241 | $installLevel = 5; |
||
242 | } |
||
243 | } else { |
||
244 | $installLevel = 5; |
||
245 | } |
||
246 | } |
||
247 | |||
248 | $installDataLevel = array(); |
||
249 | $errorData = false; |
||
250 | // Install Templates |
||
251 | if ($installLevel === 5 && (isset ($_POST['template']) || $installData)) { |
||
252 | $selTemplates = $_POST['template']; |
||
253 | foreach ($moduleTemplates as $k => $moduleTemplate) { |
||
254 | if (! is_array($moduleTemplate)) { |
||
255 | continue; |
||
256 | } |
||
257 | $installDataLevel['templates'][$moduleTemplate[0]] = array( |
||
258 | 'data' => array( |
||
259 | 'desc' => $moduleTemplate[1], |
||
260 | 'category' => $moduleTemplate[4], |
||
261 | 'locked' => $moduleTemplate[5], |
||
262 | 'file' => $moduleTemplate[3], |
||
263 | 'id' => $moduleTemplate[7], |
||
264 | ), |
||
265 | 'type' => '', // update, create |
||
266 | /*'error' => array( |
||
267 | 'type' => '' // sql, file_not_found |
||
268 | 'content' => '' |
||
269 | )*/ |
||
270 | ); |
||
271 | $installSample = in_array('sample', $moduleTemplate[6]) && $installData === 1; |
||
272 | if ($installSample || in_array($k, $selTemplates)) { |
||
273 | $name = mysqli_real_escape_string($conn, $moduleTemplate[0]); |
||
274 | $desc = mysqli_real_escape_string($conn, $moduleTemplate[1]); |
||
275 | $category = mysqli_real_escape_string($conn, $moduleTemplate[4]); |
||
276 | $locked = mysqli_real_escape_string($conn, $moduleTemplate[5]); |
||
277 | $filecontent = $moduleTemplate[3]; |
||
278 | $save_sql_id_as = $moduleTemplate[7]; // Nessecary for demo-site |
||
279 | if (!file_exists($filecontent)) { |
||
280 | $installDataLevel['templates'][$moduleTemplate[0]]['error'] = array( |
||
281 | 'type' => 'file_not_found' |
||
282 | ); |
||
283 | } else { |
||
284 | // Create the category if it does not already exist |
||
285 | $category_id = getCreateDbCategory($category, $sqlParser); |
||
286 | |||
287 | // Strip the first comment up top |
||
288 | $template = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1); |
||
289 | $template = mysqli_real_escape_string($conn, $template); |
||
290 | |||
291 | // See if the template already exists |
||
292 | $query = "SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'"; |
||
293 | $rs = mysqli_query($sqlParser->conn, $query); |
||
294 | |||
295 | if (mysqli_num_rows($rs)) { |
||
296 | $installDataLevel['templates'][$moduleTemplate[0]]['type'] = 'update'; |
||
297 | $query = "UPDATE $dbase.`" . $table_prefix . "site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked' WHERE templatename='$name' LIMIT 1;"; |
||
298 | if (!mysqli_query($sqlParser->conn, $query)) { |
||
299 | $errors += 1; |
||
300 | $installDataLevel['templates'][$moduleTemplate[0]]['error'] = array( |
||
301 | 'type' => 'sql', |
||
302 | 'content' => mysqli_error($sqlParser->conn) |
||
303 | ); |
||
304 | $errorData = true; |
||
305 | break; |
||
306 | } |
||
307 | View Code Duplication | if (!is_null($save_sql_id_as)) { |
|
308 | $sql_id = @mysqli_insert_id($sqlParser->conn); |
||
309 | if (!$sql_id) { |
||
310 | $query = "SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name' LIMIT 1;"; |
||
311 | $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, $query)); |
||
312 | $sql_id = $idQuery['id']; |
||
313 | } |
||
314 | $custom_placeholders[$save_sql_id_as] = $sql_id; |
||
315 | } |
||
316 | } else { |
||
317 | $installDataLevel['templates'][$moduleTemplate[0]]['type'] = 'create'; |
||
318 | $query = "INSERT INTO $dbase.`" . $table_prefix . "site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');"; |
||
319 | if (!@mysqli_query($sqlParser->conn, $query)) { |
||
320 | $errors += 1; |
||
321 | $installDataLevel['templates'][$moduleTemplate[0]]['error'] = array( |
||
322 | 'type' => 'sql', |
||
323 | 'content' => mysqli_error($sqlParser->conn) |
||
324 | ); |
||
325 | $errorData = true; |
||
326 | break; |
||
327 | } |
||
328 | if ($save_sql_id_as !== null) { |
||
329 | $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
||
330 | } |
||
331 | } |
||
332 | } |
||
333 | } else { |
||
334 | $installDataLevel['templates'][$moduleTemplate[0]]['type'] = 'skip'; |
||
335 | } |
||
336 | } |
||
337 | } |
||
338 | |||
339 | // Install Template Variables |
||
340 | if ($installLevel === 5 && $errorData === false && (isset ($_POST['tv']) || $installData)) { |
||
341 | $selTVs = $_POST['tv']; |
||
342 | foreach ($moduleTVs as $k => $moduleTV) { |
||
343 | $installDataLevel['tvs'][$moduleTV[0]] = array( |
||
344 | 'data' => array( |
||
345 | 'desc' => $moduleTV[2], |
||
346 | 'caption' => $moduleTV[1], |
||
347 | 'category' => $moduleTV[10], |
||
348 | 'locked' => $moduleTV[11], |
||
349 | 'file' => $moduleTV[8], |
||
350 | 'input_type' => $moduleTV[3], |
||
351 | 'input_options' => $moduleTV[4], |
||
352 | 'input_default' => $moduleTV[5], |
||
353 | 'output_widget' => $moduleTV[6], |
||
354 | 'output_widget_params' => $moduleTV[7], |
||
355 | 'assignments' => $moduleTV[9] |
||
356 | ), |
||
357 | 'type' => '', // update, create |
||
358 | /*'error' => array( |
||
359 | 'type' => '' // sql, file_not_found |
||
360 | 'content' => '' |
||
361 | )*/ |
||
362 | ); |
||
363 | |||
364 | $installSample = in_array('sample', $moduleTV[12]) && $installData == 1; |
||
365 | if ($installSample || in_array($k, $selTVs)) { |
||
366 | $name = mysqli_real_escape_string($conn, $moduleTV[0]); |
||
367 | $caption = mysqli_real_escape_string($conn, $moduleTV[1]); |
||
368 | $desc = mysqli_real_escape_string($conn, $moduleTV[2]); |
||
369 | $input_type = mysqli_real_escape_string($conn, $moduleTV[3]); |
||
370 | $input_options = mysqli_real_escape_string($conn, $moduleTV[4]); |
||
371 | $input_default = mysqli_real_escape_string($conn, $moduleTV[5]); |
||
372 | $output_widget = mysqli_real_escape_string($conn, $moduleTV[6]); |
||
373 | $output_widget_params = mysqli_real_escape_string($conn, $moduleTV[7]); |
||
374 | $filecontent = $moduleTV[8]; |
||
375 | $assignments = $moduleTV[9]; |
||
376 | $category = mysqli_real_escape_string($conn, $moduleTV[10]); |
||
377 | $locked = mysqli_real_escape_string($conn, $moduleTV[11]); |
||
378 | |||
379 | |||
380 | // Create the category if it does not already exist |
||
381 | $category = getCreateDbCategory($category, $sqlParser); |
||
382 | |||
383 | $query = "SELECT * FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name'"; |
||
384 | $rs = mysqli_query($sqlParser->conn,$query); |
||
385 | if (mysqli_num_rows($rs)) { |
||
386 | $installDataLevel['tvs'][$moduleTV[0]]['type'] = 'update'; |
||
387 | while ($row = mysqli_fetch_assoc($rs)) { |
||
388 | $query = "UPDATE $dbase.`" . $table_prefix . "site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};"; |
||
389 | if (!mysqli_query($sqlParser->conn, $query)) { |
||
390 | $installDataLevel['tvs'][$moduleTV[0]]['error'] = array( |
||
391 | 'type' => 'sql', |
||
392 | 'content' => mysqli_error($sqlParser->conn) |
||
393 | ); |
||
394 | |||
395 | $errorData = true; |
||
396 | break 2; |
||
397 | } |
||
398 | } |
||
399 | } else { |
||
400 | $installDataLevel['tvs'][$moduleTV[0]]['type'] = 'create'; |
||
401 | $q = "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',$category,$locked,'$input_options','$output_widget','$output_widget_params','$input_default');"; |
||
402 | if (!mysqli_query($sqlParser->conn, $q)) { |
||
403 | $installDataLevel['tvs'][$moduleTV[0]]['error'] = array( |
||
404 | 'type' => 'sql', |
||
405 | 'content' => mysqli_error($sqlParser->conn) |
||
406 | ); |
||
407 | $errorData = true; |
||
408 | break; |
||
409 | } |
||
410 | } |
||
411 | |||
412 | // add template assignments |
||
413 | $assignments = explode(',', $assignments); |
||
414 | |||
415 | if (count($assignments) > 0) { |
||
416 | |||
417 | // remove existing tv -> template assignments |
||
418 | $query = "SELECT id FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name' AND description='$desc';"; |
||
419 | $ds = mysqli_query($sqlParser->conn, $query); |
||
420 | $row = mysqli_fetch_assoc($ds); |
||
421 | $id = $row["id"]; |
||
422 | $query = 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\''; |
||
423 | mysqli_query($sqlParser->conn, $query); |
||
424 | |||
425 | // add tv -> template assignments |
||
426 | foreach ($assignments as $assignment) { |
||
427 | $template = mysqli_real_escape_string($conn, $assignment); |
||
428 | $query = "SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$template';"; |
||
429 | $ts = mysqli_query($sqlParser->conn, $query); |
||
430 | if ($ds && $ts) { |
||
431 | $tRow = mysqli_fetch_assoc($ts); |
||
432 | $templateId = $tRow['id']; |
||
433 | $query = "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"; |
||
434 | mysqli_query($sqlParser->conn,$query); |
||
435 | } |
||
436 | } |
||
437 | } |
||
438 | } |
||
439 | } |
||
440 | } |
||
441 | |||
442 | // Install Chunks |
||
443 | if ($installLevel === 5 && $errorData === false && (isset ($_POST['chunk']) || $installData)) { |
||
444 | $selChunks = $_POST['chunk']; |
||
445 | foreach ($moduleChunks as $k => $moduleChunk) { |
||
446 | if (! is_array($moduleChunk)) { |
||
447 | continue; |
||
448 | } |
||
449 | $installDataLevel['chunks'][$moduleChunk[0]] = array( |
||
450 | 'data' => array( |
||
451 | 'desc' => $moduleChunk[1], |
||
452 | 'category' => $moduleChunk[3], |
||
453 | 'overwrite' => $moduleChunk[4], |
||
454 | 'file' => $moduleChunk[2], |
||
455 | 'installset' => $moduleChunk[5] |
||
456 | ), |
||
457 | 'type' => '', // update, create, overwrite, skip |
||
458 | /*'error' => array( |
||
459 | 'type' => '' // sql, file_not_found |
||
460 | 'content' => '' |
||
461 | )*/ |
||
462 | ); |
||
463 | $installSample = in_array('sample', $moduleChunk[5]) && $installData == 1; |
||
464 | $count_new_name = 0; |
||
465 | if ($installSample || in_array($k, $selChunks)) { |
||
466 | $name = mysqli_real_escape_string($conn, $moduleChunk[0]); |
||
467 | $desc = mysqli_real_escape_string($conn, $moduleChunk[1]); |
||
468 | $category = mysqli_real_escape_string($conn, $moduleChunk[3]); |
||
469 | $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]); |
||
470 | $filecontent = $moduleChunk[2]; |
||
471 | |||
472 | if (!file_exists($filecontent)) { |
||
473 | $installDataLevel['chunks'][$moduleChunk[0]]['error'] = array( |
||
474 | 'type' => 'file_not_found' |
||
475 | ); |
||
476 | } else { |
||
477 | // Create the category if it does not already exist |
||
478 | $category_id = getCreateDbCategory($category, $sqlParser); |
||
479 | |||
480 | $chunk = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1); |
||
481 | $chunk = mysqli_real_escape_string($conn, $chunk); |
||
482 | $rs = mysqli_query( |
||
483 | $sqlParser->conn, |
||
484 | "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$name'" |
||
485 | ); |
||
486 | $count_original_name = mysqli_num_rows($rs); |
||
487 | View Code Duplication | if ($overwrite == 'false') { |
|
488 | $newname = $name . '-' . str_replace('.', '_', $modx_version); |
||
489 | $rs = mysqli_query( |
||
490 | $sqlParser->conn, |
||
491 | "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$newname'" |
||
492 | ); |
||
493 | $count_new_name = mysqli_num_rows($rs); |
||
494 | } |
||
495 | $update = $count_original_name > 0 && $overwrite === 'true'; |
||
496 | if ($update) { |
||
497 | $installDataLevel['chunks'][$moduleChunk[0]]['type'] = 'update'; |
||
498 | if (!mysqli_query($sqlParser->conn, |
||
499 | "UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) { |
||
500 | $errors += 1; |
||
501 | $installDataLevel['chunks'][$moduleChunk[0]]['error'] = array( |
||
502 | 'type' => 'sql', |
||
503 | 'content' => mysqli_error($sqlParser->conn) |
||
504 | ); |
||
505 | $errorData = true; |
||
506 | break; |
||
507 | } |
||
508 | } elseif ($count_new_name == 0) { |
||
509 | if ($count_original_name > 0 && $overwrite == 'false') { |
||
510 | $installDataLevel['chunks'][$moduleChunk[0]]['type'] = 'overwrite'; |
||
511 | $installDataLevel['chunks'][$moduleChunk[0]]['newname'] = $newname; |
||
512 | $name = $newname; |
||
513 | } else { |
||
514 | $installDataLevel['chunks'][$moduleChunk[0]]['type'] = 'create'; |
||
515 | } |
||
516 | $query = "INSERT INTO $dbase.`" . $table_prefix . "site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);"; |
||
517 | if (!mysqli_query($sqlParser->conn, $query)) { |
||
518 | $errors += 1; |
||
519 | $installDataLevel['chunks'][$moduleChunk[0]]['error'] = array( |
||
520 | 'type' => 'sql', |
||
521 | 'content' => mysqli_error($sqlParser->conn) |
||
522 | ); |
||
523 | $errorData = true; |
||
524 | break; |
||
525 | } |
||
526 | } |
||
527 | } |
||
528 | } else { |
||
529 | $installDataLevel['chunks'][$moduleChunk[0]]['type'] = 'skip'; |
||
530 | } |
||
531 | } |
||
532 | |||
533 | } |
||
534 | |||
535 | // Install Modules |
||
536 | if ($installLevel === 5 && $errorData === false && (isset ($_POST['module']) || $installData)) { |
||
537 | $selModules = $_POST['module']; |
||
538 | foreach ($moduleModules as $k => $moduleModule) { |
||
539 | if (! is_array($moduleModule)) { |
||
540 | continue; |
||
541 | } |
||
542 | $installDataLevel['modules'][$moduleModule[0]] = array( |
||
543 | 'data' => array( |
||
544 | 'desc' => $moduleModule[1], |
||
545 | 'category' => $moduleModule[6], |
||
546 | 'file' => $moduleModule[2], |
||
547 | 'guid' => $moduleModule[4], |
||
548 | 'props' => $moduleModule[3], |
||
549 | 'shared' => $moduleModule[5], |
||
550 | ), |
||
551 | 'type' => '', // update, create |
||
552 | /*'error' => array( |
||
553 | 'type' => '' // sql, file_not_found |
||
554 | 'content' => '' |
||
555 | )*/ |
||
556 | ); |
||
557 | $installSample = in_array('sample', $moduleModule[7]) && $installData == 1; |
||
558 | if ($installSample || in_array($k, $selModules)) { |
||
559 | $name = mysqli_real_escape_string($conn, $moduleModule[0]); |
||
560 | $desc = mysqli_real_escape_string($conn, $moduleModule[1]); |
||
561 | $filecontent = $moduleModule[2]; |
||
562 | $properties = $moduleModule[3]; |
||
563 | $guid = mysqli_real_escape_string($conn, $moduleModule[4]); |
||
564 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
||
565 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
||
566 | View Code Duplication | if (!file_exists($filecontent)) { |
|
567 | $installDataLevel['modules'][$moduleModule[0]]['error'] = array( |
||
568 | 'type' => 'file_not_found' |
||
569 | ); |
||
570 | } else { |
||
571 | // Create the category if it does not already exist |
||
572 | $category = getCreateDbCategory($category, $sqlParser); |
||
573 | |||
574 | $module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
||
0 ignored issues
–
show
|
|||
575 | // $module = removeDocblock($module, 'module'); // Modules have no fileBinding, keep docblock for info-tab |
||
576 | $module = mysqli_real_escape_string($conn, $module); |
||
577 | $rs = mysqli_query($sqlParser->conn, |
||
578 | "SELECT * FROM $dbase.`" . $table_prefix . "site_modules` WHERE name='$name'"); |
||
579 | if (mysqli_num_rows($rs)) { |
||
580 | $installDataLevel['modules'][$moduleModule[0]]['type'] = 'update'; |
||
581 | $row = mysqli_fetch_assoc($rs); |
||
582 | $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
||
583 | if (!mysqli_query($sqlParser->conn, |
||
584 | "UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
||
585 | $installDataLevel['modules'][$moduleModule[0]]['error'] = array( |
||
586 | 'type' => 'sql', |
||
587 | 'content' => mysqli_error($sqlParser->conn) |
||
588 | ); |
||
589 | $errorData = true; |
||
590 | break; |
||
591 | } |
||
592 | } else { |
||
593 | $installDataLevel['modules'][$moduleModule[0]]['type'] = 'create'; |
||
594 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
||
595 | if (!mysqli_query($sqlParser->conn, |
||
596 | "INSERT INTO $dbase.`" . $table_prefix . "site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) { |
||
597 | $installDataLevel['modules'][$moduleModule[0]]['error'] = array( |
||
598 | 'type' => 'sql', |
||
599 | 'content' => mysqli_error($sqlParser->conn) |
||
600 | ); |
||
601 | $errorData = true; |
||
602 | break; |
||
603 | } |
||
604 | } |
||
605 | } |
||
606 | } else { |
||
607 | $installDataLevel['modules'][$moduleModule[0]]['type'] = 'skip'; |
||
608 | } |
||
609 | } |
||
610 | } |
||
611 | |||
612 | // Install Plugins |
||
613 | if ($installLevel === 5 && $errorData === false && (isset ($_POST['plugin']) || $installData)) { |
||
614 | $selPlugs = $_POST['plugin']; |
||
615 | foreach ($modulePlugins as $k => $modulePlugin) { |
||
616 | if (! is_array($modulePlugin)) { |
||
617 | continue; |
||
618 | } |
||
619 | $installDataLevel['plugins'][$modulePlugin[0]] = array( |
||
620 | 'data' => array( |
||
621 | 'desc' => $modulePlugin[1], |
||
622 | 'file' => $modulePlugin[2], |
||
623 | 'category' => $modulePlugin[6], |
||
624 | 'guid' => $modulePlugin[5], |
||
625 | 'disabled' => $modulePlugin[9], |
||
626 | 'events' => explode(',', $modulePlugin[4]), |
||
627 | 'props' => $modulePlugin[3] |
||
628 | ), |
||
629 | 'type' => '', // update, create |
||
630 | /*'error' => array( |
||
631 | 'type' => '' // sql, file_not_found |
||
632 | 'content' => '' |
||
633 | )*/ |
||
634 | ); |
||
635 | |||
636 | $installSample = is_array($modulePlugin[8]) && in_array('sample', $modulePlugin[8]) && $installData == 1; |
||
637 | |||
638 | if ($installSample || in_array($k, $selPlugs)) { |
||
639 | $name = mysqli_real_escape_string($conn, $modulePlugin[0]); |
||
640 | $desc = mysqli_real_escape_string($conn, $modulePlugin[1]); |
||
641 | $filecontent = $modulePlugin[2]; |
||
642 | $properties = $modulePlugin[3]; |
||
643 | $events = explode(",", $modulePlugin[4]); |
||
644 | $guid = mysqli_real_escape_string($conn, $modulePlugin[5]); |
||
645 | $category = mysqli_real_escape_string($conn, $modulePlugin[6]); |
||
646 | $leg_names = ''; |
||
647 | $disabled = $modulePlugin[9]; |
||
648 | View Code Duplication | if (array_key_exists(7, $modulePlugin)) { |
|
649 | // parse comma-separated legacy names and prepare them for sql IN clause |
||
650 | $leg_names = "'" . implode( |
||
651 | "','", |
||
652 | preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7])) |
||
653 | ) . "'"; |
||
654 | } |
||
655 | if (! file_exists($filecontent)) { |
||
656 | $installDataLevel['plugins'][$modulePlugin[0]]['error'] = array( |
||
657 | 'type' => 'file_not_found' |
||
658 | ); |
||
659 | } else { |
||
660 | |||
661 | // disable legacy versions based on legacy_names provided |
||
662 | View Code Duplication | if (!empty($leg_names)) { |
|
663 | $update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);"; |
||
664 | $rs = mysqli_query($sqlParser->conn, $update_query); |
||
665 | } |
||
666 | |||
667 | // Create the category if it does not already exist |
||
668 | $category = getCreateDbCategory($category, $sqlParser); |
||
669 | |||
670 | $plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
||
0 ignored issues
–
show
|
|||
671 | $plugin = removeDocblock($plugin, 'plugin'); |
||
672 | $plugin = mysqli_real_escape_string($conn, $plugin); |
||
673 | $query = "SELECT * FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name'"; |
||
674 | $rs = mysqli_query($sqlParser->conn, $query); |
||
675 | if (mysqli_num_rows($rs)) { |
||
676 | $installDataLevel['plugins'][$modulePlugin[0]]['type'] = 'update'; |
||
677 | $insert = true; |
||
678 | while ($row = mysqli_fetch_assoc($rs)) { |
||
679 | $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
||
680 | if ($row['description'] == $desc) { |
||
681 | $query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};"; |
||
682 | if (!mysqli_query($sqlParser->conn, $query)) { |
||
683 | $installDataLevel['plugins'][$modulePlugin[0]]['error'] = array( |
||
684 | 'type' => 'sql', |
||
685 | 'content' => mysqli_error($sqlParser->conn) |
||
686 | ); |
||
687 | $errorData = true; |
||
688 | break 2; |
||
689 | } |
||
690 | $insert = false; |
||
691 | } else { |
||
692 | $query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};"; |
||
693 | if (!mysqli_query($sqlParser->conn, $query)) { |
||
694 | $installDataLevel['plugins'][$modulePlugin[0]]['error'] = array( |
||
695 | 'type' => 'sql', |
||
696 | 'content' => mysqli_error($sqlParser->conn) |
||
697 | ); |
||
698 | $errorData = true; |
||
699 | break 2; |
||
700 | } |
||
701 | } |
||
702 | } |
||
703 | if ($insert === true) { |
||
704 | if(!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$props','$guid','0',$category);")) { |
||
705 | $installDataLevel['plugins'][$modulePlugin[0]]['error'] = array( |
||
706 | 'type' => 'sql', |
||
707 | 'content' => mysqli_error($sqlParser->conn) |
||
708 | ); |
||
709 | $errorData = true; |
||
710 | break; |
||
711 | } |
||
712 | } |
||
713 | } else { |
||
714 | $installDataLevel['plugins'][$modulePlugin[0]]['type'] = 'create'; |
||
715 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
||
716 | $query = "INSERT INTO $dbase.`" . $table_prefix . "site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);"; |
||
717 | if (!mysqli_query($sqlParser->conn, $query)) { |
||
718 | $installDataLevel['plugins'][$modulePlugin[0]]['error'] = array( |
||
719 | 'type' => 'sql', |
||
720 | 'content' => mysqli_error($sqlParser->conn) |
||
721 | ); |
||
722 | $errorData = true; |
||
723 | break; |
||
724 | } |
||
725 | } |
||
726 | // add system events |
||
727 | View Code Duplication | if (count($events) > 0) { |
|
728 | $query = "SELECT id FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name' AND description='$desc';"; |
||
729 | $ds = mysqli_query($sqlParser->conn, $query); |
||
730 | if ($ds) { |
||
731 | $row = mysqli_fetch_assoc($ds); |
||
732 | $id = $row["id"]; |
||
733 | $_events = implode("','", $events); |
||
734 | // add new events |
||
735 | $sql = "INSERT IGNORE INTO $dbase.`" . $table_prefix . "site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`" . $table_prefix . "system_eventnames` se WHERE name IN ('{$_events}')"; |
||
736 | mysqli_query($sqlParser->conn, $sql); |
||
737 | // remove absent events |
||
738 | $sql = "DELETE `pe` FROM {$dbase}.`{$table_prefix}site_plugin_events` `pe` LEFT JOIN {$dbase}.`{$table_prefix}system_eventnames` `se` ON `pe`.`evtid`=`se`.`id` AND `name` IN ('{$_events}') WHERE ISNULL(`name`) AND `pluginid` = {$id}"; |
||
739 | mysqli_query($sqlParser->conn, $sql); |
||
740 | } |
||
741 | } |
||
742 | } |
||
743 | } else { |
||
744 | $installDataLevel['plugins'][$modulePlugin[0]]['type'] = 'skip'; |
||
745 | } |
||
746 | } |
||
747 | } |
||
748 | |||
749 | // Install Snippets |
||
750 | if ($installLevel === 5 && $errorData === false && (isset ($_POST['snippet']) || $installData)) { |
||
751 | $selSnips = $_POST['snippet']; |
||
752 | foreach ($moduleSnippets as $k => $moduleSnippet) { |
||
753 | if (! is_array($moduleSnippet)) { |
||
754 | continue; |
||
755 | } |
||
756 | $installDataLevel['snippets'][$moduleSnippet[0]] = array( |
||
757 | 'data' => array( |
||
758 | 'desc' => $moduleSnippet[1], |
||
759 | 'category' => $moduleSnippet[4], |
||
760 | 'props' => $moduleSnippet[3], |
||
761 | 'file' => $moduleSnippet[2] |
||
762 | ), |
||
763 | 'type' => '', // update, create, skip |
||
764 | /*'error' => array( |
||
765 | 'type' => '' // sql, file_not_found |
||
766 | 'content' => '' |
||
767 | )*/ |
||
768 | ); |
||
769 | $installSample = in_array('sample', $moduleSnippet[5]) && $installData == 1; |
||
770 | if ($installSample || in_array($k, $selSnips)) { |
||
771 | $name = mysqli_real_escape_string($conn, $moduleSnippet[0]); |
||
772 | $desc = mysqli_real_escape_string($conn, $moduleSnippet[1]); |
||
773 | $filecontent = $moduleSnippet[2]; |
||
774 | $properties = $moduleSnippet[3]; |
||
775 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
||
776 | View Code Duplication | if (!file_exists($filecontent)) { |
|
777 | $installDataLevel['snippets'][$moduleSnippet[0]]['error'] = array( |
||
778 | 'type' => 'file_not_found' |
||
779 | ); |
||
780 | } else { |
||
781 | // Create the category if it does not already exist |
||
782 | $category = getCreateDbCategory($category, $sqlParser); |
||
783 | |||
784 | $snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent))); |
||
0 ignored issues
–
show
|
|||
785 | $snippet = removeDocblock($snippet, 'snippet'); |
||
786 | $snippet = mysqli_real_escape_string($conn, $snippet); |
||
787 | $rs = mysqli_query($sqlParser->conn, |
||
788 | "SELECT * FROM $dbase.`" . $table_prefix . "site_snippets` WHERE name='$name'"); |
||
789 | if (mysqli_num_rows($rs)) { |
||
790 | $installDataLevel['snippets'][$moduleSnippet[0]]['type'] = 'update'; |
||
791 | $row = mysqli_fetch_assoc($rs); |
||
792 | $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
||
793 | if (!mysqli_query($sqlParser->conn, |
||
794 | "UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
||
795 | $installDataLevel['snippets'][$moduleSnippet[0]]['error'] = array( |
||
796 | 'type' => 'sql', |
||
797 | 'content' => mysqli_error($sqlParser->conn) |
||
798 | ); |
||
799 | $errorData = true; |
||
800 | break; |
||
801 | } |
||
802 | } else { |
||
803 | $installDataLevel['snippets'][$moduleSnippet[0]]['type'] = 'create'; |
||
804 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
||
805 | if (!mysqli_query($sqlParser->conn, |
||
806 | "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) { |
||
807 | $installDataLevel['snippets'][$moduleSnippet[0]]['error'] = array( |
||
808 | 'type' => 'sql', |
||
809 | 'content' => mysqli_error($sqlParser->conn) |
||
810 | ); |
||
811 | $errorData = true; |
||
812 | break; |
||
813 | } |
||
814 | } |
||
815 | } |
||
816 | } else { |
||
817 | $installDataLevel['snippets'][$moduleSnippet[0]]['type'] = 'skip'; |
||
818 | } |
||
819 | } |
||
820 | } |
||
821 | |||
822 | // Install demo-site |
||
823 | if ($installLevel === 5 && $errorData === false && ($installData && $moduleSQLDataFile)) { |
||
824 | $installDataLevel['demo'] = array(); |
||
825 | $sqlParser->process($moduleSQLDataFile); |
||
826 | // display database results |
||
827 | if ($sqlParser->installFailed === true) { |
||
828 | $errors += 1; |
||
829 | $sqlErrors = count($sqlParser->mysqlErrors); |
||
830 | $installDataLevel['demo']['error'] = array(); |
||
831 | for ($i = 0; $i < $sqlErrors; $i++) { |
||
832 | $installDataLevel['demo']['error'][] = array( |
||
833 | 'content' => $sqlParser->mysqlErrors[$i]['error'], |
||
834 | 'sql' => $sqlParser->mysqlErrors[$i]['sql'] |
||
835 | ); |
||
836 | } |
||
837 | $errorData = true; |
||
838 | View Code Duplication | } else { |
|
839 | $installLevel = 6; |
||
840 | $sql = sprintf("SELECT id FROM `%ssite_templates` WHERE templatename='EVO startup - Bootstrap'", |
||
841 | $sqlParser->prefix); |
||
842 | $rs = mysqli_query($sqlParser->conn, $sql); |
||
843 | if (mysqli_num_rows($rs)) { |
||
844 | $row = mysqli_fetch_assoc($rs); |
||
845 | $sql = sprintf('UPDATE `%ssite_content` SET template=%s WHERE template=4', $sqlParser->prefix, |
||
846 | $row['id']); |
||
847 | mysqli_query($sqlParser->conn, $sql); |
||
848 | } |
||
849 | } |
||
850 | } |
||
851 | |||
852 | if ($errorData === false) { |
||
853 | $installLevel = 6; |
||
854 | } |
||
855 | |||
856 | $errorInstall = false; |
||
857 | if ($installLevel === 6) { |
||
858 | $installDependencyLevel = array(); |
||
859 | |||
860 | // Install Dependencies |
||
861 | foreach ($moduleDependencies as $dependency) { |
||
862 | $installDependencyLevel[$dependency['module']] = array( |
||
863 | // 'type' => '' //create, update |
||
864 | /*'error' => array( |
||
865 | 'type' => 'sql', |
||
866 | 'content' => '' |
||
867 | )*/ |
||
868 | /*'extra' => array( |
||
869 | 'type' => '', //error, done |
||
870 | 'content' => '' //dependency name or error message |
||
871 | )*/ |
||
872 | ); |
||
873 | $query = 'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"'; |
||
874 | $ds = mysqli_query($sqlParser->conn, $query); |
||
875 | View Code Duplication | if (!$ds) { |
|
876 | $installDependencyLevel[$dependency['module']]['error'] = array( |
||
877 | 'type' => 'sql', |
||
878 | 'content' => mysqli_error($sqlParser->conn) |
||
879 | ); |
||
880 | $errorInstall = true; |
||
881 | break; |
||
882 | } else { |
||
883 | $row = mysqli_fetch_assoc($ds); |
||
884 | $moduleId = $row["id"]; |
||
885 | $moduleGuid = $row["guid"]; |
||
886 | } |
||
887 | // get extra id |
||
888 | $query = 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"'; |
||
889 | $ds = mysqli_query($sqlParser->conn, $query); |
||
890 | View Code Duplication | if (!$ds) { |
|
891 | $installDependencyLevel[$dependency['module']]['error'] = array( |
||
892 | 'type' => 'sql', |
||
893 | 'content' => mysqli_error($sqlParser->conn) |
||
894 | ); |
||
895 | $errorInstall = true; |
||
896 | break; |
||
897 | } else { |
||
898 | $row = mysqli_fetch_assoc($ds); |
||
899 | $extraId = $row["id"]; |
||
900 | } |
||
901 | // setup extra as module dependency |
||
902 | $query = 'SELECT module FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type'] . ' LIMIT 1'; |
||
903 | $ds = mysqli_query($sqlParser->conn, $query); |
||
904 | if (!$ds) { |
||
905 | $installDependencyLevel[$dependency['module']]['error'] = array( |
||
906 | 'type' => 'sql', |
||
907 | 'content' => mysqli_error($sqlParser->conn) |
||
908 | ); |
||
909 | $errorInstall = true; |
||
910 | break; |
||
911 | } else { |
||
912 | if (mysqli_num_rows($ds) === 0) { |
||
913 | $query = 'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')'; |
||
914 | mysqli_query($sqlParser->conn, $query); |
||
915 | $installDependencyLevel[$dependency['module']]['type'] = 'create'; |
||
916 | } else { |
||
917 | $query = 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` SET module = ' . $moduleId . ', resource = ' . $extraId . ', type = ' . $dependency['type'] . ' WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type']; |
||
918 | mysqli_query($sqlParser->conn, $query); |
||
919 | $installDependencyLevel[$dependency['module']]['type'] = 'update'; |
||
920 | } |
||
921 | if ($dependency['type'] == 30 || $dependency['type'] == 40) { |
||
922 | // set extra guid for plugins and snippets |
||
923 | $query = 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1'; |
||
924 | $ds = mysqli_query($sqlParser->conn, $query); |
||
925 | if (!$ds) { |
||
926 | $installDependencyLevel[$dependency['module']]['extra'] = array( |
||
927 | 'type' => 'error', |
||
928 | 'content' => mysqli_error($sqlParser->conn) |
||
929 | ); |
||
930 | $errorInstall = true; |
||
931 | break; |
||
932 | } else { |
||
933 | if (mysqli_num_rows($ds) != 0) { |
||
934 | $query = 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId; |
||
935 | $ds= mysqli_query($sqlParser->conn, $query); |
||
936 | $installDependencyLevel[$dependency['module']]['extra'] = array( |
||
937 | 'type' => 'done', |
||
938 | 'content' => $dependency['name'] |
||
939 | ); |
||
940 | } |
||
941 | } |
||
942 | } |
||
943 | } |
||
944 | } |
||
945 | if ($errorInstall === false) { |
||
946 | $installLevel = 7; |
||
947 | } |
||
948 | } |
||
949 | |||
950 | if ($installLevel === 7) { |
||
951 | // call back function |
||
952 | if ($callBackFnc != "") { |
||
953 | $callBackFnc($sqlParser); |
||
954 | } |
||
955 | |||
956 | // Setup the MODX API -- needed for the cache processor |
||
957 | if (file_exists(dirname(__DIR__, 3) . '/' . MGR_DIR . '/includes/config_mutator.php')) { |
||
958 | require_once dirname(__DIR__, 3) . '/' . MGR_DIR . '/includes/config_mutator.php'; |
||
959 | } |
||
960 | define('MODX_API_MODE', true); |
||
961 | if (!defined('MODX_BASE_PATH')) { |
||
962 | define('MODX_BASE_PATH', $base_path); |
||
963 | } |
||
964 | if (!defined('MODX_MANAGER_PATH')) { |
||
965 | define('MODX_MANAGER_PATH', $base_path . MGR_DIR . '/'); |
||
966 | } |
||
967 | $database_type = 'mysqli'; |
||
968 | // initiate a new document parser |
||
969 | if (!defined('EVO_BOOTSTRAP_FILE')) { |
||
970 | define('EVO_BOOTSTRAP_FILE', EVO_CORE_PATH . 'bootstrap.php'); |
||
971 | require_once EVO_CORE_PATH . 'bootstrap.php'; |
||
972 | } |
||
973 | |||
974 | if (! defined('MODX_CLASS')) { |
||
975 | define('MODX_CLASS', '\DocumentParser'); |
||
976 | } |
||
977 | |||
978 | $modx = evolutionCMS(); |
||
979 | $modx->getDatabase()->connect(); |
||
980 | // always empty cache after install |
||
981 | $modx->clearCache(); |
||
982 | // $sync = new \EvolutionCMS\Legacy\Cache(); |
||
983 | // $sync->setCachepath(dirname(__DIR__, 3) . '/assets/cache/'); |
||
984 | // $sync->setReport(false); |
||
985 | // $sync->emptyCache(); // first empty the cache |
||
986 | |||
987 | // try to chmod the cache go-rwx (for suexeced php) |
||
988 | @chmod(dirname(__DIR__, 3) . '/assets/cache/siteCache.idx.php', 0600); |
||
989 | @chmod(dirname(__DIR__, 3) . '/assets/cache/sitePublishing.idx.php', 0600); |
||
990 | |||
991 | // remove any locks on the manager functions so initial manager login is not blocked |
||
992 | mysqli_query($conn, "TRUNCATE TABLE `" . $table_prefix . "active_users`"); |
||
993 | |||
994 | // close db connection |
||
995 | // $sqlParser->close(); |
||
996 | |||
997 | // andrazk 20070416 - release manager access |
||
998 | View Code Duplication | if (file_exists(dirname(__DIR__, 3) . '/assets/cache/installProc.inc.php')) { |
|
999 | @chmod(dirname(__DIR__, 3) . '/assets/cache/installProc.inc.php', 0755); |
||
1000 | unlink(dirname(__DIR__, 3) . '/assets/cache/installProc.inc.php'); |
||
1001 | } |
||
1002 | } |
||
1003 | } |
||
1004 | include_once dirname(__DIR__) . '/template/actions/install.php'; |
||
1005 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.