$maxSize) {
$output = substr($string, 0, $maxSize/2).'...'.substr($string, -$maxSize/2);
} else {
$output = $string;
}
return $output;
}
function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '', $db = NULL) {
if(defined('HAS_DIED'))
die(T_('message_die() was called multiple times.'));
define('HAS_DIED', 1);
$sql_store = $sql;
// Get SQL error if we are debugging. Do this as soon as possible to prevent
// subsequent queries from overwriting the status of sql_error()
if (DEBUG && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) {
$sql_error = is_null($db) ? '' : $db->sql_error();
$debug_text = '';
if ($sql_error['message'] != '')
$debug_text .= '
'. T_('SQL Error') .' : '. $sql_error['code'] .' '. $sql_error['message'];
if ($sql_store != '')
$debug_text .= '
'. $sql_store;
if ($err_line != '' && $err_file != '')
$debug_text .= '
'. T_('Line') .' : '. $err_line .'
'. T_('File') .' :'. $err_file;
}
switch($msg_code) {
case GENERAL_MESSAGE:
if ($msg_title == '')
$msg_title = T_('Information');
break;
case CRITICAL_MESSAGE:
if ($msg_title == '')
$msg_title = T_('Critical Information');
break;
case GENERAL_ERROR:
if ($msg_text == '')
$msg_text = T_('An error occured');
if ($msg_title == '')
$msg_title = T_('General Error');
break;
case CRITICAL_ERROR:
// Critical errors mean we cannot rely on _ANY_ DB information being
// available so we're going to dump out a simple echo'd statement
if ($msg_text == '')
$msg_text = T_('An critical error occured');
if ($msg_title == '')
$msg_title = T_('Critical Error');
break;
}
// Add on DEBUG info if we've enabled debug mode and this is an error. This
// prevents debug info being output for general messages should DEBUG be
// set TRUE by accident (preventing confusion for the end user!)
if (DEBUG && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) {
if ($debug_text != '')
$msg_text = $msg_text . '
'. T_('DEBUG MODE') .''. $debug_text;
}
echo "\n