Index: branches/5.1.x/core/kernel/globals.php =================================================================== diff -u -N -r13392 -r13393 --- branches/5.1.x/core/kernel/globals.php (.../globals.php) (revision 13392) +++ branches/5.1.x/core/kernel/globals.php (.../globals.php) (revision 13393) @@ -1,6 +1,6 @@ \n") { - $resave = true; - } - $ln++; - $line = trim($line); - $line = preg_replace('/;[.]*/', '', $line); - if(strlen($line) > 0) { - //echo $line . " - "; - if (preg_match('/^\[[a-z]+\]$/i', str_replace(' ', '', $line))) { - //echo 'section'; - $section = mb_substr($line,1,(mb_strlen($line)-2)); - if ($parse_section) { - $retval[$section] = array(); - } - continue; - } elseif(strpos($line, '=') !== false) { - //echo 'main element'; - list($key,$val) = explode(' = ',$line); - if (!$parse_section) { - $retval[trim($key)] = str_replace('"', '', $val); - } - else { - $retval[$section][trim($key)] = str_replace('"', '', $val); - } - } //end if - //echo '
'; - } //end if - } //end foreach - if($resave) - { - $fp = fopen($file, 'w'); - reset($contents); - fwrite($fp,'<'.'?'.'php die() ?'.">\n\n"); - foreach($contents as $line) fwrite($fp,"$line"); - fclose($fp); - } + if ($contents && $contents[0] == '<' . '?' . 'php die() ?' . ">\n") { + // format of "config.php" file before 5.1.0 version + array_shift($contents); - return $retval; + return parse_ini_string(implode('', $contents), $parse_section); + } + + $_CONFIG = Array (); + require($file); + + if ($parse_section) { + return $_CONFIG; + } + + $ret = Array (); + + foreach ($_CONFIG as $section => $section_variables) { + $ret = array_merge($ret, $section_variables); + } + + return $ret; } +if ( !function_exists('parse_ini_string') ) { + /** + * Equivalent for "parse_ini_string" function available since PHP 5.3.0 + * + * @param string $ini + * @param bool $process_sections + * @param int $scanner_mode + * @return Array + */ + function parse_ini_string($ini, $process_sections = false, $scanner_mode = null) + { + # Generate a temporary file. + $tempname = tempnam('/tmp', 'ini'); + $fp = fopen($tempname, 'w'); + fwrite($fp, $ini); + $ini = parse_ini_file($tempname, !empty($process_sections)); + fclose($fp); + @unlink($tempname); + + return $ini; + } +} + if( !function_exists('getmicrotime') ) { function getmicrotime()