$project_path = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'project';
set_include_path(get_include_path() . PATH_SEPARATOR . $ipf_path . PATH_SEPARATOR . $project_path);
require 'ipf.php';
-IPF::boot($ipf_path, $project_path);
-return IPF_Project::getInstance()->run();
+return IPF::boot($ipf_path, $project_path) && IPF_Project::getInstance()->run();
+
{
private static $settings = array();
- private static function applySettings($settings)
+ private static function applySettings(&$settings)
{
foreach($settings as $key=>$val)
IPF::$settings[strtolower($key)] = $val;
}
}
+ private static function requestedFileExists()
+ {
+ $parts = explode('?', $_SERVER['REQUEST_URI'], 2);
+ $path = $_SERVER['DOCUMENT_ROOT'] . urldecode($parts[0]);
+ return is_file($path);
+ }
+
public static function boot($ipf_path, $project_path)
{
- IPF::$settings['ipf_path']=$ipf_path;
- IPF::$settings['project_path']=$project_path;
+ if (php_sapi_name() === 'cli-server' && IPF::requestedFileExists())
+ return false;
+
+ IPF::$settings['ipf_path'] = $ipf_path;
+ IPF::$settings['project_path'] = $project_path;
+
try {
IPF::loadSettings();
- date_default_timezone_set(IPF::$settings['time_zone']);
+ date_default_timezone_set(IPF::$settings['time_zone']);
} catch(IPF_Exception_Settings $e) {
die('Setting Error: '.$e->getMessage()."\n");
}
+ return true;
}
private function __construct() {}
$cli->run();
}
- private function requestedFileExists()
- {
- $parts = explode('?', $_SERVER['REQUEST_URI'], 2);
- $path = $_SERVER['DOCUMENT_ROOT'] . urldecode($parts[0]);
- return is_file($path);
- }
-
public function run() {
- $sapiName = php_sapi_name();
-
- if ($sapiName === 'cli-server' && $this->requestedFileExists())
- return false;
-
if (IPF::get('debug')) {
$this->sqlProfiler = new IPF_ORM_Connection_Profiler();
IPF_ORM_Manager::getInstance()->dbListeners[] = $this->sqlProfiler;
IPF_ORM_Manager::getInstance()->openConnection(IPF::get('database', IPF::get('dsn')));
- if ($sapiName === 'cli') {
+ if (php_sapi_name() === 'cli') {
$this->cli();
} else {
$this->loadModels();