* * Copyright (c) 2010 Dennis Morhardt * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ // UTF-8 rocks! declare(encoding='UTF-8'); header("Content-type: text/html; charset=utf-8"); // Settings define("DS", "/"); define("BASE", dirname(__FILE__) . DS); define("URL_BASE", "/"); define("VERSION", "3.0-alpha"); define("TRAILING_SLASH", false); define("DEBUG", true); define('DATABASE', 'mongodb://localhost/posdev'); define("CACHE", "dummy://"); define("TIMEZONE", "GMT"); // Flush the headers flush(); // Autoloading function __autoload($classname) { // Autoload only php on speed core files or JetPacks if ( false === strstr( $classname, "PoS\\" ) && false === strstr( $classname, "JetPack\\" ) && false === strstr( $classname, "DataSource\\" ) ) return false; // Find JetPack main file if ( strstr( $classname, "JetPack\\" ) ): $parts = explode("\\", $classname); if ( 2 == count($parts) ) $classname = $classname . '_' . $parts[1]; endif; // Replace the _ from the class names to / // and JetPack with JetPacks $classfile = str_replace(array('_', '\\', 'JetPack'), array(DS, DS, 'JetPacks'), $classname) . ".php"; $file = BASE . "framework" . DS . $classfile; // Find the DataSource if ( strstr( $classname, "DataSource\\" ) ) $file = BASE . "app" . DS . "datasources" . DS . str_replace('DataSource\\', '', $classname) . ".php"; // Check if the class exists if ( false === is_file( $file ) ) return false; // Include the classes include_once $file; return true; } // Shutdown handler to catch php errors function __shutdown_handler() { if ( $error = error_get_last() ): if ( isset($error['type'] ) && ( $error['type'] == E_ERROR || $error['type'] == E_PARSE || $error['type'] == E_COMPILE_ERROR ) ): ob_end_clean(); throw new PoS\Exception("PHP Error: " . $error['message'], null, $error['line'], $error['file']); endif; endif; } // Minimal start if ( defined("MINIMAL_START") && true === MINIMAL_START ) return; // Start to catch and register the shutdown handler ob_start(); register_shutdown_function('__shutdown_handler'); // Set default time zone date_default_timezone_set(TIMEZONE); // Load the routes include_once BASE . "app" . DS . "Routes.php"; // Start the framework PoS\Framework::__init(); // Save the cache or close the memcache connection PoS\Cache::__stop(); // Flush it! ob_end_flush();