コード例 #1
0
ファイル: Frix.php プロジェクト: ricobl/frix
	static function start ($config_file = null) {
		
		// Default config file, default path: the Frix dir
		self::load_config( join_path(array(dirname(__FILE__), 'default_config.php')) );
		
		// Load user config file
		// Default config file path: same dir of the root 'index.php' file
		self::load_config($config_file ? $config_file : join_path(dirname($_SERVER['SCRIPT_FILENAME']), 'config.php'));
		
		// Import commonly used modules
		load('RequestHandler');
		load('Router');
		load('Fs');
		load('App');
		load('Db/Db');
		load('Field');
		load('Db/Model');
		load('Db/Query');
		load('Template');
		
		// Create a database connection
		Db::create(Frix::config('DB_URL'));
		
		// Use PATH_INFO to feed the request handler
		$path = $_SERVER['PATH_INFO'];
		
		// Make sure the path ends with a '/'
		if ($path[strlen($path)-1] != '/') {
			// If not POSTing, fix the path and redirect
			if ($_SERVER['REQUEST_METHOD'] != 'POST') {
				redir(url(Frix::config('WEB_ROOT'), $path));
			}
			
			// Otherwise, just fix the path
			$path = url($path);
		}
		
		// Create a request handler
		$handler = new RequestHandler(Frix::config('ROUTES'), $path);
		
		// Start processing the request
		$handler->start();
		
	}