=10) the app will die. 10 has more priority than 1 */ function error($msg, $file="", $line="", $priority=5) { global $config,$abs; if($config['mode'] == 'd' or $config['mode'] == 't') { print <<

Error!

$msg

END; if($file and $line) { $line = $line - 1; print "In file '$file' at line $line..
";
			
			//Get the 5 lines surronding the error lines - before and after
			$lines = explode("\n",file_get_contents($file));
			for($i=$line-5; $i<$line+5; $i++) {
				if($i == $line) print '';
				print "\n$i) ";
				print str_replace(
					array('<',"\t"),
					array('<','  '),
					$lines[$i]
				);//Trim it?
				if($i == $line) print '';
			}
			print '
'; } print '
'; exit(); } else { if($priority >= 10) die($msg); } } /** * Shows the status of the system. If there is many success message, it will show up as a list. If there is just 1, * it shows as a div message. Same goes for error message - it uses a different classname. Success uses the classname * 'message-success' and Errors use the classname 'message-error' */ function showStatus() { global $QUERY; if($QUERY['success']) { if(is_array($QUERY['success'])) { print "\n"; } else { print "
$QUERY[success]
\n"; } } if($QUERY['error']) { if(is_array($QUERY['error'])) { print "\n"; } else { print "
$QUERY[error]
\n"; } } } /** * Shows the final message - redirects to a new page with the message in the URL */ function showMessage($message, $url='', $status="success",$extra_data=array(), $use_existing_params=true) { //If it is an ajax request, Just print the data if(isset($_REQUEST['ajax'])) { $success = ''; $error = ''; $insert_id = ''; if($status == 'success') $success = $message; if($status == 'error' or $status == 'failure') $error = $message; $data = array( "success" => $success, "error" => $error ) + $extra_data; print json_encode($data); } elseif(isset($_REQUEST['layout']) and $_REQUEST['layout']==='cli') { if($status === 'success') print $message . "\n"; } else { if(!$url) { global $QUERY; $QUERY[$status] = $message; return; } if(strpos($url, 'http://') === false) { global $config; $url = joinPath($config['site_url'], $url); } $goto = str_replace('&', '&', getLink($url, array($status=>$message) + $extra_data, $use_existing_params)); header("Location:$goto"); } exit; } /** * Converts the given MySQL Date format to PHP date formatting string. %Y-%m-%d becomes Y-m-d. */ function phpDateFormat($format_string) { $replace_rules = array( '%a' => 'D', '%b' => 'M', '%c' => 'n', '%D' => 'jS', '%e' => 'j', '%f' => 'u', '%j' => 'z', '%k' => 'G', '%l' => 'g', '%p' => 'A', '%r' => 'h:i:s A', '%S' => 's', '%T' => 'H:i:s', '%U' => 'W', // Limited functionality. '%u' => 'W', '%v' => 'W', // Limited functionality. '%V' => 'W', // Limited functionality. '%W' => 'l', '%' => '' ); return str_replace(array_keys($replace_rules), array_values($replace_rules), $format_string); }