All pastes #49175 Raw Edit

Miscellany

public text v1 · immutable
#49175 ·published 2006-04-12 16:03 UTC
rendered paste body
<?php
	function error_out ($error, $source = "page", $disablelog = false) {
		if ($source == "page") {
			if ($error == 404 || $error == 403) {
				if (file_exists ("files/" . option_get ("core", "custom$error"))) {
					if (option_get ("core", "logerrors") && !($disablelog)) log_add ("HTTP Error 404: " . $_SERVER["REQUEST_URI"]); 
					if ((include_once "files/" . option_get ("core", "custom$error")) !== false) return (true);
				} else {
					if (option_get ("core", "logerrors") && !($disablelog)) log_add ("Error: '" . locale_text ("error.$error") . "': " . $_SERVER["REQUEST_URI"]); 
					print ("<b style=\"error\">" . locale_text ("error.$error") . "</b>\n");
					return (true);
				}
			}
		} else {
			if (option_get ("core", "logerrors") && !($disablelog)) log_add ("Error: '" . $error . "' from '" . $source . "': " . $_SERVER["REQUEST_URI"]); 
			print ("<b style=\"error\">$source: $error</b>\n");
			return (true);
		}
		return (false);
	}
	
	function log_add ($msg) {
		$log = fopen ("logs/log " . date ("Y-m-d") . ".log", "a");
		if (!fwrite ($log, "[" . date ("H-i-s") . "] " . $msg)) {
			error_out (locale_text ("logwrite"), $disablelog = true);
		}
	}
?>