'HTTP/1.1', 'HTTP_ACCEPT' => 'text/plain;q=0.5', 'HTTP_ACCEPT_LANGUAGE' => '*;q=0.5', 'HTTP_ACCEPT_ENCODING' => '', 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1;q=0.5', 'SERVER_SIGNATURE' => 'Command-line PHP/' . phpversion(), 'SERVER_SOFTWARE' => 'PHP/' . phpversion(), 'SERVER_ADDR' => '127.0.0.1', 'REMOTE_ADDR' => '127.0.0.1', 'REQUEST_METHOD' => 'GET', 'HTTP_USER_AGENT' => 'CLI', ); $_SERVER = array_merge($serverDefaults, $_SERVER); /** * If we have an HTTP_HOST value, then we're being called from the webserver and there are some things that * need checking */ } else { /** * Fix magic quotes setting */ if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { if($_REQUEST) stripslashes_recursively($_REQUEST); if($_GET) stripslashes_recursively($_GET); if($_POST) stripslashes_recursively($_POST); if($_COOKIE) stripslashes_recursively($_COOKIE); } /** * Fix HTTP_HOST from reverse proxies */ if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { // Get the first host, in case there's multiple separated through commas $_SERVER['HTTP_HOST'] = strtok($_SERVER['HTTP_X_FORWARDED_HOST'], ','); } } /** * Define system paths */ if(!defined('BASE_PATH')) { // Assuming that this file is framework/core/Core.php we can then determine the base path $candidateBasePath = rtrim(dirname(dirname(dirname(__FILE__))), DIRECTORY_SEPARATOR); // We can't have an empty BASE_PATH. Making it / means that double-slashes occur in places but that's benign. // This likely only happens on chrooted environemnts if($candidateBasePath == '') $candidateBasePath = DIRECTORY_SEPARATOR; define('BASE_PATH', $candidateBasePath); } if(!defined('BASE_URL')) { // Determine the base URL by comparing SCRIPT_NAME to SCRIPT_FILENAME and getting common elements $path = realpath($_SERVER['SCRIPT_FILENAME']); if(substr($path, 0, strlen(BASE_PATH)) == BASE_PATH) { $urlSegmentToRemove = substr($path, strlen(BASE_PATH)); if(substr($_SERVER['SCRIPT_NAME'], -strlen($urlSegmentToRemove)) == $urlSegmentToRemove) { $baseURL = substr($_SERVER['SCRIPT_NAME'], 0, -strlen($urlSegmentToRemove)); define('BASE_URL', rtrim($baseURL, DIRECTORY_SEPARATOR)); } } // If that didn't work, failover to the old syntax. Hopefully this isn't necessary, and maybe // if can be phased out? if(!defined('BASE_URL')) { $dir = (strpos($_SERVER['SCRIPT_NAME'], 'index.php') !== false) ? dirname($_SERVER['SCRIPT_NAME']) : dirname(dirname($_SERVER['SCRIPT_NAME'])); define('BASE_URL', rtrim($dir, DIRECTORY_SEPARATOR)); } } define('MODULES_DIR', 'modules'); define('MODULES_PATH', BASE_PATH . '/' . MODULES_DIR); define('THEMES_DIR', 'themes'); define('THEMES_PATH', BASE_PATH . '/' . THEMES_DIR); // Relies on this being in a subdir of the framework. // If it isn't, or is symlinked to a folder with a different name, you must define FRAMEWORK_DIR if(!defined('FRAMEWORK_DIR')) { define('FRAMEWORK_DIR', basename(dirname(dirname(__FILE__)))); } define('FRAMEWORK_PATH', BASE_PATH . '/' . FRAMEWORK_DIR); define('FRAMEWORK_ADMIN_DIR', FRAMEWORK_DIR . '/admin'); define('FRAMEWORK_ADMIN_PATH', BASE_PATH . '/' . FRAMEWORK_ADMIN_DIR); // These are all deprecated. Use the FRAMEWORK_ versions instead. define('SAPPHIRE_DIR', FRAMEWORK_DIR); define('SAPPHIRE_PATH', FRAMEWORK_PATH); define('SAPPHIRE_ADMIN_DIR', FRAMEWORK_ADMIN_DIR); define('SAPPHIRE_ADMIN_PATH', FRAMEWORK_ADMIN_PATH); define('THIRDPARTY_DIR', FRAMEWORK_DIR . '/thirdparty'); define('THIRDPARTY_PATH', BASE_PATH . '/' . THIRDPARTY_DIR); define('ASSETS_DIR', 'assets'); define('ASSETS_PATH', BASE_PATH . '/' . ASSETS_DIR); /////////////////////////////////////////////////////////////////////////////// // INCLUDES if(defined('CUSTOM_INCLUDE_PATH')) { $includePath = '.' . PATH_SEPARATOR . CUSTOM_INCLUDE_PATH . PATH_SEPARATOR . FRAMEWORK_PATH . PATH_SEPARATOR . FRAMEWORK_PATH . '/parsers' . PATH_SEPARATOR . THIRDPARTY_PATH . PATH_SEPARATOR . get_include_path(); } else { $includePath = '.' . PATH_SEPARATOR . FRAMEWORK_PATH . PATH_SEPARATOR . FRAMEWORK_PATH . '/parsers' . PATH_SEPARATOR . THIRDPARTY_PATH . PATH_SEPARATOR . get_include_path(); } set_include_path($includePath); /** * Define the temporary folder if it wasn't defined yet */ require_once 'core/TempPath.php'; if(!defined('TEMP_FOLDER')) { define('TEMP_FOLDER', getTempFolder(BASE_PATH)); }