$this->$k = $v;
}
$this->_parseConfig();
-
+
// echo '<PRE>'; print_r($this);exit;
if ($this->cli) {
$args = $_SERVER['argv'];
$this->_run($this->run,false,$args);
return;
}
-
+
// handle apache mod_rewrite..
// it looks like this might not work anymore..
*/
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';
}
$this->classPrefix = str_replace('/', '_', $this->project) . '_';
-
- // list the available options..
+ // list the available options..
if ($this->cli && empty($_SERVER['argv'][1])) {
require_once 'HTML/FlexyFramework/Cli.php';
$fcli = new HTML_FlexyFramework_Cli($this);
}
$this->_validateDatabase();
-
+
$this->_validateTemplate();
}
* overlay array properties..
*/
- function applyIf($prop, $ar) {
+ function applyIf($prop, $ar)
+ {
if (!isset($this->$prop)) {
$this->$prop = $ar;
return;
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'];
$iniCache = ini_get('session.save_path') .'/' .
- 'dbcfg-' . $user . '/'. str_replace('/', '_', $this->project) ;
+ 'dbcfg-' . $user . '/'. str_replace('/', '_', $this->project);
if ($this->appNameShort) {
if ($this->version) {
$iniCache .= '.' . $this->version;
}
- if ($this->database === false) {
- return;
- }
+
$dburl = parse_url($this->database);
if (!empty($dburl['path'])) {
$this->dataObjectsOriginalIni = $this->DB_DataObject[$dbini];
///print_r($this->DB_DataObject);exit;
}
- //
-
-
-
+
+
$this->DB_DataObject[$dbini] = $iniCache;
// we now have the configuration file name..
if (!file_exists($iniCache) || empty( $this->dataObjectsCacheExpires)) {
+ $this->debug(__METHOD__ . ':calling generate do cache');
$this->generateDataobjectsCache(true);
return;
}
{
//$this->debug('generateDataobjectsCache: force=' . ($force ? 'yes' : 'no'));
if (!$this->dataObjectsCache) { // does not use dataObjects Caching..
- $this->debug('generateDataobjectsCache', 'dataObjectsCache - empty');
+ $this->debug('generateDataobjectsCache: dataObjectsCache - empty');
return;
}
$iniCache = $this->DB_DataObject[$dbini];
- if ($force && file_exists($iniCache)) {
- unlink($iniCache);
- clearstatcache();
+ $this->debug('generateDataobjectsCache:' .dirname($iniCache).'/*.ini');
+
+ $replace = array();
+
+ if (file_exists($iniCache)) {
+ $files = glob(dirname($iniCache).'/*.ini');
+ foreach($files as $f) {
+ $replace[$f] = md5(file_get_contents($f)); // hash it..
+
+ }
}
+ $this->debug('generateDataobjectsCache: DONE ini delete');
$iniCacheTmp = $iniCache . '.tmp' .md5(rand()); // random to stop two processes using the same file.
// has it expired..
$this->_exposeToPear(); // this will reset the debug level...
DB_DataObject::DebugLevel($dl);
+ $this->debug('generateDataobjectsCache: running generator');
// DB_DataObject::debugLevel(1);
require_once 'HTML/FlexyFramework/Generator.php';
$generator = new HTML_FlexyFramework_Generator();
$generator->start();
-
- HTML_FlexyFramework_Generator::writeCache($iniCacheTmp, $iniCache);
+ $this->debug('generateDataobjectsCache: done generator');
+
+ HTML_FlexyFramework_Generator::writeCache($iniCacheTmp, $iniCache, $replace);
// reset the cache to the correct lcoation.
$this->DB_DataObject[$dbini] = $iniCache;
- $this->_exposeToPear();
+
+
+ $this->_exposeToPear();
+ DB_DataObject::DebugLevel($dl);
+
//$GLOBALS['_DB_DATAOBJECT']['INI'][$this->database] = parse_ini_file($iniCache, true);
//$GLOBALS['_DB_DATAOBJECT']['SEQUENCE']
// clear any dataobject cache..
/* 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>
if (PEAR::isError($err = $x->getDatabaseConnection())) {
- $this->fatalError("Configuration or Database Error: could not connect to Database, <BR>
- Please check the value given to HTML_FlexyFramework, or run with debug on!<BR>
- <BR> ".$err->toString());
+ $this->fatalError("Configuration or Database Error: could not connect to Database, <BR>
+ Please check the value given to HTML_FlexyFramework, or run with debug on!<BR>
+ <BR> ".$err->toString());
+ }
+ $res = $err->query("SELECT @@global.read_only as 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!
$options['dont_die'] = $dd ;
$classobj->bootLoader = $this;
$classobj->request = $newRequest;
$classobj->timer = &$this->timer;
+ $classobj->cli = $this->cli;
$this->page = $classobj;
if ($this->cli && !$isRedirect ) { // redirect always just takes redirect args..
// echo '<PRE>'; print_r($this);exit;
// echo "CHECK GET AUTH?";
+
if (!method_exists($classobj, 'getAuth')) {
// echo "NO GET AUTH?";
$this->fatalError("class $classname does not have a getAuth Method");
return $result;
}
}
+
/* allow redirect from start */
if (method_exists($classobj,"start")) {
if (is_string($redirect = $classobj->start($subRequest,$isRedirect,$args))) {
}
$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????
}
- $request_array=explode("/",$request);
+ $request_array = explode("/",$request);
$original_request_array = $request_array;
$sub_request_array = array();
$l = count($request_array)-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());
HTML_FlexyFramework::run($this->fatalAction,$msg);
exit;
}
-
+ header('HTTP/1.1 503 Service Temporarily Unavailable');
+ header('Status: 503 Service Temporarily Unavailable');
+ header('Retry-After: 300');
echo $this->cli ? $msg ."\n" : "<H1>$msg</H1>configuration information<PRE>";
if ($showConfig) {