Index: branches/5.1.x/tools/fix_perms.sh =================================================================== diff -u -N -r12127 -r13393 --- branches/5.1.x/tools/fix_perms.sh (.../fix_perms.sh) (revision 12127) +++ branches/5.1.x/tools/fix_perms.sh (.../fix_perms.sh) (revision 13393) @@ -1,4 +1,4 @@ -touch ../config.php +touch ../system/config.php -chmod -R 777 ../system ../themes ../config.php +chmod -R 777 ../system Index: branches/5.1.x/core/install/install_toolkit.php =================================================================== diff -u -N -r13392 -r13393 --- branches/5.1.x/core/install/install_toolkit.php (.../install_toolkit.php) (revision 13392) +++ branches/5.1.x/core/install/install_toolkit.php (.../install_toolkit.php) (revision 13393) @@ -1,6 +1,6 @@ INIFile)) { - return Array(); + return Array (); } - if( file_exists($this->INIFile) && !is_readable($this->INIFile) ) { + if (file_exists($this->INIFile) && !is_readable($this->INIFile)) { die('Could Not Open Ini File'); } $contents = file($this->INIFile); - $retval = Array(); - $section = ''; - $ln = 1; - $resave = false; - foreach ($contents as $line) { - if ($ln == 1 && $line != '<'.'?'.'php die() ?'.">\n") { - $resave = true; - } + if ($contents && $contents[0] == '<' . '?' . 'php die() ?' . ">\n") { + // format of "config.php" file before 5.1.0 version + array_shift($contents); - $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); - } - } - } + return $this->parseIniString(implode('', $contents), $parse_section); } - if ($resave) { - $fp = fopen($this->INIFile, 'w'); - reset($contents); - fwrite($fp,'<'.'?'.'php die() ?'.">\n\n"); - foreach ($contents as $line) { - fwrite($fp,"$line"); - } - fclose($fp); - } + $_CONFIG = Array (); + require($this->INIFile); - return $retval; + if ($parse_section) { + return $_CONFIG; + } + + $ret = Array (); + + foreach ($_CONFIG as $section => $section_variables) { + $ret = array_merge($ret, $section_variables); + } + + return $ret; } + /** + * 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 parseIniString($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; + } + function SaveConfig($silent = false) { if (!is_writable($this->INIFile) && !is_writable(dirname($this->INIFile))) { @@ -515,15 +512,16 @@ } $fp = fopen($this->INIFile, 'w'); - fwrite($fp,'<'.'?'.'php die() ?'.">\n\n"); + fwrite($fp, '<' . '?' . 'php' . "\n\n"); foreach ($this->systemConfig as $section_name => $section_data) { - fwrite($fp, '['.$section_name."]\n"); foreach ($section_data as $key => $value) { - fwrite($fp, $key.' = "'.$value.'"'."\n"); + fwrite($fp, '$_CONFIG[\'' . $section_name . '\'][\'' . $key . '\'] = \'' . addslashes($value) . '\';' . "\n"); } + fwrite($fp, "\n"); } + fclose($fp); } Index: branches/5.1.x/core/install/upgrades.php =================================================================== diff -u -N -r13151 -r13393 --- branches/5.1.x/core/install/upgrades.php (.../upgrades.php) (revision 13151) +++ branches/5.1.x/core/install/upgrades.php (.../upgrades.php) (revision 13393) @@ -1,6 +1,6 @@ Conn->Query('DROP TABLE IF EXISTS ' . TABLE_PREFIX . 'Phrase'); $this->Conn->Query('RENAME TABLE ' . $temp_table . ' TO ' . TABLE_PREFIX . 'Phrase'); + + // save "config.php" in php format, not ini format as before + $this->_toolkit->SaveConfig(); } } } \ No newline at end of file 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()