Initial commit

This commit is contained in:
Frank Schubert
2021-03-29 23:04:42 +02:00
commit 4ea4927931
3737 changed files with 709905 additions and 0 deletions
@@ -0,0 +1,45 @@
<?php
class mfExceptionhandler {
private $Code;
private $Message;
private $timestamp;
private $Time;
private $Trace;
private $TraceS;
public function __construct(Exception $e) {
$this->Code=(int)$e->getCode();
$this->Message=$e->getMessage();
$this->timestamp=date('U');
$this->Time=date('Y-m-s H:i:s',$this->timestamp);
$this->Trace = $e->getTrace();
$this->TraceS = $e->getTraceAsString();
}
public function getTrace() {
return $this->Trace;
}
public function getTraceAsString() {
return $this->TraceS;
}
public function __toString() {
$str="[".$this->Time."] ";
if(is_numeric($this->Code) && $this->Code > 0) {
$str.="(Error code ".$this->Code.") ";
}
$str.=$this->Message;
return (string) $str;
}
public function __get($name) {
if(property_exists($this, $name)) {
return $this->$name;
}
return null;
}
}
@@ -0,0 +1,42 @@
<?php
class mfExceptionhandlerController {
private $log;
private $Layout;
private $Exception;
public function __construct(Exception $e) {
$this->log=mfLoghandler::singleton();
$this->Layout=Layout::singleton();
$this->Exception=new mfExceptionhandler($e);
$this->logException();
$this->displayException();
}
private function displayException() {
$template="mfExceptionhandler/mfExceptionhandler.cli";
if(defined("mfUI") && mfUI!="cli") {
$template="mfExceptionhandler/mfExceptionhandler.web";
$code=$this->Exception->Code;
if($code) {
$template="mfExceptionhandler/error_$code";
if(!file_exists(VIEWDIR."/".$template.".php")) {
$template="mfExceptionhandler/mfExceptionhandler.web";
}
}
}
$this->Layout->setTemplate($template);
$this->Layout->set("Exception",$this->Exception);
$this->Layout->display();
if($code) {
exit($code);
}
exit(1);
}
private function logException() {
$this->log->crit("Unhandled Exception: (".$this->Exception->Code.") ".$this->Exception->Message);
}
}