diff --git a/dibi/Nette/IDebugPanel.php b/dibi/Nette/IDebugPanel.php deleted file mode 100644 index 9363886f..00000000 --- a/dibi/Nette/IDebugPanel.php +++ /dev/null @@ -1,44 +0,0 @@ - 'Internal error.', - PREG_BACKTRACK_LIMIT_ERROR => 'Backtrack limit was exhausted.', - PREG_RECURSION_LIMIT_ERROR => 'Recursion limit was exhausted.', - PREG_BAD_UTF8_ERROR => 'Malformed UTF-8 data.', - 5 => 'Offset didn\'t correspond to the begin of a valid UTF-8 code point.', // PREG_BAD_UTF8_OFFSET_ERROR - ); - $code = preg_last_error(); - parent::__construct(isset($messages[$code]) ? $messages[$code] : 'Unknown error.', $code); - } - } -} - -if (!interface_exists(/*Nette\*/'IDebugPanel', FALSE)) { - require_once dirname(__FILE__) . '/Nette/IDebugPanel.php'; -} - -if (!class_exists('DateTime53', FALSE)) { require_once dirname(__FILE__) . '/Nette/DateTime53.php'; } +/** @package exceptions */ +class PcreException extends Exception { + + public function __construct($message = '%msg.') + { + static $messages = array( + PREG_INTERNAL_ERROR => 'Internal error', + PREG_BACKTRACK_LIMIT_ERROR => 'Backtrack limit was exhausted', + PREG_RECURSION_LIMIT_ERROR => 'Recursion limit was exhausted', + PREG_BAD_UTF8_ERROR => 'Malformed UTF-8 data', + 5 => 'Offset didn\'t correspond to the begin of a valid UTF-8 code point', // PREG_BAD_UTF8_OFFSET_ERROR + ); + $code = preg_last_error(); + parent::__construct(str_replace('%msg', isset($messages[$code]) ? $messages[$code] : 'Unknown error', $message), $code); + } +} + + /** * @deprecated diff --git a/dibi/libs/DibiException.php b/dibi/libs/DibiException.php index 98ae10b5..93dcbbfc 100644 --- a/dibi/libs/DibiException.php +++ b/dibi/libs/DibiException.php @@ -18,7 +18,7 @@ * @copyright Copyright (c) 2005, 2010 David Grudl * @package dibi */ -class DibiException extends Exception implements /*Nette\*/IDebugPanel +class DibiException extends Exception implements IDebugPanel { /** @var string */ private $sql; diff --git a/dibi/libs/DibiObject.php b/dibi/libs/DibiObject.php index 4434265f..6b023ddd 100644 --- a/dibi/libs/DibiObject.php +++ b/dibi/libs/DibiObject.php @@ -77,7 +77,7 @@ abstract class DibiObject */ final public function getReflection() { - return new /*\*/ReflectionObject($this); + return new ReflectionObject($this); } @@ -94,15 +94,15 @@ abstract class DibiObject $class = get_class($this); if ($name === '') { - throw new /*\*/MemberAccessException("Call to class '$class' method without name."); + throw new MemberAccessException("Call to class '$class' method without name."); } // event functionality if (preg_match('#^on[A-Z]#', $name)) { - $rp = new /*\*/ReflectionProperty($class, $name); + $rp = new ReflectionProperty($class, $name); if ($rp->isPublic() && !$rp->isStatic()) { $list = $this->$name; - if (is_array($list) || $list instanceof /*\*/Traversable) { + if (is_array($list) || $list instanceof Traversable) { foreach ($list as $handler) { /**/if (is_object($handler)) { call_user_func_array(array($handler, '__invoke'), $args); @@ -122,7 +122,7 @@ abstract class DibiObject return call_user_func_array($cb, $args); } - throw new /*\*/MemberAccessException("Call to undefined method $class::$name()."); + throw new MemberAccessException("Call to undefined method $class::$name()."); } @@ -137,7 +137,7 @@ abstract class DibiObject public static function __callStatic($name, $args) { $class = get_called_class(); - throw new /*\*/MemberAccessException("Call to undefined static method $class::$name()."); + throw new MemberAccessException("Call to undefined static method $class::$name()."); } @@ -215,7 +215,7 @@ abstract class DibiObject $class = get_class($this); if ($name === '') { - throw new /*\*/MemberAccessException("Cannot read a class '$class' property without name."); + throw new MemberAccessException("Cannot read a class '$class' property without name."); } // property getter support @@ -236,7 +236,7 @@ abstract class DibiObject } $name = func_get_arg(0); - throw new /*\*/MemberAccessException("Cannot read an undeclared property $class::\$$name."); + throw new MemberAccessException("Cannot read an undeclared property $class::\$$name."); } @@ -253,7 +253,7 @@ abstract class DibiObject $class = get_class($this); if ($name === '') { - throw new /*\*/MemberAccessException("Cannot assign to a class '$class' property without name."); + throw new MemberAccessException("Cannot assign to a class '$class' property without name."); } // property setter support @@ -266,12 +266,12 @@ abstract class DibiObject } else { $name = func_get_arg(0); - throw new /*\*/MemberAccessException("Cannot assign to a read-only property $class::\$$name."); + throw new MemberAccessException("Cannot assign to a read-only property $class::\$$name."); } } $name = func_get_arg(0); - throw new /*\*/MemberAccessException("Cannot assign to an undeclared property $class::\$$name."); + throw new MemberAccessException("Cannot assign to an undeclared property $class::\$$name."); } @@ -298,7 +298,7 @@ abstract class DibiObject public function __unset($name) { $class = get_class($this); - throw new /*\*/MemberAccessException("Cannot unset the property $class::\$$name."); + throw new MemberAccessException("Cannot unset the property $class::\$$name."); } diff --git a/dibi/libs/DibiProfiler.php b/dibi/libs/DibiProfiler.php index fb653c80..5fe393a1 100644 --- a/dibi/libs/DibiProfiler.php +++ b/dibi/libs/DibiProfiler.php @@ -22,7 +22,7 @@ * @copyright Copyright (c) 2005, 2010 David Grudl * @package dibi */ -class DibiProfiler extends DibiObject implements IDibiProfiler, /*Nette\*/IDebugPanel +class DibiProfiler extends DibiObject implements IDibiProfiler, IDebugPanel { /** maximum number of rows */ static public $maxQueries = 30; @@ -52,8 +52,12 @@ class DibiProfiler extends DibiObject implements IDibiProfiler, /*Nette\*/IDebug public function __construct(array $config) { - if (class_exists(/*Nette\*/'Debug', FALSE) && is_callable(/*Nette\*/'Debug::addPanel')) { - /*Nette\*/Debug::addPanel($this); + if (is_callable('Nette\Debug::addPanel')) { + call_user_func('Nette\Debug::addPanel', $this); + } elseif (is_callable('NDebug::addPanel')) { + NDebug::addPanel($this); + } elseif (is_callable('Debug::addPanel')) { + Debug::addPanel($this); } $this->useFirebug = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'FirePHP/'); diff --git a/examples/Nette/Debug.php b/examples/Nette/Debug.php index 6ce844a5..df2413f6 100644 --- a/examples/Nette/Debug.php +++ b/examples/Nette/Debug.php @@ -7,7 +7,7 @@ * This source file is subject to the "Nette license" that is bundled * with this package in the file license.txt, and/or GPL license. * - * For more information please see http://nette.org + * For more information please see http://nettephp.com * * @copyright Copyright (c) 2004, 2010 David Grudl * @license http://nette.org/license Nette license @@ -24,6 +24,7 @@ static$consoleMode;public static$time;private static$firebugDetected;private static$ajaxDetected;public +static$source;public static$maxDepth=3;public static$maxLen=150;public static$showLocation=FALSE;const @@ -31,6 +32,7 @@ DEVELOPMENT=FALSE;const PRODUCTION=TRUE;const DETECT=NULL;public static$strictMode=FALSE;public +static$scream=FALSE;public static$onFatalError=array();public static$mailer=array(__CLASS__,'defaultMailer');public static$emailSnooze=172800;private @@ -44,10 +46,10 @@ static$panels=array();private static$dumps;private static$errors;public static$counters=array();const -LOG='LOG';const INFO='INFO';const -WARN='WARN';const ERROR='ERROR';const +LOG='LOG';const +WARN='WARN';const TRACE='TRACE';const EXCEPTION='EXCEPTION';const GROUP_START='GROUP_START';const @@ -59,7 +61,7 @@ new LogicException("Cannot instantiate static class ".get_class($this));}public static function -_init(){self::$time=microtime(TRUE);self::$consoleMode=PHP_SAPI==='cli';self::$productionMode=self::DETECT;self::$firebugDetected=isset($_SERVER['HTTP_USER_AGENT'])&&strpos($_SERVER['HTTP_USER_AGENT'],'FirePHP/');self::$ajaxDetected=isset($_SERVER['HTTP_X_REQUESTED_WITH'])&&$_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest';$tab=array(__CLASS__,'renderTab');$panel=array(__CLASS__,'renderPanel');self::addPanel(new +_init(){self::$time=microtime(TRUE);self::$consoleMode=PHP_SAPI==='cli';self::$productionMode=self::DETECT;if(self::$consoleMode){self::$source=empty($_SERVER['argv'])?'cli':'cli: '.$_SERVER['argv'][0];}else{self::$firebugDetected=isset($_SERVER['HTTP_USER_AGENT'])&&strpos($_SERVER['HTTP_USER_AGENT'],'FirePHP/');self::$ajaxDetected=isset($_SERVER['HTTP_X_REQUESTED_WITH'])&&$_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest';if(isset($_SERVER['REQUEST_URI'])){self::$source=(isset($_SERVER['HTTPS'])&&strcasecmp($_SERVER['HTTPS'],'off')?'https://':'http://').(isset($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:(isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:'')).$_SERVER['REQUEST_URI'];}}$tab=array(__CLASS__,'renderTab');$panel=array(__CLASS__,'renderPanel');self::addPanel(new DebugPanel('time',$tab,$panel));self::addPanel(new DebugPanel('memory',$tab,$panel));self::addPanel(new DebugPanel('errors',$tab,$panel));self::addPanel(new @@ -72,16 +74,16 @@ function barDump($var,$title=NULL){if(!self::$productionMode){$dump=array();foreach((is_array($var)?$var:array(''=>$var))as$key=>$val){$dump[$key]=self::dump($val,TRUE);}self::$dumps[]=array('title'=>$title,'dump'=>$dump);}return$var;}private static function -_dump(&$var,$level){static$tableUtf,$tableBin,$re='#[^\x09\x0A\x0D\x20-\x7E\xA0-\x{10FFFF}]#u';if($tableUtf===NULL){foreach(range("\x00","\xFF")as$ch){if(ord($ch)<32&&strpos("\r\n\t",$ch)===FALSE)$tableUtf[$ch]=$tableBin[$ch]='\\x'.str_pad(dechex(ord($ch)),2,'0',STR_PAD_LEFT);elseif(ord($ch)<127)$tableUtf[$ch]=$tableBin[$ch]=$ch;else{$tableUtf[$ch]=$ch;$tableBin[$ch]='\\x'.dechex(ord($ch));}}$tableUtf['\\x']=$tableBin['\\x']='\\\\x';}if(is_bool($var)){return"bool(".($var?'TRUE':'FALSE').")\n";}elseif($var===NULL){return"NULL\n";}elseif(is_int($var)){return"int($var)\n";}elseif(is_float($var)){return"float($var)\n";}elseif(is_string($var)){if(self::$maxLen&&strlen($var)>self::$maxLen){$s=htmlSpecialChars(substr($var,0,self::$maxLen),ENT_NOQUOTES).' ... ';}else{$s=htmlSpecialChars($var,ENT_NOQUOTES);}$s=strtr($s,preg_match($re,$s)||preg_last_error()?$tableBin:$tableUtf);return"string(".strlen($var).") \"$s\"\n";}elseif(is_array($var)){$s="array(".count($var).") ";$space=str_repeat($space1=' ',$level);static$marker;if($marker===NULL)$marker=uniqid("\x00",TRUE);if(empty($var)){}elseif(isset($var[$marker])){$s.="{\n$space$space1*RECURSION*\n$space}";}elseif($level{\n";$var[$marker]=0;foreach($var -as$k=>&$v){if($k===$marker)continue;$k=is_int($k)?$k:'"'.strtr($k,preg_match($re,$k)||preg_last_error()?$tableBin:$tableUtf).'"';$s.="$space$space1$k => ".self::_dump($v,$level+1);}unset($var[$marker]);$s.="$space}";}else{$s.="{\n$space$space1...\n$space}";}return$s."\n";}elseif(is_object($var)){$arr=(array)$var;$s="object(".get_class($var).") (".count($arr).") ";$space=str_repeat($space1=' ',$level);static$list=array();if(empty($arr)){$s.="{}";}elseif(in_array($var,$list,TRUE)){$s.="{\n$space$space1*RECURSION*\n$space}";}elseif($level{\n";$list[]=$var;foreach($arr -as$k=>&$v){$m='';if($k[0]==="\x00"){$m=$k[1]==='*'?' protected':' private';$k=substr($k,strrpos($k,"\x00")+1);}$k=strtr($k,preg_match($re,$k)||preg_last_error()?$tableBin:$tableUtf);$s.="$space$space1\"$k\"$m => ".self::_dump($v,$level+1);}array_pop($list);$s.="$space}";}else{$s.="{\n$space$space1...\n$space}";}return$s."\n";}elseif(is_resource($var)){return"resource of type(".get_resource_type($var).")\n";}else{return"unknown type\n";}}public +_dump(&$var,$level){static$tableUtf,$tableBin,$reBinary='#[^\x09\x0A\x0D\x20-\x7E\xA0-\x{10FFFF}]#u';if($tableUtf===NULL){foreach(range("\x00","\xFF")as$ch){if(ord($ch)<32&&strpos("\r\n\t",$ch)===FALSE)$tableUtf[$ch]=$tableBin[$ch]='\\x'.str_pad(dechex(ord($ch)),2,'0',STR_PAD_LEFT);elseif(ord($ch)<127)$tableUtf[$ch]=$tableBin[$ch]=$ch;else{$tableUtf[$ch]=$ch;$tableBin[$ch]='\\x'.dechex(ord($ch));}}$tableBin["\\"]='\\\\';$tableBin["\r"]='\\r';$tableBin["\n"]='\\n';$tableBin["\t"]='\\t';$tableUtf['\\x']=$tableBin['\\x']='\\\\x';}if(is_bool($var)){return($var?'TRUE':'FALSE')."\n";}elseif($var===NULL){return"NULL\n";}elseif(is_int($var)){return"$var\n";}elseif(is_float($var)){$var=(string)$var;if(strpos($var,'.')===FALSE)$var.='.0';return"$var\n";}elseif(is_string($var)){if(self::$maxLen&&strlen($var)>self::$maxLen){$s=htmlSpecialChars(substr($var,0,self::$maxLen),ENT_NOQUOTES).' ... ';}else{$s=htmlSpecialChars($var,ENT_NOQUOTES);}$s=strtr($s,preg_match($reBinary,$s)||preg_last_error()?$tableBin:$tableUtf);$len=strlen($var);return"\"$s\"".($len>1?" ($len)":"")."\n";}elseif(is_array($var)){$s="array(".count($var).") ";$space=str_repeat($space1=' ',$level);$brackets=range(0,count($var)-1)===array_keys($var)?"[]":"{}";static$marker;if($marker===NULL)$marker=uniqid("\x00",TRUE);if(empty($var)){}elseif(isset($var[$marker])){$brackets=$var[$marker];$s.="$brackets[0] *RECURSION* $brackets[1]";}elseif($level$brackets[0]\n";$var[$marker]=$brackets;foreach($var +as$k=>&$v){if($k===$marker)continue;$k=is_int($k)?$k:'"'.strtr($k,preg_match($reBinary,$k)||preg_last_error()?$tableBin:$tableUtf).'"';$s.="$space$space1$k => ".self::_dump($v,$level+1);}unset($var[$marker]);$s.="$space$brackets[1]";}else{$s.="$brackets[0] ... $brackets[1]";}return$s."\n";}elseif(is_object($var)){$arr=(array)$var;$s="".get_class($var)."(".count($arr).") ";$space=str_repeat($space1=' ',$level);static$list=array();if(empty($arr)){}elseif(in_array($var,$list,TRUE)){$s.="{ *RECURSION* }";}elseif($level{\n";$list[]=$var;foreach($arr +as$k=>&$v){$m='';if($k[0]==="\x00"){$m=$k[1]==='*'?' protected':' private';$k=substr($k,strrpos($k,"\x00")+1);}$k=strtr($k,preg_match($reBinary,$k)||preg_last_error()?$tableBin:$tableUtf);$s.="$space$space1\"$k\"$m => ".self::_dump($v,$level+1);}array_pop($list);$s.="$space}";}else{$s.="{ ... }";}return$s."\n";}elseif(is_resource($var)){return"".get_resource_type($var)." resource\n";}else{return"unknown type\n";}}public static function timer($name=NULL){static$time=array();$now=microtime(TRUE);$delta=isset($time[$name])?$now-$time[$name]:0;$time[$name]=$now;return$delta;}public static function enable($mode=NULL,$logFile=NULL,$email=NULL){error_reporting(E_ALL|E_STRICT);if(is_bool($mode)){self::$productionMode=$mode;}elseif(is_string($mode)){$mode=preg_split('#[,\s]+#',$mode);}if(is_array($mode)){self::$productionMode=!isset($_SERVER['REMOTE_ADDR'])||!in_array($_SERVER['REMOTE_ADDR'],$mode,TRUE);}if(self::$productionMode===self::DETECT){if(class_exists('Environment')){self::$productionMode=Environment::isProduction();}elseif(isset($_SERVER['SERVER_ADDR'])||isset($_SERVER['LOCAL_ADDR'])){$addr=isset($_SERVER['SERVER_ADDR'])?$_SERVER['SERVER_ADDR']:$_SERVER['LOCAL_ADDR'];$oct=explode('.',$addr);self::$productionMode=$addr!=='::1'&&(count($oct)!==4||($oct[0]!=='10'&&$oct[0]!=='127'&&($oct[0]!=='172'||$oct[1]<16||$oct[1]>31)&&($oct[0]!=='169'||$oct[1]!=='254')&&($oct[0]!=='192'||$oct[1]!=='168')));}else{self::$productionMode=!self::$consoleMode;}}if(self::$productionMode&&$logFile!==FALSE){self::$logFile='log/php_error.log';if(class_exists('Environment')){if(is_string($logFile)){self::$logFile=Environment::expand($logFile);}else -try{self::$logFile=Environment::expand('%logDir%/php_error.log');}catch(InvalidStateException$e){}}elseif(is_string($logFile)){self::$logFile=$logFile;}ini_set('error_log',self::$logFile);}if(function_exists('ini_set')){ini_set('display_errors',!self::$productionMode);ini_set('html_errors',!self::$logFile&&!self::$consoleMode);ini_set('log_errors',FALSE);}elseif(ini_get('display_errors')!=!self::$productionMode&&ini_get('display_errors')!==(self::$productionMode?'stderr':'stdout')){throw +try{self::$logFile=Environment::expand('%logDir%/php_error.log');}catch(InvalidStateException$e){}}elseif(is_string($logFile)){self::$logFile=$logFile;}ini_set('error_log',self::$logFile);}if(function_exists('ini_set')){ini_set('display_errors',!self::$productionMode);ini_set('html_errors',FALSE);ini_set('log_errors',FALSE);}elseif(ini_get('display_errors')!=!self::$productionMode&&ini_get('display_errors')!==(self::$productionMode?'stderr':'stdout')){throw new NotSupportedException('Function ini_set() must be enabled.');}self::$sendEmails=self::$logFile&&$email;if(self::$sendEmails){if(is_string($email)){self::$emailHeaders['To']=$email;}elseif(is_array($email)){self::$emailHeaders=$email+self::$emailHeaders;}}if(!defined('E_DEPRECATED')){define('E_DEPRECATED',8192);}if(!defined('E_USER_DEPRECATED')){define('E_USER_DEPRECATED',16384);}register_shutdown_function(array(__CLASS__,'_shutdownHandler'));set_exception_handler(array(__CLASS__,'_exceptionHandler'));set_error_handler(array(__CLASS__,'_errorHandler'));self::$enabled=TRUE;}public static @@ -90,11 +92,17 @@ isEnabled(){return self::$enabled;}public static function -log($message){error_log(@date('[Y-m-d H-i-s] ').trim($message).PHP_EOL,3,self::$logFile);}public +log($message,$priority=self::INFO){if(!self::$logFile){return;}if($message +instanceof +Exception){$exception=$message;$message="PHP Fatal error: Uncaught exception ".get_class($exception)." with message '".$exception->getMessage()."' in ".$exception->getFile().":".$exception->getLine();}error_log(@date('[Y-m-d H-i-s] ').trim($message).(self::$source?' @ '.self::$source:'').PHP_EOL,3,self::$logFile);if($priority===self::ERROR&&self::$sendEmails&&@filemtime(self::$logFile.'.email-sent')+self::$emailSnoozegetPrevious():(isset($exception->previous)?$exception->previous:'')));foreach(new +DirectoryIterator(dirname(self::$logFile))as$entry){if(strpos($entry,$hash)){$skip=TRUE;break;}}if(empty($skip)&&self::$logHandle=@fopen(dirname(self::$logFile)."/exception ".@date('Y-m-d H-i-s')." $hash.html",'w')){ob_start();ob_start(array(__CLASS__,'_writeFile'),1);self::_paintBlueScreen($exception);ob_end_flush();ob_end_clean();fclose(self::$logHandle);}}}public static function -_shutdownHandler(){static$types=array(E_ERROR=>1,E_CORE_ERROR=>1,E_COMPILE_ERROR=>1,E_PARSE=>1);$error=error_get_last();if(isset($types[$error['type']])){if(!headers_sent()){header('HTTP/1.1 500 Internal Server Error');}if(ini_get('html_errors')){$error['message']=html_entity_decode(strip_tags($error['message']),ENT_QUOTES,'UTF-8');}self::processException(new -FatalErrorException($error['message'],0,$error['type'],$error['file'],$error['line'],NULL),TRUE);}if(self::$showBar&&!self::$productionMode&&!self::$ajaxDetected&&!self::$consoleMode){foreach(headers_list()as$header){if(strncasecmp($header,'Content-Type:',13)===0){if(substr($header,14,9)==='text/html'){break;}return;}}$panels=array();foreach(self::$panels +_writeFile($buffer){fwrite(self::$logHandle,$buffer);}public +static +function +_shutdownHandler(){static$types=array(E_ERROR=>1,E_CORE_ERROR=>1,E_COMPILE_ERROR=>1,E_PARSE=>1);$error=error_get_last();if(isset($types[$error['type']])){self::_exceptionHandler(new +FatalErrorException($error['message'],0,$error['type'],$error['file'],$error['line'],NULL));return;}if(self::$showBar&&!self::$productionMode&&!self::$ajaxDetected&&!self::$consoleMode&&(!preg_match('#^Content-Type: (?!text/html)#im',implode("\n",headers_list())))){$panels=array();foreach(self::$panels as$panel){$panels[]=array('id'=>preg_replace('#[^a-z0-9]+#i','-',$panel->getId()),'tab'=>$tab=(string)$panel->getTab(),'panel'=>$tab?(string)$panel->getPanel():NULL);}ob_start();?> @@ -169,44 +177,41 @@ trim($panel['tab'])?>',trim($panel['tab']),'';end getCode()?'#'.$e->getCode().' ':'').$e->getMessage(),"\n";exit;}$htmlMode=!self::$ajaxDetected&&!preg_match('#^Content-Type: (?!text/html)#im',implode("\n",headers_list()));if(self::$productionMode){if(self::$consoleMode){echo"ERROR: the server encountered an internal error and was unable to complete your request.\n";}elseif($htmlMode){echo"\n\n";echo"\n\n";echo"Server Error\n\n

Server Error

\n\n

We're sorry! The server encountered an internal error and was unable to complete your request. Please try again later.

\n\n

500 error

";}}else{if(self::$consoleMode){echo"$exception\n";}elseif(self::$firebugDetected&&!headers_sent()&&!$htmlMode){self::fireLog($exception,self::EXCEPTION);}elseif($htmlMode){self::_paintBlueScreen($exception);}}foreach(self::$onFatalError +as$handler){call_user_func($handler,$exception);}}public static function -_errorHandler($severity,$message,$file,$line,$context){if($severity===E_RECOVERABLE_ERROR||$severity===E_USER_ERROR){throw +_errorHandler($severity,$message,$file,$line,$context){if(self::$scream){error_reporting(E_ALL|E_STRICT);}if($severity===E_RECOVERABLE_ERROR||$severity===E_USER_ERROR){throw new FatalErrorException($message,0,$severity,$file,$line,$context);}elseif(($severity&error_reporting())!==$severity){return -NULL;}elseif(self::$strictMode){self::_exceptionHandler(new -FatalErrorException($message,0,$severity,$file,$line,$context),TRUE);}static$types=array(E_WARNING=>'Warning',E_USER_WARNING=>'Warning',E_NOTICE=>'Notice',E_USER_NOTICE=>'Notice',E_STRICT=>'Strict standards',E_DEPRECATED=>'Deprecated',E_USER_DEPRECATED=>'Deprecated');$message='PHP '.(isset($types[$severity])?$types[$severity]:'Unknown error').": $message in $file:$line";if(self::$logFile){if(self::$sendEmails){self::sendEmail($message);}self::log($message);return +FALSE;}elseif(self::$strictMode){self::_exceptionHandler(new +FatalErrorException($message,0,$severity,$file,$line,$context));exit;}static$types=array(E_WARNING=>'Warning',E_COMPILE_WARNING=>'Warning',E_USER_WARNING=>'Warning',E_NOTICE=>'Notice',E_USER_NOTICE=>'Notice',E_STRICT=>'Strict standards',E_DEPRECATED=>'Deprecated',E_USER_DEPRECATED=>'Deprecated');$message='PHP '.(isset($types[$severity])?$types[$severity]:'Unknown error').": $message in $file:$line";if(self::$logFile){self::log($message,self::ERROR);return NULL;}elseif(!self::$productionMode){if(self::$showBar){self::$errors[]=$message;}if(self::$firebugDetected&&!headers_sent()){self::fireLog(strip_tags($message),self::ERROR);}return self::$consoleMode||(!self::$showBar&&!self::$ajaxDetected)?FALSE:NULL;}return FALSE;}public static function -processException(Exception$exception,$outputAllowed=FALSE){if(!self::$enabled){return;}elseif(self::$logFile){try{$hash=md5($exception.(method_exists($exception,'getPrevious')?$exception->getPrevious():(isset($exception->previous)?$exception->previous:'')));self::log("PHP Fatal error: Uncaught ".str_replace("Stack trace:\n".$exception->getTraceAsString(),'',$exception));foreach(new -DirectoryIterator(dirname(self::$logFile))as$entry){if(strpos($entry,$hash)){$skip=TRUE;break;}}$file='compress.zlib://'.dirname(self::$logFile)."/exception ".@date('Y-m-d H-i-s')." $hash.html.gz";if(empty($skip)&&self::$logHandle=@fopen($file,'w')){ob_start();ob_start(array(__CLASS__,'_writeFile'),1);self::_paintBlueScreen($exception);ob_end_flush();ob_end_clean();fclose(self::$logHandle);}if(self::$sendEmails){self::sendEmail((string)$exception);}}catch(Exception$e){if(!headers_sent()){header('HTTP/1.1 500 Internal Server Error');}echo'Nette\Debug fatal error: ',get_class($e),': ',($e->getCode()?'#'.$e->getCode().' ':'').$e->getMessage(),"\n";exit;}}elseif(self::$productionMode){}elseif(self::$consoleMode){if($outputAllowed){echo"$exception\n";}}elseif(self::$firebugDetected&&self::$ajaxDetected&&!headers_sent()){self::fireLog($exception,self::EXCEPTION);}elseif($outputAllowed){if(!headers_sent()){@ob_end_clean();while(ob_get_level()&&@ob_end_clean());if(in_array('Content-Encoding: gzip',headers_list()))header('Content-Encoding: identity',TRUE);}self::_paintBlueScreen($exception);}elseif(self::$firebugDetected&&!headers_sent()){self::fireLog($exception,self::EXCEPTION);}foreach(self::$onFatalError -as$handler){call_user_func($handler,$exception);}}public +processException(Exception$exception){self::log($exception);}public static function -toStringException(Exception$exception){if(self::$enabled){self::_exceptionHandler($exception);}else{trigger_error($exception->getMessage(),E_USER_ERROR);}}public +toStringException(Exception$exception){if(self::$enabled){self::_exceptionHandler($exception);}else{trigger_error($exception->getMessage(),E_USER_ERROR);}exit;}public static function -_paintBlueScreen(Exception$exception){$internals=array();foreach(array('Object','ObjectMixin')as$class){if(class_exists($class,FALSE)){$rc=new -ReflectionClass($class);$internals[$rc->getFileName()]=TRUE;}}if(class_exists('Environment',FALSE)){$application=Environment::getServiceLocator()->hasService('Nette\Application\Application',TRUE)?Environment::getServiceLocator()->getService('Nette\Application\Application'):NULL;}if(!function_exists('_netteDebugPrintCode')){function -_netteDebugPrintCode($file,$line,$count=15){if(function_exists('ini_set')){ini_set('highlight.comment','#999; font-style: italic');ini_set('highlight.default','#000');ini_set('highlight.html','#06b');ini_set('highlight.keyword','#d24; font-weight: bold');ini_set('highlight.string','#080');}$start=max(1,$line-floor($count/2));$source=@file_get_contents($file);if(!$source)return;$source=explode("\n",highlight_string($source,TRUE));$spans=1;echo$source[0];$source=explode('
',$source[1]);array_unshift($source,NULL);$i=$start;while(--$i>=1){if(preg_match('#.*(]*>)#',$source[$i],$m)){if($m[1]!==''){$spans++;echo$m[1];}break;}}$source=array_slice($source,$start,$count,TRUE);end($source);$numWidth=strlen((string)key($source));foreach($source +_paintBlueScreen(Exception$exception){if(class_exists('Environment',FALSE)){$application=Environment::getServiceLocator()->hasService('Nette\\Application\\Application',TRUE)?Environment::getServiceLocator()->getService('Nette\\Application\\Application'):NULL;}if(!function_exists('_netteDebugPrintCode')){function +_netteDebugPrintCode($file,$line,$count=15){if(function_exists('ini_set')){ini_set('highlight.comment','#999; font-style: italic');ini_set('highlight.default','#000');ini_set('highlight.html','#06B');ini_set('highlight.keyword','#C22; font-weight: bold');ini_set('highlight.string','#080');}$start=max(1,$line-floor($count/2));$source=@file_get_contents($file);if(!$source)return;$source=explode("\n",highlight_string($source,TRUE));$spans=1;echo$source[0];$source=explode('
',$source[1]);array_unshift($source,NULL);$i=$start;while(--$i>=1){if(preg_match('#.*(]*>)#',$source[$i],$m)){if($m[1]!==''){$spans++;echo$m[1];}break;}}$source=array_slice($source,$start,$count,TRUE);end($source);$numWidth=strlen((string)key($source));foreach($source as$n=>$s){$spans+=substr_count($s,'Line %{$numWidth}s: %s\n%s",$n,strip_tags($s),preg_replace('#[^>]*(<[^>]+>)[^<]*#','$1',$s));}else{printf("Line %{$numWidth}s: %s\n",$n,$s);}}echo str_repeat('',$spans),'';}function _netteDump($dump){return'
'.preg_replace_callback('#(^|\s+)?(.*)\((\d+)\) #','_netteDumpCb',$dump).'
';}function _netteDumpCb($m){return"$m[1]$m[2]($m[3]) ".(trim($m[1])||$m[3]<7?' ':'