getMethod("register_service"); try { // Invoke the static method to kick off the service handler $register_method->invoke(null); } catch (Exception $ex) { // Try to include the control.inc file instead; if the module needs a direct access point (should be REALLY rare... file downloads [that can't be done over XHR], RSS feeds, etc.) $msg = "Uncaught exception from service `{$config["pageIndex"]}`; bailing out. Detail:

".$ex->getMessage(); http_response_code(400); header("HTTP/ 400 $msg"); die($msg); } } } catch(Exception $ex) { $msg = "A request has been made to a service (`{$config["pageIndex"]}`) that produced an error. This should not happen, please check the URL and try again."; error_log("Error loading service: ".$ex->getMessage()); http_response_code(400); header("HTTP/ 400 $msg"); die($msg); } break; default: // Default functionality - render a page if it exists, select index if nothing is specified if (!$config["pageIndex"]) $config["pageIndex"] = "index"; // Check that control file exists for a page (last attempt) $controlFile = "pages/{$config["pageIndex"]}/control.inc"; $literalFile = $config["baseAppDir"].substr($_SERVER["REQUEST_URI"], 1); if (file_exists($literalFile) && !is_dir($literalFile)) { // Request for an actual filename that exists in the app directory structure echo @file_get_contents($literalFile); } elseif (file_exists($controlFile)) { // Application page (/pages) // Include the model.inc (not required) @include("pages/{$config["pageIndex"]}/model.inc"); // Include the required Control file include($controlFile); } else { $conf = new \Proteus\Modules\Config\Site(); if ($conf->legacyPageBuilder) { $pageObj = \Proteus\Modules\PageContent\Logic\ContentPage::getByAccessKey($config["pageIndex"]); $a = new \Proteus\Modules\PageContent\UI\ContentPage($pageObj); } else { $a = new \Proteus\Modules\PageBuilder\UI\Page(); } $a->render(); // // Page access key is the last element of the URL // if (count($config["params"])) $config["pageIndex"] = array_pop($config["params"]); // // // Scrub it just to be safe // $config["pageIndex"] = preg_replace("/[^a-z0-9_\-#]/is", "", $config["pageIndex"]); // // // TODO: access key build for nested menus (breadcrumbs!) // $pageObj = \Proteus\Modules\PageContent\Logic\ContentPage::getByAccessKey($config["pageIndex"]); // // if (!$pageObj->id) // { // // Route to 404 page if the page is not found // header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); // include($config["baseAppDir"]."404.php"); // } // else // { // $a = new \Proteus\Modules\PageContent\UI\ContentPage($pageObj); // $a->render(); // } } } exit(0); ?>