GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b130b6...8a2f54 )
by gyeong-won
07:36
created

adminAdminController   C

Complexity

Total Complexity 74

Size/Duplication

Total Lines 582
Duplicated Lines 4.12 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 0
Metric Value
dl 24
loc 582
rs 5.5244
c 0
b 0
f 0
wmc 74
lcom 1
cbo 8

18 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 10 10 2
B procAdminMenuReset() 0 25 4
C procAdminRecompileCacheFile() 0 76 11
A procAdminLogout() 0 7 1
A procAdminInsertDefaultDesignInfo() 0 12 2
C updateDefaultDesignInfo() 0 50 8
B makeDefaultDesignFile() 0 30 5
B procAdminToggleFavorite() 0 36 4
C cleanFavorite() 0 43 8
A procAdminEnviromentGatheringAgreement() 0 15 2
B procAdminUpdateConfig() 0 58 8
A procAdminDeleteLogo() 0 16 2
A _insertFavorite() 0 10 1
A _deleteFavorite() 0 7 1
A _deleteAllFavorite() 0 6 1
A procAdminRemoveIcons() 0 22 3
C procAdminUpdateSitelock() 7 42 7
B procAdminUpdateEmbedWhitelist() 7 43 4

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like adminAdminController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use adminAdminController, and based on these observations, apply Extract Interface, too.

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()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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;
0 ignored issues
show
Unused Code introduced by
$oModule is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
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)
0 ignored issues
show
Bug Best Practice introduced by
The expression $tmp_cache_list of type string[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
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;
0 ignored issues
show
Bug introduced by
The property site_srl does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
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;
0 ignored issues
show
Bug introduced by
The variable $designInfo does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
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']);
0 ignored issues
show
Unused Code introduced by
The assignment to $width is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
Unused Code introduced by
The assignment to $height is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
Unused Code introduced by
The assignment to $attrs is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
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);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
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);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
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');
0 ignored issues
show
Unused Code introduced by
$oInstallController is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
509
510
		$db_info = Context::getDBInfo();
511
512
		$db_info->use_sitelock = ($vars->use_sitelock) ? $vars->use_sitelock : 'N';
0 ignored issues
show
Bug introduced by
The property use_sitelock does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
513
		$db_info->sitelock_title = $vars->sitelock_title;
0 ignored issues
show
Bug introduced by
The property sitelock_title does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
514
		$db_info->sitelock_message = $vars->sitelock_message;
0 ignored issues
show
Bug introduced by
The property sitelock_message does not seem to exist. Did you mean message?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
515
516
		$whitelist = $vars->sitelock_whitelist;
0 ignored issues
show
Bug introduced by
The property sitelock_whitelist does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
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;
0 ignored issues
show
Bug introduced by
The property embed_white_object does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
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;
0 ignored issues
show
Bug introduced by
The property embed_white_iframe does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
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