/libs/Nette/loader.php
PHP | 19983 lines | 16680 code | 3295 blank | 8 comment | 1933 complexity | 760910a90a941effafb0a54c47873564 MD5 | raw file
Possible License(s): BSD-3-Clause
Large files files are truncated, but you can click here to view the full file
- <?php //netteloader=Nette\Framework
- namespace {
- /**
- * Nette Framework (version 2.0-dev released on 2011-06-13, http://nette.org)
- *
- * Copyright (c) 2004, 2011 David Grudl (http://davidgrudl.com)
- *
- * For the full copyright and license information, please view
- * the file license.txt that was distributed with this source code.
- */
- error_reporting(E_ALL | E_STRICT);
- @set_magic_quotes_runtime(FALSE);
- iconv_set_encoding('internal_encoding', 'UTF-8');
- extension_loaded('mbstring') && mb_internal_encoding('UTF-8');
- @header('X-Powered-By: Nette Framework');
- define('NETTE', TRUE);
- define('NETTE_DIR', __DIR__);
- define('NETTE_VERSION_ID', 20000);
- define('NETTE_PACKAGE', '5.3');
- }
- namespace Nette\Diagnostics {
- use Nette;
- interface IBarPanel
- {
- function getTab();
- function getPanel();
- }
- }
- namespace Nette\Application {
- use Nette;
- interface IPresenter
- {
- function run(Request $request);
- }
- interface IPresenterFactory
- {
- function getPresenterClass(& $name);
- function createPresenter($name);
- }
- interface IResponse
- {
- function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse);
- }
- interface IRouter
- {
- const ONE_WAY = 1;
- const SECURED = 2;
- function match(Nette\Http\IRequest $httpRequest);
- function constructUrl(Request $appRequest, Nette\Http\Url $refUrl);
- }
- }
- namespace Nette {
- use Nette;
- interface IFreezable
- {
- function freeze();
- function isFrozen();
- }
- }
- namespace Nette\ComponentModel {
- use Nette;
- interface IComponent
- {
- const NAME_SEPARATOR = '-';
- function getName();
- function getParent();
- function setParent(IContainer $parent = NULL, $name = NULL);
- }
- interface IContainer extends IComponent
- {
- function addComponent(IComponent $component, $name);
- function removeComponent(IComponent $component);
- function getComponent($name);
- function getComponents($deep = FALSE, $filterType = NULL);
- }
- }
- namespace Nette\Application\UI {
- use Nette;
- interface ISignalReceiver
- {
- function signalReceived($signal);
- }
- interface IStatePersistent
- {
- function loadState(array $params);
- function saveState(array & $params);
- }
- interface IPartiallyRenderable extends IRenderable
- {
- }
- interface IRenderable
- {
- function invalidateControl();
- function isControlInvalid();
- }
- }
- namespace Nette\Caching {
- use Nette;
- interface IStorage
- {
- function read($key);
- function write($key, $data, array $dependencies);
- function remove($key);
- function clean(array $conds);
- }
- }
- namespace Nette\Caching\Storages {
- use Nette;
- interface IJournal
- {
- function write($key, array $dependencies);
- function clean(array $conditions);
- }
- }
- namespace Nette\Config {
- use Nette;
- interface IAdapter
- {
- static function load($file);
- static function save($config, $file);
- }
- }
- namespace Nette\Database {
- use Nette;
- interface ISupplementalDriver
- {
- function delimite($name);
- function formatDateTime(\DateTime $value);
- function formatLike($value, $pos);
- function applyLimit(&$sql, $limit, $offset);
- function normalizeRow($row, $statement);
- }
- }
- namespace Nette\DI {
- use Nette;
- interface IContainer
- {
- function addService($name, $service);
- function getService($name);
- function removeService($name);
- function hasService($name);
- }
- interface IServiceBuilder
- {
- function createService(IContainer $container);
- }
- }
- namespace Nette\Forms {
- use Nette;
- interface IControl
- {
- function loadHttpData();
- function setValue($value);
- function getValue();
- function getRules();
- function getErrors();
- function isDisabled();
- function translate($s, $count = NULL);
- }
- interface ISubmitterControl extends IControl
- {
- function isSubmittedBy();
- function getValidationScope();
- }
- interface IFormRenderer
- {
- function render(Form $form);
- }
- }
- namespace Nette\Http {
- use Nette;
- interface IRequest
- {
- const
- GET = 'GET',
- POST = 'POST',
- HEAD = 'HEAD',
- PUT = 'PUT',
- DELETE = 'DELETE';
- function getUrl();
- function getQuery($key = NULL, $default = NULL);
- function getPost($key = NULL, $default = NULL);
- function getFile($key);
- function getFiles();
- function getCookie($key, $default = NULL);
- function getCookies();
- function getMethod();
- function isMethod($method);
- function getHeader($header, $default = NULL);
- function getHeaders();
- function isSecured();
- function isAjax();
- function getRemoteAddress();
- function getRemoteHost();
- }
- interface IResponse
- {
- const PERMANENT = 2116333333;
- const BROWSER = 0;
- const
- S200_OK = 200,
- S204_NO_CONTENT = 204,
- S300_MULTIPLE_CHOICES = 300,
- S301_MOVED_PERMANENTLY = 301,
- S302_FOUND = 302,
- S303_SEE_OTHER = 303,
- S303_POST_GET = 303,
- S304_NOT_MODIFIED = 304,
- S307_TEMPORARY_REDIRECT= 307,
- S400_BAD_REQUEST = 400,
- S401_UNAUTHORIZED = 401,
- S403_FORBIDDEN = 403,
- S404_NOT_FOUND = 404,
- S405_METHOD_NOT_ALLOWED = 405,
- S410_GONE = 410,
- S500_INTERNAL_SERVER_ERROR = 500,
- S501_NOT_IMPLEMENTED = 501,
- S503_SERVICE_UNAVAILABLE = 503;
- function setCode($code);
- function getCode();
- function setHeader($name, $value);
- function addHeader($name, $value);
- function setContentType($type, $charset = NULL);
- function redirect($url, $code = self::S302_FOUND);
- function setExpiration($seconds);
- function isSent();
- function getHeaders();
- function setCookie($name, $value, $expire, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL);
- function deleteCookie($name, $path = NULL, $domain = NULL, $secure = NULL);
- }
- interface ISessionStorage
- {
- function open($savePath, $sessionName);
- function close();
- function read($id);
- function write($id, $data);
- function remove($id);
- function clean($maxlifetime);
- }
- interface IUser
- {
- function login();
- function logout($clearIdentity = FALSE);
- function isLoggedIn();
- function getIdentity();
- function setAuthenticator(Nette\Security\IAuthenticator $handler);
- function getAuthenticator();
- function setNamespace($namespace);
- function getNamespace();
- function getRoles();
- function isInRole($role);
- function isAllowed();
- function setAuthorizator(Nette\Security\IAuthorizator $handler);
- function getAuthorizator();
- }
- }
- namespace Nette\Latte {
- use Nette;
- interface IMacro
- {
- function initialize();
- function finalize();
- function nodeOpened(MacroNode $node);
- function nodeClosed(MacroNode $node);
- }
- }
- namespace Nette\Localization {
- use Nette;
- interface ITranslator
- {
- function translate($message, $count = NULL);
- }
- }
- namespace Nette\Mail {
- use Nette;
- interface IMailer
- {
- function send(Message $mail);
- }
- }
- namespace Nette\Reflection {
- use Nette;
- interface IAnnotation
- {
- function __construct(array $values);
- }
- }
- namespace Nette\Security {
- use Nette;
- interface IAuthenticator
- {
- const USERNAME = 0,
- PASSWORD = 1;
- const IDENTITY_NOT_FOUND = 1,
- INVALID_CREDENTIAL = 2,
- FAILURE = 3,
- NOT_APPROVED = 4;
- function authenticate(array $credentials);
- }
- interface IAuthorizator
- {
- const ALL = NULL;
- const ALLOW = TRUE;
- const DENY = FALSE;
- function isAllowed($role, $resource, $privilege);
- }
- interface IIdentity
- {
- function getId();
- function getRoles();
- }
- interface IResource
- {
- function getResourceId();
- }
- interface IRole
- {
- function getRoleId();
- }
- }
- namespace Nette\Templating {
- use Nette;
- interface ITemplate
- {
- function render();
- }
- interface IFileTemplate extends ITemplate
- {
- function setFile($file);
- function getFile();
- }
- }
- namespace Nette {
- use Nette;
- class ArgumentOutOfRangeException extends \InvalidArgumentException
- {
- }
- class InvalidStateException extends \RuntimeException
- {
- }
- class NotImplementedException extends \LogicException
- {
- }
- class NotSupportedException extends \LogicException
- {
- }
- class DeprecatedException extends NotSupportedException
- {
- }
- class MemberAccessException extends \LogicException
- {
- }
- class IOException extends \RuntimeException
- {
- }
- class FileNotFoundException extends IOException
- {
- }
- class DirectoryNotFoundException extends IOException
- {
- }
- class InvalidArgumentException extends \InvalidArgumentException
- {
- }
- class OutOfRangeException extends \OutOfRangeException
- {
- }
- class UnexpectedValueException extends \UnexpectedValueException
- {
- }
- class StaticClassException extends \LogicException
- {
- }
- class FatalErrorException extends \ErrorException
- {
- function __construct($message, $code, $severity, $file, $line, $context)
- {
- parent::__construct($message, $code, $severity, $file, $line);
- $this->context = $context;
- }
- }
- abstract class Object
- {
- static function getReflection()
- {
- return new Reflection\ClassType(get_called_class());
- }
- function __call($name, $args)
- {
- return ObjectMixin::call($this, $name, $args);
- }
- static function __callStatic($name, $args)
- {
- return ObjectMixin::callStatic(get_called_class(), $name, $args);
- }
- static function extensionMethod($name, $callback = NULL)
- {
- if (strpos($name, '::') === FALSE) {
- $class = get_called_class();
- } else {
- list($class, $name) = explode('::', $name);
- }
- $class = new Reflection\ClassType($class);
- if ($callback === NULL) {
- return $class->getExtensionMethod($name);
- } else {
- $class->setExtensionMethod($name, $callback);
- }
- }
- function &__get($name)
- {
- return ObjectMixin::get($this, $name);
- }
- function __set($name, $value)
- {
- return ObjectMixin::set($this, $name, $value);
- }
- function __isset($name)
- {
- return ObjectMixin::has($this, $name);
- }
- function __unset($name)
- {
- ObjectMixin::remove($this, $name);
- }
- }
- }
- namespace Nette\Utils {
- use Nette;
- final class LimitedScope
- {
- private static $vars;
- final function __construct()
- {
- throw new Nette\StaticClassException;
- }
- static function evaluate()
- {
- if (func_num_args() > 1) {
- self::$vars = func_get_arg(1);
- extract(self::$vars);
- }
- $res = eval('?>' . func_get_arg(0));
- if ($res === FALSE && ($error = error_get_last()) && $error['type'] === E_PARSE) {
- throw new Nette\FatalErrorException($error['message'], 0, $error['type'], $error['file'], $error['line'], NULL);
- }
- return $res;
- }
- static function load()
- {
- if (func_num_args() > 1) {
- self::$vars = func_get_arg(1);
- extract(self::$vars);
- }
- return include func_get_arg(0);
- }
- }
- }
- namespace Nette\Loaders {
- use Nette;
- abstract class AutoLoader extends Nette\Object
- {
- static private $loaders = array();
- public static $count = 0;
- final static function load($type)
- {
- foreach (func_get_args() as $type) {
- if (!class_exists($type)) {
- throw new Nette\InvalidStateException("Unable to load class or interface '$type'.");
- }
- }
- }
- final static function getLoaders()
- {
- return array_values(self::$loaders);
- }
- function register()
- {
- if (!function_exists('spl_autoload_register')) {
- throw new Nette\NotSupportedException('spl_autoload does not exist in this PHP installation.');
- }
- spl_autoload_register(array($this, 'tryLoad'));
- self::$loaders[spl_object_hash($this)] = $this;
- }
- function unregister()
- {
- unset(self::$loaders[spl_object_hash($this)]);
- return spl_autoload_unregister(array($this, 'tryLoad'));
- }
- abstract function tryLoad($type);
- }
- }
- namespace Nette\Diagnostics {
- use Nette;
- final class Debugger
- {
- public static $productionMode;
- public static $consoleMode;
- public static $time;
- private static $ajaxDetected;
- public static $source;
- public static $editor = 'editor://open/?file=%file&line=%line';
- public static $maxDepth = 3;
- public static $maxLen = 150;
- public static $showLocation = FALSE;
- const DEVELOPMENT = FALSE,
- PRODUCTION = TRUE,
- DETECT = NULL;
- public static $blueScreen;
- public static $strictMode = FALSE;
- public static $scream = FALSE;
- public static $onFatalError = array();
- private static $enabled = FALSE;
- private static $lastError = FALSE;
- public static $logger;
- public static $fireLogger;
- public static $logDirectory;
- public static $email;
- public static $mailer;
- public static $emailSnooze;
- public static $bar;
- private static $errorPanel;
- private static $dumpPanel;
- const DEBUG = 'debug',
- INFO = 'info',
- WARNING = 'warning',
- ERROR = 'error',
- CRITICAL = 'critical';
- final function __construct()
- {
- throw new Nette\StaticClassException;
- }
- static function _init()
- {
- self::$time = microtime(TRUE);
- self::$consoleMode = PHP_SAPI === 'cli';
- self::$productionMode = self::DETECT;
- if (self::$consoleMode) {
- self::$source = empty($_SERVER['argv']) ? 'cli' : 'cli: ' . implode(' ', $_SERVER['argv']);
- } else {
- 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'];
- }
- }
- self::$logger = new Logger;
- self::$logDirectory = & self::$logger->directory;
- self::$email = & self::$logger->email;
- self::$mailer = & self::$logger->mailer;
- self::$emailSnooze = & Logger::$emailSnooze;
- self::$fireLogger = new FireLogger;
- self::$blueScreen = new BlueScreen;
- self::$blueScreen->addPanel(function($e) {
- if ($e instanceof Nette\Templating\FilterException) {
- return array(
- 'tab' => 'Template',
- 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($e->sourceFile, $e->sourceLine)
- . ' <b>Line:</b> ' . ($e->sourceLine ? $e->sourceLine : 'n/a') . '</p>'
- . ($e->sourceLine ? '<pre>' . BlueScreen::highlightFile($e->sourceFile, $e->sourceLine) . '</pre>' : '')
- );
- }
- });
- self::$bar = new Bar;
- self::$bar->addPanel(new DefaultBarPanel('time'));
- self::$bar->addPanel(new DefaultBarPanel('memory'));
- self::$bar->addPanel(self::$errorPanel = new DefaultBarPanel('errors'));
- self::$bar->addPanel(self::$dumpPanel = new DefaultBarPanel('dumps'));
- }
- static function enable($mode = NULL, $logDirectory = 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 127.0.0.1 ::1");
- }
- 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('Nette\Environment')) {
- self::$productionMode = Nette\Environment::isProduction();
- } elseif (isset($_SERVER['SERVER_ADDR']) || isset($_SERVER['LOCAL_ADDR'])) {
- $addrs = array();
- if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- $addrs = preg_split('#,\s*#', $_SERVER['HTTP_X_FORWARDED_FOR']);
- }
- if (isset($_SERVER['REMOTE_ADDR'])) {
- $addrs[] = $_SERVER['REMOTE_ADDR'];
- }
- $addrs[] = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
- self::$productionMode = FALSE;
- foreach ($addrs as $addr) {
- $oct = explode('.', $addr);
- if ($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')))
- ) {
- self::$productionMode = TRUE;
- break;
- }
- }
- } else {
- self::$productionMode = !self::$consoleMode;
- }
- }
- if (is_string($logDirectory)) {
- self::$logDirectory = realpath($logDirectory);
- if (self::$logDirectory === FALSE) {
- throw new Nette\DirectoryNotFoundException("Directory '$logDirectory' is not found.");
- }
- } elseif ($logDirectory === FALSE) {
- self::$logDirectory = FALSE;
- } elseif (self::$logDirectory === NULL) {
- self::$logDirectory = defined('APP_DIR') ? APP_DIR . '/../log' : getcwd() . '/log';
- }
- if (self::$logDirectory) {
- ini_set('error_log', self::$logDirectory . '/php_error.log');
- }
- 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 Nette\NotSupportedException('Function ini_set() must be enabled.');
- }
- if ($email) {
- if (!is_string($email)) {
- throw new Nette\InvalidArgumentException('Email address must be a string.');
- }
- self::$email = $email;
- }
- if (!defined('E_DEPRECATED')) {
- define('E_DEPRECATED', 8192);
- }
- if (!defined('E_USER_DEPRECATED')) {
- define('E_USER_DEPRECATED', 16384);
- }
- if (!self::$enabled) {
- register_shutdown_function(array(__CLASS__, '_shutdownHandler'));
- set_exception_handler(array(__CLASS__, '_exceptionHandler'));
- set_error_handler(array(__CLASS__, '_errorHandler'));
- self::$enabled = TRUE;
- }
- }
- static function isEnabled()
- {
- return self::$enabled;
- }
- static function log($message, $priority = self::INFO)
- {
- if (self::$logDirectory === FALSE) {
- return;
- } elseif (!self::$logDirectory) {
- throw new Nette\InvalidStateException('Logging directory is not specified in Nette\Diagnostics\Debugger::$logDirectory.');
- }
- if ($message instanceof \Exception) {
- $exception = $message;
- $message = "PHP Fatal error: "
- . ($message instanceof Nette\FatalErrorException
- ? $exception->getMessage()
- : "Uncaught exception " . get_class($exception) . " with message '" . $exception->getMessage() . "'")
- . " in " . $exception->getFile() . ":" . $exception->getLine();
- $hash = md5($exception );
- $exceptionFilename = "exception " . @date('Y-m-d H-i-s') . " $hash.html";
- foreach (new \DirectoryIterator(self::$logDirectory) as $entry) {
- if (strpos($entry, $hash)) {
- $exceptionFilename = NULL; break;
- }
- }
- }
- self::$logger->log(array(
- @date('[Y-m-d H-i-s]'),
- $message,
- self::$source ? ' @ ' . self::$source : NULL,
- !empty($exceptionFilename) ? ' @@ ' . $exceptionFilename : NULL
- ), $priority);
- if (!empty($exceptionFilename) && $logHandle = @fopen(self::$logDirectory . '/'. $exceptionFilename, 'w')) {
- ob_start();
- ob_start(function($buffer) use($logHandle) { fwrite($logHandle, $buffer); }, 1);
- self::$blueScreen->render($exception);
- ob_end_flush();
- ob_end_clean();
- fclose($logHandle);
- }
- }
- static function _shutdownHandler()
- {
- if (!self::$enabled) {
- return;
- }
- 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 Nette\FatalErrorException($error['message'], 0, $error['type'], $error['file'], $error['line'], NULL));
- }
- if (self::$bar && !self::$productionMode && !self::$ajaxDetected && !self::$consoleMode
- && !preg_match('#^Content-Type: (?!text/html)#im', implode("\n", headers_list()))
- ) {
- self::$bar->render();
- }
- }
- static function _exceptionHandler(\Exception $exception)
- {
- if (!headers_sent()) {
- header('HTTP/1.1 500 Internal Server Error');
- }
- $htmlMode = !self::$ajaxDetected && !preg_match('#^Content-Type: (?!text/html)#im', implode("\n", headers_list()));
- try {
- if (self::$productionMode) {
- self::log($exception, self::ERROR);
- if (self::$consoleMode) {
- echo "ERROR: the server encountered an internal error and was unable to complete your request.\n";
- } elseif ($htmlMode) {
- ?>
- <!DOCTYPE html>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta name=robots content=noindex><meta name=generator content="Nette Framework">
- <style>body{color:#333;background:white;width:500px;margin:100px auto}h1{font:bold 47px/1.5 sans-serif;margin:.6em 0}p{font:21px/1.5 Georgia,serif;margin:1.5em 0}small{font-size:70%;color:gray}</style>
- <title>Server Error</title>
- <h1>Server Error</h1>
- <p>We're sorry! The server encountered an internal error and was unable to complete your request. Please try again later.</p>
- <p><small>error 500</small></p>
- <?php
- }
- } else {
- if (self::$consoleMode) {
- echo "$exception\n";
- } elseif ($htmlMode) {
- self::$blueScreen->render($exception);
- if (self::$bar) {
- self::$bar->render();
- }
- } elseif (!self::fireLog($exception, self::ERROR)) {
- self::log($exception);
- }
- }
- foreach (self::$onFatalError as $handler) {
- call_user_func($handler, $exception);
- }
- } catch (\Exception $e) {
- echo "\nNette\\Debug FATAL ERROR: thrown ", get_class($e), ': ', $e->getMessage(),
- "\nwhile processing ", get_class($exception), ': ', $exception->getMessage(), "\n";
- }
- self::$enabled = FALSE;
- exit(255);
- }
- static function _errorHandler($severity, $message, $file, $line, $context)
- {
- if (self::$scream) {
- error_reporting(E_ALL | E_STRICT);
- }
- if (self::$lastError !== FALSE && ($severity & error_reporting()) === $severity) {
- self::$lastError = new \ErrorException($message, 0, $severity, $file, $line);
- return NULL;
- }
- if ($severity === E_RECOVERABLE_ERROR || $severity === E_USER_ERROR) {
- throw new Nette\FatalErrorException($message, 0, $severity, $file, $line, $context);
- } elseif (($severity & error_reporting()) !== $severity) {
- return FALSE;
- } elseif (self::$strictMode && !self::$productionMode) {
- self::_exceptionHandler(new Nette\FatalErrorException($message, 0, $severity, $file, $line, $context));
- }
- 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";
- $count = & self::$errorPanel->data["$message|$file|$line"];
- if ($count++) {
- return NULL;
- } elseif (self::$productionMode) {
- self::log("$message in $file:$line", self::ERROR);
- return NULL;
- } else {
- $ok = self::fireLog(new \ErrorException($message, 0, $severity, $file, $line), self::WARNING);
- return self::$consoleMode || (!self::$bar && !$ok) ? FALSE : NULL;
- }
- return FALSE;
- }
- static function toStringException(\Exception $exception)
- {
- if (self::$enabled) {
- self::_exceptionHandler($exception);
- } else {
- trigger_error($exception->getMessage(), E_USER_ERROR);
- }
- }
- static function tryError()
- {
- if (!self::$enabled && self::$lastError === FALSE) {
- set_error_handler(array(__CLASS__, '_errorHandler'));
- }
- self::$lastError = NULL;
- }
- static function catchError(& $error)
- {
- if (!self::$enabled && self::$lastError !== FALSE) {
- restore_error_handler();
- }
- $error = self::$lastError;
- self::$lastError = FALSE;
- return (bool) $error;
- }
- static function dump($var, $return = FALSE)
- {
- if (!$return && self::$productionMode) {
- return $var;
- }
- $output = "<pre class=\"nette-dump\">" . Helpers::htmlDump($var) . "</pre>\n";
- if (!$return) {
- $trace = debug_backtrace();
- $i = !isset($trace[1]['class']) && isset($trace[1]['function']) && $trace[1]['function'] === 'dump' ? 1 : 0;
- if (isset($trace[$i]['file'], $trace[$i]['line']) && is_file($trace[$i]['file'])) {
- $lines = file($trace[$i]['file']);
- preg_match('#dump\((.*)\)#', $lines[$trace[$i]['line'] - 1], $m);
- $output = substr_replace(
- $output,
- ' title="' . htmlspecialchars((isset($m[0]) ? "$m[0] \n" : '') . "in file {$trace[$i]['file']} on line {$trace[$i]['line']}") . '"',
- 4, 0);
- if (self::$showLocation) {
- $output = substr_replace(
- $output,
- ' <small>in ' . Helpers::editorLink($trace[$i]['file'], $trace[$i]['line']) . ":{$trace[$i]['line']}</small>",
- -8, 0);
- }
- }
- }
- if (self::$consoleMode) {
- $output = htmlspecialchars_decode(strip_tags($output), ENT_NOQUOTES);
- }
- if ($return) {
- return $output;
- } else {
- echo $output;
- return $var;
- }
- }
- static function timer($name = NULL)
- {
- static $time = array();
- $now = microtime(TRUE);
- $delta = isset($time[$name]) ? $now - $time[$name] : 0;
- $time[$name] = $now;
- return $delta;
- }
- static function barDump($var, $title = NULL)
- {
- if (!self::$productionMode) {
- $dump = array();
- foreach ((is_array($var) ? $var : array('' => $var)) as $key => $val) {
- $dump[$key] = Helpers::clickableDump($val);
- }
- self::$dumpPanel->data[] = array('title' => $title, 'dump' => $dump);
- }
- return $var;
- }
- static function fireLog($message)
- {
- if (!self::$productionMode) {
- return self::$fireLogger->log($message);
- }
- }
- static function addPanel(IBarPanel $panel, $id = NULL)
- {
- self::$bar->addPanel($panel, $id);
- }
- }
- class Logger extends Nette\Object
- {
- const DEBUG = 'debug',
- INFO = 'info',
- WARNING = 'warning',
- ERROR = 'error',
- CRITICAL = 'critical';
- public static $emailSnooze = 172800;
- public $mailer = array(__CLASS__, 'defaultMailer');
- public $directory;
- public $email;
- function log($message, $priority = self::INFO)
- {
- if (!is_dir($this->directory)) {
- throw new Nette\DirectoryNotFoundException("Directory '$this->directory' is not found or is not directory.");
- }
- if (is_array($message)) {
- $message = implode(' ', $message);
- }
- $res = error_log(trim($message) . PHP_EOL, 3, $this->directory . '/' . strtolower($priority) . '.log');
- if (($priority === self::ERROR || $priority === self::CRITICAL) && $this->email && $this->mailer
- && @filemtime($this->directory . '/email-sent') + self::$emailSnooze < time()
- && @file_put_contents($this->directory . '/email-sent', 'sent')
- ) {
- call_user_func($this->mailer, $message, $this->email);
- }
- return $res;
- }
- private static function defaultMailer($message, $email)
- {
- $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] :
- (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '');
- $parts = str_replace(
- array("\r\n", "\n"),
- array("\n", PHP_EOL),
- array(
- 'headers' => "From: noreply@$host\nX-Mailer: Nette Framework\n",
- 'subject' => "PHP: An error occurred on the server $host",
- 'body' => "[" . @date('Y-m-d H:i:s') . "] $message",
- )
- );
- mail($email, $parts['subject'], $parts['body'], $parts['headers']);
- }
- }
- class FireLogger extends Nette\Object
- {
- const DEBUG = 'debug',
- INFO = 'info',
- WARNING = 'warning',
- ERROR = 'error',
- CRITICAL = 'critical';
- private static $payload = array('logs' => array());
- static function log($message, $priority = self::DEBUG)
- {
- if (!isset($_SERVER['HTTP_X_FIRELOGGER']) || headers_sent()) {
- return FALSE;
- }
- $item = array(
- 'name' => 'PHP',
- 'level' => $priority,
- 'order' => count(self::$payload['logs']),
- 'time' => str_pad(number_format((microtime(TRUE) - Debugger::$time) * 1000, 1, '.', ' '), 8, '0', STR_PAD_LEFT) . ' ms',
- 'template' => '',
- 'message' => '',
- 'style' => 'background:#767ab6',
- );
- $args = func_get_args();
- if (isset($args[0]) && is_string($args[0])) {
- $item['template'] = array_shift($args);
- }
- if (isset($args[0]) && $args[0] instanceof \Exception) {
- $e = array_shift($args);
- $trace = $e->getTrace();
- if (isset($trace[0]['class']) && $trace[0]['class'] === 'Nette\Diagnostics\Debugger'
- && ($trace[0]['function'] === '_shutdownHandler' || $trace[0]['function'] === '_errorHandler')
- ) {
- unset($trace[0]);
- }
- $file = str_replace(dirname(dirname(dirname($e->getFile()))), "\xE2\x80\xA6", $e->getFile());
- $item['template'] = ($e instanceof \ErrorException ? '' : get_class($e) . ': ')
- . $e->getMessage() . ($e->getCode() ? ' #' . $e->getCode() : '') . ' in ' . $file . ':' . $e->getLine();
- $item['pathname'] = $e->getFile();
- $item['lineno'] = $e->getLine();
- } else {
- $trace = debug_backtrace();
- if (isset($trace[1]['class']) && $trace[1]['class'] === 'Nette\Diagnostics\Debugger'
- && ($trace[1]['function'] === 'fireLog')
- ) {
- unset($trace[0]);
- }
- foreach ($trace as $frame) {
- if (isset($frame['file']) && is_file($frame['file'])) {
- $item['pathname'] = $frame['file'];
- $item['lineno'] = $frame['line'];
- break;
- }
- }
- }
- $item['exc_info'] = array('', '', array());
- $item['exc_frames'] = array();
- foreach ($trace as $frame) {
- $frame += array('file' => NULL, 'line' => NULL, 'class' => NULL, 'type' => NULL, 'function' => NULL, 'object' => NULL, 'args' => NULL);
- $item['exc_info'][2][] = array($frame['file'], $frame['line'], "$frame[class]$frame[type]$frame[function]", $frame['object']);
- $item['exc_frames'][] = $frame['args'];
- }
- if (isset($args[0]) && in_array($args[0], array(self::DEBUG, self::INFO, self::WARNING, self::ERROR, self::CRITICAL), TRUE)) {
- $item['level'] = array_shift($args);
- }
- $item['args'] = $args;
- self::$payload['logs'][] = self::jsonDump($item, -1);
- foreach (str_split(base64_encode(@json_encode(self::$payload)), 4990) as $k => $v) {
- header("FireLogger-de11e-$k:$v");
- }
- return TRUE;
- }
- private static function jsonDump(&$var, $level = 0)
- {
- if (is_bool($var) || is_null($var) || is_int($var) || is_float($var)) {
- return $var;
- } elseif (is_string($var)) {
- if (Debugger::$maxLen && strlen($var) > Debugger::$maxLen) {
- $var = substr($var, 0, Debugger::$maxLen) . " \xE2\x80\xA6 ";
- }
- return Nette\Utils\Strings::fixEncoding($var);
- } elseif (is_array($var)) {
- static $marker;
- if ($marker === NULL) {
- $marker = uniqid("\x00", TRUE);
- }
- if (isset($var[$marker])) {
- return "\xE2\x80\xA6RECURSION\xE2\x80\xA6";
- } elseif ($level < Debugger::$maxDepth || !Debugger::$maxDepth) {
- $var[$marker] = TRUE;
- $res = array();
- foreach ($var as $k => &$v) {
- if ($k !== $marker) {
- $res[self::jsonDump($k)] = self::jsonDump($v, $level + 1);
- }
- }
- unset($var[$marker]);
- return $res;
- } else {
- return " \xE2\x80\xA6 ";
- }
- } elseif (is_object($var)) {
- $arr = (array) $var;
- static $list = array();
- if (in_array($var, $list, TRUE)) {
- return "\xE2\x80\xA6RECURSION\xE2\x80\xA6";
- } elseif ($level < Debugger::$maxDepth || !Debugger::$maxDepth) {
- $list[] = $var;
- $res = array("\x00" => '(object) ' . get_class($var));
- foreach ($arr as $k => &$v) {
- if ($k[0] === "\x00") {
- $k = substr($k, strrpos($k, "\x00") + 1);
- }
- $res[self::jsonDump($k)] = self::jsonDump($v, $level + 1);
- }
- array_pop($list);
- return $res;
- } else {
- return " \xE2\x80\xA6 ";
- }
- } elseif (is_resource($var)) {
- return "resource " . get_resource_type($var);
- } else {
- return "unknown type";
- }
- }
- }
- class BlueScreen extends Nette\Object
- {
- private $panels = array();
- function addPanel($panel, $id = NULL)
- {
- if ($id === NULL) {
- $this->panels[] = $panel;
- } else {
- $this->panels[$id] = $panel;
- }
- }
- function render(\Exception $exception)
- {
- $panels = $this->panels;
- static $errorTypes = array(
- E_ERROR => 'Fatal Error',
- E_USER_ERROR => 'User Error',
- E_RECOVERABLE_ERROR => 'Recoverable Error',
- E_CORE_ERROR => 'Core Error',
- E_COMPILE_ERROR => 'Compile Error',
- E_PARSE => 'Parse Error',
- E_WARNING => 'Warning',
- E_CORE_WARNING => 'Core Warning',
- E_COMPILE_WARNING => 'Compile Warning',
- E_USER_WARNING => 'User Warning',
- E_NOTICE => 'Notice',
- E_USER_NOTICE => 'User Notice',
- E_STRICT => 'Strict',
- E_DEPRECATED => 'Deprecated',
- E_USER_DEPRECATED => 'User Deprecated',
- );
- $title = ($exception instanceof Nette\FatalErrorException && isset($errorTypes[$exception->getSeverity()])) ? $errorTypes[$exception->getSeverity()] : get_class($exception);
- $expandPath = NETTE_DIR . DIRECTORY_SEPARATOR;
- $counter = 0;
- ?><!-- "' --></script></style></pre></xmp></table>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta name="robots" content="noindex,noarchive">
- <meta name="generator" content="Nette Framework">
- <title><?php echo htmlspecialchars($title) ?></title><!-- <?php
- $ex = $exception; echo $ex->getMessage(), ($ex->getCode() ? ' #' . $ex->getCode() : '');
- while ((method_exists($ex, 'getPrevious') && $ex = $ex->getPrevious()) || (isset($ex->previous) && $ex = $ex->previous)) echo '; caused by ', get_class($ex), ' ', $ex->getMessage(), ($ex->getCode() ? ' #' . $ex->getCode() : '');
- ?> -->
- <style type="text/css" class="nette">html{overflow-y:scroll}body{margin:0 0 2em;padding:0}#netteBluescreen{font:9pt/1.5 Verdana,sans-serif;background:white;color:#333;position:absolute;left:0;top:0;width:100%;z-index:23178;text-align:left}#netteBluescreen *{font:inherit;color:inherit;background:transparent;border:none;margin:0;padding:0;text-align:inherit;text-indent:0}#netteBluescreen b{font-weight:bold}#netteBluescreen i{font-style:italic}#netteBluescreen a{text-decoration:none;color:#328ADC;padding:2px 4px;margin:-2px -4px}#netteBluescreen a:hover,#netteBluescreen a:active,#netteBluescreen a:focus{color:#085AA3}#netteBluescreen a abbr{font-family:sans-serif;color:#BBB}#netteBluescreenIcon{position:absolute;right:.5em;top:.5em;z-index:23179;text-decoration:none;background:#CD1818;padding:3px}#netteBluescreenError{background:#CD1818;color:white;font:13pt/1.5 Verdana,sans-serif!important;display:block}#netteBluescreenError #netteBsSearch{color:#CD1818;font-size:.7em}#netteBluescreenError:hover #netteBsSearch{color:#ED8383}#netteBluescreen h1{font-size:18pt;font-weight:normal;text-shadow:1px 1px 0 rgba(0,0,0,.4);margin:.7em 0}#netteBluescreen h2{font:14pt/1.5 sans-serif!important;color:#888;margin:.6em 0}#netteBluescreen h3{font:bold 10pt/1.5 Verdana,sans-serif!important;margin:1em 0;padding:0}#netteBluescreen p,#netteBluescreen pre{margin:.8em 0}#netteBluescreen pre,#netteBluescreen code,#netteBluescreen table{font:9pt/1.5 Consolas,monospace!important}#netteBluescreen pre,#netteBluescreen table{background:#FDF5CE;padding:.4em .7em;border:1px dotted silver;overflow:auto}#netteBluescreen table pre{padding:0;margin:0;border:none}#netteBluescreen pre.nette-dump span{color:#C22}#netteBluescreen pre.nette-dump a{color:#333}#netteBluescreen div.panel{padding:1px 25px}#netteBluescreen div.inner{background:#F4F3F1;padding:.1em 1em 1em;border-radius:8px;-moz-border-radius:8px;-webkit-border-radius:8px}#netteBluescreen table{border-collapse:collapse;width:100%}#netteBluescreen .outer{overflow:auto}#netteBluescreen td,#netteBluescreen th{vertical-align:top;text-align:left;padding:2px 6px;border:1px solid #e6dfbf}#netteBluescreen th{width:10%;font-weight:bold}#netteBluescreen tr:nth-child(2n),#netteBluescreen tr:nth-child(2n) pre{background-color:#F7F0CB}#netteBluescreen ol{margin:1em 0;padding-left:2.5em}#netteBluescreen ul{font:7pt/1.5 Verdana,sans-serif!important;padding:2em 4em;margin:1em 0 0;color:#777;background:#F6F5F3 url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFEAAAAjCAMAAADbuxbOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADBQTFRF/fz24d7Y7Onj5uLd9vPu3drUzMvG09LN39zW8e7o2NbQ3NnT29jS0M7J1tXQAAAApvmsFgAAABB0Uk5T////////////////////AOAjXRkAAAKlSURBVHja7FbbsqQgDAwENEgc//9vN+SCWDtbtXPmZR/Wc6o02mlC58LA9ckFAOszvMV8xNgyUjyXhojfMVKvRL0ZHavxXYy5JrmchMdzou8YlTClxajtK8ZGGpWRoBr1+gFjKfHkJPbizabLgzE3pH7Iu4K980xgFvlrVzMZoVBWhtvouCDdcTDmTgMCJdVxJ9MKO6XxnliM7hxi5lbj2ZVM4l8DqYyKoNLYcfqBB1/LpHYxEcfVG6ZpMDgyFUVWY/Q1sSYPpIdSAKWqLWL0XqWiMWc4hpH0OQOMOAgdycY4N9Sb7wWANQs3rsDSdLAYiuxi5siVfOhBWIrtH0G3kNaF/8Q4kCPE1kMucG/ZMUBUCOgiKJkPuWWTLGVgLGpwns1DraUayCtoBqERyaYtVsm85NActRooezvSLO/sKZP/nq8n4+xcyjNsRu8zW6KWpdb7wjiQd4WrtFZYFiKHENSmWp6xshh96c2RQ+c7Lt+qbijyEjHWUJ/pZsy8MGIUuzNiPySK2Gqoh6ZTRF6ko6q3nVTkaA//itIrDpW6l3SLo8juOmqMXkYknu5FdQxWbhCfKHEGDhxxyTVaXJF3ZjSl3jMksjSOOKmne9pI+mcG5QvaUJhI9HpkmRo2NpCrDJvsktRhRE2MM6F2n7dt4OaMUq8bCctk0+PoMRzL+1l5PZ2eyM/Owr86gf8z/tOM53lom5+nVcFuB+eJVzlXwAYy9TZ9s537tfqcsJWbEU4nBngZo6FfO9T9CdhfBtmk2dLiAy8uS4zwOpMx2HqYbTC+amNeAYTpsP4SIgvWfUBWXxn3CMHW3ffd7k3+YIkx7w0t/CVGvcPejoeOlzOWzeGbawOHqXQGUTMZRcfj4XPCgW9y/fuvVn8zD9P1QHzv80uAAQA0i3Jer7Jr7gAAAABJRU5ErkJggg==') 99% 10px no-repeat;border-top:1px solid #DDD}#netteBluescreen .highlight{background:#CD1818;color:white;font-weight:bold;font-style:normal;display:table;padding:0 .4em;margin:0 -.4em}#netteBluescreen .line{color:#9F9C7F;font-weight:normal;font-style:normal}#netteBluescreen a[href^=editor\:]{color:inherit;border-bottom:1px dotted #C1D2E1}</style>
- </head>
- <body>
- <div id="netteBluescreen">
- <a id="netteBluescreenIcon" href="#" rel="next"><abbr>▼</abbr></a
- ><div>
- <div id="netteBluescreenError" class="panel">
- <h1><?php echo htmlspecialchars($title), ($exception->getCode() ? ' #' . $exception->getCode() : '') ?></h1>
- <p><?php echo htmlspecialchars($exception->getMessage()) ?> <a href="http://www.google.cz/search?sourceid=nette&q=<?php echo urlencode($title . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $exception->getMessage())) ?>" id="netteBsSearch">search►</a></p>
- </div>
- <?php $ex = $exception; $level = 0; ?>
- <?php do { ?>
- <?php if ($level++): ?>
- <div class="panel">
- <h2><a href="#" rel="netteBsPnl<?php echo ++$counter ?>">Caused by <abbr><?php echo ($collapsed = $level > 2) ? '►' : '▼' ?></abbr></a></h2>
- <div id="netteBsPnl<?php echo $counter ?>" class="<?php echo $collapsed ? 'nette-collapsed ' : '' ?>inner">
- <div class="panel">
- <h1><?php echo htmlspecialchars(get_class($ex)), ($ex->getCode() ? ' #' . $ex->getCode() : '') ?></h1>
- <p><b><?php echo htmlspecialchars($ex->getMessage()) ?></b></p>
- </div>
- <?php endif ?>
- <?php foreach ($panels as $panel): ?>
- <?php $panel = call_user_func($panel, $ex); if (empty($panel['tab']) || empty($panel['panel'])) continue; ?>
- <div class="panel">
- <h2><a href="#" rel="netteBsPnl<?php echo ++$counter ?>"><?php echo htmlSpecialChars($panel['tab']) ?> <abbr>▼</abbr></a></h2>
- <div id="netteBsPnl<?php echo $counter ?>" class="inner">
- <?php echo $panel['panel'] ?>
- </div></div>
- <?php endforeach ?>
- <?php $stack = $ex->getTrace(); $expanded = NULL ?>
- <?php if (strpos($ex->getFile(), $expandPath) === 0) {
- foreach ($stack as $key => $row) {
- if (isset($row['file']) && strpos($row['file'], $expandPath) !== 0) { $expanded = $key; break; }
- }
- } ?>
- <div class="panel">
- <h2><a href="#" rel="netteBsPnl<?php echo ++$counter ?>">Source file <abbr><?php echo ($collapsed = $expanded !== NULL) ? '►' : '▼' ?></abbr></a></h2>
- <div id="netteBsPnl<?php echo $counter ?>" class="<?php echo $collapsed ? 'nette-collapsed ' : '' ?>inner">
- <p><b>File:</b> <?php echo Helpers::editorLink($ex->getFile(), $ex->getLine()) ?> <b>Line:</b> <?php echo $ex->getLine() ?></p>
- <?php if (is_file($ex->getFile())): ?><pre><?php echo self::highlightFile($ex->getFile(), $ex->getLine(), 15, isset($ex->context) ? $ex->context : NULL) ?></pre><?php endif ?>
- </div></div>
- <?php if (isset($stack[0]['class']) && $stack[0]['class'] === 'Nette\Diagnostics\Debugger' && ($stack[0]['function'] === '_shutdownHandler' || $stack[0]['function'] === '_errorHandler')) unset($stack[0]) ?>
- <?php if ($stack): ?>
- <div class="panel">
- <h2><a href="#" rel="netteBsPnl<?php echo ++$counter ?>">Call stack <abbr>▼</abbr></a></h2>
- <div id="netteBsPnl<?php echo $counter ?>" class="inner">
- <ol>
- <?php foreach ($stack as $key => $row): ?>
- <li><p>
- <?php if (isset($row['file']) && is_file($row['file'])): ?>
- <?php echo Helpers::editorLink($row['file'], $row['line']), ':', $row['line'] ?>
- <?php else: ?>
- <i>inner-code</i><?php if (isset($row['line'])) echo ':', $row['line'] ?>
- <?php endif ?>
- <?php if (isset($row['file']) && is_file($row['file'])): ?><a href="#" rel="netteBsSrc<?php echo "$level-$key" ?>">source <abbr>►</abbr></a> <?php endif ?>
- <?php if (isset($row['class'])) echo $row['class'] . $row['type'] ?>
- <?php echo $row['function'] ?>
- (<?php if (!empty($row['args'])): ?><a href="#" rel="netteBsArgs<?php echo "$level-$key" ?>">arguments <abbr>►</abbr></a><?php endif ?>)
- </p>
- <?php if (!empty($row['args'])): ?>
- <div class="nette-collapsed outer" id="netteBsArgs<?php echo "$level-$key" ?>">
- <table>
- <?php
- try {
- $r = isset($row['class']) ? new \ReflectionMethod($row['class'], $row['function']) : new \ReflectionFunction($row['function']);
- $params = $r->getParameters();
- } catch (\Exception $e) {
- $params = array();
- }
- foreach ($row['args'] as $k => $v) {
- echo '<tr><th>', (isset($params[$k]) ? '$' . $params[$k]->name : "#$k"), '</th><td>';
- echo Helpers::clickableDump($v);
- echo "</td></tr>\n";
- }
- ?>
- </table>
- </div>
- <?php endif ?>
- <?php if (isset($row['file']) && is_file($row['file'])): ?>
- <pre <?php if ($expanded !== $key) echo 'class="nette-collapsed"'; ?> id="netteBsSrc<?php echo "$level-$key" ?>"><?php echo self::highlightFile($row['file'], $row['line']) ?></pre>
- <?php endif ?>
- </li>
- <?php endforeach ?>
- </ol>
- </div></div>
- <?php endif ?>
- <?php if (isset($ex->context) && is_array($ex->context)):?>
- <div class="panel">
- <h2><a href="#" rel="netteBsPnl<?php echo ++$counter ?>">Variables <abbr>►</abbr></a></h2>
- <div id="netteBsPnl<?php echo $counter ?>" class="nette-collapsed inner">
- <div class="outer">
- <table>
- <?php
- foreach ($ex->context as $k => $v) {
- echo '<tr><th>$', htmlspecialchars($k), '</th><td>', Helpers::clickableDump($v), "</td></tr>\n";
- }
- ?>
- </table>
- </div>
- </div></div>
- <?php endif ?>
- <?php } while ((method_exists($ex, 'getPrevious') && $ex = $ex->getPrevious()) || (isset($ex->previous) && $ex = $ex->previous)); ?>
- <?php while (--$level) echo '</div></div>' ?>
- <?php foreach ($panels as $panel): ?>
- <?php $panel = call_user_func($panel, NULL); if (empty($panel['tab']) || empty($panel['panel'])) continue; ?>
- <div class="panel">
- <h2><a href="#" rel="netteBsPnl<?php echo ++$counter ?>"><?php echo htmlSpecialChars($panel['tab']) ?> <abbr>►</abbr></a></h2>
- <div id="netteBsPnl<?php echo $counter ?>" class="nette-collapsed inner">
- <?php echo $panel['panel'] ?>
- </div></div>
- <?php endforeach ?>
- <div class="panel">
- <h2><a href="#" rel="netteBsPnl<?php echo ++$counter ?>">Environment <abbr>►</abbr></a></h2>
- <div id="netteBsPnl<?php echo $counter ?>" class="nette-collapsed inner">
- <?php
- $list = get_defined_constants(TRUE);
- if (!empty($list['user'])):?>
- <h3><a href="#" rel="netteBsPnl-env-const">Constants <abbr>▼</abbr></a></h3>
- <div class="outer">
- <table id="netteBsPnl-env-const">
- <?php
- foreach ($list['user'] as $k => $v) {
- echo '<tr><th>', htmlspecialchars($k), '</th>';
- echo '<td>', Helpers::clickableDump($v), "</td></tr>\n";
- }
- ?>
- </table>
- </div>
- <?php endif ?>
- <h3><a href="#" rel="netteBsPnl-env-files">Included files <abbr>►</abbr></a> (<?php echo count(get_included_files()) ?>)</h3>
- <div class="outer">
- <table id="netteBsPnl-env-files" class="nette-collapsed">
- <?php
- foreach (get_included_files() as $v) {
- echo '<tr><td>', htmlspecialchars($v), "</td></tr>\n";
- }
- ?>
- </table>
- </div>
- <h3>$_SERVER</h3>
- <?php if (empty($_SERVER)):?>
- <p><i>empty</i></p>
- <?php else: ?>
- <div class="outer">
- <table>
- <?php
- foreach ($_SERVER as $k => $v) echo '<tr><th>', htmlspecialchars($k), '</th><td>', Helpers::clickableDump($v), "</td></tr>\n";
- ?>
- </table>
- </div>
- <?php endif ?>
- </div></div>
- <div class="panel">
- <h2><a href="#" rel="netteBsPnl<?php echo ++$counter ?>">HTTP request <abbr>►</abbr></a></h2>
- <div id="netteBsPnl<?php echo $counter ?>" class="nette-collapsed inner">
- <?php if (function_exists('apache_request_headers')): ?>
- <h3>Headers</h3>
- <div class="outer">
- <table>
- <?php
- foreach (apache_request_headers() as $k => $v) echo '<tr><th>', htmlspecialchars($k), '</th><td>', htmlspecialchars($v), "</td></tr>\n";
- ?>
- </table>
- </div>
- <?php endif ?>
- <?php foreach (array('_GET', '_POST', '_COOKIE') as $name): ?>
- <h3>$<?php echo $name ?></h3>
- <?php if (empty($GLOBALS[$name])):?>
- <p><i>empty</i></p>
- <?php else: ?>
- <div class="outer">
- <table>
- <?php
- foreach ($GLOBALS[$name] as $k => $v) echo '<tr><th>', htmlspecialchars($k), '</th><td>', Helpers::clickableDump($v), "</td></tr>\n";
- ?>
- </table>
- </div>
- <?php endif ?>
- <?php endforeach ?>
- </div></div>
- <div class="panel">
- <h2><a href="#" rel="netteBsPnl<?php echo ++$counter ?>">HTTP response <abbr>►</abbr></a></h2>
- <div id="netteBsPnl<?php echo $counter ?>" class="nette-collapsed inner">
- <h3>Headers</h3>
- <?php if (headers_list()): ?>
- <pre><?php
- foreach (headers_list() as $s) echo htmlspecialchars($s), '<br>';
- ?></pre>
- <?php else: ?>
- <p><i>no headers</i></p>
- <?php endif ?>
- </div></div>
- <ul>
- <li>Report generated at <?php echo @date('Y/m/d H:i:s', Debugger::$time) ?></li>
- <?php if (preg_match('#^https?://#', Debugger::$source)): ?>
- <li><a href="<?php echo htmlSpecialChars(Debugger::$source) ?>"><?php echo htmlSpecialChars(Debugger::$source) ?></a></li>
- <?php elseif (Debugger::$source): ?>
- <li><?php echo htmlSpecialChars(Debugger::$source) ?></li>
- <?php endif ?>
- <li>PHP <?php echo htmlSpecialChars(PHP_VERSION) ?></li>
- <?php if (isset($_SERVER['SERVER_SOFTWARE'])): ?><li><?php echo htmlSpecialChars($_SERVER['SERVER_SOFTWARE']) ?></li><?php endif ?>
- <?php if (class_exists('Nette\Framework')): ?><li><?php echo htmlSpecialChars('Nette Framework ' . Nette\Framework::VERSION) ?> <i>(revision <?php echo htmlSpecialChars(Nette\Framework::REVISION) ?>)</i></li><?php endif ?>
- </ul>
- </div>
- </div>
- <script type="text/javascript">/*<![CDATA[*/var bs=document.getElementById("netteBluescreen");document.body.appendChild(bs);document.onkeyup=function(b){b=b||window.event;b.keyCode==27&&!b.shiftKey&&!b.altKey&&!b.ctrlKey&&!b.metaKey&&bs.onclick({target:document.getElementById("netteBluescreenIcon")})};
- for(var i=0,styles=document.styleSheets;i<styles.length;i++)if((styles[i].owningElement||styles[i].ownerNode).className!=="nette"){styles[i].oldDisabled=styles[i].disabled;styles[i].disabled=true}else styles[i].addRule?styles[i].addRule(".nette-collapsed","display: none"):styles[i].insertRule(".nette-collapsed { display: none }",0);
- bs.onclick=function(b){b=b||window.event;for(var a=b.target||b.srcElement;a&&a.tagName&&a.tagName.toLowerCase()!=="a";)a=a.parentNode;if(!a||!a.rel)return true;for(var d=a.getElementsByTagName("abbr")[0],c=a.rel==="next"?a.nextSibling:document.getElementById(a.rel);c.nodeType!==1;)c=c.nextSibling;b=c.currentStyle?c.currentStyle.display=="none":getComputedStyle(c,null).display=="none";try{d.innerHTML=String.fromCharCode(b?9660:9658)}catch(e){}c.style.display=b?c.tagName.toLowerCase()==="code"?"inline":
- "block":"none";if(a.id==="netteBluescreenIcon"){a=0;for(d=document.styleSheets;a<d.length;a++)if((d[a].owningElement||d[a].ownerNode).className!=="nette")d[a].disabled=b?true:d[a].oldDisabled}return false};/*]]>*/</script>
- </body>
- </html>
- <?php
- }
- static function highlightFile($file, $line, $count = 15, $vars = array())
- {
- 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;
- $out = $source[0];
- $source = explode('<br />', $source[1]);
- array_unshift($source, NULL);
- $i = $start;
- while (--$i >= 1) {
- if (preg_match('#.*(</?span[^>]*>)#', $source[$i], $m)) {
- if ($m[1] !== '</span>') {
- $spans++; $out .= $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, '<span') - substr_count($s, '</span');
- $s = str_replace(array("\r", "\n"), array('', ''), $s);
- preg_match_all('#<[^>]+>#', $s, $tags);
- if ($n === $line) {
- $out .= sprintf(
- "<span class='highlight'>%{$numWidth}s: %s\n</span>%s",
- $n,
- strip_tags($s),
- implode('', $tags[0])
- );
- } else {
- $out .= sprintf("<span class='line'>%{$numWidth}s:</span> %s\n", $n, $s);
- }
- }
- $out .= str_repeat('</span>', $spans) . '</code>';
- $out = preg_replace_callback('#">\$(\w+)( )?</span>#', function($m) use($vars) {
- return isset($vars[$m[1]])
- ? '" title="' . str_replace('"', '"', strip_tags(Helpers::htmlDump($vars[$m[1]]))) . $m[0]
- : $m[0];
- }, $out);
- return $out;
- }
- }
- class Bar extends Nette\Object
- {
- private $panels = array();
- function addPanel(IBarPanel $panel, $id = NULL)
- {
- if ($id === NULL) {
- $c = 0;
- do {
- $id = get_class($panel) . ($c++ ? "-$c" : '');
- } while (isset($this->panels[$id]));
- }
- $this->panels[$id] = $panel;
- }
- function render()
- {
- $panels = array();
- foreach ($this->panels as $id => $panel) {
- try {
- $panels[] = array(
- 'id' => preg_replace('#[^a-z0-9]+#i', '-', $id),
- 'tab' => $tab = (string) $panel->getTab(),
- 'panel' => $tab ? (string) $panel->getPanel() : NULL,
- );
- } catch (\Exception $e) {
- $panels[] = array(
- 'id' => "error-$id",
- 'tab' => "Error: $id",
- 'panel' => nl2br(htmlSpecialChars((string) $e)),
- );
- }
- }
- ?>
- <!-- Nette Debug Bar -->
- <?php ob_start() ?>
-
- <style id="nette-debug-style" class="nette">#nette-debug{display:none;position:fixed}body#nette-debug{margin:5px 5px 0;display:block}#nette-debug *{font:inherit;color:inherit;background:transparent;margin:0;padding:0;border:none…
Large files files are truncated, but you can click here to view the full file