2 // Import framework stuff
3 use CoreFramework\Configuration\FrameworkConfiguration;
4 use CoreFramework\Loader\ClassLoader;
7 * Loads more include files by using the generic class loader
9 * @author Roland Haeder <webmaster@shipsimu.org>
11 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
12 * @license GNU GPL 3.0 or any newer version
13 * @link http://www.shipsimu.org
15 * @todo Minimize these includes
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 // Include the class loader function
32 require FrameworkConfiguration::getSelfInstance()->getConfigEntry('framework_base_path') . 'loader/class_ClassLoader.php';
35 * Shall we include additional configs where you can configure some things?
36 * Then load matching config file.
38 ClassLoader::getSelfInstance()->loadExtraConfigs();
40 // Register auto-load function with the SPL
41 // @TODO This makes the core depending on the SPL. But it should be installed anyway.
42 spl_autoload_register('CoreFramework\Loader\ClassLoader::autoLoad');
44 // Does the user has an application specified?
45 // @TODO Find a nicer OOP-ed way for this
46 if (!empty($_GET['app'])) {
47 // Set the application from string
48 $application = (string) $_GET['app'];
49 } elseif (!empty($_SERVER['argv'][1])) {
50 // Set the application from string
51 $application = (string) $_SERVER['argv'][1];
52 $app = explode('=', trim($application));
53 if ($app[0] == 'app') {
54 // Application is valid!
55 $application = trim($app[1]);
57 // Invalid entry found, first must be "app"!
58 $application = FrameworkConfiguration::getSelfInstance()->getConfigEntry('default_application');
61 // Set the "application selector" application
62 $application = FrameworkConfiguration::getSelfInstance()->getConfigEntry('default_application');
65 // Secure it, by keeping out tags
66 $application = htmlentities(strip_tags($application), ENT_QUOTES);
68 // Secure it a little more with a reg.exp.
69 $application = preg_replace('/([^a-z0-9_-])+/i', '', $application);
71 // Set the application name for later usage
72 FrameworkConfiguration::getSelfInstance()->setConfigEntry('app_name', $application);
74 // Scan for all framework classes, exceptions and interfaces
75 ClassLoader::scanFrameworkClasses();