コード例 #1
0
 public function tearDown()
 {
     Layout::reset();
     Factory::getInstance()->output->set_output('');
 }
コード例 #2
0
ファイル: Logger.php プロジェクト: fuzeworks/core
 /**
  * Calls an HTTP error, sends it as a header, and loads a template if required to do so.
  *
  * @param int  $errno HTTP error code
  * @param bool $view  true to view error on website
  */
 public static function http_error($errno = 500, $view = true)
 {
     $http_codes = array(400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', 506 => 'Variant Also Negotiates', 509 => 'Bandwidth Limit Exceeded', 510 => 'Not Extended', 511 => 'Network Authentication Required');
     self::logError('HTTP-error ' . $errno . ' called');
     self::log('Sending header HTTP/1.1 ' . $errno . ' ' . $http_codes[$errno]);
     header('HTTP/1.1 ' . $errno . ' ' . $http_codes[$errno]);
     // Do we want the error-view with it?
     if ($view == false) {
         return;
     }
     // Load the view
     $view = 'errors/' . $errno;
     self::log('Loading view ' . $view);
     // Try and load the view, if impossible, load HTTP code instead.
     try {
         Layout::reset();
         Layout::view($view);
     } catch (LayoutException $exception) {
         // No error page could be found, just echo the result
         Factory::getInstance()->output->set_output("<h1>{$errno}</h1><h3>" . $http_codes[$errno] . '</h3>');
     }
 }
コード例 #3
0
ファイル: Core.php プロジェクト: fuzeworks/core
 /**
  * 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();
 }