public static function run() { define('DINGO_VERSION', '0.7.1'); // Start buffer ob_start(); // Autoloading files require_once SYSTEM . '/core/core.php'; require_once SYSTEM . '/core/error.php'; spl_autoload_register(array('bootstrap', 'autoload')); bootstrap::addPackage(SYSTEM . '/core'); bootstrap::addPackage(SYSTEM . '/library'); bootstrap::addPackage(APPLICATION . '/'); load::library('db'); require_once APPLICATION . '/' . CONFIG . '/' . CONFIGURATION . '/config.php'; set_error_handler('dingo_error'); set_exception_handler('dingo_exception'); // Load route configuration require_once APPLICATION . '/' . CONFIG . '/' . CONFIGURATION . '/route.php'; set_error_handler('dingo_error'); set_exception_handler('dingo_exception'); config::set('system', SYSTEM); config::set('application', APPLICATION); config::set('config', CONFIG); // Load route configuration require_once APPLICATION . '/' . CONFIG . '/' . CONFIGURATION . '/route.php'; // Get route $uri = route::get(bootstrap::get_request_url()); // Set current page define('CURRENT_PAGE', $uri['string']); // Validate if (!route::valid($uri)) { load::error('general', 'Invalid URL', 'The requested URL contains invalid characters.'); } // Load Controller //---------------------------------------------------------------------------------------------- // Initialize controller $tmp = "{$uri['controller_class']}_controller"; if (!class_exists($tmp)) { load::error('404'); } $controller = new $tmp(); unset($tmp); // Check if using valid REST API if (api::get()) { if (!empty($controller->controller_api) and is_array($controller->controller_api) and !empty($controller->controller_api[$uri['function']]) and is_array($controller->controller_api[$uri['function']])) { foreach ($controller->controller_api[$uri['function']] as $e) { api::permit($e); } if (!api::allowed(api::get())) { load::error('404'); } } else { load::error('404'); } } // Autoload Components bootstrap::autoload1($controller); // Check to see if function exists if (!is_callable(array($controller, $uri['function']))) { // Try replacing underscores with dashes $minus_function_name = str_replace('-', '_', $uri['function']); if (!is_callable(array($controller, $minus_function_name))) { load::error('404'); } else { $uri['function'] = $minus_function_name; } } // Run Function call_user_func_array(array($controller, $uri['function']), $uri['arguments']); // Display echoed content ob_end_flush(); }