コード例 #1
0
ファイル: DB_driver.php プロジェクト: fuzeworks/core
 /**
  * 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
 }
コード例 #2
0
ファイル: Modules.php プロジェクト: fuzeworks/core
 /**
  * The Module Callable.
  *
  * When a module listens for a specific routing path, this callable get's called.
  * After this the module can handle the request with the route() function in the module's root directory
  *
  * @param array   Regex matches
  */
 public static function moduleCallable($matches = array())
 {
     // First detect what module is attached to this route
     Logger::newLevel('Module callable called!');
     // Get the route
     $route = !empty($matches['route']) ? $matches['route'] : null;
     // See if the route exists
     if (isset(self::$module_routes[$route])) {
         Logger::log("Module '" . self::$module_routes[$route] . "' matched given route");
         // Load the module
         $mod = self::get(self::$module_routes[$route]);
         unset($matches['route']);
         $mod->route($matches);
     } else {
         Logger::logError('Route did not match known module. Fatal error');
         return Logger::http_error(500);
     }
     Logger::stopLevel();
 }