// Handles our errors.
function convert_error_hanlder($error_level, $error_string, $file, $line)
{
// Our error_log
$convert_error_log = dirname(__FILE__) . '/convert_error_log';
// Open the file up for writing (with pointer at end).
$fp = fopen($convert_error_log, 'a+');
$error_string = '';
// Can't open it!
if (!$fp)
$no_write_file = true;
// Lets leave a paper trail.
$backtace = debug_backtrace();
// Generate a simple error message familer to PHP errors.
$error_data = "\r" . $error_level % 255 == E_ERROR ? 'Error' : ($error_level % 255 == E_WARNING ? 'Warning' : 'Notice') . ': ' . $error_string, ' in ' . $file . ' on line ' . $line . "\r" . 'Backtrace report' . "\r" . '---';
// Now loop through our backtrace for output.
foreach ($backtace as $trail)
{
foreach ($trail as $key => $value)
{
if (!is_array($value))
$error_data .= "\t " . $key . " (key): " . $value . "\r";
else
{
$error_data .= "\t" . $key . " (key): " . "\r";
foreach ($value as $vkey => $vvalue)
$error_data .= "\t\t" . $vkey . " (key): " . $vvalue . "\r";
}
}
// Add an extra return.
$error_data .= "\r";
}
// Send it out to the error log. Only if we can though.
if (empty($no_write_file))
{
fwrite($fp, $error_data);
fclose($fp);
}
// Now send something to let the user know.
echo $error_data;
}