{'.get_class($this).'}
'.$string_output;
$string_output .= '
Script Run Time: '.$script_end.'
';
$string_output .= '
';
}
}
return $string_output;
}
// METHOD write_error_msg
// PARAMS $level: the level to write
// RETURN none
// DESCRIPTION
// writes error msg data to file for current level
private function write_error_msg($level, $error_string)
{
if (($this->debug_output[$level] || $this->debug_output_all) && !$this->debug_output_not[$level])
{
// only write if write is requested
if (($this->print_output[$level] || $this->print_output_all) && !$this->print_output_not[$level])
{
// replace all html tags
// $error_string = preg_replace("/(<\/?)(\w+)([^>]*>)/", "##\\2##", $error_string);
// $error_string = preg_replace("/(<\/?)(\w+)([^>]*>)/", "", $error_string);
// replace special line break tag
// $error_string = str_replace('', "\n", $error_string);
// init output variable
$output = $error_string; // output formated error string to output file
// init base file path
$fn = ROOT.LOG.$this->log_print_file.'.'.$this->log_file_name_ext;
if ($this->log_per_run)
{
if ($GLOBALS['LOG_FILE_UNIQUE_ID'])
$this->log_file_unique_id = $GLOBALS['LOG_FILE_UNIQUE_ID'];
if (!$this->log_file_unique_id)
$GLOBALS['LOG_FILE_UNIQUE_ID'] = $this->log_file_unique_id = date('Y-m-d_His').'_U_'.substr(hash('sha1', uniqid(mt_rand(), true)), 0, 8);
$rpl_string = '_'.$this->log_file_unique_id; // add 8 char unique string
}
else
{
$rpl_string = !$this->log_print_file_date ? '' : '_'.date('Y-m-d'); // add date to file
}
$fn = str_replace('##DATE##', $rpl_string, $fn); // create output filename
$rpl_string = !$this->log_per_level ? '' : '_'.$level; // if request to write to one file
$fn = str_replace('##LEVEL##', $rpl_string, $fn); // create output filename
$rpl_string = !$this->log_per_class ? '' : '_'.get_class($this); // set sub class settings
$fn = str_replace('##CLASS##', $rpl_string, $fn); // create output filename
$rpl_string = !$this->log_per_page ? '' : '_'.$this->get_page_name(1); // if request to write to one file
$fn = str_replace('##PAGENAME##', $rpl_string, $fn); // create output filename
// write to file
// first check if max file size is is set and file is bigger
if ($this->log_max_filesize > 0 && ((filesize($fn) / 1024) > $this->log_max_filesize))
{
// for easy purpose, rename file only to attach timestamp, nur sequence numbering
rename($fn, $fn.'.'.date("YmdHis"));
}
$fp = fopen($fn, 'a');
if ($fp !== false)
{
fwrite($fp, $output);
fclose($fp);
}
else
{
echo "";
}
} // do write to file
}
}
// METHOD reset_error_msg
// PARAMS level -> optional level
// RETURN none
// DESC unsests the error message array
// can be used if writing is primary to file
// if no level given resets all
public function reset_error_msg($level = '')
{
if (!$level)
unset($this->error_msg);
else
unset($this->error_msg[$level]);
}
// METHOD ErrorHandler
// PARAMS none
// RETURN none
// DESC catch function to handle all errors that are not handled by php itself
// eg all errors that would be surpressed are written to a log file if this function is enabled
// to use it call with set_error_handler(array("baisc", "ErrorHandler"));
// NOTE: this will only catch any additional erros created AFTER the set_error_hanlder was set, so mostly no strict/notices from the classes are visible
public static function ErrorHandler($type, $message, $file, $line, $context)
{
// error levels for PHP
// values based on 5.3
$error_level = array (
1 => 'E_ERROR',
2 => 'E_WARNING',
4 => 'E_PARSE',
8 => 'E_NOTICE',
16 => 'E_CORE_ERROR',
32 => 'E_CORE_WARNING',
64 => 'E_COMPILE_ERROR',
128 => 'E_COMPILE_WARNING',
256 => 'E_USER_ERROR',
512 => 'E_USER_WARNING',
1024 => 'E_USER_NOTICE',
2048 => 'E_STRICT',
4096 => 'E_RECOVERABLE_ERROR', // since 5.2
8192 => 'E_DEPRICATED', // since 5.3
16384 => 'E_USER_DEPRICATED', // since 5.3
30719 => 'E_ALL' // 6143 in 5.2, 2047 in previous versions
);
$fn = ROOT.LOG.'php_errors-'.date('Y-m-d').'.log';
$output = '['.basic::print_time().'] {'.basic::get_page_name().'} ['.$file.'] <'.$line.'> ['.$error_level[$type].'|'.$type.']: '.$message."\n";
$fp = fopen($fn, 'a');
fwrite($fp, $output);
fclose($fp);
return false;
}
// METHOD print_ar
// PARAMS $array
// RETURN string html formatted
// DESCRIPTION
// prints a html formatted (pre) array
public static function print_ar($array)
{
return "