/** * Set Message * * @param string $msg * @param string $val = '' * @return void */ protected function _set_error_message($msg, $val = '') { Language::get('email'); if (sscanf($msg, 'lang:%s', $line) !== 1 or FALSE === ($line = Language::line($line))) { $this->_debug_msg[] = str_replace('%s', $val, $msg) . '<br />'; } else { $this->_debug_msg[] = str_replace('%s', $val, $line) . '<br />'; } }
/** * Display an error message * * @param string the error message * @param string any "swap" values * @param bool whether to localize the message * @return string sends the application/views/errors/error_db.php template */ public function display_error($error = '', $swap = '', $native = FALSE) { // First load the language Language::get('db'); $heading = Language::line('db_error_heading'); if ($native === TRUE) { $message = (array) $error; } else { $message = is_array($error) ? $error : array(str_replace('%s', $swap, Language::line($error))); } // Find the most likely culprit of the error by going through // the backtrace until the source file is no longer in the // database folder. $trace = debug_backtrace(); foreach ($trace as $call) { if (isset($call['file'], $call['class'])) { // We'll need this on Windows, as APPPATH and BASEPATH will always use forward slashes if (DIRECTORY_SEPARATOR !== '/') { $call['file'] = str_replace('\\', '/', $call['file']); } if (strpos($call['file'], Core::$coreDir . DS . 'Database') === FALSE && strpos($call['class'], 'Loader') === FALSE) { // Found it - use a relative path for safety $message[] = 'Filename: ' . str_replace(array('Application', 'Core'), '', $call['file']); $message[] = 'Line Number: ' . $call['line']; break; } } } Logger::logError($heading); foreach ($message as $message) { Logger::logError($message); } Logger::http_error(500); exit(8); // EXIT_DATABASE }
/** * Initializes the core. * * @throws \Exception */ public static function init() { // Set the CWD for usage in the shutdown function self::$cwd = getcwd(); // Set the core dir for when the loading of classes is required self::$coreDir = dirname(__DIR__); // If the environment is not yet defined, use production settings if (!defined('ENVIRONMENT')) { define('ENVIRONMENT', 'PRODUCTION'); } // Defines the time the framework starts. Used for timing functions in the framework if (!defined('STARTTIME')) { define('STARTTIME', microtime(true)); define('DS', DIRECTORY_SEPARATOR); } // Load basics ignore_user_abort(true); register_shutdown_function(array('\\FuzeWorks\\Core', 'shutdown')); // Load core functionality new Factory(); // Load the config file of the FuzeWorks core $config = Config::get('core'); // Disable events if requested to do so if (!$config->enable_events) { Events::disable(); } // Build all the registers for correct operation, if modules are enabled if ($config->enable_modules) { Modules::buildRegister($config->registry_caching, $config->registry_caching_method, $config->registry_caching_time); } // And fire the coreStartEvent $event = Events::fireEvent('coreStartEvent'); if ($event->isCancelled()) { return true; } // And initialize multiple classes Layout::init(); Language::init(); }