public static function initialize() { if (self::$is_initialized) { return; } set_error_handler(array(get_class(), 'exception_error_handler')); if (!defined('DEBUG')) { define('DEBUG', FALSE); } error_reporting(DEBUG ? E_ALL : 0); set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__))); spl_autoload_register(array(get_class(), 'autoloader')); if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc()) { $_POST = self::stripslashes_recursive($_POST); $_GET = self::stripslashes_recursive($_GET); $_COOKIE = self::stripslashes_recursive($_COOKIE); $_REQUEST = self::stripslashes_recursive($_REQUEST); @ini_set('magic_quotes_gpc', FALSE); } if (function_exists('get_magic_quotes_gpc')) { @set_magic_quotes_runtime(FALSE); } @ini_set('memory_limit', '-1'); @ini_set('pcre.recursion_limit', '100'); if (extension_loaded('mbstring')) { mb_internal_encoding('UTF-8'); } if (extension_loaded('iconv')) { iconv_set_encoding('internal_encoding', 'UTF-8'); } date_default_timezone_set('UTC'); self::$is_initialized = TRUE; }
/** * Initializes basic PHP stuff like error handling, include paths, magic quote reversal, internal character encoding, timezones. */ public static function initialize() { // Check initialization status if (self::$is_initialized) { return; } // Set up error handling set_error_handler(array(get_class(), 'exception_error_handler')); // Define DEBUG constant if (!defined('DEBUG')) { define('DEBUG', FALSE); } // Set error reporting level error_reporting(DEBUG ? E_ALL : 0); // Set up include path set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__))); // Set up autoloader spl_autoload_register(array(get_class(), 'autoloader')); // Get rid of magic quotes if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc()) { $_POST = self::stripslashes_recursive($_POST); $_GET = self::stripslashes_recursive($_GET); $_COOKIE = self::stripslashes_recursive($_COOKIE); $_REQUEST = self::stripslashes_recursive($_REQUEST); @ini_set('magic_quotes_gpc', FALSE); } if (function_exists('get_magic_quotes_gpc') && function_exists('set_magic_quotes_runtime')) { @set_magic_quotes_runtime(FALSE); } // Try to remove any memory limitations @ini_set('memory_limit', '-1'); // Try to set the PCRE recursion limit to a sane value // See http://stackoverflow.com/a/7627962 @ini_set('pcre.recursion_limit', '100'); // Set internal character encoding @ini_set('default_charset', 'UTF-8'); if (extension_loaded('mbstring')) { @mb_internal_encoding('UTF-8'); } if (version_compare(PHP_VERSION, '5.6', '<') && extension_loaded('iconv')) { @iconv_set_encoding('internal_encoding', 'UTF-8'); } // Set the timezone date_default_timezone_set('UTC'); // Set initialization status self::$is_initialized = TRUE; }