use md5sum on ini files to determine if they need re-writing
[pear] / HTML / FlexyFramework.php
index c999582..b9297b7 100755 (executable)
@@ -208,12 +208,21 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
      */
     function loadModuleConfig($cfg)
     {
+         
+        $proj = $cfg['project'];
+        $rootDir = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
+        
+        $cls = $proj.'_Config';
+         if (file_exists($rootDir . '/'.str_replace('_','/', $cls). '.php')) {
+            require_once str_replace('_','/', $cls). '.php';
+            $c = new $cls();
+            if (method_exists($c,'init')) {
+                $cfg = $c->init($this,$cfg);
+            }
+        }
         if (empty($cfg['enable'])) {
             return $cfg;
         }
-        $proj = $cfg['project'];
-        $rootDir = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
-
         foreach(explode(',',$cfg['enable']) as $m) {
             $cls = $proj.'_'. $m . '_Config';
 
@@ -495,7 +504,13 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
     function _configDataObjectsCache()
     {
         // cli works under different users... it may cause problems..
+        
         $this->debug(__METHOD__);
+        
+        if ($this->database === false) {
+            return;
+        }
+        
         if (function_exists('posix_getpwuid')) {
             $uinfo = posix_getpwuid( posix_getuid () ); 
             $user = $uinfo['name'];
@@ -506,7 +521,7 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
         
 
         $iniCache = ini_get('session.save_path') .'/' . 
-               'dbcfg-' . $user . '/'. str_replace('/', '_', $this->project) ;
+               'dbcfg-' . $user . '/'. str_replace('/', '_', $this->project);
         
         
         if ($this->appNameShort) {
@@ -515,9 +530,7 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
         if ($this->version) {
             $iniCache .= '.' . $this->version;
         }
-        if ($this->database === false) {
-            return;
-        }
+       
         
         $dburl = parse_url($this->database);
         if (!empty($dburl['path'])) {
@@ -535,10 +548,8 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
             $this->dataObjectsOriginalIni = $this->DB_DataObject[$dbini];
             ///print_r($this->DB_DataObject);exit;
         }
-        // 
-        
-        
-        
+          
+         
         $this->DB_DataObject[$dbini] =   $iniCache;
         // we now have the configuration file name..
         
@@ -575,13 +586,15 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
         
         $iniCache = $this->DB_DataObject[$dbini];
         $this->debug('generateDataobjectsCache:' .dirname($iniCache).'/*.ini');
-        if ($force && file_exists($iniCache)) {
-            
+        
+        $replace = array();
+        
+        if (file_exists($iniCache)) {
             $files = glob(dirname($iniCache).'/*.ini');
             foreach($files as $f) {
-                unlink($f);
+                $replace[$f] = md5(file_get_contents($f)); // hash it..
+               
             }
-            clearstatcache();
         }
         $this->debug('generateDataobjectsCache: DONE ini delete');
         
@@ -624,7 +637,7 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
         $generator->start();
         $this->debug('generateDataobjectsCache: done generator');
 
-        HTML_FlexyFramework_Generator::writeCache($iniCacheTmp, $iniCache); 
+        HTML_FlexyFramework_Generator::writeCache($iniCacheTmp, $iniCache, $replace); 
         // reset the cache to the correct lcoation.
         $this->DB_DataObject[$dbini] = $iniCache;
         
@@ -853,7 +866,7 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
         /* have I been initialized */
         
         
-        if (get_magic_quotes_gpc() && !$this->cli) {
+        if (version_compare(PHP_VERSION, '7.0.0') < 0  && get_magic_quotes_gpc() && !$this->cli) {
             $this->fatalError(
                 "magic quotes is enabled add the line<BR>
                    php_value magic_quotes_gpc 0<BR>
@@ -903,8 +916,9 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
                  <BR> ".$err->toString());
         }
         $res = $err->query("SELECT @@global.read_only as ro");
-        $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
-        if (!empty($row['ro'])) {
+        
+        $row = is_a($res, 'DB_Error') ? false : $res->fetchRow(DB_FETCHMODE_ASSOC);
+        if (!$row || (!empty($row['ro']) && empty($options['skip-read-only-check']))) {
             $this->fatalError("Database is configured to be read-only - please check database<BR> ".$err->toString());
         }
         // reset dont die!
@@ -1145,7 +1159,8 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
         }
         
         $startRequest = $request;
-        $request =@ array_shift(explode('?', $request));
+        $ra = explode('?', $request);
+        $request =  array_shift($ra);
         $this->debug("INPUT REQUEST $request<BR>");
         if (!$isRedirect) {
             // check that request forms contains baseurl????
@@ -1256,7 +1271,7 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
         }
         
         
-        $request_array=explode("/",$request);
+        $request_array = explode("/",$request);
         $original_request_array = $request_array;
         $sub_request_array = array();
         $l = count($request_array)-1;
@@ -1420,7 +1435,8 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
             return true;
         }
         // file exists, but process might not be the same..
-        $name = array_pop(explode('_', get_class($class)));
+        $ea = explode('_', get_class($class));
+        $name = array_pop($ea);
         $cmd = file_get_contents('/proc/' . $oldpid.'/cmdline');
         if (!preg_match('/php/i',$cmd) || !preg_match('/'.$name.'/i',$cmd)) {
             file_put_contents($lock, getmypid());