$line) { $line = rtrim(preg_replace("/#.*/","",$line)); if (preg_match("/\[.*\]/", $line, $parts)) { $section = $parts[0]; $section = preg_replace("/[\[\]]/","",$section); $config->{$section} = (object)array(); } elseif (preg_match("/=/",$line)) { list($var,$value) = explode('=',$line); $var = preg_replace('/ $/','',$var); $value = preg_replace('/^ +/','',$value); $config->{$section}->{$var} = $value; } } } ## Write to log if debugging is on function Debug($message) { global $config; if ($config->{'general'}->{'debug'}) { BCLog($message); } } ## Write to the log file function BCLog($message) { global $config; $logfile = $config->{'general'}->{'logfile'}; if (! $logfile) { return; } $timestamp = date("Y z H:i:s"); $LOG=fopen($logfile,"a"); $string="$timestamp $message\n"; fwrite($LOG,$string); fclose($LOG); }