<?php

define ("SVR_INF",   0);
define ("SVR_WARN",  1);
define ("SVR_ERR",   2);
define ("SVR_FATAL", 3);

class Err {
    var $code, $p;

    function Err ($code) {
	$this->code=$code;
	$this->p=func_get_args();
    }

    function report () {
	global $errStrings, $errSeverities;
	$format = $errStrings[$this->code];
	if ($format) {
	    return sprintf ($format, $this->p[1], $this->p[2], $this->p[3], $this->p[4]);
	}
	return sprintf ("Unlisted error: %s %s %s %s %s",
		$this->code, $this->p[1], $this->p[2], $this->p[3], $this->p[4]);
    }

    function log () {
	global $script_name;
	return sprintf ("%s: %s '%s' '%s' '%s' '%s'",
		$script_name, $this->code, $this->p[1], $this->p[2], $this->p[3], $this->p[4]);
    }
}

function terminate ($err) {
    global $db;

    echo "Na stránce se vyskytly chyby. Nebude zobrazena správně"."\n</body>\n</html>\n";
   /* $stderr=fopen ("php://stderr","w");
    if ($stderr) {
	fputs ($stderr, $err->log());
	fclose ($stderr);
    }*/
    if ($db) { $db->rollback(); $db->close(); }
    die();

}
?>
