]> git.andy128k.dev Git - ipf.git/commitdiff
performance tricks.
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 15 Jun 2013 14:31:59 +0000 (17:31 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 15 Jun 2013 14:31:59 +0000 (17:31 +0300)
index.php
ipf.php
ipf/project.php

index 7e3a3228a979c9db70f79fd82b50b0c9adf64b2b..444325d17dfef8bd2ad1f4870ae44e77f737d30c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -6,5 +6,5 @@ $ipf_path = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'ipf'
 $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();
+
diff --git a/ipf.php b/ipf.php
index 76d97677507c4bccca95d80b9fe0fb1db52c515e..bed0bf198635116f6723f72b0828f440f3ba281f 100644 (file)
--- a/ipf.php
+++ b/ipf.php
@@ -11,7 +11,7 @@ final class IPF
 {
     private static $settings = array();
 
-    private static function applySettings($settings)
+    private static function applySettings(&$settings)
     {
         foreach($settings as $key=>$val)
             IPF::$settings[strtolower($key)] = $val;
@@ -105,16 +105,28 @@ final class IPF
         }
     }
 
+    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() {}
index a2b36794995de7792bb4817e327a07068972becd..3f2de1baf43f04206e95e21dd2c0a3b18475f10a 100644 (file)
@@ -153,19 +153,7 @@ final class IPF_Project{
         $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;
@@ -173,7 +161,7 @@ final class IPF_Project{
 
         IPF_ORM_Manager::getInstance()->openConnection(IPF::get('database', IPF::get('dsn')));
 
-        if ($sapiName === 'cli') {
+        if (php_sapi_name() === 'cli') {
             $this->cli();
         } else {
             $this->loadModels();