forked from evolution-cms/evolution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.info.php
More file actions
executable file
·356 lines (341 loc) · 13.5 KB
/
Copy pathsetup.info.php
File metadata and controls
executable file
·356 lines (341 loc) · 13.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<?php
//:: EVO Installer Setup file
//:::::::::::::::::::::::::::::::::::::::::
if (is_file($base_path . 'assets/cache/siteManager.php')) {
include_once($base_path . 'assets/cache/siteManager.php');
}
if(!defined('MGR_DIR')) define('MGR_DIR', 'manager');
require_once('../'.MGR_DIR.'/includes/version.inc.php');
$chunkPath = $base_path .'install/assets/chunks';
$snippetPath = $base_path .'install/assets/snippets';
$pluginPath = $base_path .'install/assets/plugins';
$modulePath = $base_path .'install/assets/modules';
$templatePath = $base_path .'install/assets/templates';
$tvPath = $base_path .'install/assets/tvs';
// setup Template template files - array : name, description, type - 0:file or 1:content, parameters, category
$mt = &$moduleTemplates;
if(is_dir($templatePath) && is_readable($templatePath)) {
$d = dir($templatePath);
while (false !== ($tplfile = $d->read()))
{
if(substr($tplfile, -4) != '.tpl') continue;
$params = parse_docblock($templatePath, $tplfile);
if(is_array($params) && (count($params)>0))
{
$description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
$mt[] = array
(
$params['name'],
$description,
// Don't think this is gonna be used ... but adding it just in case 'type'
$params['type'],
"$templatePath/{$params['filename']}",
$params['modx_category'],
$params['lock_template'],
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false,
isset($params['save_sql_id_as']) ? $params['save_sql_id_as'] : NULL // Nessecary to fix template-ID for demo-site
);
}
}
$d->close();
}
// setup Template Variable template files
$mtv = &$moduleTVs;
if(is_dir($tvPath) && is_readable($tvPath)) {
$d = dir($tvPath);
while (false !== ($tplfile = $d->read())) {
if(substr($tplfile, -4) != '.tpl') continue;
$params = parse_docblock($tvPath, $tplfile);
if(is_array($params) && (count($params)>0)) {
$description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
$mtv[] = array(
$params['name'],
$params['caption'],
$description,
$params['input_type'],
$params['input_options'],
$params['input_default'],
$params['output_widget'],
$params['output_widget_params'],
"$templatePath/{$params['filename']}", /* not currently used */
$params['template_assignments']!="*"?$params['template_assignments']:implode(",",array_map(create_function('$v','return $v[0];'),$mt)), /* comma-separated list of template names */
$params['modx_category'],
$params['lock_tv'], /* value should be 1 or 0 */
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
);
}
}
$d->close();
}
// setup chunks template files - array : name, description, type - 0:file or 1:content, file or content
$mc = &$moduleChunks;
if(is_dir($chunkPath) && is_readable($chunkPath)) {
$d = dir($chunkPath);
while (false !== ($tplfile = $d->read())) {
if(substr($tplfile, -4) != '.tpl') {
continue;
}
$params = parse_docblock($chunkPath, $tplfile);
if(is_array($params) && count($params) > 0) {
$mc[] = array(
$params['name'],
$params['description'],
"$chunkPath/{$params['filename']}",
$params['modx_category'],
array_key_exists('overwrite', $params) ? $params['overwrite'] : 'true',
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
);
}
}
$d->close();
}
// setup snippets template files - array : name, description, type - 0:file or 1:content, file or content,properties
$ms = &$moduleSnippets;
if(is_dir($snippetPath) && is_readable($snippetPath)) {
$d = dir($snippetPath);
while (false !== ($tplfile = $d->read())) {
if(substr($tplfile, -4) != '.tpl') {
continue;
}
$params = parse_docblock($snippetPath, $tplfile);
if(is_array($params) && count($params) > 0) {
$description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
$ms[] = array(
$params['name'],
$description,
"$snippetPath/{$params['filename']}",
$params['properties'],
$params['modx_category'],
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
);
}
}
$d->close();
}
// setup plugins template files - array : name, description, type - 0:file or 1:content, file or content,properties
$mp = &$modulePlugins;
if(is_dir($pluginPath) && is_readable($pluginPath)) {
$d = dir($pluginPath);
while (false !== ($tplfile = $d->read())) {
if(substr($tplfile, -4) != '.tpl') {
continue;
}
$params = parse_docblock($pluginPath, $tplfile);
if(is_array($params) && count($params) > 0) {
$description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
$mp[] = array(
$params['name'],
$description,
"$pluginPath/{$params['filename']}",
$params['properties'],
$params['events'],
$params['guid'],
$params['modx_category'],
$params['legacy_names'],
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false,
intval($params['disabled'])
);
}
}
$d->close();
}
// setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams
$mm = &$moduleModules;
$mdp = &$moduleDependencies;
if(is_dir($modulePath) && is_readable($modulePath)) {
$d = dir($modulePath);
while (false !== ($tplfile = $d->read())) {
if(substr($tplfile, -4) != '.tpl') {
continue;
}
$params = parse_docblock($modulePath, $tplfile);
if(is_array($params) && count($params) > 0) {
$description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
$mm[] = array(
$params['name'],
$description,
"$modulePath/{$params['filename']}",
$params['properties'],
$params['guid'],
intval($params['shareparams']),
$params['modx_category'],
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
);
}
if (intval($params['shareparams']) || !empty($params['dependencies'])) {
$dependencies = explode(',', $params['dependencies']);
foreach ($dependencies as $dependency) {
$dependency = explode(':', $dependency);
switch (trim($dependency[0])) {
case 'template':
$mdp[] = array(
'module' => $params['name'],
'table' => 'templates',
'column' => 'templatename',
'type' => 50,
'name' => trim($dependency[1])
);
break;
case 'tv':
case 'tmplvar':
$mdp[] = array(
'module' => $params['name'],
'table' => 'tmplvars',
'column' => 'name',
'type' => 60,
'name' => trim($dependency[1])
);
break;
case 'chunk':
case 'htmlsnippet':
$mdp[] = array(
'module' => $params['name'],
'table' => 'htmlsnippets',
'column' => 'name',
'type' => 10,
'name' => trim($dependency[1])
);
break;
case 'snippet':
$mdp[] = array(
'module' => $params['name'],
'table' => 'snippets',
'column' => 'name',
'type' => 40,
'name' => trim($dependency[1])
);
break;
case 'plugin':
$mdp[] = array(
'module' => $params['name'],
'table' => 'plugins',
'column' => 'name',
'type' => 30,
'name' => trim($dependency[1])
);
break;
case 'resource':
$mdp[] = array(
'module' => $params['name'],
'table' => 'content',
'column' => 'pagetitle',
'type' => 20,
'name' => trim($dependency[1])
);
break;
}
}
}
}
$d->close();
}
// setup callback function
$callBackFnc = "clean_up";
function clean_up($sqlParser) {
$ids = array();
$mysqlVerOk = -1;
if(function_exists("mysqli_get_server_info")) {
$mysqlVerOk = (version_compare(mysqli_get_server_info($sqlParser->conn),"4.0.2")>=0);
}
// secure web documents - privateweb
mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 0 WHERE privateweb = 1");
$sql = "SELECT DISTINCT sc.id
FROM `".$sqlParser->prefix."site_content` sc
LEFT JOIN `".$sqlParser->prefix."document_groups` dg ON dg.document = sc.id
LEFT JOIN `".$sqlParser->prefix."webgroup_access` wga ON wga.documentgroup = dg.document_group
WHERE wga.id>0";
$ds = mysqli_query($sqlParser->conn,$sql);
if(!$ds) {
echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
}
else {
while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
if(count($ids)>0) {
mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")");
unset($ids);
}
}
// secure manager documents privatemgr
mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 0 WHERE privatemgr = 1");
$sql = "SELECT DISTINCT sc.id
FROM `".$sqlParser->prefix."site_content` sc
LEFT JOIN `".$sqlParser->prefix."document_groups` dg ON dg.document = sc.id
LEFT JOIN `".$sqlParser->prefix."membergroup_access` mga ON mga.documentgroup = dg.document_group
WHERE mga.id>0";
$ds = mysqli_query($sqlParser->conn,$sql);
if(!$ds) {
echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
}
else {
while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
if(count($ids)>0) {
mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")");
unset($ids);
}
}
}
function parse_docblock($element_dir, $filename) {
$params = array();
$fullpath = $element_dir . '/' . $filename;
if(is_readable($fullpath)) {
$tpl = @fopen($fullpath, "r");
if($tpl) {
$params['filename'] = $filename;
$docblock_start_found = false;
$name_found = false;
$description_found = false;
$docblock_end_found = false;
while(!feof($tpl)) {
$line = fgets($tpl);
if(!$docblock_start_found) {
// find docblock start
if(strpos($line, '/**') !== false) {
$docblock_start_found = true;
}
continue;
} elseif(!$name_found) {
// find name
$ma = null;
if(preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
$params['name'] = trim($ma[1]);
$name_found = !empty($params['name']);
}
continue;
} elseif(!$description_found) {
// find description
$ma = null;
if(preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
$params['description'] = trim($ma[1]);
$description_found = !empty($params['description']);
}
continue;
} else {
$ma = null;
if(preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) {
$param = trim($ma[1]);
$val = trim($ma[2]);
if(!empty($param) && !empty($val)) {
if($param == 'internal') {
$ma = null;
if(preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) {
$param = trim($ma[1]);
$val = trim($ma[2]);
}
//if($val !== '0' && (empty($param) || empty($val))) {
if(empty($param)) {
continue;
}
}
$params[$param] = $val;
}
} elseif(preg_match("/^\s*\*\/\s*$/", $line)) {
$docblock_end_found = true;
break;
}
}
}
@fclose($tpl);
}
}
return $params;
}