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 — develop ( 755201...07ce67 )
by gyeong-won
12:25
created

config.inc.php ➔ __xe_autoload()   D

Complexity

Conditions 10
Paths 72

Size

Total Lines 30
Code Lines 16

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 10
eloc 16
nc 72
nop 1
dl 0
loc 30
rs 4.8196

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* Copyright (C) NAVER <http://www.navercorp.com> */
3
4
/**
5
 * set the include of the class file and other environment configurations
6
 *
7
 * @file   config/config.inc.php
8
 * @author NAVER ([email protected])
9
 */
10
if(version_compare(PHP_VERSION, '5.4.0', '<'))
11
{
12
	@error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING);
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...
13
}
14
else
15
{
16
	@error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING ^ E_STRICT);
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...
17
}
18
19
if(!defined('__XE__'))
20
{
21
	exit();
22
}
23
24
/**
25
 * @deprecated __ZBXE__ will be removed. Use __XE__ instead.
26
 */
27
define('__ZBXE__', __XE__);
28
29
/**
30
 * Display XE's full version.
31
 */
32
define('__XE_VERSION__', '1.8.19');
33
define('__XE_VERSION_ALPHA__', (stripos(__XE_VERSION__, 'alpha') !== false));
34
define('__XE_VERSION_BETA__', (stripos(__XE_VERSION__, 'beta') !== false));
35
define('__XE_VERSION_RC__', (stripos(__XE_VERSION__, 'rc') !== false));
36
define('__XE_VERSION_STABLE__', (!__XE_VERSION_ALPHA__ && !__XE_VERSION_BETA__ && !__XE_VERSION_RC__));
37
38
define('__XE_MIN_PHP_VERSION__', '5.3.0');
39
define('__XE_RECOMMEND_PHP_VERSION__', '5.5.0');
40
41
/**
42
 * @deprecated __ZBXE_VERSION__ will be removed. Use __XE_VERSION__ instead.
43
 */
44
define('__ZBXE_VERSION__', __XE_VERSION__);
45
46
/**
47
 * The base path to where you installed zbXE Wanted
48
 */
49
define('_XE_PATH_', str_replace('config/config.inc.php', '', str_replace('\\', '/', __FILE__)));
50
51
52
// Set can use other method instead cookie to store session id(for file upload)
53
ini_set('session.use_only_cookies', 0);
54
55
56
if(file_exists(_XE_PATH_ . 'config/package.inc.php'))
57
{
58
	require _XE_PATH_ . 'config/package.inc.php';
59
}
60
else
61
{
62
	/**
63
	 * Package type
64
	 */
65
	define('_XE_PACKAGE_', 'XE');
66
67
	/**
68
	 * Location
69
	 */
70
	define('_XE_LOCATION_', 'en');
71
72
	/**
73
	 * Location site
74
	 */
75
	define('_XE_LOCATION_SITE_', 'http://www.xpressengine.com/');
76
77
	/**
78
	 * Download server
79
	 */
80
	define('_XE_DOWNLOAD_SERVER_', 'http://download.xpressengine.com/');
81
}
82
83
/*
84
 * user configuration files which override the default settings
85
 * save the following information into config/config.user.inc.php
86
 * <?php
87
 * define('__DEBUG__', 0);
88
 * define('__DEBUG_OUTPUT__', 0);
89
 * define('__DEBUG_PROTECT__', 1);
90
 * define('__DEBUG_PROTECT_IP__', '127.0.0.1');
91
 * define('__DEBUG_DB_OUTPUT__', 0);
92
 * define('__LOG_SLOW_QUERY__', 0);
93
 * define('__LOG_SLOW_TRIGGER__', 0);
94
 * define('__LOG_SLOW_ADDON__', 0);
95
 * define('__LOG_SLOW_WIDGET__', 0);
96
 * define('__OB_GZHANDLER_ENABLE__', 1);
97
 * define('__ENABLE_PHPUNIT_TEST__', 0);
98
 * define('__PROXY_SERVER__', 'http://domain:port/path');
99
 */
100
if(file_exists(_XE_PATH_ . 'config/config.user.inc.php'))
101
{
102
	require _XE_PATH_ . 'config/config.user.inc.php';
103
}
104
105
if(!defined('__DEBUG__'))
106
{
107
	/**
108
	 * output debug message(bit value)
109
	 *
110
	 * <pre>
111
	 * 0: generate debug messages/not display
112
	 * 1: display messages through debugPrint() function
113
	 * 2: output execute time, Request/Response info
114
	 * 4: output DB query history
115
	 * </pre>
116
	 */
117
	define('__DEBUG__', 0);
118
}
119
120
if(!defined('__DEBUG_OUTPUT__'))
121
{
122
	/**
123
	 * output location of debug message
124
	 *
125
	 * <pre>
126
	 * 0: connect to the files/_debug_message.php and output
127
	 * 1: HTML output as a comment on the bottom (when response method is the HTML)
128
	 * 2: Firebug console output (PHP 4 & 5. Firebug/FirePHP plug-in required)
129
	 * </pre>
130
	 */
131
	define('__DEBUG_OUTPUT__', 0);
132
}
133
134
if(!defined('__DEBUG_PROTECT__'))
135
{
136
	/**
137
	 * output comments of the firePHP console and browser
138
	 *
139
	 * <pre>
140
	 * 0: No limit (not recommended)
141
	 * 1: Allow only specified IP addresses
142
	 * </pre>
143
	 */
144
	define('__DEBUG_PROTECT__', 1);
145
}
146
147
if(!defined('__DEBUG_PROTECT_IP__'))
148
{
149
	/**
150
	 * Set a ip address to allow debug
151
	 */
152
	define('__DEBUG_PROTECT_IP__', '127.0.0.1');
153
}
154
155
if(!defined('__DEBUG_DB_OUTPUT__'))
156
{
157
	/**
158
	 * DB error message definition
159
	 *
160
	 * <pre>
161
	 * 0: No output
162
	 * 1: files/_debug_db_query.php connected to the output
163
	 * </pre>
164
	 */
165
	define('__DEBUG_DB_OUTPUT__', 0);
166
}
167
168
if(!defined('__LOG_SLOW_QUERY__'))
169
{
170
	/**
171
	 * Query log for only timeout query among DB queries
172
	 *
173
	 * <pre>
174
	 * 0: Do not leave a log
175
	 * = 0: leave a log when the slow query takes over specified seconds
176
	 * Log file is saved as ./files/_slowlog_query.php file
177
	 * </pre>
178
	 */
179
	define('__LOG_SLOW_QUERY__', 0);
180
}
181
182
if(!defined('__LOG_SLOW_TRIGGER__'))
183
{
184
	/**
185
	 * Trigger excute time log
186
	 *
187
	 * <pre>
188
	 * 0: Do not leave a log
189
	 * > 0: leave a log when the trigger takes over specified milliseconds
190
	 * Log file is saved as ./files/_slowlog_trigger.php
191
	 * </pre>
192
	 */
193
	define('__LOG_SLOW_TRIGGER__', 0);
194
}
195
196
if(!defined('__LOG_SLOW_ADDON__'))
197
{
198
	/**
199
	 * Addon excute time log
200
	 *
201
	 * <pre>
202
	 * 0: Do not leave a log
203
	 * > 0: leave a log when the trigger takes over specified milliseconds
204
	 * Log file is saved as ./files/_slowlog_addon.php
205
	 * </pre>
206
	 */
207
	define('__LOG_SLOW_ADDON__', 0);
208
}
209
210
if(!defined('__LOG_SLOW_WIDGET__'))
211
{
212
	/**
213
	 * Widget excute time log
214
	 *
215
	 * <pre>
216
	 * 0: Do not leave a log
217
	 * > 0: leave a log when the widget takes over specified milliseconds
218
	 * Log file is saved as ./files/_slowlog_widget.php
219
	 * </pre>
220
	 */
221
	define('__LOG_SLOW_WIDGET__', 0);
222
}
223
224
if(!defined('__DEBUG_QUERY__'))
225
{
226
	/**
227
	 * Leave DB query information
228
	 *
229
	 * <pre>
230
	 * 0: Do not add information to the query
231
	 * 1: Comment the XML Query ID
232
	 * </pre>
233
	 */
234
	define('__DEBUG_QUERY__', 0);
235
}
236
237
if(!defined('__OB_GZHANDLER_ENABLE__'))
238
{
239
	/**
240
	 * option to enable/disable a compression feature using ob_gzhandler
241
	 *
242
	 * <pre>
243
	 * 0: Not used
244
	 * 1: Enabled
245
	 * Only particular servers may have a problem in IE browser when sending a compression
246
	 * </pre>
247
	 */
248
	define('__OB_GZHANDLER_ENABLE__', 1);
249
}
250
251
if(!defined('__ENABLE_PHPUNIT_TEST__'))
252
{
253
	/**
254
	 * decide to use/not use the php unit test (Path/tests/index.php)
255
	 *
256
	 * <pre>
257
	 * 0: Not used
258
	 * 1: Enabled
259
	 * </pre>
260
	 */
261
	define('__ENABLE_PHPUNIT_TEST__', 0);
262
}
263
264
if(!defined('__PROXY_SERVER__'))
265
{
266
	/**
267
	 * __PROXY_SERVER__ has server information to request to the external through the target server
268
	 * FileHandler:: getRemoteResource uses the constant
269
	 */
270
	define('__PROXY_SERVER__', NULL);
271
}
272
273
// Require specific files when using Firebug console output
274
if((__DEBUG_OUTPUT__ == 2) && version_compare(PHP_VERSION, '6.0.0') === -1)
275
{
276
	require _XE_PATH_ . 'libs/FirePHPCore/FirePHP.class.php';
277
}
278
279
// Set Timezone as server time
280
if(version_compare(PHP_VERSION, '5.3.0') >= 0)
281
{
282
	date_default_timezone_set(@date_default_timezone_get());
283
}
284
285
// Require a function-defined-file for simple use
286
require(_XE_PATH_ . 'config/func.inc.php');
287
288
if(__DEBUG__) {
289
	define('__StartTime__', getMicroTime());
290
}
291
292
if(__DEBUG__) {
293
	$GLOBALS['__elapsed_class_load__'] = 0;
294
}
295
296
$GLOBALS['__xe_autoload_file_map'] = array_change_key_case(array(
297
	'CacheBase' => 'classes/cache/CacheHandler.class.php',
298
	'CacheHandler' => 'classes/cache/CacheHandler.class.php',
299
	'Context' => 'classes/context/Context.class.php',
300
	'DB' => 'classes/db/DB.class.php',
301
	'Query' => 'classes/db/queryparts/Query.class.php',
302
	'Subquery' => 'classes/db/queryparts/Subquery.class.php',
303
	'Condition' => 'classes/db/queryparts/condition/Condition.class.php',
304
	'ConditionGroup' => 'classes/db/queryparts/condition/ConditionGroup.class.php',
305
	'ConditionSubquery' => 'classes/db/queryparts/condition/ConditionSubquery.class.php',
306
	'ConditionWithArgument' => 'classes/db/queryparts/condition/ConditionWithArgument.class.php',
307
	'ConditionWithoutArgument' => 'classes/db/queryparts/condition/ConditionWithoutArgument.class.php',
308
	'ClickCountExpression' => 'classes/db/queryparts/expression/ClickCountExpression.class.php',
309
	'documentItem' => 'modules/document/document.item.php',
310
	'DeleteExpression' => 'classes/db/queryparts/expression/DeleteExpression.class.php',
311
	'Expression' => 'classes/db/queryparts/expression/Expression.class.php',
312
	'InsertExpression' => 'classes/db/queryparts/expression/InsertExpression.class.php',
313
	'SelectExpression' => 'classes/db/queryparts/expression/SelectExpression.class.php',
314
	'StarExpression' => 'classes/db/queryparts/expression/StarExpression.class.php',
315
	'UpdateExpression' => 'classes/db/queryparts/expression/UpdateExpression.class.php',
316
	'UpdateExpressionWithoutArgument' => 'classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php',
317
	'Limit' => 'classes/db/queryparts/limit/Limit.class.php',
318
	'OrderByColumn' => 'classes/db/queryparts/order/OrderByColumn.class.php',
319
	'CubridTableWithHint' => 'classes/db/queryparts/table/CubridTableWithHint.class.php',
320
	'IndexHint' => 'classes/db/queryparts/table/IndexHint.class.php',
321
	'JoinTable' => 'classes/db/queryparts/table/JoinTable.class.php',
322
	'MssqlTableWithHint' => 'classes/db/queryparts/table/MssqlTableWithHint.class.php',
323
	'MysqlTableWithHint' => 'classes/db/queryparts/table/MysqlTableWithHint.class.php',
324
	'Table' => 'classes/db/queryparts/table/Table.class.php',
325
	'DisplayHandler' => 'classes/display/DisplayHandler.class.php',
326
	'HTMLDisplayHandler' => 'classes/display/HTMLDisplayHandler.php',
327
	'JSCallbackDisplayHandler' => 'classes/display/JSCallbackDisplayHandler.php',
328
	'JSONDisplayHandler' => 'classes/display/JSONDisplayHandler.php',
329
	'VirtualXMLDisplayHandler' => 'classes/display/VirtualXMLDisplayHandler.php',
330
	'XMLDisplayHandler' => 'classes/display/XMLDisplayHandler.php',
331
	'EditorHandler' => 'classes/editor/EditorHandler.class.php',
332
	'ExtraVar' => 'classes/extravar/Extravar.class.php',
333
	'ExtraItem' => 'classes/extravar/Extravar.class.php',
334
	'FileHandler' => 'classes/file/FileHandler.class.php',
335
	'FileObject' => 'classes/file/FileObject.class.php',
336
	'FrontEndFileHandler' => 'classes/frontendfile/FrontEndFileHandler.class.php',
337
	'Handler' => 'classes/handler/Handler.class.php',
338
	'XEHttpRequest' => 'classes/httprequest/XEHttpRequest.class.php',
339
	'Mail' => 'classes/mail/Mail.class.php',
340
	'Mobile' => 'classes/mobile/Mobile.class.php',
341
	'ModuleHandler' => 'classes/module/ModuleHandler.class.php',
342
	'ModuleObject' => 'classes/module/ModuleObject.class.php',
343
	'Object' => 'classes/object/Object.class.php',
344
	'PageHandler' => 'classes/page/PageHandler.class.php',
345
	'EmbedFilter' => 'classes/security/EmbedFilter.class.php',
346
	'IpFilter' => 'classes/security/IpFilter.class.php',
347
	'Password' => 'classes/security/Password.class.php',
348
	'Purifier' => 'classes/security/Purifier.class.php',
349
	'Security' => 'classes/security/Security.class.php',
350
	'UploadFileFilter' => 'classes/security/UploadFileFilter.class.php',
351
	'TemplateHandler' => 'classes/template/TemplateHandler.class.php',
352
	'Validator' => 'classes/validator/Validator.class.php',
353
	'WidgetHandler' => 'classes/widget/WidgetHandler.class.php',
354
	'GeneralXmlParser' => 'classes/xml/GeneralXmlParser.class.php',
355
	'Xml_Node_' => 'classes/xml/XmlParser.class.php',
356
	'XmlGenerator' => 'classes/xml/XmlGenerator.class.php',
357
	'XmlJsFilter' => 'classes/xml/XmlJsFilter.class.php',
358
	'XmlLangParser' => 'classes/xml/XmlLangParser.class.php',
359
	'XmlParser' => 'classes/xml/XmlParser.class.php',
360
	'XmlQueryParser' => 'classes/xml/XmlQueryParser.class.php',
361
	'DBParser' => 'classes/xml/xmlquery/DBParser.class.php',
362
	'QueryParser' => 'classes/xml/xmlquery/QueryParser.class.php',
363
	'Argument' => 'classes/xml/xmlquery/argument/Argument.class.php',
364
	'ConditionArgument' => 'classes/xml/xmlquery/argument/ConditionArgument.class.php',
365
	'SortArgument' => 'classes/xml/xmlquery/argument/SortArgument.class.php',
366
	'DefaultValue' => 'classes/xml/xmlquery/queryargument/DefaultValue.class.php',
367
	'QueryArgument' => 'classes/xml/xmlquery/queryargument/QueryArgument.class.php',
368
	'SortQueryArgument' => 'classes/xml/xmlquery/queryargument/SortQueryArgument.class.php',
369
	'QueryArgumentValidator' => 'classes/xml/xmlquery/queryargument/validator/QueryArgumentValidator.class.php',
370
	'ColumnTag' => 'classes/xml/xmlquery/tags/column/ColumnTag.class.php',
371
	'InsertColumnTag' => 'classes/xml/xmlquery/tags/column/InsertColumnTag.class.php',
372
	'InsertColumnTagWithoutArgument' => 'classes/xml/xmlquery/tags/column/InsertColumnTagWithoutArgument.class.php',
373
	'InsertColumnsTag' => 'classes/xml/xmlquery/tags/column/InsertColumnsTag.class.php',
374
	'SelectColumnTag' => 'classes/xml/xmlquery/tags/column/SelectColumnTag.class.php',
375
	'SelectColumnsTag' => 'classes/xml/xmlquery/tags/column/SelectColumnsTag.class.php',
376
	'UpdateColumnTag' => 'classes/xml/xmlquery/tags/column/UpdateColumnTag.class.php',
377
	'UpdateColumnsTag' => 'classes/xml/xmlquery/tags/column/UpdateColumnsTag.class.php',
378
	'ConditionGroupTag' => 'classes/xml/xmlquery/tags/condition/ConditionGroupTag.class.php',
379
	'ConditionTag' => 'classes/xml/xmlquery/tags/condition/ConditionTag.class.php',
380
	'ConditionsTag' => 'classes/xml/xmlquery/tags/condition/ConditionsTag.class.php',
381
	'JoinConditionsTag' => 'classes/xml/xmlquery/tags/condition/JoinConditionsTag.class.php',
382
	'GroupsTag' => 'classes/xml/xmlquery/tags/group/GroupsTag.class.php',
383
	'IndexTag' => 'classes/xml/xmlquery/tags/navigation/IndexTag.class.php',
384
	'LimitTag' => 'classes/xml/xmlquery/tags/navigation/LimitTag.class.php',
385
	'NavigationTag' => 'classes/xml/xmlquery/tags/navigation/NavigationTag.class.php',
386
	'QueryTag' => 'classes/xml/xmlquery/tags/query/QueryTag.class.php',
387
	'HintTableTag' => 'classes/xml/xmlquery/tags/table/HintTableTag.class.php',
388
	'TableTag' => 'classes/xml/xmlquery/tags/table/TableTag.class.php',
389
	'TablesTag' => 'classes/xml/xmlquery/tags/table/TablesTag.class.php',
390
), CASE_LOWER);
391
392
function __xe_autoload($class_name)
393
{
394
	if(__DEBUG__) {
395
		$time_at = getMicroTime();
396
	}
397
398
	if(isset($GLOBALS['__xe_autoload_file_map'][strtolower($class_name)]))
399
	{
400
		require _XE_PATH_ . $GLOBALS['__xe_autoload_file_map'][strtolower($class_name)];
401
	}
402
	elseif(preg_match('/^([a-zA-Z0-9_]+?)(Admin)?(View|Controller|Model|Api|Wap|Mobile)?$/', $class_name, $matches))
403
	{
404
		$candidate_filename = array();
405
		$candidate_filename[] = 'modules/' . $matches[1] . '/' . $matches[1];
406
		if(isset($matches[2]) && $matches[2]) $candidate_filename[] = 'admin';
407
		$candidate_filename[] = (isset($matches[3]) && $matches[3]) ? strtolower($matches[3]) : 'class';
408
		$candidate_filename[] = 'php';
409
410
		$candidate_filename = implode('.', $candidate_filename);
411
412
		if(file_exists(_XE_PATH_ . $candidate_filename))
413
		{
414
			require _XE_PATH_ . $candidate_filename;
415
		}
416
	}
417
418
	if(__DEBUG__) {
419
		$GLOBALS['__elapsed_class_load__'] += getMicroTime() - $time_at;
0 ignored issues
show
Bug introduced by
The variable $time_at 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...
420
	}
421
}
422
spl_autoload_register('__xe_autoload');
423
424
if(file_exists(_XE_PATH_  . '/vendor/autoload.php')) {
425
	require _XE_PATH_  . '/vendor/autoload.php';
426
}
427
/* End of file config.inc.php */
428
/* Location: ./config/config.inc.php */
429