Index: trunk/globals.php =================================================================== diff -u -r1442 -r1566 --- trunk/globals.php (.../globals.php) (revision 1442) +++ trunk/globals.php (.../globals.php) (revision 1566) @@ -1,5 +1,58 @@ \n") { + $resave = true; + } + $ln++; + $line = trim($line); + $line = eregi_replace(';[.]*','',$line); + if(strlen($line) > 0) { + //echo $line . " - "; + if(eregi('^[[a-z]+]$',str_replace(' ', '', $line))) { + //echo 'section'; + $section = substr($line,1,(strlen($line)-2)); + if ($parse_section) { + $retval[$section] = array(); + } + continue; + } elseif(eregi('=',$line)) { + //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); + } + + return $retval; + } +} + $vars = parse_portal_ini($pathtoroot."config.php"); while($key = key($vars)) @@ -32,58 +85,6 @@ $LogLevel=0; $LogFile = NULL; - -function parse_portal_ini($file, $parse_section = false) { - if(!file_exists($file) && !is_readable($file)) - die('Could Not Open Ini File'); - - $contents = file($file); - - $retval = array(); - - $section = ''; - $ln = 1; - $resave = false; - foreach($contents as $line) { - if ($ln == 1 && $line != '<'.'?'.'php die() ?'.">\n") { - $resave = true; - } - $ln++; - $line = trim($line); - $line = eregi_replace(';[.]*','',$line); - if(strlen($line) > 0) { - //echo $line . " - "; - if(eregi('^[[a-z]+]$',str_replace(' ', '', $line))) { - //echo 'section'; - $section = substr($line,1,(strlen($line)-2)); - if ($parse_section) { - $retval[$section] = array(); - } - continue; - } elseif(eregi('=',$line)) { - //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); - } - - return $retval; -} - /** * @return object * @desc Returns reference to database connection @@ -741,12 +742,15 @@ return $ret; } -function getmicrotime() -{ - list($usec, $sec) = explode(" ",microtime()); - return ((float)$usec + (float)$sec); -} +if (!function_exists( 'getmicrotime' ) ) { + function getmicrotime() + { + list($usec, $sec) = explode(" ",microtime()); + return ((float)$usec + (float)$sec); + } +} + function SetMissingDataErrors($f) { global $FormError; @@ -1367,10 +1371,12 @@ return $x; } -function print_pre($str) -{ - // no comments here :) - echo '
'.print_r($str, true).'
'; +if (!function_exists('print_pre')) { + function print_pre($str) + { + // no comments here :) + echo '
'.print_r($str, true).'
'; + } } function GetOptions($field) // by Alex @@ -1566,18 +1572,20 @@ if($SFValue == 1 || $SFValue == 2) $list->Clear(); } -/** - * Returns array value if key exists - * - * @param Array $aArray - * @param int $aIndex - * @return string - */ -function getArrayValue(&$aArray, $aIndex) +if( !function_exists('getArrayValue') ) { - return isset($aArray[$aIndex]) ? $aArray[$aIndex] : false; + /** + * Returns array value if key exists + * + * @param Array $aArray + * @param int $aIndex + * @return string + */ + function getArrayValue(&$aArray, $aIndex) + { + return isset($aArray[$aIndex]) ? $aArray[$aIndex] : false; + } } - function MakeHTMLTag($element, $attrib_prefix) { $result = Array();