|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* EVO Cli Installer |
|
4
|
|
|
* php cli-install.php --database_server=localhost --database=db --database_user=dbuser --database_password=dbpass |
|
5
|
|
|
* --table_prefix=evo_ --cmsadmin=admin [email protected] --cmspassword=123456 --language=ru --mode=new |
|
6
|
|
|
* --installData=n --removeInstall=y |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
$self = 'install/cli-install.php'; |
|
10
|
|
|
$path = __DIR__ . '/'; |
|
11
|
|
|
$base_path = dirname(__DIR__) . '/'; |
|
12
|
|
|
define('MODX_API_MODE', true); |
|
13
|
|
|
define('MODX_BASE_PATH', $base_path); |
|
14
|
|
|
define('MODX_SITE_URL', '/'); |
|
15
|
|
|
|
|
16
|
|
|
require_once 'src/functions.php'; |
|
17
|
|
|
|
|
18
|
|
|
// set error reporting |
|
19
|
|
|
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); |
|
20
|
|
|
|
|
21
|
|
|
if (is_file($base_path . "assets/cache/siteManager.php")) { |
|
22
|
|
|
include_once($base_path . "assets/cache/siteManager.php"); |
|
23
|
|
|
} |
|
24
|
|
|
if (!defined('MGR_DIR') && is_dir($base_path . "manager")) { |
|
25
|
|
|
define('MGR_DIR', 'manager'); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
require_once 'src/lang.php'; |
|
29
|
|
|
require_once($base_path . MGR_DIR . '/includes/version.inc.php'); |
|
30
|
|
|
|
|
31
|
|
|
$moduleName = "EVO"; |
|
32
|
|
|
$moduleVersion = $modx_branch . ' ' . $modx_version; |
|
33
|
|
|
$moduleRelease = $modx_release_date; |
|
34
|
|
|
$moduleSQLBaseFile = $path . 'stubs/sql/setup.sql'; |
|
35
|
|
|
$moduleSQLDataFile = $path . 'stubs/sql/setup.data.sql'; |
|
36
|
|
|
$moduleSQLResetFile = $path . 'stubs/sql/setup.data.reset.sql'; |
|
37
|
|
|
|
|
38
|
|
|
$moduleChunks = array(); // chunks - array : name, description, type - 0:file or 1:content, file or content |
|
39
|
|
|
$moduleTemplates = array(); // templates - array : name, description, type - 0:file or 1:content, file or content |
|
40
|
|
|
$moduleSnippets = array(); // snippets - array : name, description, type - 0:file or 1:content, file or content,properties |
|
41
|
|
|
$modulePlugins = array(); // plugins - array : name, description, type - 0:file or 1:content, file or content,properties, events,guid |
|
42
|
|
|
$moduleModules = array(); // modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid |
|
43
|
|
|
$moduleTemplates = array(); // templates - array : name, description, type - 0:file or 1:content, file or content,properties |
|
44
|
|
|
$moduleTVs = array(); // template variables - array : name, description, type - 0:file or 1:content, file or content,properties |
|
45
|
|
|
$moduleDependencies = array(); // module depedencies - array : module, table, column, type, name |
|
46
|
|
|
$errors = 0; |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
$installMode = 0; |
|
50
|
|
|
$installData = 0; |
|
51
|
|
|
$tableprefixauto = base_convert(rand(10, 20), 10, 36) . substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), |
|
52
|
|
|
rand(0, 33), 3) . '_'; |
|
53
|
|
|
|
|
54
|
|
|
$args = array_slice($argv, 1); |
|
55
|
|
|
|
|
56
|
|
|
if (empty($args)) { |
|
57
|
|
|
echo 'Install Evolution CMS' . PHP_EOL; |
|
58
|
|
|
//$installYes = readline("Type 'y' to continue: "); |
|
59
|
|
|
//if ($installYes != 'y') return; |
|
60
|
|
|
|
|
61
|
|
|
//set param manual |
|
62
|
|
|
$databasehost = readline($_lang['connection_screen_database_host'] . ' [localhost] '); |
|
63
|
|
|
$databaseloginname = readline($_lang['connection_screen_database_login'] . ' '); |
|
64
|
|
|
$databaseloginpassword = readline($_lang['connection_screen_database_pass'] . ' '); |
|
65
|
|
|
$database_name = readline($_lang['connection_screen_database_name'] . ' '); |
|
66
|
|
|
$tableprefix = readline($_lang['connection_screen_table_prefix'] . ' [' . $tableprefixauto . '] '); |
|
67
|
|
|
$database_connection_method = readline($_lang['connection_screen_connection_method'] . ' [SET CHARACTER SET] '); |
|
68
|
|
|
$database_collation = readline($_lang['connection_screen_collation'] . ' [utf8_general_ci] '); |
|
69
|
|
|
$cmsadmin = readline($_lang['connection_screen_default_admin_login'] . ' [admin] '); |
|
70
|
|
|
$cmsadminemail = readline($_lang['connection_screen_default_admin_email'] . ' '); |
|
71
|
|
|
$cmspassword = readline($_lang['connection_screen_default_admin_password'] . ' '); |
|
72
|
|
|
$managerlanguage = readline('Мanager language:' . ' [en] '); |
|
73
|
|
|
$installData = readline('Instal demo-site (y/n):' . ' [n] '); |
|
74
|
|
|
|
|
75
|
|
|
} else { |
|
76
|
|
|
|
|
77
|
|
|
$cli_variables = []; |
|
78
|
|
|
foreach ($args as $arg) { |
|
79
|
|
|
$tmp = array_map('trim', explode('=', $arg)); |
|
80
|
|
|
if (count($tmp) === 2) { |
|
81
|
|
|
$k = ltrim($tmp[0], '-'); |
|
82
|
|
|
|
|
83
|
|
|
$cli_variables[$k] = $tmp[1]; |
|
84
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
$databasehost = $cli_variables['database_server']; |
|
89
|
|
|
$databaseloginname = $cli_variables['database_user']; |
|
90
|
|
|
$databaseloginpassword = $cli_variables['database_password']; |
|
91
|
|
|
$database_name = $cli_variables['database']; |
|
92
|
|
|
$tableprefix = $cli_variables['table_prefix']; |
|
93
|
|
|
|
|
94
|
|
|
$cmsadmin = $cli_variables['cmsadmin']; |
|
95
|
|
|
$cmsadminemail = $cli_variables['cmsadminemail']; |
|
96
|
|
|
$cmspassword = $cli_variables['cmspassword']; |
|
97
|
|
|
|
|
98
|
|
|
$managerlanguage = $cli_variables['language']; |
|
99
|
|
|
$installData = $cli_variables['installData']; |
|
100
|
|
|
$mode = $cli_variables['mode']; |
|
101
|
|
|
$removeInstall = $cli_variables['removeInstall']; |
|
102
|
|
|
|
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
|
|
106
|
|
|
if ($databasehost == '') { |
|
107
|
|
|
$databasehost = 'localhost'; |
|
108
|
|
|
} |
|
109
|
|
|
if ($tableprefix == '') { |
|
110
|
|
|
$tableprefix = $tableprefixauto; |
|
111
|
|
|
} |
|
112
|
|
|
if ($database_connection_method == '') { |
|
113
|
|
|
$database_connection_method = 'SET CHARACTER SET'; |
|
114
|
|
|
} |
|
115
|
|
|
if ($database_collation == '') { |
|
116
|
|
|
$database_collation = 'utf8_general_ci'; |
|
117
|
|
|
} |
|
118
|
|
|
if ($cmsadmin == '') { |
|
119
|
|
|
$cmsadmin = 'admin'; |
|
120
|
|
|
} |
|
121
|
|
|
if ($managerlanguage == '') { |
|
122
|
|
|
$managerlanguage = 'en'; |
|
123
|
|
|
} |
|
124
|
|
|
if ($installData == 'y') { |
|
125
|
|
|
$installData = 1; |
|
126
|
|
|
} |
|
127
|
|
|
if ($mode == 'upgrade') { |
|
128
|
|
|
$installMode = 1; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
//добавить обработку языка |
|
132
|
|
|
|
|
133
|
|
|
switch ($managerlanguage) { |
|
134
|
|
|
case 'ru': |
|
135
|
|
|
$managerlanguage = 'russian-UTF8'; |
|
136
|
|
|
break; |
|
137
|
|
|
|
|
138
|
|
|
case 'en': |
|
139
|
|
|
default: |
|
140
|
|
|
$managerlanguage = 'english'; |
|
141
|
|
|
break; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
////////////////////////////////////////////////////////////////////////////////////// |
|
145
|
|
View Code Duplication |
if (!function_exists('f_owc')) { |
|
146
|
|
|
/** |
|
147
|
|
|
* @param $path |
|
148
|
|
|
* @param $data |
|
149
|
|
|
* @param null|int $mode |
|
150
|
|
|
*/ |
|
151
|
|
|
function f_owc($path, $data, $mode = null) |
|
152
|
|
|
{ |
|
153
|
|
|
try { |
|
154
|
|
|
// make an attempt to create the file |
|
155
|
|
|
$hnd = fopen($path, 'w'); |
|
156
|
|
|
fwrite($hnd, $data); |
|
157
|
|
|
fclose($hnd); |
|
158
|
|
|
|
|
159
|
|
|
if (null !== $mode) { |
|
160
|
|
|
chmod($path, $mode); |
|
161
|
|
|
} |
|
162
|
|
|
} catch (Exception $e) { |
|
163
|
|
|
// Nothing, this is NOT normal |
|
164
|
|
|
unset($e); |
|
165
|
|
|
} |
|
166
|
|
|
} |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
// check PHP version |
|
170
|
|
|
define('PHP_MIN_VERSION', '5.4.0'); |
|
171
|
|
|
$phpMinVersion = PHP_MIN_VERSION; // Maybe not necessary. For backward compatibility |
|
172
|
|
|
echo PHP_EOL . $_lang['checking_php_version']; |
|
173
|
|
|
// -1 if left is less, 0 if equal, +1 if left is higher |
|
174
|
|
|
if (version_compare(phpversion(), PHP_MIN_VERSION) < 0) { |
|
175
|
|
|
$errors++; |
|
176
|
|
|
$tmp = $_lang['you_running_php'] . phpversion() . str_replace('[+min_version+]', PHP_MIN_VERSION, |
|
177
|
|
|
$_lang["modx_requires_php"]); |
|
178
|
|
|
echo $_lang['failed'] . ' ' . $tmp . PHP_EOL; |
|
179
|
|
|
} else { |
|
180
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
// check directories |
|
184
|
|
|
// cache exists? |
|
185
|
|
|
echo strip_tags($_lang['checking_if_cache_exist']); |
|
186
|
|
View Code Duplication |
if (!file_exists($path . "../assets/cache") || !file_exists($path . "../assets/cache/rss")) { |
|
187
|
|
|
echo $_lang['failed'] . PHP_EOL; |
|
188
|
|
|
$errors++; |
|
189
|
|
|
} else { |
|
190
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
|
|
194
|
|
|
// cache writable? |
|
195
|
|
|
echo strip_tags($_lang['checking_if_cache_writable']); |
|
196
|
|
View Code Duplication |
if (!is_writable($path . "../assets/cache")) { |
|
197
|
|
|
$errors++; |
|
198
|
|
|
echo $_lang['failed'] . PHP_EOL; |
|
199
|
|
|
} else { |
|
200
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
|
|
204
|
|
|
// cache files writable? |
|
205
|
|
|
echo strip_tags($_lang['checking_if_cache_file_writable']); |
|
206
|
|
|
$tmp = $path . "../assets/cache/siteCache.idx.php"; |
|
207
|
|
|
if (!file_exists($tmp)) { |
|
208
|
|
|
f_owc($tmp, "<?php //EVO site cache file ?>"); |
|
209
|
|
|
} |
|
210
|
|
View Code Duplication |
if (!is_writable($tmp)) { |
|
211
|
|
|
$errors++; |
|
212
|
|
|
echo $_lang['failed'] . PHP_EOL; |
|
213
|
|
|
} else { |
|
214
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
|
|
218
|
|
|
echo strip_tags($_lang['checking_if_cache_file2_writable']); |
|
219
|
|
View Code Duplication |
if (!is_writable($path . "../assets/cache/sitePublishing.idx.php")) { |
|
220
|
|
|
$errors++; |
|
221
|
|
|
echo $_lang['failed'] . PHP_EOL; |
|
222
|
|
|
} else { |
|
223
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
|
|
227
|
|
|
// File Browser directories exists? |
|
228
|
|
|
echo strip_tags($_lang['checking_if_images_exist']); |
|
229
|
|
View Code Duplication |
switch (true) { |
|
230
|
|
|
case !file_exists($path . "../assets/images"): |
|
231
|
|
|
case !file_exists($path . "../assets/files"): |
|
232
|
|
|
case !file_exists($path . "../assets/backup"): |
|
233
|
|
|
//case !file_exists("../assets/.thumbs"): |
|
234
|
|
|
$errors++; |
|
235
|
|
|
echo $_lang['failed'] . PHP_EOL; |
|
236
|
|
|
break; |
|
237
|
|
|
default: |
|
238
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
|
|
242
|
|
|
// File Browser directories writable? |
|
243
|
|
|
echo strip_tags($_lang['checking_if_images_writable']); |
|
244
|
|
View Code Duplication |
switch (true) { |
|
245
|
|
|
case !is_writable($path . "../assets/images"): |
|
246
|
|
|
case !is_writable($path . "../assets/files"): |
|
247
|
|
|
case !is_writable($path . "../assets/backup"): |
|
248
|
|
|
//case !is_writable("../assets/.thumbs"): |
|
249
|
|
|
$errors++; |
|
250
|
|
|
echo $_lang['failed'] . PHP_EOL; |
|
251
|
|
|
break; |
|
252
|
|
|
default: |
|
253
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
|
|
257
|
|
|
// export exists? |
|
258
|
|
|
echo strip_tags($_lang['checking_if_export_exists']); |
|
259
|
|
View Code Duplication |
if (!file_exists($path . "../assets/export")) { |
|
260
|
|
|
echo $_lang['failed'] . PHP_EOL; |
|
261
|
|
|
$errors++; |
|
262
|
|
|
} else { |
|
263
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
264
|
|
|
} |
|
265
|
|
|
|
|
266
|
|
|
|
|
267
|
|
|
// export writable? |
|
268
|
|
|
echo strip_tags($_lang['checking_if_export_writable']); |
|
269
|
|
View Code Duplication |
if (!is_writable($path . "../assets/export")) { |
|
270
|
|
|
echo $_lang['failed'] . PHP_EOL; |
|
271
|
|
|
$errors++; |
|
272
|
|
|
} else { |
|
273
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
|
|
277
|
|
|
// config.inc.php writable? |
|
278
|
|
|
echo strip_tags($_lang['checking_if_config_exist_and_writable']); |
|
279
|
|
|
$tmp = $path . "../" . MGR_DIR . "/includes/config.inc.php"; |
|
280
|
|
View Code Duplication |
if (!is_file($tmp)) { |
|
281
|
|
|
f_owc($tmp, "<?php //EVO configuration file ?>", 0666); |
|
282
|
|
|
} else { |
|
283
|
|
|
@chmod($tmp, 0666); |
|
284
|
|
|
} |
|
285
|
|
|
$isWriteable = is_writable($tmp); |
|
286
|
|
View Code Duplication |
if (!$isWriteable) { |
|
287
|
|
|
$errors++; |
|
288
|
|
|
echo $_lang['failed'] . PHP_EOL; |
|
289
|
|
|
} else { |
|
290
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
|
|
294
|
|
|
// connect to the database |
|
295
|
|
|
if ($installMode == 1) { |
|
296
|
|
|
include $path . "../" . MGR_DIR . "/includes/config.inc.php"; |
|
297
|
|
|
} else { |
|
298
|
|
|
// get db info from post |
|
299
|
|
|
$database_server = $databasehost; |
|
300
|
|
|
$database_user = $databaseloginname; |
|
301
|
|
|
$database_password = $databaseloginpassword; |
|
302
|
|
|
$database_collation = $database_collation; |
|
303
|
|
|
$database_charset = substr($database_collation, 0, strpos($database_collation, '_') - 1); |
|
304
|
|
|
$database_connection_charset = $database_collation; |
|
305
|
|
|
$database_connection_method = $database_connection_method; |
|
306
|
|
|
$dbase = '`' . $database_name . '`'; |
|
307
|
|
|
$table_prefix = $tableprefix; |
|
308
|
|
|
} |
|
309
|
|
|
echo $_lang['creating_database_connection']; |
|
310
|
|
|
if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) { |
|
311
|
|
|
$errors++; |
|
312
|
|
|
echo $_lang['database_connection_failed'] . PHP_EOL; |
|
313
|
|
|
} else { |
|
314
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
|
|
318
|
|
|
// make sure we can use the database |
|
319
|
|
|
if ($installMode > 0 && !mysqli_query($conn, "USE {$dbase}")) { |
|
320
|
|
|
$errors++; |
|
321
|
|
|
echo $_lang['database_use_failed'] . PHP_EOL; |
|
322
|
|
|
} |
|
323
|
|
|
|
|
324
|
|
|
// check the database collation if not specified in the configuration |
|
325
|
|
View Code Duplication |
if (!isset ($database_connection_charset) || empty ($database_connection_charset)) { |
|
326
|
|
|
if (!$rs = mysqli_query($conn, "show session variables like 'collation_database'")) { |
|
327
|
|
|
$rs = mysqli_query($conn, "show session variables like 'collation_server'"); |
|
328
|
|
|
} |
|
329
|
|
|
if ($rs && $collation = mysqli_fetch_row($rs)) { |
|
330
|
|
|
$database_collation = $collation[1]; |
|
331
|
|
|
} |
|
332
|
|
|
if (empty ($database_collation)) { |
|
333
|
|
|
$database_collation = 'utf8_unicode_ci'; |
|
334
|
|
|
} |
|
335
|
|
|
$database_charset = substr($database_collation, 0, strpos($database_collation, '_') - 1); |
|
336
|
|
|
$database_connection_charset = $database_charset; |
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
|
|
// determine the database connection method if not specified in the configuration |
|
340
|
|
|
if (!isset($database_connection_method) || empty($database_connection_method)) { |
|
341
|
|
|
$database_connection_method = 'SET CHARACTER SET'; |
|
342
|
|
|
} |
|
343
|
|
|
|
|
344
|
|
|
// check table prefix |
|
345
|
|
|
if ($conn && $installMode == 0) { |
|
346
|
|
|
echo $_lang['checking_table_prefix'] . $table_prefix . '`: '; |
|
347
|
|
View Code Duplication |
if ($rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) { |
|
348
|
|
|
echo $_lang['failed'] . ' ' . $_lang['table_prefix_already_inuse_note'] . PHP_EOL; |
|
349
|
|
|
$errors++; |
|
350
|
|
|
|
|
351
|
|
|
} else { |
|
352
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
353
|
|
|
} |
|
354
|
|
|
} elseif ($conn && $installMode == 2) { |
|
355
|
|
|
echo $_lang['checking_table_prefix'] . $table_prefix . '`: '; |
|
356
|
|
View Code Duplication |
if (!$rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) { |
|
357
|
|
|
echo $_lang['failed'] . ' ' . $_lang['table_prefix_not_exist'] . PHP_EOL; |
|
358
|
|
|
$errors++; |
|
359
|
|
|
|
|
360
|
|
|
} else { |
|
361
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
362
|
|
|
} |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
|
|
// check mysql version |
|
366
|
|
|
if ($conn) { |
|
367
|
|
|
echo $_lang['checking_mysql_version']; |
|
368
|
|
|
if (version_compare(mysqli_get_server_info($conn), '5.0.51', '=')) { |
|
369
|
|
|
echo $_lang['warning'] . ' ' . $_lang['mysql_5051'] . PHP_EOL; |
|
370
|
|
|
echo $_lang['mysql_5051_warning'] . PHP_EOL; |
|
371
|
|
View Code Duplication |
} else { |
|
372
|
|
|
echo $_lang['ok'] . ' ' . $_lang['mysql_version_is'] . mysqli_get_server_info($conn) . PHP_EOL; |
|
373
|
|
|
} |
|
374
|
|
|
} |
|
375
|
|
|
|
|
376
|
|
|
// check for strict mode |
|
377
|
|
|
if ($conn) { |
|
378
|
|
|
echo $_lang['checking_mysql_strict_mode']; |
|
379
|
|
|
$mysqlmode = mysqli_query($conn, "SELECT @@global.sql_mode"); |
|
380
|
|
|
if (mysqli_num_rows($mysqlmode) > 0) { |
|
381
|
|
|
$modes = mysqli_fetch_array($mysqlmode, MYSQLI_NUM); |
|
382
|
|
|
//$modes = array("STRICT_TRANS_TABLES"); // for testing |
|
383
|
|
|
// print_r($modes); |
|
384
|
|
|
foreach ($modes as $mode) { |
|
385
|
|
|
if (stristr($mode, "STRICT_TRANS_TABLES") !== false || stristr($mode, "STRICT_ALL_TABLES") !== false) { |
|
386
|
|
|
echo $_lang['warning'] . ' ' . $_lang['strict_mode'] . PHP_EOL; |
|
387
|
|
|
echo $_lang['strict_mode_error'] . PHP_EOL; |
|
388
|
|
|
} else { |
|
389
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
390
|
|
|
} |
|
391
|
|
|
} |
|
392
|
|
|
} else { |
|
393
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
394
|
|
|
} |
|
395
|
|
|
} |
|
396
|
|
|
// Version and strict mode check end |
|
397
|
|
|
|
|
398
|
|
|
// andrazk 20070416 - add install flag and disable manager login |
|
399
|
|
|
// assets/cache writable? |
|
400
|
|
|
if (is_writable($path . "../assets/cache")) { |
|
401
|
|
View Code Duplication |
if (file_exists($path . '../assets/cache/installProc.inc.php')) { |
|
402
|
|
|
@chmod($path . '../assets/cache/installProc.inc.php', 0755); |
|
403
|
|
|
unlink($path . '../assets/cache/installProc.inc.php'); |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
f_owc($path . "../assets/cache/installProc.inc.php", '<?php $installStartTime = ' . time() . '; ?>'); |
|
407
|
|
|
} |
|
408
|
|
|
|
|
409
|
|
View Code Duplication |
if ($installMode > 0 && $_POST['installdata'] == "1") { |
|
410
|
|
|
echo $_lang['sample_web_site'] . ': ' . $_lang['sample_web_site_note'] . PHP_EOL; |
|
411
|
|
|
} |
|
412
|
|
|
|
|
413
|
|
|
if ($errors > 0) { |
|
414
|
|
|
echo $_lang['setup_cannot_continue'] . ' '; |
|
415
|
|
|
|
|
416
|
|
View Code Duplication |
if ($errors > 1) { |
|
417
|
|
|
echo $errors . " " . $_lang['errors'] . $_lang['please_correct_errors'] . $_lang['and_try_again_plural']; |
|
418
|
|
|
} else { |
|
419
|
|
|
echo $_lang['error'] . $_lang['please_correct_error'] . $_lang['and_try_again'] . PHP_EOL; |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
|
|
die(); |
|
423
|
|
|
} |
|
424
|
|
|
|
|
425
|
|
|
|
|
426
|
|
|
////////////////////////////////////////////////////////////////////////////////////// |
|
427
|
|
|
$create = false; |
|
428
|
|
|
|
|
429
|
|
|
// set timout limit |
|
430
|
|
|
@ set_time_limit(120); // used @ to prevent warning when using safe mode? |
|
431
|
|
|
|
|
432
|
|
|
//echo $_lang['setup_database'].PHP_EOL; |
|
433
|
|
|
|
|
434
|
|
|
|
|
435
|
|
|
if ($installMode == 1) { |
|
436
|
|
|
include $path . "../" . MGR_DIR . "/includes/config.inc.php"; |
|
437
|
|
|
} else { |
|
438
|
|
|
// get db info from post |
|
439
|
|
|
$database_server = $databasehost; |
|
440
|
|
|
$database_user = $databaseloginname; |
|
441
|
|
|
$database_password = $databaseloginpassword; |
|
442
|
|
|
$database_collation = $database_collation; |
|
443
|
|
|
$database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
|
444
|
|
|
$database_connection_charset = $database_charset; |
|
445
|
|
|
$database_connection_method = $database_connection_method; |
|
446
|
|
|
$dbase = "`" . $database_name . "`"; |
|
447
|
|
|
$table_prefix = $tableprefix; |
|
448
|
|
|
$adminname = $cmsadmin; |
|
449
|
|
|
$adminemail = $cmsadminemail; |
|
450
|
|
|
$adminpass = $cmspassword; |
|
451
|
|
|
$managerlanguage = $managerlanguage; |
|
452
|
|
|
$custom_placeholders = array(); |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
// set session name variable |
|
456
|
|
|
if (!isset ($site_sessionname)) { |
|
457
|
|
|
$site_sessionname = 'SN' . uniqid(''); |
|
458
|
|
|
} |
|
459
|
|
|
|
|
460
|
|
|
// get base path and url |
|
461
|
|
|
$a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"]))); |
|
462
|
|
|
if (count($a) > 1) { |
|
463
|
|
|
array_pop($a); |
|
464
|
|
|
} |
|
465
|
|
|
$url = implode("install", $a); |
|
466
|
|
|
reset($a); |
|
467
|
|
|
$a = explode("install", str_replace("\\", "/", realpath(__DIR__))); |
|
468
|
|
|
if (count($a) > 1) { |
|
469
|
|
|
array_pop($a); |
|
470
|
|
|
} |
|
471
|
|
|
$pth = implode("install", $a); |
|
472
|
|
|
unset ($a); |
|
473
|
|
|
$base_url = $url . (substr($url, -1) != "/" ? "/" : ""); |
|
474
|
|
|
$base_path = $pth . (substr($pth, -1) != "/" ? "/" : ""); |
|
475
|
|
|
|
|
476
|
|
|
// connect to the database |
|
477
|
|
|
echo $_lang['setup_database_create_connection'] . ': '; |
|
478
|
|
|
if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) { |
|
479
|
|
|
echo $_lang["setup_database_create_connection_failed"] . " " . $_lang['setup_database_create_connection_failed_note'] . PHP_EOL; |
|
480
|
|
|
|
|
481
|
|
|
return; |
|
482
|
|
|
} else { |
|
483
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
484
|
|
|
} |
|
485
|
|
|
|
|
486
|
|
|
// select database |
|
487
|
|
|
echo $_lang['setup_database_selection'] . str_replace("`", "", $dbase) . "`: "; |
|
488
|
|
|
if (!mysqli_select_db($conn, str_replace("`", "", $dbase))) { |
|
489
|
|
|
echo $_lang['setup_database_selection_failed'] . " " . $_lang['setup_database_selection_failed_note'] . PHP_EOL; |
|
490
|
|
|
$create = true; |
|
491
|
|
|
} else { |
|
492
|
|
|
if (function_exists('mysqli_set_charset')) { |
|
493
|
|
|
mysqli_set_charset($conn, $database_charset); |
|
494
|
|
|
} |
|
495
|
|
|
mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); |
|
496
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
497
|
|
|
} |
|
498
|
|
|
|
|
499
|
|
|
// try to create the database |
|
500
|
|
|
if ($create) { |
|
501
|
|
|
echo $_lang['setup_database_creation'] . str_replace("`", "", $dbase) . "`: "; |
|
502
|
|
|
// if(!@mysqli_create_db(str_replace("`","",$dbase), $conn)) { |
|
503
|
|
|
if (!mysqli_query($conn, |
|
504
|
|
|
"CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) { |
|
505
|
|
|
echo $_lang['setup_database_creation_failed'] . " " . $_lang['setup_database_creation_failed_note'] . PHP_EOL; |
|
506
|
|
|
$errors += 1; |
|
507
|
|
|
|
|
508
|
|
|
echo 'database charset: ' . $database_charset . PHP_EOL; |
|
509
|
|
|
echo 'database collation: ' . $database_collation . PHP_EOL; |
|
510
|
|
|
|
|
511
|
|
|
echo $_lang['setup_database_creation_failed_note2'] . PHP_EOL; |
|
512
|
|
|
|
|
513
|
|
|
die(); |
|
514
|
|
|
|
|
515
|
|
|
} else { |
|
516
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
517
|
|
|
} |
|
518
|
|
|
} |
|
519
|
|
|
|
|
520
|
|
|
// check table prefix |
|
521
|
|
|
if ($installMode == 0) { |
|
522
|
|
|
echo $_lang['checking_table_prefix'] . $table_prefix . "`: "; |
|
523
|
|
|
if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) { |
|
524
|
|
|
echo $_lang['failed'] . " " . $_lang['table_prefix_already_inuse'] . PHP_EOL; |
|
525
|
|
|
$errors += 1; |
|
526
|
|
|
echo $_lang['table_prefix_already_inuse_note'] . PHP_EOL; |
|
527
|
|
|
|
|
528
|
|
|
return; |
|
529
|
|
|
} else { |
|
530
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
531
|
|
|
} |
|
532
|
|
|
} |
|
533
|
|
|
|
|
534
|
|
View Code Duplication |
if (!function_exists('propertiesNameValue')) { |
|
535
|
|
|
/** |
|
536
|
|
|
* parses a resource property string and returns the result as an array |
|
537
|
|
|
* duplicate of method in documentParser class |
|
538
|
|
|
* |
|
539
|
|
|
* @param string $propertyString |
|
540
|
|
|
* @return array |
|
541
|
|
|
*/ |
|
542
|
|
|
function propertiesNameValue($propertyString) |
|
543
|
|
|
{ |
|
544
|
|
|
$parameter = array(); |
|
545
|
|
|
if (!empty ($propertyString)) { |
|
546
|
|
|
$tmpParams = explode("&", $propertyString); |
|
547
|
|
|
$countParams = count($tmpParams); |
|
548
|
|
|
for ($x = 0; $x < $countParams; $x++) { |
|
549
|
|
|
if (strpos($tmpParams[$x], '=', 0)) { |
|
550
|
|
|
$pTmp = explode("=", $tmpParams[$x]); |
|
551
|
|
|
$pvTmp = explode(";", trim($pTmp[1])); |
|
552
|
|
|
if ($pvTmp[1] == 'list' && $pvTmp[3] != "") { |
|
553
|
|
|
$parameter[trim($pTmp[0])] = $pvTmp[3]; |
|
554
|
|
|
} //list default |
|
555
|
|
|
else { |
|
556
|
|
|
if ($pvTmp[1] != 'list' && $pvTmp[2] != "") { |
|
557
|
|
|
$parameter[trim($pTmp[0])] = $pvTmp[2]; |
|
558
|
|
|
} |
|
559
|
|
|
} |
|
560
|
|
|
} |
|
561
|
|
|
} |
|
562
|
|
|
} |
|
563
|
|
|
|
|
564
|
|
|
return $parameter; |
|
565
|
|
|
} |
|
566
|
|
|
} |
|
567
|
|
|
|
|
568
|
|
|
// check status of Inherit Parent Template plugin |
|
569
|
|
|
$auto_template_logic = 'parent'; |
|
570
|
|
|
if ($installMode != 0) { |
|
571
|
|
|
$rs = mysqli_query($conn, |
|
572
|
|
|
"SELECT properties, disabled FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='Inherit Parent Template'"); |
|
573
|
|
|
$row = mysqli_fetch_row($rs); |
|
574
|
|
|
if (!$row) { |
|
575
|
|
|
// not installed |
|
576
|
|
|
$auto_template_logic = 'system'; |
|
577
|
|
View Code Duplication |
} else { |
|
578
|
|
|
if ($row[1] == 1) { |
|
579
|
|
|
// installed but disabled |
|
580
|
|
|
$auto_template_logic = 'system'; |
|
581
|
|
|
} else { |
|
582
|
|
|
// installed, enabled .. see how it's configured |
|
583
|
|
|
$properties = parseProperties($row[0]); |
|
584
|
|
|
if (isset($properties['inheritTemplate'])) { |
|
585
|
|
|
if ($properties['inheritTemplate'] == 'From First Sibling') { |
|
586
|
|
|
$auto_template_logic = 'sibling'; |
|
587
|
|
|
} |
|
588
|
|
|
} |
|
589
|
|
|
} |
|
590
|
|
|
} |
|
591
|
|
|
} |
|
592
|
|
|
|
|
593
|
|
|
|
|
594
|
|
|
// open db connection |
|
595
|
|
|
$setupPath = realpath(__DIR__); |
|
596
|
|
|
$chunkPath = $path . 'assets/chunks'; |
|
597
|
|
|
$snippetPath = $path . 'assets/snippets'; |
|
598
|
|
|
$pluginPath = $path . 'assets/plugins'; |
|
599
|
|
|
$modulePath = $path . 'assets/modules'; |
|
600
|
|
|
$templatePath = $path . 'assets/templates'; |
|
601
|
|
|
$tvPath = $path . 'assets/tvs'; |
|
602
|
|
|
|
|
603
|
|
|
// setup Template template files - array : name, description, type - 0:file or 1:content, parameters, category |
|
604
|
|
|
$mt = &$moduleTemplates; |
|
605
|
|
View Code Duplication |
if (is_dir($templatePath) && is_readable($templatePath)) { |
|
606
|
|
|
$d = dir($templatePath); |
|
607
|
|
|
while (false !== ($tplfile = $d->read())) { |
|
608
|
|
|
if (substr($tplfile, -4) != '.tpl') { |
|
609
|
|
|
continue; |
|
610
|
|
|
} |
|
611
|
|
|
$params = parse_docblock($templatePath, $tplfile); |
|
612
|
|
|
if (is_array($params) && (count($params) > 0)) { |
|
613
|
|
|
$description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
|
614
|
|
|
$mt[] = array |
|
615
|
|
|
( |
|
616
|
|
|
$params['name'], |
|
617
|
|
|
$description, |
|
618
|
|
|
// Don't think this is gonna be used ... but adding it just in case 'type' |
|
619
|
|
|
$params['type'], |
|
620
|
|
|
"$templatePath/{$params['filename']}", |
|
621
|
|
|
$params['modx_category'], |
|
622
|
|
|
$params['lock_template'], |
|
623
|
|
|
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false, |
|
624
|
|
|
isset($params['save_sql_id_as']) ? $params['save_sql_id_as'] : null |
|
625
|
|
|
// Nessecary to fix template-ID for demo-site |
|
626
|
|
|
); |
|
627
|
|
|
} |
|
628
|
|
|
} |
|
629
|
|
|
$d->close(); |
|
630
|
|
|
} |
|
631
|
|
|
|
|
632
|
|
|
// setup Template Variable template files |
|
633
|
|
|
$mtv = &$moduleTVs; |
|
634
|
|
|
if (is_dir($tvPath) && is_readable($tvPath)) { |
|
635
|
|
|
$d = dir($tvPath); |
|
636
|
|
View Code Duplication |
while (false !== ($tplfile = $d->read())) { |
|
637
|
|
|
if (substr($tplfile, -4) != '.tpl') { |
|
638
|
|
|
continue; |
|
639
|
|
|
} |
|
640
|
|
|
$params = parse_docblock($tvPath, $tplfile); |
|
641
|
|
|
if (is_array($params) && (count($params) > 0)) { |
|
642
|
|
|
$description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
|
643
|
|
|
$mtv[] = array( |
|
644
|
|
|
$params['name'], |
|
645
|
|
|
$params['caption'], |
|
646
|
|
|
$description, |
|
647
|
|
|
$params['input_type'], |
|
648
|
|
|
$params['input_options'], |
|
649
|
|
|
$params['input_default'], |
|
650
|
|
|
$params['output_widget'], |
|
651
|
|
|
$params['output_widget_params'], |
|
652
|
|
|
"$templatePath/{$params['filename']}", |
|
653
|
|
|
/* not currently used */ |
|
654
|
|
|
$params['template_assignments'] != "*" ? $params['template_assignments'] : implode(",", |
|
655
|
|
|
array_map(create_function('$v', 'return $v[0];'), $mt)), |
|
656
|
|
|
/* comma-separated list of template names */ |
|
657
|
|
|
$params['modx_category'], |
|
658
|
|
|
$params['lock_tv'], |
|
659
|
|
|
/* value should be 1 or 0 */ |
|
660
|
|
|
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false |
|
661
|
|
|
); |
|
662
|
|
|
} |
|
663
|
|
|
} |
|
664
|
|
|
$d->close(); |
|
665
|
|
|
} |
|
666
|
|
|
|
|
667
|
|
|
// setup chunks template files - array : name, description, type - 0:file or 1:content, file or content |
|
668
|
|
|
$mc = &$moduleChunks; |
|
669
|
|
View Code Duplication |
if (is_dir($chunkPath) && is_readable($chunkPath)) { |
|
670
|
|
|
$d = dir($chunkPath); |
|
671
|
|
|
while (false !== ($tplfile = $d->read())) { |
|
672
|
|
|
if (substr($tplfile, -4) != '.tpl') { |
|
673
|
|
|
continue; |
|
674
|
|
|
} |
|
675
|
|
|
$params = parse_docblock($chunkPath, $tplfile); |
|
676
|
|
|
if (is_array($params) && count($params) > 0) { |
|
677
|
|
|
$mc[] = array( |
|
678
|
|
|
$params['name'], |
|
679
|
|
|
$params['description'], |
|
680
|
|
|
"$chunkPath/{$params['filename']}", |
|
681
|
|
|
$params['modx_category'], |
|
682
|
|
|
array_key_exists('overwrite', $params) ? $params['overwrite'] : 'true', |
|
683
|
|
|
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false |
|
684
|
|
|
); |
|
685
|
|
|
} |
|
686
|
|
|
} |
|
687
|
|
|
$d->close(); |
|
688
|
|
|
} |
|
689
|
|
|
|
|
690
|
|
|
// setup snippets template files - array : name, description, type - 0:file or 1:content, file or content,properties |
|
691
|
|
|
$ms = &$moduleSnippets; |
|
692
|
|
View Code Duplication |
if (is_dir($snippetPath) && is_readable($snippetPath)) { |
|
693
|
|
|
$d = dir($snippetPath); |
|
694
|
|
|
while (false !== ($tplfile = $d->read())) { |
|
695
|
|
|
if (substr($tplfile, -4) != '.tpl') { |
|
696
|
|
|
continue; |
|
697
|
|
|
} |
|
698
|
|
|
$params = parse_docblock($snippetPath, $tplfile); |
|
699
|
|
|
if (is_array($params) && count($params) > 0) { |
|
700
|
|
|
$description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
|
701
|
|
|
$ms[] = array( |
|
702
|
|
|
$params['name'], |
|
703
|
|
|
$description, |
|
704
|
|
|
"$snippetPath/{$params['filename']}", |
|
705
|
|
|
$params['properties'], |
|
706
|
|
|
$params['modx_category'], |
|
707
|
|
|
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false |
|
708
|
|
|
); |
|
709
|
|
|
} |
|
710
|
|
|
} |
|
711
|
|
|
$d->close(); |
|
712
|
|
|
} |
|
713
|
|
|
|
|
714
|
|
|
// setup plugins template files - array : name, description, type - 0:file or 1:content, file or content,properties |
|
715
|
|
|
$mp = &$modulePlugins; |
|
716
|
|
View Code Duplication |
if (is_dir($pluginPath) && is_readable($pluginPath)) { |
|
717
|
|
|
$d = dir($pluginPath); |
|
718
|
|
|
while (false !== ($tplfile = $d->read())) { |
|
719
|
|
|
if (substr($tplfile, -4) != '.tpl') { |
|
720
|
|
|
continue; |
|
721
|
|
|
} |
|
722
|
|
|
$params = parse_docblock($pluginPath, $tplfile); |
|
723
|
|
|
if (is_array($params) && count($params) > 0) { |
|
724
|
|
|
$description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
|
725
|
|
|
$mp[] = array( |
|
726
|
|
|
$params['name'], |
|
727
|
|
|
$description, |
|
728
|
|
|
"$pluginPath/{$params['filename']}", |
|
729
|
|
|
$params['properties'], |
|
730
|
|
|
$params['events'], |
|
731
|
|
|
$params['guid'], |
|
732
|
|
|
$params['modx_category'], |
|
733
|
|
|
$params['legacy_names'], |
|
734
|
|
|
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false, |
|
735
|
|
|
(int)$params['disabled'] |
|
736
|
|
|
); |
|
737
|
|
|
} |
|
738
|
|
|
} |
|
739
|
|
|
$d->close(); |
|
740
|
|
|
} |
|
741
|
|
|
|
|
742
|
|
|
// setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams |
|
743
|
|
|
$mm = &$moduleModules; |
|
744
|
|
|
$mdp = &$moduleDependencies; |
|
745
|
|
View Code Duplication |
if (is_dir($modulePath) && is_readable($modulePath)) { |
|
746
|
|
|
$d = dir($modulePath); |
|
747
|
|
|
while (false !== ($tplfile = $d->read())) { |
|
748
|
|
|
if (substr($tplfile, -4) != '.tpl') { |
|
749
|
|
|
continue; |
|
750
|
|
|
} |
|
751
|
|
|
$params = parse_docblock($modulePath, $tplfile); |
|
752
|
|
|
if (is_array($params) && count($params) > 0) { |
|
753
|
|
|
$description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
|
754
|
|
|
$mm[] = array( |
|
755
|
|
|
$params['name'], |
|
756
|
|
|
$description, |
|
757
|
|
|
"$modulePath/{$params['filename']}", |
|
758
|
|
|
$params['properties'], |
|
759
|
|
|
$params['guid'], |
|
760
|
|
|
(int)$params['shareparams'], |
|
761
|
|
|
$params['modx_category'], |
|
762
|
|
|
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false |
|
763
|
|
|
); |
|
764
|
|
|
} |
|
765
|
|
|
if ((int)$params['shareparams'] || !empty($params['dependencies'])) { |
|
766
|
|
|
$dependencies = explode(',', $params['dependencies']); |
|
767
|
|
|
foreach ($dependencies as $dependency) { |
|
768
|
|
|
$dependency = explode(':', $dependency); |
|
769
|
|
|
switch (trim($dependency[0])) { |
|
770
|
|
|
case 'template': |
|
771
|
|
|
$mdp[] = array( |
|
772
|
|
|
'module' => $params['name'], |
|
773
|
|
|
'table' => 'templates', |
|
774
|
|
|
'column' => 'templatename', |
|
775
|
|
|
'type' => 50, |
|
776
|
|
|
'name' => trim($dependency[1]) |
|
777
|
|
|
); |
|
778
|
|
|
break; |
|
779
|
|
|
case 'tv': |
|
780
|
|
|
case 'tmplvar': |
|
781
|
|
|
$mdp[] = array( |
|
782
|
|
|
'module' => $params['name'], |
|
783
|
|
|
'table' => 'tmplvars', |
|
784
|
|
|
'column' => 'name', |
|
785
|
|
|
'type' => 60, |
|
786
|
|
|
'name' => trim($dependency[1]) |
|
787
|
|
|
); |
|
788
|
|
|
break; |
|
789
|
|
|
case 'chunk': |
|
790
|
|
|
case 'htmlsnippet': |
|
791
|
|
|
$mdp[] = array( |
|
792
|
|
|
'module' => $params['name'], |
|
793
|
|
|
'table' => 'htmlsnippets', |
|
794
|
|
|
'column' => 'name', |
|
795
|
|
|
'type' => 10, |
|
796
|
|
|
'name' => trim($dependency[1]) |
|
797
|
|
|
); |
|
798
|
|
|
break; |
|
799
|
|
|
case 'snippet': |
|
800
|
|
|
$mdp[] = array( |
|
801
|
|
|
'module' => $params['name'], |
|
802
|
|
|
'table' => 'snippets', |
|
803
|
|
|
'column' => 'name', |
|
804
|
|
|
'type' => 40, |
|
805
|
|
|
'name' => trim($dependency[1]) |
|
806
|
|
|
); |
|
807
|
|
|
break; |
|
808
|
|
|
case 'plugin': |
|
809
|
|
|
$mdp[] = array( |
|
810
|
|
|
'module' => $params['name'], |
|
811
|
|
|
'table' => 'plugins', |
|
812
|
|
|
'column' => 'name', |
|
813
|
|
|
'type' => 30, |
|
814
|
|
|
'name' => trim($dependency[1]) |
|
815
|
|
|
); |
|
816
|
|
|
break; |
|
817
|
|
|
case 'resource': |
|
818
|
|
|
$mdp[] = array( |
|
819
|
|
|
'module' => $params['name'], |
|
820
|
|
|
'table' => 'content', |
|
821
|
|
|
'column' => 'pagetitle', |
|
822
|
|
|
'type' => 20, |
|
823
|
|
|
'name' => trim($dependency[1]) |
|
824
|
|
|
); |
|
825
|
|
|
break; |
|
826
|
|
|
} |
|
827
|
|
|
} |
|
828
|
|
|
} |
|
829
|
|
|
} |
|
830
|
|
|
$d->close(); |
|
831
|
|
|
} |
|
832
|
|
|
|
|
833
|
|
|
// setup callback function |
|
834
|
|
|
$callBackFnc = "clean_up"; |
|
835
|
|
|
|
|
836
|
|
|
include $path . "src/sqlParser.class.php"; |
|
837
|
|
|
$sqlParser = new SqlParser($database_server, $database_user, $database_password, str_replace("`", "", $dbase), |
|
838
|
|
|
$table_prefix, $adminname, $adminemail, $adminpass, $database_connection_charset, $managerlanguage, |
|
839
|
|
|
$database_connection_method, $auto_template_logic); |
|
840
|
|
|
$sqlParser->mode = ($installMode < 1) ? "new" : "upd"; |
|
841
|
|
|
/* image and file manager paths now handled via settings screen in Manager |
|
842
|
|
|
$sqlParser->imageUrl = 'http://' . $_SERVER['SERVER_NAME'] . $base_url . "assets/"; |
|
843
|
|
|
$sqlParser->imageUrl = "assets/"; |
|
844
|
|
|
$sqlParser->imagePath = $base_path . "assets/"; |
|
845
|
|
|
$sqlParser->fileManagerPath = $base_path; |
|
846
|
|
|
*/ |
|
847
|
|
|
$sqlParser->ignoreDuplicateErrors = true; |
|
848
|
|
|
$sqlParser->connect(); |
|
849
|
|
|
|
|
850
|
|
|
// install/update database |
|
851
|
|
|
echo $_lang['setup_database_creating_tables']; |
|
852
|
|
|
if ($moduleSQLBaseFile) { |
|
853
|
|
|
$sqlParser->process($moduleSQLBaseFile); |
|
854
|
|
|
// display database results |
|
855
|
|
|
if ($sqlParser->installFailed == true) { |
|
856
|
|
|
$errors += 1; |
|
857
|
|
|
echo $_lang['database_alerts'] . PHP_EOL; |
|
858
|
|
|
echo $_lang['setup_couldnt_install'] . PHP_EOL; |
|
859
|
|
|
echo $_lang['installation_error_occured'] . PHP_EOL; |
|
860
|
|
|
for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
|
861
|
|
|
echo $sqlParser->mysqlErrors[$i]["error"] . " " . $_lang['during_execution_of_sql'] . " " . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . PHP_EOL; |
|
862
|
|
|
} |
|
863
|
|
|
echo $_lang['some_tables_not_updated'] . PHP_EOL; |
|
864
|
|
|
die(); |
|
865
|
|
|
} else { |
|
866
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
867
|
|
|
} |
|
868
|
|
|
} |
|
869
|
|
|
|
|
870
|
|
|
// custom or not |
|
871
|
|
|
if (file_exists($path . "../assets/cache/siteManager.php")) { |
|
872
|
|
|
$mgrdir = 'include_once(__DIR__."/../../assets/cache/siteManager.php");'; |
|
873
|
|
|
} else { |
|
874
|
|
|
$mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
|
875
|
|
|
} |
|
876
|
|
|
|
|
877
|
|
|
// write the config.inc.php file if new installation |
|
878
|
|
|
echo $_lang['writing_config_file']; |
|
879
|
|
|
|
|
880
|
|
|
$confph = array(); |
|
881
|
|
|
$confph['database_server'] = $database_server; |
|
882
|
|
|
$confph['user_name'] = mysqli_real_escape_string($conn, $database_user); |
|
883
|
|
|
$confph['password'] = mysqli_real_escape_string($conn, $database_password); |
|
884
|
|
|
$confph['connection_charset'] = $database_connection_charset; |
|
885
|
|
|
$confph['connection_method'] = $database_connection_method; |
|
886
|
|
|
$confph['dbase'] = str_replace('`', '', $dbase); |
|
887
|
|
|
$confph['table_prefix'] = $table_prefix; |
|
888
|
|
|
$confph['lastInstallTime'] = time(); |
|
889
|
|
|
$confph['site_sessionname'] = $site_sessionname; |
|
890
|
|
|
|
|
891
|
|
|
$configString = file_get_contents($path . 'stubs/config.tpl'); |
|
892
|
|
|
$configString = parse($configString, $confph); |
|
893
|
|
|
|
|
894
|
|
|
$filename = $base_path . MGR_DIR . '/includes/config.inc.php'; |
|
895
|
|
|
$configFileFailed = false; |
|
896
|
|
|
if (@ !$handle = fopen($filename, 'w')) { |
|
897
|
|
|
$configFileFailed = true; |
|
898
|
|
|
} |
|
899
|
|
|
|
|
900
|
|
|
// write $somecontent to our opened file. |
|
901
|
|
|
if (@ fwrite($handle, $configString) === false) { |
|
902
|
|
|
$configFileFailed = true; |
|
903
|
|
|
} |
|
904
|
|
|
@ fclose($handle); |
|
905
|
|
|
|
|
906
|
|
|
// try to chmod the config file go-rwx (for suexeced php) |
|
907
|
|
|
$chmodSuccess = @chmod($filename, 0404); |
|
908
|
|
|
|
|
909
|
|
|
if ($configFileFailed == true) { |
|
|
|
|
|
|
910
|
|
|
echo $_lang['failed'] . PHP_EOL; |
|
911
|
|
|
$errors += 1; |
|
912
|
|
|
|
|
913
|
|
|
echo $_lang['cant_write_config_file'] . ' ' . MGR_DIR . '/includes/config.inc.php' . PHP_EOL; |
|
914
|
|
|
echo ' ' . PHP_EOL; |
|
915
|
|
|
echo ' ' . PHP_EOL; |
|
916
|
|
|
echo $configString; |
|
917
|
|
|
echo ' ' . PHP_EOL; |
|
918
|
|
|
echo ' ' . PHP_EOL; |
|
919
|
|
|
echo $_lang['cant_write_config_file_note'] . PHP_EOL; |
|
920
|
|
|
die(); |
|
921
|
|
|
|
|
922
|
|
|
} else { |
|
923
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
924
|
|
|
} |
|
925
|
|
|
|
|
926
|
|
|
// generate new site_id and set manager theme to default |
|
927
|
|
|
if ($installMode == 0) { |
|
928
|
|
|
$siteid = uniqid(''); |
|
929
|
|
|
mysqli_query($sqlParser->conn, |
|
930
|
|
|
"REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')"); |
|
931
|
|
View Code Duplication |
} else { |
|
932
|
|
|
// update site_id if missing |
|
933
|
|
|
$ds = mysqli_query($sqlParser->conn, |
|
934
|
|
|
"SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'"); |
|
935
|
|
|
if ($ds) { |
|
936
|
|
|
$r = mysqli_fetch_assoc($ds); |
|
937
|
|
|
$siteid = $r['setting_value']; |
|
938
|
|
|
if ($siteid == '' || $siteid = 'MzGeQ2faT4Dw06+U49x3') { |
|
939
|
|
|
$siteid = uniqid(''); |
|
940
|
|
|
mysqli_query($sqlParser->conn, |
|
941
|
|
|
"REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')"); |
|
942
|
|
|
} |
|
943
|
|
|
} |
|
944
|
|
|
} |
|
945
|
|
|
|
|
946
|
|
|
// Reset database for installation of demo-site |
|
947
|
|
|
if ($installData && $moduleSQLDataFile && $moduleSQLResetFile) { |
|
948
|
|
|
echo $_lang['resetting_database']; |
|
949
|
|
|
$sqlParser->process($moduleSQLResetFile); |
|
950
|
|
|
// display database results |
|
951
|
|
|
if ($sqlParser->installFailed == true) { |
|
952
|
|
|
$errors += 1; |
|
953
|
|
|
echo $_lang['database_alerts'] . PHP_EOL; |
|
954
|
|
|
echo $_lang['setup_couldnt_install'] . PHP_EOL; |
|
955
|
|
|
echo $_lang['installation_error_occured'] . PHP_EOL . PHP_EOL; |
|
956
|
|
|
/* |
|
957
|
|
|
for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
|
958
|
|
|
echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
959
|
|
|
} |
|
960
|
|
|
echo "</p>";*/ |
|
961
|
|
|
echo $_lang['some_tables_not_updated'] . PHP_EOL; |
|
962
|
|
|
die(); |
|
963
|
|
|
} else { |
|
964
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
965
|
|
|
} |
|
966
|
|
|
} |
|
967
|
|
|
|
|
968
|
|
|
// Install Templates |
|
969
|
|
|
$moduleTemplate = $mt; |
|
970
|
|
|
if (!empty($moduleTemplate) || $installData) { |
|
971
|
|
|
echo PHP_EOL . $_lang['templates'] . ":" . PHP_EOL; |
|
972
|
|
|
//$selTemplates = $_POST['template']; |
|
973
|
|
|
foreach ($moduleTemplates as $k => $moduleTemplate) { |
|
974
|
|
|
$installSample = in_array('sample', $moduleTemplate[6]) && $installData == 1; |
|
975
|
|
|
if ($installSample || is_array($moduleTemplate)) { |
|
976
|
|
|
$name = mysqli_real_escape_string($conn, $moduleTemplate[0]); |
|
977
|
|
|
$desc = mysqli_real_escape_string($conn, $moduleTemplate[1]); |
|
978
|
|
|
$category = mysqli_real_escape_string($conn, $moduleTemplate[4]); |
|
979
|
|
|
$locked = mysqli_real_escape_string($conn, $moduleTemplate[5]); |
|
980
|
|
|
$filecontent = $moduleTemplate[3]; |
|
981
|
|
|
$save_sql_id_as = $moduleTemplate[7]; // Nessecary for demo-site |
|
982
|
|
|
if (!file_exists($filecontent)) { |
|
983
|
|
|
echo " $name: " . $_lang['unable_install_template'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
984
|
|
|
} else { |
|
985
|
|
|
// Create the category if it does not already exist |
|
986
|
|
|
$category_id = getCreateDbCategory($category, $sqlParser); |
|
987
|
|
|
|
|
988
|
|
|
// Strip the first comment up top |
|
989
|
|
|
$template = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1); |
|
990
|
|
|
$template = mysqli_real_escape_string($conn, $template); |
|
991
|
|
|
|
|
992
|
|
|
// See if the template already exists |
|
993
|
|
|
$rs = mysqli_query($sqlParser->conn, |
|
994
|
|
|
"SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'"); |
|
995
|
|
|
|
|
996
|
|
|
if (mysqli_num_rows($rs)) { |
|
997
|
|
|
if (!mysqli_query($sqlParser->conn, |
|
998
|
|
|
"UPDATE $dbase.`" . $table_prefix . "site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked' WHERE templatename='$name' LIMIT 1;")) { |
|
999
|
|
|
$errors += 1; |
|
1000
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1001
|
|
|
|
|
1002
|
|
|
return; |
|
1003
|
|
|
} |
|
1004
|
|
View Code Duplication |
if (!is_null($save_sql_id_as)) { |
|
1005
|
|
|
$sql_id = @mysqli_insert_id($sqlParser->conn); |
|
1006
|
|
|
if (!$sql_id) { |
|
1007
|
|
|
$idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, |
|
1008
|
|
|
"SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name' LIMIT 1;")); |
|
1009
|
|
|
$sql_id = $idQuery['id']; |
|
1010
|
|
|
} |
|
1011
|
|
|
$custom_placeholders[$save_sql_id_as] = $sql_id; |
|
1012
|
|
|
} |
|
1013
|
|
|
echo " $name: " . $_lang['upgraded'] . PHP_EOL; |
|
1014
|
|
|
} else { |
|
1015
|
|
|
if (!@ mysqli_query($sqlParser->conn, |
|
1016
|
|
|
"INSERT INTO $dbase.`" . $table_prefix . "site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) { |
|
1017
|
|
|
$errors += 1; |
|
1018
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1019
|
|
|
die(); |
|
1020
|
|
|
} |
|
1021
|
|
|
if (!is_null($save_sql_id_as)) { |
|
1022
|
|
|
$custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
1023
|
|
|
} |
|
1024
|
|
|
echo " $name: " . $_lang['installed'] . PHP_EOL; |
|
1025
|
|
|
} |
|
1026
|
|
|
} |
|
1027
|
|
|
} |
|
1028
|
|
|
} |
|
1029
|
|
|
} |
|
1030
|
|
|
|
|
1031
|
|
|
// Install Template Variables |
|
1032
|
|
|
$moduleTVs = $mtv; |
|
1033
|
|
|
if (is_array($moduleTVs) || $installData) { |
|
1034
|
|
|
echo PHP_EOL . $_lang['tvs'] . ': ' . PHP_EOL; |
|
1035
|
|
|
//$selTVs = $_POST['tv']; |
|
1036
|
|
|
foreach ($moduleTVs as $k => $moduleTV) { |
|
1037
|
|
|
$installSample = in_array('sample', $moduleTV[12]) && $installData == 1; |
|
1038
|
|
|
if ($installSample || is_array($moduleTVs)) { |
|
1039
|
|
|
$name = mysqli_real_escape_string($conn, $moduleTV[0]); |
|
1040
|
|
|
$caption = mysqli_real_escape_string($conn, $moduleTV[1]); |
|
1041
|
|
|
$desc = mysqli_real_escape_string($conn, $moduleTV[2]); |
|
1042
|
|
|
$input_type = mysqli_real_escape_string($conn, $moduleTV[3]); |
|
1043
|
|
|
$input_options = mysqli_real_escape_string($conn, $moduleTV[4]); |
|
1044
|
|
|
$input_default = mysqli_real_escape_string($conn, $moduleTV[5]); |
|
1045
|
|
|
$output_widget = mysqli_real_escape_string($conn, $moduleTV[6]); |
|
1046
|
|
|
$output_widget_params = mysqli_real_escape_string($conn, $moduleTV[7]); |
|
1047
|
|
|
$filecontent = $moduleTV[8]; |
|
1048
|
|
|
$assignments = $moduleTV[9]; |
|
1049
|
|
|
$category = mysqli_real_escape_string($conn, $moduleTV[10]); |
|
1050
|
|
|
$locked = mysqli_real_escape_string($conn, $moduleTV[11]); |
|
1051
|
|
|
|
|
1052
|
|
|
|
|
1053
|
|
|
// Create the category if it does not already exist |
|
1054
|
|
|
$category = getCreateDbCategory($category, $sqlParser); |
|
1055
|
|
|
|
|
1056
|
|
|
$rs = mysqli_query($sqlParser->conn, |
|
1057
|
|
|
"SELECT * FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name'"); |
|
1058
|
|
|
if (mysqli_num_rows($rs)) { |
|
1059
|
|
|
$insert = true; |
|
1060
|
|
|
while ($row = mysqli_fetch_assoc($rs)) { |
|
1061
|
|
|
if (!mysqli_query($sqlParser->conn, |
|
1062
|
|
|
"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']};")) { |
|
1063
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1064
|
|
|
|
|
1065
|
|
|
return; |
|
1066
|
|
|
} |
|
1067
|
|
|
$insert = false; |
|
1068
|
|
|
} |
|
1069
|
|
|
echo " $name: " . $_lang['upgraded'] . PHP_EOL; |
|
1070
|
|
|
} else { |
|
1071
|
|
|
$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');"; |
|
1072
|
|
|
if (!mysqli_query($sqlParser->conn, $q)) { |
|
1073
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1074
|
|
|
|
|
1075
|
|
|
return; |
|
1076
|
|
|
} |
|
1077
|
|
|
echo " $name: " . $_lang['installed'] . PHP_EOL; |
|
1078
|
|
|
} |
|
1079
|
|
|
|
|
1080
|
|
|
// add template assignments |
|
1081
|
|
|
$assignments = explode(',', $assignments); |
|
1082
|
|
|
|
|
1083
|
|
|
if (count($assignments) > 0) { |
|
1084
|
|
|
|
|
1085
|
|
|
// remove existing tv -> template assignments |
|
1086
|
|
|
$ds = mysqli_query($sqlParser->conn, |
|
1087
|
|
|
"SELECT id FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name' AND description='$desc';"); |
|
1088
|
|
|
$row = mysqli_fetch_assoc($ds); |
|
1089
|
|
|
$id = $row["id"]; |
|
1090
|
|
|
mysqli_query($sqlParser->conn, |
|
1091
|
|
|
'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\''); |
|
1092
|
|
|
|
|
1093
|
|
|
// add tv -> template assignments |
|
1094
|
|
|
foreach ($assignments as $assignment) { |
|
1095
|
|
|
$template = mysqli_real_escape_string($conn, $assignment); |
|
1096
|
|
|
$ts = mysqli_query($sqlParser->conn, |
|
1097
|
|
|
"SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$template';"); |
|
1098
|
|
View Code Duplication |
if ($ds && $ts) { |
|
1099
|
|
|
$tRow = mysqli_fetch_assoc($ts); |
|
1100
|
|
|
$templateId = $tRow['id']; |
|
1101
|
|
|
mysqli_query($sqlParser->conn, |
|
1102
|
|
|
"INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); |
|
1103
|
|
|
} |
|
1104
|
|
|
} |
|
1105
|
|
|
} |
|
1106
|
|
|
} |
|
1107
|
|
|
} |
|
1108
|
|
|
} |
|
1109
|
|
|
|
|
1110
|
|
|
|
|
1111
|
|
|
$moduleChunks = $mc; |
|
1112
|
|
|
// Install Chunks |
|
1113
|
|
|
if (is_array($moduleChunks) || $installData) { |
|
1114
|
|
|
echo PHP_EOL . $_lang['chunks'] . ": " . PHP_EOL; |
|
1115
|
|
|
foreach ($moduleChunks as $k => $moduleChunk) { |
|
1116
|
|
|
$installSample = in_array('sample', $moduleChunk[5]) && $installData == 1; |
|
1117
|
|
|
$count_new_name = 0; |
|
1118
|
|
|
if ($installSample || is_array($moduleChunks)) { |
|
1119
|
|
|
|
|
1120
|
|
|
$name = mysqli_real_escape_string($conn, $moduleChunk[0]); |
|
1121
|
|
|
$desc = mysqli_real_escape_string($conn, $moduleChunk[1]); |
|
1122
|
|
|
$category = mysqli_real_escape_string($conn, $moduleChunk[3]); |
|
1123
|
|
|
$overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]); |
|
1124
|
|
|
$filecontent = $moduleChunk[2]; |
|
1125
|
|
|
|
|
1126
|
|
|
if (!file_exists($filecontent)) { |
|
1127
|
|
|
echo " $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
1128
|
|
|
} else { |
|
1129
|
|
|
|
|
1130
|
|
|
// Create the category if it does not already exist |
|
1131
|
|
|
$category_id = getCreateDbCategory($category, $sqlParser); |
|
1132
|
|
|
|
|
1133
|
|
|
$chunk = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1); |
|
1134
|
|
|
$chunk = mysqli_real_escape_string($conn, $chunk); |
|
1135
|
|
|
$rs = mysqli_query($sqlParser->conn, |
|
1136
|
|
|
"SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$name'"); |
|
1137
|
|
|
$count_original_name = mysqli_num_rows($rs); |
|
1138
|
|
View Code Duplication |
if ($overwrite == 'false') { |
|
1139
|
|
|
$newname = $name . '-' . str_replace('.', '_', $modx_version); |
|
1140
|
|
|
$rs = mysqli_query($sqlParser->conn, |
|
1141
|
|
|
"SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$newname'"); |
|
1142
|
|
|
$count_new_name = mysqli_num_rows($rs); |
|
1143
|
|
|
} |
|
1144
|
|
|
$update = $count_original_name > 0 && $overwrite == 'true'; |
|
1145
|
|
|
if ($update) { |
|
1146
|
|
|
if (!mysqli_query($sqlParser->conn, |
|
1147
|
|
|
"UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) { |
|
1148
|
|
|
$errors += 1; |
|
1149
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1150
|
|
|
|
|
1151
|
|
|
return; |
|
1152
|
|
|
} |
|
1153
|
|
|
echo " $name: " . $_lang['upgraded'] . PHP_EOL; |
|
1154
|
|
|
} elseif ($count_new_name == 0) { |
|
1155
|
|
|
if ($count_original_name > 0 && $overwrite == 'false') { |
|
1156
|
|
|
$name = $newname; |
|
1157
|
|
|
} |
|
1158
|
|
|
if (!mysqli_query($sqlParser->conn, |
|
1159
|
|
|
"INSERT INTO $dbase.`" . $table_prefix . "site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) { |
|
1160
|
|
|
$errors += 1; |
|
1161
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1162
|
|
|
|
|
1163
|
|
|
return; |
|
1164
|
|
|
} |
|
1165
|
|
|
echo " $name: " . $_lang['installed'] . PHP_EOL; |
|
1166
|
|
|
} |
|
1167
|
|
|
} |
|
1168
|
|
|
} |
|
1169
|
|
|
} |
|
1170
|
|
|
} |
|
1171
|
|
|
|
|
1172
|
|
|
// Install Modules |
|
1173
|
|
|
$moduleModules = $mm; |
|
1174
|
|
|
if (is_array($moduleModules) || $installData) { |
|
1175
|
|
|
echo PHP_EOL . $_lang['modules'] . ":" . PHP_EOL; |
|
1176
|
|
|
//$selModules = $_POST['module']; |
|
1177
|
|
|
foreach ($moduleModules as $k => $moduleModule) { |
|
1178
|
|
|
$installSample = in_array('sample', $moduleModule[7]) && $installData == 1; |
|
1179
|
|
|
if ($installSample || is_array($moduleModules)) { |
|
1180
|
|
|
$name = mysqli_real_escape_string($conn, $moduleModule[0]); |
|
1181
|
|
|
$desc = mysqli_real_escape_string($conn, $moduleModule[1]); |
|
1182
|
|
|
$filecontent = $moduleModule[2]; |
|
1183
|
|
|
$properties = $moduleModule[3]; |
|
1184
|
|
|
$guid = mysqli_real_escape_string($conn, $moduleModule[4]); |
|
1185
|
|
|
$shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
|
1186
|
|
|
$category = mysqli_real_escape_string($conn, $moduleModule[6]); |
|
1187
|
|
|
if (!file_exists($filecontent)) { |
|
1188
|
|
|
echo " $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
1189
|
|
|
} else { |
|
1190
|
|
|
|
|
1191
|
|
|
// Create the category if it does not already exist |
|
1192
|
|
|
$category = getCreateDbCategory($category, $sqlParser); |
|
1193
|
|
|
|
|
1194
|
|
|
$module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
|
|
|
|
|
|
1195
|
|
|
// $module = removeDocblock($module, 'module'); // Modules have no fileBinding, keep docblock for info-tab |
|
1196
|
|
|
$module = mysqli_real_escape_string($conn, $module); |
|
1197
|
|
|
$rs = mysqli_query($sqlParser->conn, |
|
1198
|
|
|
"SELECT * FROM $dbase.`" . $table_prefix . "site_modules` WHERE name='$name'"); |
|
1199
|
|
|
if (mysqli_num_rows($rs)) { |
|
1200
|
|
|
$row = mysqli_fetch_assoc($rs); |
|
1201
|
|
|
$props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
1202
|
|
|
if (!mysqli_query($sqlParser->conn, |
|
1203
|
|
|
"UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
|
1204
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1205
|
|
|
|
|
1206
|
|
|
return; |
|
1207
|
|
|
} |
|
1208
|
|
|
echo " $name: " . $_lang['upgraded'] . PHP_EOL; |
|
1209
|
|
|
} else { |
|
1210
|
|
|
if ($properties != null) { |
|
1211
|
|
|
$properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
|
1212
|
|
|
} |
|
1213
|
|
|
if (!mysqli_query($sqlParser->conn, |
|
1214
|
|
|
"INSERT INTO $dbase.`" . $table_prefix . "site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) { |
|
1215
|
|
|
echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
1216
|
|
|
|
|
1217
|
|
|
return; |
|
1218
|
|
|
} |
|
1219
|
|
|
echo " $name: " . $_lang['installed'] . PHP_EOL; |
|
1220
|
|
|
} |
|
1221
|
|
|
} |
|
1222
|
|
|
} |
|
1223
|
|
|
} |
|
1224
|
|
|
} |
|
1225
|
|
|
|
|
1226
|
|
|
// Install Plugins |
|
1227
|
|
|
$modulePlugins = $mp; |
|
1228
|
|
|
if (is_array($modulePlugins) || $installData) { |
|
1229
|
|
|
echo PHP_EOL . $_lang['plugins'] . ":" . PHP_EOL; |
|
1230
|
|
|
$selPlugs = $_POST['plugin']; |
|
1231
|
|
|
foreach ($modulePlugins as $k => $modulePlugin) { |
|
1232
|
|
|
//$installSample = in_array('sample', $modulePlugin[8]) && $installData == 1; |
|
1233
|
|
|
if ($installSample || is_array($modulePlugins)) { |
|
1234
|
|
|
$name = mysqli_real_escape_string($conn, $modulePlugin[0]); |
|
1235
|
|
|
$desc = mysqli_real_escape_string($conn, $modulePlugin[1]); |
|
1236
|
|
|
$filecontent = $modulePlugin[2]; |
|
1237
|
|
|
$properties = $modulePlugin[3]; |
|
1238
|
|
|
$events = explode(",", $modulePlugin[4]); |
|
1239
|
|
|
$guid = mysqli_real_escape_string($conn, $modulePlugin[5]); |
|
1240
|
|
|
$category = mysqli_real_escape_string($conn, $modulePlugin[6]); |
|
1241
|
|
|
$leg_names = ''; |
|
1242
|
|
|
$disabled = $modulePlugin[9]; |
|
1243
|
|
View Code Duplication |
if (array_key_exists(7, $modulePlugin)) { |
|
1244
|
|
|
// parse comma-separated legacy names and prepare them for sql IN clause |
|
1245
|
|
|
$leg_names = "'" . implode("','", |
|
1246
|
|
|
preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
|
1247
|
|
|
} |
|
1248
|
|
|
if (!file_exists($filecontent)) { |
|
1249
|
|
|
echo " $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
1250
|
|
|
} else { |
|
1251
|
|
|
|
|
1252
|
|
|
// disable legacy versions based on legacy_names provided |
|
1253
|
|
View Code Duplication |
if (!empty($leg_names)) { |
|
1254
|
|
|
$update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);"; |
|
1255
|
|
|
$rs = mysqli_query($sqlParser->conn, $update_query); |
|
1256
|
|
|
} |
|
1257
|
|
|
|
|
1258
|
|
|
// Create the category if it does not already exist |
|
1259
|
|
|
$category = getCreateDbCategory($category, $sqlParser); |
|
1260
|
|
|
|
|
1261
|
|
|
$plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
|
|
|
|
|
|
1262
|
|
|
$plugin = removeDocblock($plugin, 'plugin'); |
|
1263
|
|
|
$plugin = mysqli_real_escape_string($conn, $plugin); |
|
1264
|
|
|
$rs = mysqli_query($sqlParser->conn, |
|
1265
|
|
|
"SELECT * FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name'"); |
|
1266
|
|
|
if (mysqli_num_rows($rs)) { |
|
1267
|
|
|
$insert = true; |
|
1268
|
|
|
while ($row = mysqli_fetch_assoc($rs)) { |
|
1269
|
|
|
$props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
1270
|
|
|
if ($row['description'] == $desc) { |
|
1271
|
|
|
if (!mysqli_query($sqlParser->conn, |
|
1272
|
|
|
"UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
|
1273
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1274
|
|
|
|
|
1275
|
|
|
return; |
|
1276
|
|
|
} |
|
1277
|
|
|
$insert = false; |
|
1278
|
|
|
} else { |
|
1279
|
|
|
if (!mysqli_query($sqlParser->conn, |
|
1280
|
|
|
"UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) { |
|
1281
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1282
|
|
|
|
|
1283
|
|
|
return; |
|
1284
|
|
|
} |
|
1285
|
|
|
} |
|
1286
|
|
|
} |
|
1287
|
|
|
if ($insert === true) { |
|
1288
|
|
|
$properties = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
1289
|
|
|
if (!mysqli_query($sqlParser->conn, |
|
1290
|
|
|
"INSERT INTO $dbase.`" . $table_prefix . "site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$properties','$guid','0',$category);")) { |
|
1291
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1292
|
|
|
|
|
1293
|
|
|
return; |
|
1294
|
|
|
} |
|
1295
|
|
|
} |
|
1296
|
|
|
echo " $name: " . $_lang['upgraded'] . PHP_EOL; |
|
1297
|
|
View Code Duplication |
} else { |
|
1298
|
|
|
if ($properties != null) { |
|
1299
|
|
|
$properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
|
1300
|
|
|
} |
|
1301
|
|
|
if (!mysqli_query($sqlParser->conn, |
|
1302
|
|
|
"INSERT INTO $dbase.`" . $table_prefix . "site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);")) { |
|
1303
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1304
|
|
|
|
|
1305
|
|
|
return; |
|
1306
|
|
|
} |
|
1307
|
|
|
echo " $name: " . $_lang['installed'] . PHP_EOL; |
|
1308
|
|
|
} |
|
1309
|
|
|
// add system events |
|
1310
|
|
|
if (count($events) > 0) { |
|
1311
|
|
|
$ds = mysqli_query($sqlParser->conn, |
|
1312
|
|
|
"SELECT id FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name' AND description='$desc';"); |
|
1313
|
|
|
if ($ds) { |
|
1314
|
|
|
$row = mysqli_fetch_assoc($ds); |
|
1315
|
|
|
$id = $row["id"]; |
|
1316
|
|
|
// remove existing events |
|
1317
|
|
|
mysqli_query($sqlParser->conn, |
|
1318
|
|
|
'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_plugin_events` WHERE pluginid = \'' . $id . '\''); |
|
1319
|
|
|
// add new events |
|
1320
|
|
|
mysqli_query($sqlParser->conn, |
|
1321
|
|
|
"INSERT 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 ('" . implode("','", |
|
1322
|
|
|
$events) . "')"); |
|
1323
|
|
|
} |
|
1324
|
|
|
} |
|
1325
|
|
|
} |
|
1326
|
|
|
} |
|
1327
|
|
|
} |
|
1328
|
|
|
} |
|
1329
|
|
|
|
|
1330
|
|
|
// Install Snippets |
|
1331
|
|
|
$moduleSnippet = $ms; |
|
1332
|
|
|
if (is_array($moduleSnippet) || $installData) { |
|
1333
|
|
|
echo PHP_EOL . $_lang['snippets'] . ":" . PHP_EOL; |
|
1334
|
|
|
//$selSnips = $_POST['snippet']; |
|
1335
|
|
|
foreach ($moduleSnippets as $k => $moduleSnippet) { |
|
1336
|
|
|
$installSample = in_array('sample', $moduleSnippet[5]) && $installData == 1; |
|
1337
|
|
|
if ($installSample || is_array($moduleSnippet)) { |
|
1338
|
|
|
$name = mysqli_real_escape_string($conn, $moduleSnippet[0]); |
|
1339
|
|
|
$desc = mysqli_real_escape_string($conn, $moduleSnippet[1]); |
|
1340
|
|
|
$filecontent = $moduleSnippet[2]; |
|
1341
|
|
|
$properties = $moduleSnippet[3]; |
|
1342
|
|
|
$category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
|
1343
|
|
|
if (!file_exists($filecontent)) { |
|
1344
|
|
|
echo " $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
1345
|
|
|
} else { |
|
1346
|
|
|
|
|
1347
|
|
|
// Create the category if it does not already exist |
|
1348
|
|
|
$category = getCreateDbCategory($category, $sqlParser); |
|
1349
|
|
|
|
|
1350
|
|
|
$snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent))); |
|
|
|
|
|
|
1351
|
|
|
$snippet = removeDocblock($snippet, 'snippet'); |
|
1352
|
|
|
$snippet = mysqli_real_escape_string($conn, $snippet); |
|
1353
|
|
|
$rs = mysqli_query($sqlParser->conn, |
|
1354
|
|
|
"SELECT * FROM $dbase.`" . $table_prefix . "site_snippets` WHERE name='$name'"); |
|
1355
|
|
|
if (mysqli_num_rows($rs)) { |
|
1356
|
|
|
$row = mysqli_fetch_assoc($rs); |
|
1357
|
|
|
$props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
1358
|
|
|
if (!mysqli_query($sqlParser->conn, |
|
1359
|
|
|
"UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
|
1360
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1361
|
|
|
|
|
1362
|
|
|
return; |
|
1363
|
|
|
} |
|
1364
|
|
|
echo " $name: " . $_lang['upgraded'] . PHP_EOL; |
|
1365
|
|
View Code Duplication |
} else { |
|
1366
|
|
|
if ($properties != null) { |
|
1367
|
|
|
$properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
|
1368
|
|
|
} |
|
1369
|
|
|
if (!mysqli_query($sqlParser->conn, |
|
1370
|
|
|
"INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) { |
|
1371
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1372
|
|
|
|
|
1373
|
|
|
return; |
|
1374
|
|
|
} |
|
1375
|
|
|
echo " $name: " . $_lang['installed'] . PHP_EOL; |
|
1376
|
|
|
} |
|
1377
|
|
|
} |
|
1378
|
|
|
} |
|
1379
|
|
|
} |
|
1380
|
|
|
} |
|
1381
|
|
|
|
|
1382
|
|
|
// Install demo-site |
|
1383
|
|
|
if ($installData && $moduleSQLDataFile) { |
|
1384
|
|
|
echo PHP_EOL . $_lang['installing_demo_site']; |
|
1385
|
|
|
$sqlParser->process($moduleSQLDataFile); |
|
1386
|
|
|
// display database results |
|
1387
|
|
|
if ($sqlParser->installFailed == true) { |
|
1388
|
|
|
$errors += 1; |
|
1389
|
|
|
echo $_lang['database_alerts'] . PHP_EOL; |
|
1390
|
|
|
echo $_lang['setup_couldnt_install'] . PHP_EOL; |
|
1391
|
|
|
echo $_lang['installation_error_occured'] . PHP_EOL . PHP_EOL; |
|
1392
|
|
|
for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
|
1393
|
|
|
echo $sqlParser->mysqlErrors[$i]["error"] . " " . $_lang['during_execution_of_sql'] . " " . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . PHP_EOL; |
|
1394
|
|
|
} |
|
1395
|
|
|
|
|
1396
|
|
|
echo $_lang['some_tables_not_updated'] . PHP_EOL; |
|
1397
|
|
|
|
|
1398
|
|
|
return; |
|
1399
|
|
View Code Duplication |
} else { |
|
1400
|
|
|
$sql = sprintf("SELECT id FROM `%ssite_templates` WHERE templatename='EVO startup - Bootstrap'", |
|
1401
|
|
|
$sqlParser->prefix); |
|
1402
|
|
|
$rs = mysqli_query($sqlParser->conn, $sql); |
|
1403
|
|
|
if (mysqli_num_rows($rs)) { |
|
1404
|
|
|
$row = mysqli_fetch_assoc($rs); |
|
1405
|
|
|
$sql = sprintf('UPDATE `%ssite_content` SET template=%s WHERE template=4', $sqlParser->prefix, $row['id']); |
|
1406
|
|
|
mysqli_query($sqlParser->conn, $sql); |
|
1407
|
|
|
} |
|
1408
|
|
|
echo $_lang['ok'] . PHP_EOL; |
|
1409
|
|
|
} |
|
1410
|
|
|
} |
|
1411
|
|
|
|
|
1412
|
|
|
// Install Dependencies |
|
1413
|
|
|
$moduleDependencies = $mdp; |
|
1414
|
|
|
foreach ($moduleDependencies as $dependency) { |
|
1415
|
|
|
$ds = mysqli_query($sqlParser->conn, |
|
1416
|
|
|
'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"'); |
|
1417
|
|
View Code Duplication |
if (!$ds) { |
|
1418
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1419
|
|
|
|
|
1420
|
|
|
return; |
|
1421
|
|
|
} else { |
|
1422
|
|
|
$row = mysqli_fetch_assoc($ds); |
|
1423
|
|
|
$moduleId = $row["id"]; |
|
1424
|
|
|
$moduleGuid = $row["guid"]; |
|
1425
|
|
|
} |
|
1426
|
|
|
// get extra id |
|
1427
|
|
|
$ds = mysqli_query($sqlParser->conn, |
|
1428
|
|
|
'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"'); |
|
1429
|
|
View Code Duplication |
if (!$ds) { |
|
1430
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1431
|
|
|
|
|
1432
|
|
|
return; |
|
1433
|
|
|
} else { |
|
1434
|
|
|
$row = mysqli_fetch_assoc($ds); |
|
1435
|
|
|
$extraId = $row["id"]; |
|
1436
|
|
|
} |
|
1437
|
|
|
// setup extra as module dependency |
|
1438
|
|
|
$ds = mysqli_query($sqlParser->conn, |
|
1439
|
|
|
'SELECT module FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type'] . ' LIMIT 1'); |
|
1440
|
|
|
if (!$ds) { |
|
1441
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1442
|
|
|
|
|
1443
|
|
|
return; |
|
1444
|
|
|
} else { |
|
1445
|
|
|
if (mysqli_num_rows($ds) === 0) { |
|
1446
|
|
|
mysqli_query($sqlParser->conn, |
|
1447
|
|
|
'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')'); |
|
1448
|
|
|
echo $dependency['module'] . ' Module: ' . $_lang['depedency_create'] . PHP_EOL; |
|
1449
|
|
|
} else { |
|
1450
|
|
|
mysqli_query($sqlParser->conn, |
|
1451
|
|
|
'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']); |
|
1452
|
|
|
echo $dependency['module'] . ' Module: ' . $_lang['depedency_update'] . PHP_EOL; |
|
1453
|
|
|
} |
|
1454
|
|
|
if ($dependency['type'] == 30 || $dependency['type'] == 40) { |
|
1455
|
|
|
// set extra guid for plugins and snippets |
|
1456
|
|
|
$ds = mysqli_query($sqlParser->conn, |
|
1457
|
|
|
'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1'); |
|
1458
|
|
|
if (!$ds) { |
|
1459
|
|
|
echo mysqli_error($sqlParser->conn) . PHP_EOL; |
|
1460
|
|
|
|
|
1461
|
|
|
return; |
|
1462
|
|
|
} else { |
|
1463
|
|
|
if (mysqli_num_rows($ds) != 0) { |
|
1464
|
|
|
mysqli_query($sqlParser->conn, |
|
1465
|
|
|
'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId); |
|
1466
|
|
|
echo $dependency['name'] . ': ' . $_lang['guid_set'] . PHP_EOL; |
|
1467
|
|
|
} |
|
1468
|
|
|
} |
|
1469
|
|
|
} |
|
1470
|
|
|
} |
|
1471
|
|
|
} |
|
1472
|
|
|
|
|
1473
|
|
|
// call back function |
|
1474
|
|
|
if ($callBackFnc != "") { |
|
1475
|
|
|
$callBackFnc ($sqlParser); |
|
1476
|
|
|
} |
|
1477
|
|
|
|
|
1478
|
|
|
// Setup the MODX API -- needed for the cache processor |
|
1479
|
|
|
if (!defined('MODX_MANAGER_PATH')) { |
|
1480
|
|
|
define('MODX_MANAGER_PATH', $base_path . MGR_DIR . '/'); |
|
1481
|
|
|
} |
|
1482
|
|
|
$database_type = 'mysqli'; |
|
1483
|
|
|
// initiate a new document parser |
|
1484
|
|
|
include_once($path . '../' . MGR_DIR . '/includes/document.parser.class.inc.php'); |
|
1485
|
|
|
$modx = new DocumentParser; |
|
1486
|
|
|
$modx->db->connect(); |
|
1487
|
|
|
// always empty cache after install |
|
1488
|
|
|
$sync = new EvolutionCMS\Cache(); |
|
1489
|
|
|
$sync->setCachepath($path . "../assets/cache/"); |
|
1490
|
|
|
$sync->setReport(false); |
|
1491
|
|
|
$sync->emptyCache(); // first empty the cache |
|
1492
|
|
|
|
|
1493
|
|
|
// try to chmod the cache go-rwx (for suexeced php) |
|
1494
|
|
|
$chmodSuccess = @chmod($path . '../assets/cache/siteCache.idx.php', 0600); |
|
1495
|
|
|
$chmodSuccess = @chmod($path . '../assets/cache/sitePublishing.idx.php', 0600); |
|
1496
|
|
|
|
|
1497
|
|
|
// remove any locks on the manager functions so initial manager login is not blocked |
|
1498
|
|
|
mysqli_query($conn, "TRUNCATE TABLE `" . $table_prefix . "active_users`"); |
|
1499
|
|
|
|
|
1500
|
|
|
// close db connection |
|
1501
|
|
|
$sqlParser->close(); |
|
1502
|
|
|
|
|
1503
|
|
|
// andrazk 20070416 - release manager access |
|
1504
|
|
View Code Duplication |
if (file_exists($path . '../assets/cache/installProc.inc.php')) { |
|
1505
|
|
|
@chmod($path . '../assets/cache/installProc.inc.php', 0755); |
|
1506
|
|
|
unlink($path . '../assets/cache/installProc.inc.php'); |
|
1507
|
|
|
} |
|
1508
|
|
|
|
|
1509
|
|
|
// setup completed! |
|
1510
|
|
|
echo PHP_EOL . $_lang['installation_successful'] . PHP_EOL . PHP_EOL; |
|
1511
|
|
|
//echo "<p>" . $_lang['to_log_into_content_manager'] . "</p>"; |
|
1512
|
|
|
if ($installMode == 0) { |
|
1513
|
|
|
echo strip_tags($_lang['installation_note']) . PHP_EOL; |
|
1514
|
|
|
} else { |
|
1515
|
|
|
echo strip_tags($_lang['upgrade_note']) . PHP_EOL; |
|
1516
|
|
|
} |
|
1517
|
|
|
|
|
1518
|
|
|
|
|
1519
|
|
|
if (empty($args)) { |
|
1520
|
|
|
echo PHP_EOL . 'Remove install folder?' . PHP_EOL; |
|
1521
|
|
|
$removeInstall = readline("Type 'y' or 'n' to continue: "); |
|
1522
|
|
|
} |
|
1523
|
|
|
//remove installFolder |
|
1524
|
|
|
if ($removeInstall === 'y') { |
|
1525
|
|
|
removeFolder($path); |
|
1526
|
|
|
removeFolder($base_path . '.tx'); |
|
1527
|
|
|
unlink($base_path . 'README.md'); |
|
1528
|
|
|
echo 'Install folder deleted!' . PHP_EOL . PHP_EOL; |
|
1529
|
|
|
} |
|
1530
|
|
|
|
When comparing two booleans, it is generally considered safer to use the strict comparison operator.