I was just going through the code of PhileCMS and came across the following line of code:
if (PHILE_CLI_MODE) {
$_SERVER['REMOTE_ADDR'] = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
}
Now what is PHILE_CLI_MODE and where is this variable coming from, i don't see it declared in the script HERE.
Can anybody tell me where this variable is coming from ?
Thank you.
It's being set in lib/Phile/Bootstrap.php
, line 79.
defined('PHILE_CLI_MODE') or define('PHILE_CLI_MODE', (php_sapi_name() == "cli") ? true : false);
It's not a variable, it's a constant defined in lib/Phile/Bootstrap.php
defined('PHILE_CLI_MODE') or define('PHILE_CLI_MODE', (php_sapi_name() == "cli") ? true : false);
This file is included everytime in the root index.php
require_once __DIR__ . '/lib/Phile/Bootstrap.php';
The constant PHILE_CLI_MODE indicates with the help of php_sapi_name(), if Phile is run via the command line (CLI = Command-line interface) or via a web browser (then it's FALSE
).
In the end, if Phile is run via the command line and $_SERVER['REMOTE_ADDR']
is not set, $_SERVER['REMOTE_ADDR']
is set to 127.0.0.1 (=localhost)