1
|
|
|
<?php |
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* adminAdminController class |
6
|
|
|
* admin controller class of admin module |
7
|
|
|
* @author NAVER ([email protected]) |
8
|
|
|
* @package /modules/admin |
9
|
|
|
* @version 0.1 |
10
|
|
|
*/ |
11
|
|
|
class adminAdminController extends admin |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* initialization |
16
|
|
|
* @return void |
17
|
|
|
*/ |
18
|
|
View Code Duplication |
function init() |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
// forbit access if the user is not an administrator |
21
|
|
|
$oMemberModel = getModel('member'); |
22
|
|
|
$logged_info = $oMemberModel->getLoggedInfo(); |
23
|
|
|
if($logged_info->is_admin != 'Y') |
24
|
|
|
{ |
25
|
|
|
return $this->stop("msg_is_not_administrator"); |
26
|
|
|
} |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Admin menu reset |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
|
|
function procAdminMenuReset() |
34
|
|
|
{ |
35
|
|
|
$menuSrl = Context::get('menu_srl'); |
36
|
|
|
if(!$menuSrl) |
37
|
|
|
{ |
38
|
|
|
return $this->stop('msg_invalid_request'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$oMenuAdminController = getAdminController('menu'); |
42
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
43
|
|
|
if($oCacheHandler->isSupport()) |
44
|
|
|
{ |
45
|
|
|
$cache_key = 'admin_menu_langs:' . Context::getLangType(); |
46
|
|
|
$oCacheHandler->delete($cache_key); |
47
|
|
|
} |
48
|
|
|
$output = $oMenuAdminController->deleteMenu($menuSrl); |
49
|
|
|
if(!$output->toBool()) |
50
|
|
|
{ |
51
|
|
|
return $output; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
FileHandler::removeDir('./files/cache/menu/admin_lang/'); |
55
|
|
|
|
56
|
|
|
$this->setRedirectUrl(Context::get('error_return_url')); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Regenerate all cache files |
61
|
|
|
* @return void |
62
|
|
|
*/ |
63
|
|
|
function procAdminRecompileCacheFile() |
64
|
|
|
{ |
65
|
|
|
// rename cache dir |
66
|
|
|
$temp_cache_dir = './files/cache_' . $_SERVER['REQUEST_TIME']; |
67
|
|
|
FileHandler::rename('./files/cache', $temp_cache_dir); |
68
|
|
|
FileHandler::makeDir('./files/cache'); |
69
|
|
|
|
70
|
|
|
// remove module extend cache |
71
|
|
|
FileHandler::removeFile(_XE_PATH_ . 'files/config/module_extend.php'); |
72
|
|
|
|
73
|
|
|
// remove debug files |
74
|
|
|
FileHandler::removeFile(_XE_PATH_ . 'files/_debug_message.php'); |
75
|
|
|
FileHandler::removeFile(_XE_PATH_ . 'files/_debug_db_query.php'); |
76
|
|
|
FileHandler::removeFile(_XE_PATH_ . 'files/_db_slow_query.php'); |
77
|
|
|
|
78
|
|
|
$oModuleModel = getModel('module'); |
79
|
|
|
$module_list = $oModuleModel->getModuleList(); |
80
|
|
|
|
81
|
|
|
// call recompileCache for each module |
82
|
|
|
foreach($module_list as $module) |
83
|
|
|
{ |
84
|
|
|
$oModule = NULL; |
|
|
|
|
85
|
|
|
$oModule = getClass($module->module); |
86
|
|
|
if(method_exists($oModule, 'recompileCache')) |
87
|
|
|
{ |
88
|
|
|
$oModule->recompileCache(); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
// remove cache |
93
|
|
|
$truncated = array(); |
94
|
|
|
$oObjectCacheHandler = CacheHandler::getInstance('object'); |
95
|
|
|
$oTemplateCacheHandler = CacheHandler::getInstance('template'); |
96
|
|
|
|
97
|
|
|
if($oObjectCacheHandler->isSupport()) |
98
|
|
|
{ |
99
|
|
|
$truncated[] = $oObjectCacheHandler->truncate(); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
if($oTemplateCacheHandler->isSupport()) |
103
|
|
|
{ |
104
|
|
|
$truncated[] = $oTemplateCacheHandler->truncate(); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
if(count($truncated) && in_array(FALSE, $truncated)) |
108
|
|
|
{ |
109
|
|
|
return new BaseObject(-1, 'msg_self_restart_cache_engine'); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
// remove cache dir |
113
|
|
|
$tmp_cache_list = FileHandler::readDir('./files', '/(^cache_[0-9]+)/'); |
114
|
|
|
if($tmp_cache_list) |
|
|
|
|
115
|
|
|
{ |
116
|
|
|
foreach($tmp_cache_list as $tmp_dir) |
117
|
|
|
{ |
118
|
|
|
if($tmp_dir) |
119
|
|
|
{ |
120
|
|
|
FileHandler::removeDir('./files/' . $tmp_dir); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
// remove duplicate indexes (only for CUBRID) |
126
|
|
|
$db_type = Context::getDBType(); |
127
|
|
|
if($db_type == 'cubrid') |
128
|
|
|
{ |
129
|
|
|
$db = DB::getInstance(); |
130
|
|
|
$db->deleteDuplicateIndexes(); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
// check autoinstall packages |
134
|
|
|
$oAutoinstallAdminController = getAdminController('autoinstall'); |
135
|
|
|
$oAutoinstallAdminController->checkInstalled(); |
136
|
|
|
|
137
|
|
|
$this->setMessage('success_updated'); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Logout |
142
|
|
|
* @return void |
143
|
|
|
*/ |
144
|
|
|
function procAdminLogout() |
145
|
|
|
{ |
146
|
|
|
$oMemberController = getController('member'); |
147
|
|
|
$oMemberController->procMemberLogout(); |
148
|
|
|
|
149
|
|
|
header('Location: ' . getNotEncodedUrl('', 'module', 'admin')); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function procAdminInsertDefaultDesignInfo() |
153
|
|
|
{ |
154
|
|
|
$vars = Context::getRequestVars(); |
155
|
|
|
if(!$vars->site_srl) |
156
|
|
|
{ |
157
|
|
|
$vars->site_srl = 0; |
|
|
|
|
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
// create a DesignInfo file |
161
|
|
|
$output = $this->updateDefaultDesignInfo($vars); |
162
|
|
|
return $this->setRedirectUrl(Context::get('error_return_url'), $output); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
public function updateDefaultDesignInfo($vars) |
166
|
|
|
{ |
167
|
|
|
$siteDesignPath = _XE_PATH_ . 'files/site_design/'; |
168
|
|
|
|
169
|
|
|
$vars->module_skin = json_decode($vars->module_skin); |
170
|
|
|
|
171
|
|
|
if(!is_dir($siteDesignPath)) |
172
|
|
|
{ |
173
|
|
|
FileHandler::makeDir($siteDesignPath); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
$siteDesignFile = _XE_PATH_ . 'files/site_design/design_' . $vars->site_srl . '.php'; |
177
|
|
|
|
178
|
|
|
$layoutTarget = 'layout_srl'; |
179
|
|
|
$skinTarget = 'skin'; |
180
|
|
|
|
181
|
|
|
if($vars->target_type == 'M') |
182
|
|
|
{ |
183
|
|
|
$layoutTarget = 'mlayout_srl'; |
184
|
|
|
$skinTarget = 'mskin'; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
if(is_readable($siteDesignFile)) |
188
|
|
|
{ |
189
|
|
|
include($siteDesignFile); |
190
|
|
|
} |
191
|
|
|
else |
192
|
|
|
{ |
193
|
|
|
$designInfo = new stdClass(); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
$layoutSrl = (!$vars->layout_srl) ? 0 : $vars->layout_srl; |
197
|
|
|
|
198
|
|
|
$designInfo->{$layoutTarget} = $layoutSrl; |
|
|
|
|
199
|
|
|
|
200
|
|
|
foreach($vars->module_skin as $moduleName => $skinName) |
201
|
|
|
{ |
202
|
|
|
if($moduleName == 'ARTICLE') |
203
|
|
|
{ |
204
|
|
|
$moduleName = 'page'; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
if(!isset($designInfo->module->{$moduleName})) $designInfo->module->{$moduleName} = new stdClass(); |
208
|
|
|
$designInfo->module->{$moduleName}->{$skinTarget} = $skinName; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
$this->makeDefaultDesignFile($designInfo, $vars->site_srl); |
212
|
|
|
|
213
|
|
|
return new BaseObject(); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
function makeDefaultDesignFile($designInfo, $site_srl = 0) |
217
|
|
|
{ |
218
|
|
|
$buff = array(); |
219
|
|
|
$buff[] = '<?php if(!defined("__XE__")) exit();'; |
220
|
|
|
$buff[] = '$designInfo = new stdClass;'; |
221
|
|
|
|
222
|
|
|
if($designInfo->layout_srl) |
223
|
|
|
{ |
224
|
|
|
$buff[] = sprintf('$designInfo->layout_srl = %s; ', $designInfo->layout_srl); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
if($designInfo->mlayout_srl) |
228
|
|
|
{ |
229
|
|
|
$buff[] = sprintf('$designInfo->mlayout_srl = %s;', $designInfo->mlayout_srl); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
$buff[] = '$designInfo->module = new stdClass;'; |
233
|
|
|
|
234
|
|
|
foreach($designInfo->module as $moduleName => $skinInfo) |
235
|
|
|
{ |
236
|
|
|
$buff[] = sprintf('$designInfo->module->%s = new stdClass;', $moduleName); |
237
|
|
|
foreach($skinInfo as $target => $skinName) |
238
|
|
|
{ |
239
|
|
|
$buff[] = sprintf('$designInfo->module->%s->%s = \'%s\';', $moduleName, $target, $skinName); |
240
|
|
|
} |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
$siteDesignFile = _XE_PATH_ . 'files/site_design/design_' . $site_srl . '.php'; |
244
|
|
|
FileHandler::writeFile($siteDesignFile, implode(PHP_EOL, $buff)); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* Toggle favorite |
249
|
|
|
* @return void |
250
|
|
|
*/ |
251
|
|
|
function procAdminToggleFavorite() |
252
|
|
|
{ |
253
|
|
|
$siteSrl = Context::get('site_srl'); |
254
|
|
|
$moduleName = Context::get('module_name'); |
255
|
|
|
|
256
|
|
|
// check favorite exists |
257
|
|
|
$oModel = getAdminModel('admin'); |
258
|
|
|
$output = $oModel->isExistsFavorite($siteSrl, $moduleName); |
259
|
|
|
if(!$output->toBool()) |
260
|
|
|
{ |
261
|
|
|
return $output; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
// if exists, delete favorite |
265
|
|
|
if($output->get('result')) |
266
|
|
|
{ |
267
|
|
|
$favoriteSrl = $output->get('favoriteSrl'); |
268
|
|
|
$output = $this->_deleteFavorite($favoriteSrl); |
269
|
|
|
$result = 'off'; |
270
|
|
|
} |
271
|
|
|
// if not exists, insert favorite |
272
|
|
|
else |
273
|
|
|
{ |
274
|
|
|
$output = $this->_insertFavorite($siteSrl, $moduleName); |
275
|
|
|
$result = 'on'; |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
if(!$output->toBool()) |
279
|
|
|
{ |
280
|
|
|
return $output; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
$this->add('result', $result); |
284
|
|
|
|
285
|
|
|
return $this->setRedirectUrl(Context::get('error_return_url'), $output); |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* Cleanning favorite |
290
|
|
|
* @return BaseObject |
291
|
|
|
*/ |
292
|
|
|
function cleanFavorite() |
293
|
|
|
{ |
294
|
|
|
$oModel = getAdminModel('admin'); |
295
|
|
|
$output = $oModel->getFavoriteList(); |
296
|
|
|
if(!$output->toBool()) |
297
|
|
|
{ |
298
|
|
|
return $output; |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
$favoriteList = $output->get('favoriteList'); |
302
|
|
|
if(!$favoriteList) |
303
|
|
|
{ |
304
|
|
|
return new BaseObject(); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
$deleteTargets = array(); |
308
|
|
|
foreach($favoriteList as $favorite) |
309
|
|
|
{ |
310
|
|
|
if($favorite->type == 'module') |
311
|
|
|
{ |
312
|
|
|
$modulePath = _XE_PATH_ . 'modules/' . $favorite->module; |
313
|
|
|
if(!is_dir($modulePath)) |
314
|
|
|
{ |
315
|
|
|
$deleteTargets[] = $favorite->admin_favorite_srl; |
316
|
|
|
} |
317
|
|
|
} |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
if(!count($deleteTargets)) |
321
|
|
|
{ |
322
|
|
|
return new BaseObject(); |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
$args = new stdClass(); |
326
|
|
|
$args->admin_favorite_srls = $deleteTargets; |
327
|
|
|
$output = executeQuery('admin.deleteFavorites', $args); |
328
|
|
|
if(!$output->toBool()) |
329
|
|
|
{ |
330
|
|
|
return $output; |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
return new BaseObject(); |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* Enviroment gathering agreement |
338
|
|
|
* @return void |
339
|
|
|
*/ |
340
|
|
|
function procAdminEnviromentGatheringAgreement() |
341
|
|
|
{ |
342
|
|
|
$isAgree = Context::get('is_agree'); |
343
|
|
|
if($isAgree == 'true') |
344
|
|
|
{ |
345
|
|
|
$_SESSION['enviroment_gather'] = 'Y'; |
346
|
|
|
} |
347
|
|
|
else |
348
|
|
|
{ |
349
|
|
|
$_SESSION['enviroment_gather'] = 'N'; |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
$redirectUrl = getNotEncodedUrl('', 'module', 'admin'); |
353
|
|
|
$this->setRedirectUrl($redirectUrl); |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
/** |
357
|
|
|
* Admin config update |
358
|
|
|
* @return void |
359
|
|
|
*/ |
360
|
|
|
function procAdminUpdateConfig() |
361
|
|
|
{ |
362
|
|
|
$adminTitle = Context::get('adminTitle'); |
363
|
|
|
$file = $_FILES['adminLogo']; |
364
|
|
|
|
365
|
|
|
$oModuleModel = getModel('module'); |
366
|
|
|
$oAdminConfig = $oModuleModel->getModuleConfig('admin'); |
367
|
|
|
|
368
|
|
|
if(!is_object($oAdminConfig)) |
369
|
|
|
{ |
370
|
|
|
$oAdminConfig = new stdClass(); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
if($file['tmp_name']) |
374
|
|
|
{ |
375
|
|
|
$target_path = 'files/attach/images/admin/'; |
376
|
|
|
FileHandler::makeDir($target_path); |
377
|
|
|
|
378
|
|
|
// Get file information |
379
|
|
|
list($width, $height, $type, $attrs) = @getimagesize($file['tmp_name']); |
|
|
|
|
380
|
|
|
if($type == 3) |
381
|
|
|
{ |
382
|
|
|
$ext = 'png'; |
383
|
|
|
} |
384
|
|
|
elseif($type == 2) |
385
|
|
|
{ |
386
|
|
|
$ext = 'jpg'; |
387
|
|
|
} |
388
|
|
|
else |
389
|
|
|
{ |
390
|
|
|
$ext = 'gif'; |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
$target_filename = sprintf('%s%s.%s.%s', $target_path, 'adminLogo', date('YmdHis'), $ext); |
394
|
|
|
@move_uploaded_file($file['tmp_name'], $target_filename); |
|
|
|
|
395
|
|
|
|
396
|
|
|
$oAdminConfig->adminLogo = $target_filename; |
397
|
|
|
} |
398
|
|
|
if($adminTitle) |
399
|
|
|
{ |
400
|
|
|
$oAdminConfig->adminTitle = strip_tags($adminTitle); |
401
|
|
|
} |
402
|
|
|
else |
403
|
|
|
{ |
404
|
|
|
unset($oAdminConfig->adminTitle); |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
if($oAdminConfig) |
408
|
|
|
{ |
409
|
|
|
$oModuleController = getController('module'); |
410
|
|
|
$oModuleController->insertModuleConfig('admin', $oAdminConfig); |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
$this->setMessage('success_updated', 'info'); |
414
|
|
|
|
415
|
|
|
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminSetup'); |
416
|
|
|
$this->setRedirectUrl($returnUrl); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* Admin logo delete |
421
|
|
|
* @return void |
422
|
|
|
*/ |
423
|
|
|
function procAdminDeleteLogo() |
424
|
|
|
{ |
425
|
|
|
$oModuleModel = getModel('module'); |
426
|
|
|
$oAdminConfig = $oModuleModel->getModuleConfig('admin'); |
427
|
|
|
|
428
|
|
|
FileHandler::removeFile(_XE_PATH_ . $oAdminConfig->adminLogo); |
429
|
|
|
unset($oAdminConfig->adminLogo); |
430
|
|
|
|
431
|
|
|
$oModuleController = getController('module'); |
432
|
|
|
$oModuleController->insertModuleConfig('admin', $oAdminConfig); |
433
|
|
|
|
434
|
|
|
$this->setMessage('success_deleted', 'info'); |
435
|
|
|
|
436
|
|
|
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminSetup'); |
437
|
|
|
$this->setRedirectUrl($returnUrl); |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* Insert favorite |
442
|
|
|
* @return object query result |
443
|
|
|
*/ |
444
|
|
|
function _insertFavorite($siteSrl, $module, $type = 'module') |
445
|
|
|
{ |
446
|
|
|
$args = new stdClass(); |
447
|
|
|
$args->adminFavoriteSrl = getNextSequence(); |
448
|
|
|
$args->site_srl = $siteSrl; |
449
|
|
|
$args->module = $module; |
450
|
|
|
$args->type = $type; |
451
|
|
|
$output = executeQuery('admin.insertFavorite', $args); |
452
|
|
|
return $output; |
453
|
|
|
} |
454
|
|
|
|
455
|
|
|
/** |
456
|
|
|
* Delete favorite |
457
|
|
|
* @return object query result |
458
|
|
|
*/ |
459
|
|
|
function _deleteFavorite($favoriteSrl) |
460
|
|
|
{ |
461
|
|
|
$args = new stdClass(); |
462
|
|
|
$args->admin_favorite_srl = $favoriteSrl; |
463
|
|
|
$output = executeQuery('admin.deleteFavorite', $args); |
464
|
|
|
return $output; |
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
/** |
468
|
|
|
* Delete all favorite |
469
|
|
|
* @return object query result |
470
|
|
|
*/ |
471
|
|
|
function _deleteAllFavorite() |
472
|
|
|
{ |
473
|
|
|
$args = new stdClass; |
474
|
|
|
$output = executeQuery('admin.deleteAllFavorite', $args); |
475
|
|
|
return $output; |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
/** |
479
|
|
|
* Remove admin icon |
480
|
|
|
* @return object|void |
481
|
|
|
*/ |
482
|
|
|
function procAdminRemoveIcons() |
483
|
|
|
{ |
484
|
|
|
|
485
|
|
|
$site_info = Context::get('site_module_info'); |
486
|
|
|
$virtual_site = ''; |
487
|
|
|
if($site_info->site_srl) |
488
|
|
|
{ |
489
|
|
|
$virtual_site = $site_info->site_srl . '/'; |
490
|
|
|
} |
491
|
|
|
|
492
|
|
|
$iconname = Context::get('iconname'); |
493
|
|
|
$file_exist = FileHandler::readFile(_XE_PATH_ . 'files/attach/xeicon/' . $virtual_site . $iconname); |
494
|
|
|
if($file_exist) |
495
|
|
|
{ |
496
|
|
|
@FileHandler::removeFile(_XE_PATH_ . 'files/attach/xeicon/' . $virtual_site . $iconname); |
|
|
|
|
497
|
|
|
} |
498
|
|
|
else |
499
|
|
|
{ |
500
|
|
|
return new BaseObject(-1, 'fail_to_delete'); |
501
|
|
|
} |
502
|
|
|
$this->setMessage('success_deleted'); |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
function procAdminUpdateSitelock() |
506
|
|
|
{ |
507
|
|
|
$vars = Context::getRequestVars(); |
508
|
|
|
$oInstallController = getController('install'); |
|
|
|
|
509
|
|
|
|
510
|
|
|
$db_info = Context::getDBInfo(); |
511
|
|
|
|
512
|
|
|
$db_info->use_sitelock = ($vars->use_sitelock) ? $vars->use_sitelock : 'N'; |
|
|
|
|
513
|
|
|
$db_info->sitelock_title = $vars->sitelock_title; |
|
|
|
|
514
|
|
|
$db_info->sitelock_message = $vars->sitelock_message; |
|
|
|
|
515
|
|
|
|
516
|
|
|
$whitelist = $vars->sitelock_whitelist; |
|
|
|
|
517
|
|
|
$whitelist = preg_replace("/[\r|\n|\r\n]+/",",",$whitelist); |
518
|
|
|
$whitelist = preg_replace("/\s+/","",$whitelist); |
519
|
|
|
if(preg_match('/(<\?|<\?php|\?>)/xsm', $whitelist)) |
520
|
|
|
{ |
521
|
|
|
$whitelist = ''; |
522
|
|
|
} |
523
|
|
|
$whitelist .= ',127.0.0.1,' . $_SERVER['REMOTE_ADDR']; |
524
|
|
|
$whitelist = explode(',',trim($whitelist, ',')); |
525
|
|
|
$whitelist = array_unique($whitelist); |
526
|
|
|
|
527
|
|
|
if(!IpFilter::validate($whitelist)) { |
528
|
|
|
return new BaseObject(-1, 'msg_invalid_ip'); |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
$db_info->sitelock_whitelist = $whitelist; |
532
|
|
|
|
533
|
|
|
$oInstallController = getController('install'); |
534
|
|
|
if(!$oInstallController->makeConfigFile()) |
535
|
|
|
{ |
536
|
|
|
return new BaseObject(-1, 'msg_invalid_request'); |
537
|
|
|
} |
538
|
|
|
|
539
|
|
View Code Duplication |
if(!in_array(Context::getRequestMethod(), array('XMLRPC','JSON'))) |
540
|
|
|
{ |
541
|
|
|
$returnUrl = Context::get('success_return_url'); |
542
|
|
|
if(!$returnUrl) $returnUrl = getNotEncodedUrl('', 'act', 'dispAdminConfigGeneral'); |
543
|
|
|
header('location:' . $returnUrl); |
544
|
|
|
return; |
545
|
|
|
} |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
function procAdminUpdateEmbedWhitelist() |
549
|
|
|
{ |
550
|
|
|
$vars = Context::getRequestVars(); |
551
|
|
|
|
552
|
|
|
$db_info = Context::getDBInfo(); |
553
|
|
|
|
554
|
|
|
$white_object = $vars->embed_white_object; |
|
|
|
|
555
|
|
|
$white_object = preg_replace("/[\r\n|\r|\n]+/", '|@|', $white_object); |
556
|
|
|
$white_object = preg_replace("/[\s\'\"]+/", '', $white_object); |
557
|
|
|
$white_object = explode('|@|', $white_object); |
558
|
|
|
$white_object = array_unique($white_object); |
559
|
|
|
|
560
|
|
|
$white_iframe = $vars->embed_white_iframe; |
|
|
|
|
561
|
|
|
$white_iframe = preg_replace("/[\r\n|\r|\n]+/", '|@|', $white_iframe); |
562
|
|
|
$white_iframe = preg_replace("/[\s\'\"]+/", '', $white_iframe); |
563
|
|
|
$white_iframe = explode('|@|', $white_iframe); |
564
|
|
|
$white_iframe = array_unique($white_iframe); |
565
|
|
|
|
566
|
|
|
$whitelist = new stdClass; |
567
|
|
|
$whitelist->object = $white_object; |
568
|
|
|
$whitelist->iframe = $white_iframe; |
569
|
|
|
|
570
|
|
|
$db_info->embed_white_object = $white_object; |
571
|
|
|
$db_info->embed_white_iframe = $white_iframe; |
572
|
|
|
|
573
|
|
|
$oInstallController = getController('install'); |
574
|
|
|
if(!$oInstallController->makeConfigFile()) |
575
|
|
|
{ |
576
|
|
|
return new BaseObject(-1, 'msg_invalid_request'); |
577
|
|
|
} |
578
|
|
|
|
579
|
|
|
require_once(_XE_PATH_ . 'classes/security/EmbedFilter.class.php'); |
580
|
|
|
$oEmbedFilter = EmbedFilter::getInstance(); |
581
|
|
|
$oEmbedFilter->_makeWhiteDomainList($whitelist); |
582
|
|
|
|
583
|
|
View Code Duplication |
if(!in_array(Context::getRequestMethod(), array('XMLRPC','JSON'))) |
584
|
|
|
{ |
585
|
|
|
$returnUrl = Context::get('success_return_url'); |
586
|
|
|
if(!$returnUrl) $returnUrl = getNotEncodedUrl('', 'act', 'dispAdminConfigGeneral'); |
587
|
|
|
header('location:' . $returnUrl); |
588
|
|
|
return; |
589
|
|
|
} |
590
|
|
|
} |
591
|
|
|
|
592
|
|
|
} |
593
|
|
|
/* End of file admin.admin.controller.php */ |
594
|
|
|
/* Location: ./modules/admin/admin.admin.controller.php */ |
595
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.