* it will try staging.ini
*
*/
-
+#[AllowDynamicProperties]
class HTML_FlexyFramework {
/**
var $dataObjectsCacheExpires = 72000; // 20 hours..
var $languages = false; // language settings -- see _handlelanguage
var $projectExtends = false; // if this is an array, it's a fallback of 'Projects' that can be called
-
+ var $database_is_readonly = false;
+
// derived.
*/
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';
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..
$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');
$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;
/* 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());
+ }
+ // only applies to mysql...
+
+ if (preg_match('/^mysql/', $this->database)) {
+ $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'])) {
+ if (empty($options['skip-read-only-check'])) {
+ $this->fatalError("Database is configured to be read-only - please check database<BR> ".$err->toString());
+ }
+ $this->database_is_readonly = true;
+ }
}
// reset dont die!
$options['dont_die'] = $dd ;
if (empty($this->HTML_Template_Flexy['compileDir'])) {
return;
}
-
+ clearstatcache();
if ( !file_exists($this->HTML_Template_Flexy['compileDir'])) {
- mkdir($this->HTML_Template_Flexy['compileDir'], 0700);
- @mkdir($this->HTML_Template_Flexy['compileDir'], 0700, true);
+ mkdir($this->HTML_Template_Flexy['compileDir'], 0700, true);
clearstatcache();
if ( !file_exists($this->HTML_Template_Flexy['compileDir'])) {
}
$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????
$sp .= ':'.((int) $_SERVER['SERVER_PORT']);
}
}
- $host = !empty($_SERVER["HTTP_X_FORWARDED_HOST"]) ? $_SERVER["HTTP_X_FORWARDED_HOST"] : $_SERVER["HTTP_HOST"];
+ // not sure why http host would not be set?
+ $host = !empty($_SERVER["HTTP_X_FORWARDED_HOST"]) ? $_SERVER["HTTP_X_FORWARDED_HOST"] :
+ (!isset($_SERVER["HTTP_HOST"]) ? 'localhost' : $_SERVER["HTTP_HOST"]);
+
header('Location: '.$http.'://'.$host .$sp . $this->baseURL);
exit;
}
- $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());