Beispiel #1
0
 public static function init()
 {
     if (self::$hasinit) {
         return false;
     }
     // Load configuration.
     self::$config = new Config('realms.ini');
     if (!self::$config->get('general', 'service_requests')) {
         // Service unavaliable. :(
         http_response_code(503);
         // 503 Service Unavaliable.
         echo 'service unavaliable';
         exit;
         // terminate here.
     }
     // Load request registry
     self::$requestRegistry = new RequestRegistry();
     // create request registry instance
     // Dynamically load request handlers.
     $handler_files = scandir('inc/Requests');
     foreach ($handler_files as $handler_file) {
         if ($handler_file == '.' || $handler_file == '..') {
             continue;
         }
         // skip ghost files
         // Load PHP file
         require 'inc/Requests/' . $handler_file;
         // Register handler
         $classname = pathinfo($handler_file, PATHINFO_FILENAME);
         self::$requestRegistry->register(new $classname());
     }
     // Realms init finish.
     self::$hasinit = true;
     return true;
 }