class_mcEvent.inc.php 3.62 KB
<?
class mcEvent extends mcReport  {
	/**
	 *	@var int --  errno, contains the level of the error raised
	 */
	private $errno;
	/**
	 * @var string -- errstr, contains the error message
	 */
	private $errstr;
	/**
	 * @var string -- errfile, which contains the filename that the error was raised in
	 */
	private $errfile;
	/**
	 * @var int -- errline, which contains the line number the error was raised at
	 */
	private $errline;
	/**
	 * @var array -- errcontext, which is an array that points to the active symbol
	 *				table at the point the error occurred. In other words,
	 *				errcontext will contain an array of every variable that
	 *				existed in the scope the error was triggered in. User error
	 *				handler must not modify error context.
	 */
	private $errcontext;

	private $array_debug_backtrace = null;
	private $ErrorFunction = null;


	protected function  __construct($param_errno, $param_errstr, $param_errfile=null, $param_errline=null, $param_errcontext=null) {
		$this->errno = $param_errno;
		$this->errstr = $param_errstr;
		$this->errcontext = $param_errcontext;


		$this->array_debug_backtrace = debug_backtrace();
		
		if($param_errfile == null ||  $param_errline == null) {

			$this->ErrorFunction = $this->array_debug_backtrace[2]["class"].$this->array_debug_backtrace[2]["type"]
			.$this->array_debug_backtrace[2]["function"]."(...) :".$this->array_debug_backtrace[1]["line"]."";

			$this->errfile = $this->array_debug_backtrace[1]['file'];
			$this->errline = $this->array_debug_backtrace[1]['line'];

		} else {
			$this->errfile = $param_errfile;
			$this->errline = $param_errline;
		}
	}

	protected function getTextMessage() {
		if(is_null($this->TextMessage)) {
			$this->TextMessage = self::mkMessage($this->errno, $this->errstr, $this->errfile, $this->errline, $this->errcontext, mcCONST::CODEOFFSET);
		}
		return $this->TextMessage;
	}

	private static function mkMessage($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext, $param_offset) {
		$var_message = mcCONST::LINEBREAK.'-------------------------------------------------------------'.mcCONST::LINEBREAK;
		if(array_key_exists($param_errno, Error::$ErrorArray)) {
			$var_message .= 'Typ:'.	mcCONST::TAB.	Error::$ErrorArray[$param_errno].	mcCONST::TAB.	date('d.m.Y  G:i').mcCONST::LINEBREAK;
		} else {
			$var_message .= 'Typ:'.	mcCONST::TAB.$param_errno.	mcCONST::TAB.	date('d. m. Y  G:i').mcCONST::LINEBREAK;
		}
		$var_message .= 'Notice:'.	mcCONST::TAB.	$param_errstr.mcCONST::LINEBREAK;
		$var_message .= 'File:'.	mcCONST::TAB.	$param_errfile.' (row: '.$param_errline.')'.mcCONST::LINEBREAK;
//		$var_message .= 'Url:'.		mcCONST::TAB.	urldecode(http_build_query($_GET)).mcCONST::LINEBREAK;
//		$var_message .= 'PHP: '.	mcCONST::TAB.	PHP_VERSION . ' (' . PHP_OS . ')'.mcCONST::LINEBREAK;
		//		$var_message .= mcCONST::LINEBREAK;
		$var_message .= self::getCodeFromRow($param_errfile, $param_errline, $param_offset);

		$var_message .= mcCONST::LINEBREAK.$param_errcontext.mcCONST::LINEBREAK;
		
		return $var_message;
	}

}

class mcNoticeEvent extends mcEvent {
	public static $count =0;
	public static function handle($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext) {
		self::add(new mcNoticeEvent($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext));
		mcNoticeEvent::$count++;
	}
}

class mcErrorEvent extends mcEvent {
	public static $count =0;
	public static function handle($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext) {
		self::add(new mcErrorEvent($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext));
		mcErrorEvent::$count++;
	}
}