$maxSize) {
$output = substr($string, 0, $maxSize/2).'...'.substr($string, -$maxSize/2);
} else {
$output = $string;
}
return $output;
}
/* Check online if a url is a valid page (Not a 404 error for example) */
function checkUrl($url) {
$h = @get_headers($url);
//look if the page doesn't return a void or 40X or 50X HTTP code error
if(is_array($h) && strpos($h[0], '40') === false && strpos($h[0], '50') === false) {
return true;
} else {
return false;
}
}
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_MODE && ($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_MODE info if we've enabled debug mode and this is an error. This
// prevents debug info being output for general messages should DEBUG_MODE be
// set TRUE by accident (preventing confusion for the end user!)
if (DEBUG_MODE && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) {
if ($debug_text != '')
$msg_text = $msg_text . '
'. T_('DEBUG MODE') .''. $debug_text;
}
echo "\n