| version 1.6, 2006/07/09 09:26:05 |
version 1.7, 2006/08/18 17:27:33 |
|
|
| * http://platon.sk/projects/Metafox/ |
* http://platon.sk/projects/Metafox/ |
| */ |
*/ |
| |
|
| /* $Platon: Metafox/error.inc.php,v 1.3 2005/11/15 17:16:36 nepto Exp $ */ |
/* $Platon: Metafox/error.inc.php,v 1.6 2006-07-09 09:26:05 nepto Exp $ */ |
| |
|
| require_once 'cfgldr.inc.php'; |
require_once 'cfgldr.inc.php'; |
| require_once 'HTML/Template/Platon.php'; |
require_once 'HTML/Template/Platon.php'; |
| Line 142 function ezin_get_main_template_source($ |
|
| Line 142 function ezin_get_main_template_source($ |
|
| function ezin_error_send_notify_email($err_ar) /* {{{ */ |
function ezin_error_send_notify_email($err_ar) /* {{{ */ |
| { |
{ |
| global $ezin_sys, $ezin_cfg; |
global $ezin_sys, $ezin_cfg; |
| |
$err_ar['error_source'] = Platon::undo_htmlspecialchars(@$err_ar['error_source']); |
| |
$err_ar['error_source'] = preg_replace('|<b>(.*)</b>|', '--> \\1 <--', |
| |
$err_ar['error_source']); |
| |
$err_msg = ''; |
| |
foreach ($err_ar as $key => $val) { |
| |
$err_msg .= sprintf("* %s:%s%s\n", $key, $key == 'error_source' ? "\n\n" : ' ', $val); |
| |
} |
| |
/* |
| |
* Checking existing error log |
| |
*/ |
| |
// TODO: fix the /tmp/ to use something more standard compliant |
| |
$error_log_file = '/tmp/Metafox-error.'.$ezin_cfg['abbreviation'].'.txt'; |
| |
$error_log_mtime = @filemtime($error_log_file); |
| |
$error_log_msg = @file_get_contents($error_log_file); |
| |
if (! strcasecmp(trim($err_msg), trim($error_log_msg)) && time() - $error_log_mtime < 300) { |
| |
return 1; |
| |
} |
| |
/* |
| |
* Error logging |
| |
*/ |
| |
if (($f_log = @fopen($error_log_file, 'w')) != false) { |
| |
fwrite($f_log, $err_msg); |
| |
@fclose($f_log); |
| |
} |
| |
/* |
| |
* E-mail composing |
| |
*/ |
| $from = ''; |
$from = ''; |
| $to = ''; |
$to = ''; |
| $subject = ''; |
$subject = ''; |
| $encoding = ''; |
$encoding = ''; |
| $message = ''; |
$message = ''; |
| $err_ar['error_source'] = Platon::undo_htmlspecialchars(@$err_ar['error_source']); |
|
| $err_ar['error_source'] = preg_replace('|<b>(.*)</b>|', '--> \\1 <--', |
|
| $err_ar['error_source']); |
|
| $tmpl = ezin_load_template($ezin_sys['tmpl']['e-mail']['error'], 1); |
$tmpl = ezin_load_template($ezin_sys['tmpl']['e-mail']['error'], 1); |
| if ($tmpl != false) { |
if ($tmpl != false) { |
| $tmpl = new HTML_Template_Platon($ezin_sys['tmpl']['e-mail']['error']); |
$tmpl = new HTML_Template_Platon($ezin_sys['tmpl']['e-mail']['error']); |
| Line 160 function ezin_error_send_notify_email($e |
|
| Line 184 function ezin_error_send_notify_email($e |
|
| $message .= 'An error has occured on your portal at server time '; |
$message .= 'An error has occured on your portal at server time '; |
| $message .= date($ezin_cfg['format_datetime']) . '.'; |
$message .= date($ezin_cfg['format_datetime']) . '.'; |
| $message .= "\nFull error report follows on the next lines.\n\n"; |
$message .= "\nFull error report follows on the next lines.\n\n"; |
| foreach ($err_ar as $key => $val) { |
$message .= $err_msg; |
| $message .= sprintf("* %s:%s%s\n", $key, $key == 'error_source' ? "\n\n" : ' ', $val); |
|
| } |
|
| $message .= "\nI wish you a fast and effective solution of this problem."; |
$message .= "\nI wish you a fast and effective solution of this problem."; |
| $message .= "\n\nYours,\n\n"; |
$message .= "\n\nYours,\n\n"; |
| $message .= $ezin_sys['software']['name']." on $ezin_cfg[name]\n\n"; |
$message .= $ezin_sys['software']['name']." on $ezin_cfg[name]\n\n"; |
| Line 183 function ezin_error_send_notify_email($e |
|
| Line 205 function ezin_error_send_notify_email($e |
|
| if (strlen($to) <= 0) { |
if (strlen($to) <= 0) { |
| $to = $ezin_cfg['admin_email']; |
$to = $ezin_cfg['admin_email']; |
| } |
} |
| |
/* |
| |
* E-mail sending |
| |
*/ |
| return ezin_email_send($to, $from, $subject, $encoding, $message); |
return ezin_email_send($to, $from, $subject, $encoding, $message); |
| } /* }}} */ |
} /* }}} */ |
| |
|