3 * @desc The application selector main include file
6 // Does the user has an application specified?
7 if (!empty($_GET[FrameworkConfiguration::getInstance()->readConfig("app_selector_get")])) {
8 // Set the application from string
9 $application = (string) $_GET[FrameworkConfiguration::getInstance()->readConfig("app_selector_get")];
10 } elseif (!empty($_SERVER['argv'][1])) {
11 // Set the application from string
12 $application = (string) $_SERVER['argv'][1];
13 $app = explode("=", trim($application));
14 if ($app[0] == FrameworkConfiguration::getInstance()->readConfig("app_selector_get")) {
15 // Application is valid!
16 $application = trim($app[1]);
18 // Invalid entry found, first must be "app"!
19 $application = FrameworkConfiguration::getInstance()->readConfig("default_application");
22 // Set the "application selector" application
23 $application = FrameworkConfiguration::getInstance()->readConfig("default_application");
26 // Secure it, by keeping out tags
27 $application = htmlentities(strip_tags($application), ENT_QUOTES);
29 // Secure it a little more with a reg.exp.
30 $application = preg_replace('/([^a-z_-])+/i', "", $application);
32 // Try to load these includes in the given order
33 $configAppIncludes = array(
34 sprintf("class_%s", FrameworkConfiguration::getInstance()->readConfig("app_helper_class")), // The ApplicationHelper class
35 "config", // The application's own configuration
36 "init", // The application initializer
37 "loader", // The application's class loader
38 "debug", // Some debugging stuff
39 "exceptions", // The application's own exception handler
40 "starter", // The application starter (calls entryPoint(), etc.)
43 // Load them all (try only)
44 foreach ($configAppIncludes as $inc) {
45 // Skip starter in test mode
46 if (($inc == "starter") && (defined('TEST'))) {
51 // Generate a FQFN for the helper class
52 $fqfn = sprintf("%s%s/%s/%s%s",
54 FrameworkConfiguration::getInstance()->readConfig("application_path"),
57 FrameworkConfiguration::getInstance()->readConfig("php_extension")
60 // Does the include file exists?
61 if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) {
64 } elseif (FrameworkConfiguration::getInstance()->readConfig("verbose_level") > 0) {
66 trigger_error(sprintf("Cannot load application script %s! File is missing or read-protected.",
67 $inc . FrameworkConfiguration::getInstance()->readConfig("php_extension")