src/Http/Response.php 0000666 00000017626 13436756135 0010616 0 ustar 00 = 50400) { if (is_int(http_response_code())) { $this->code = http_response_code(); } header_register_callback($this->removeDuplicateCookies); } } /** * Sets HTTP response code. * @param int * @return self * @throws Nette\InvalidArgumentException if code is invalid * @throws Nette\InvalidStateException if HTTP headers have been sent */ public function setCode($code) { $code = (int) $code; if ($code < 100 || $code > 599) { throw new Nette\InvalidArgumentException("Bad HTTP response '$code'."); } self::checkHeaders(); $this->code = $code; $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; header($protocol . ' ' . $code, TRUE, $code); return $this; } /** * Returns HTTP response code. * @return int */ public function getCode() { return $this->code; } /** * Sends a HTTP header and replaces a previous one. * @param string header name * @param string header value * @return self * @throws Nette\InvalidStateException if HTTP headers have been sent */ public function setHeader($name, $value) { self::checkHeaders(); if ($value === NULL) { header_remove($name); } elseif (strcasecmp($name, 'Content-Length') === 0 && ini_get('zlib.output_compression')) { // ignore, PHP bug #44164 } else { header($name . ': ' . $value, TRUE, $this->code); } return $this; } /** * Adds HTTP header. * @param string header name * @param string header value * @return self * @throws Nette\InvalidStateException if HTTP headers have been sent */ public function addHeader($name, $value) { self::checkHeaders(); header($name . ': ' . $value, FALSE, $this->code); return $this; } /** * Sends a Content-type HTTP header. * @param string mime-type * @param string charset * @return self * @throws Nette\InvalidStateException if HTTP headers have been sent */ public function setContentType($type, $charset = NULL) { $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : '')); return $this; } /** * Redirects to a new URL. Note: call exit() after it. * @param string URL * @param int HTTP code * @return void * @throws Nette\InvalidStateException if HTTP headers have been sent */ public function redirect($url, $code = self::S302_FOUND) { $this->setCode($code); $this->setHeader('Location', $url); echo "
Please click here to continue.
"; } /** * Sets the number of seconds before a page cached on a browser expires. * @param string|int|DateTime time, value 0 means "until the browser is closed" * @return self * @throws Nette\InvalidStateException if HTTP headers have been sent */ public function setExpiration($time) { if (!$time) { // no cache $this->setHeader('Cache-Control', 's-maxage=0, max-age=0, must-revalidate'); $this->setHeader('Expires', 'Mon, 23 Jan 1978 10:00:00 GMT'); return $this; } $time = DateTime::from($time); $this->setHeader('Cache-Control', 'max-age=' . ($time->format('U') - time())); $this->setHeader('Expires', self::date($time)); return $this; } /** * Checks if headers have been sent. * @return bool */ public function isSent() { return headers_sent(); } /** * Return the value of the HTTP header. * @param string * @param mixed * @return mixed */ public function getHeader($header, $default = NULL) { $header .= ':'; $len = strlen($header); foreach (headers_list() as $item) { if (strncasecmp($item, $header, $len) === 0) { return ltrim(substr($item, $len)); } } return $default; } /** * Returns a list of headers to sent. * @return array */ public function getHeaders() { $headers = array(); foreach (headers_list() as $header) { $a = strpos($header, ':'); $headers[substr($header, 0, $a)] = (string) substr($header, $a + 2); } return $headers; } /** * Returns HTTP valid date format. * @param string|int|DateTime * @return string */ public static function date($time = NULL) { $time = DateTime::from($time); $time->setTimezone(new \DateTimeZone('GMT')); return $time->format('D, d M Y H:i:s \G\M\T'); } /** * @return void */ public function __destruct() { if (self::$fixIE && isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE ') !== FALSE && in_array($this->code, array(400, 403, 404, 405, 406, 408, 409, 410, 500, 501, 505), TRUE) && preg_match('#^text/html(?:;|$)#', $this->getHeader('Content-Type', 'text/html')) ) { echo Nette\Utils\Random::generate(2e3, " \t\r\n"); // sends invisible garbage for IE self::$fixIE = FALSE; } } /** * Sends a cookie. * @param string name of the cookie * @param string value * @param string|int|DateTime expiration time, value 0 means "until the browser is closed" * @param string * @param string * @param bool * @param bool * @return self * @throws Nette\InvalidStateException if HTTP headers have been sent */ public function setCookie($name, $value, $time, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL) { self::checkHeaders(); setcookie( $name, $value, $time ? DateTime::from($time)->format('U') : 0, $path === NULL ? $this->cookiePath : (string) $path, $domain === NULL ? $this->cookieDomain : (string) $domain, $secure === NULL ? $this->cookieSecure : (bool) $secure, $httpOnly === NULL ? $this->cookieHttpOnly : (bool) $httpOnly ); $this->removeDuplicateCookies(); return $this; } /** * Deletes a cookie. * @param string name of the cookie. * @param string * @param string * @param bool * @return void * @throws Nette\InvalidStateException if HTTP headers have been sent */ public function deleteCookie($name, $path = NULL, $domain = NULL, $secure = NULL) { $this->setCookie($name, FALSE, 0, $path, $domain, $secure); } /** * Removes duplicate cookies from response. * @return void */ public function removeDuplicateCookies() { if (headers_sent($file, $line) || ini_get('suhosin.cookie.encrypt')) { return; } $flatten = array(); foreach (headers_list() as $header) { if (preg_match('#^Set-Cookie: .+?=#', $header, $m)) { $flatten[$m[0]] = $header; header_remove('Set-Cookie'); } } foreach (array_values($flatten) as $key => $header) { header($header, $key === 0); } } private function checkHeaders() { if (headers_sent($file, $line)) { throw new Nette\InvalidStateException('Cannot send header after HTTP headers have been sent' . ($file ? " (output started at $file:$line)." : '.')); } elseif (ob_get_length() && !array_filter(ob_get_status(TRUE), function($i) { return !$i['chunk_size']; })) { trigger_error('Possible problem: you are sending a HTTP header while already having some data in output buffer. Try OutputDebugger or start session earlier.', E_USER_NOTICE); } } } src/Http/RequestFactory.php 0000666 00000016000 13436756135 0011761 0 ustar 00 array('#/{2,}#' => '/'), // '%20' => '' 'url' => array(), // '#[.,)]\z#' => '' ); /** @var bool */ private $binary = FALSE; /** @var array */ private $proxies = array(); /** * @param bool * @return self */ public function setBinary($binary = TRUE) { $this->binary = (bool) $binary; return $this; } /** * @param array|string * @return self */ public function setProxy($proxy) { $this->proxies = (array) $proxy; return $this; } /** * Creates current HttpRequest object. * @return Request */ public function createHttpRequest() { // DETECTS URI, base path and script path of the request. $url = new UrlScript; $url->scheme = !empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https' : 'http'; $url->user = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : ''; $url->password = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : ''; // host & port if ((isset($_SERVER[$tmp = 'HTTP_HOST']) || isset($_SERVER[$tmp = 'SERVER_NAME'])) && preg_match('#^([a-z0-9_.-]+|\[[a-f0-9:]+\])(:\d+)?\z#i', $_SERVER[$tmp], $pair) ) { $url->host = strtolower($pair[1]); if (isset($pair[2])) { $url->port = (int) substr($pair[2], 1); } elseif (isset($_SERVER['SERVER_PORT'])) { $url->port = (int) $_SERVER['SERVER_PORT']; } } // path & query if (isset($_SERVER['REQUEST_URI'])) { // Apache, IIS 6.0 $requestUrl = $_SERVER['REQUEST_URI']; } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0 (PHP as CGI ?) $requestUrl = $_SERVER['ORIG_PATH_INFO']; if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') { $requestUrl .= '?' . $_SERVER['QUERY_STRING']; } } else { $requestUrl = ''; } $requestUrl = Strings::replace($requestUrl, $this->urlFilters['url']); $tmp = explode('?', $requestUrl, 2); $url->path = Strings::replace($tmp[0], $this->urlFilters['path']); $url->query = isset($tmp[1]) ? $tmp[1] : ''; // normalized url $url->canonicalize(); $url->path = Strings::fixEncoding($url->path); // detect script path if (isset($_SERVER['SCRIPT_NAME'])) { $script = $_SERVER['SCRIPT_NAME']; } elseif (isset($_SERVER['DOCUMENT_ROOT'], $_SERVER['SCRIPT_FILENAME']) && strncmp($_SERVER['DOCUMENT_ROOT'], $_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT'])) === 0 ) { $script = '/' . ltrim(strtr(substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT'])), '\\', '/'), '/'); } else { $script = '/'; } $path = strtolower($url->path) . '/'; $script = strtolower($script) . '/'; $max = min(strlen($path), strlen($script)); for ($i = 0; $i < $max; $i++) { if ($path[$i] !== $script[$i]) { break; } elseif ($path[$i] === '/') { $url->scriptPath = substr($url->path, 0, $i + 1); } } // GET, POST, COOKIE $useFilter = (!in_array(ini_get('filter.default'), array('', 'unsafe_raw')) || ini_get('filter.default_flags')); parse_str($url->query, $query); if (!$query) { $query = $useFilter ? filter_input_array(INPUT_GET, FILTER_UNSAFE_RAW) : (empty($_GET) ? array() : $_GET); } $post = $useFilter ? filter_input_array(INPUT_POST, FILTER_UNSAFE_RAW) : (empty($_POST) ? array() : $_POST); $cookies = $useFilter ? filter_input_array(INPUT_COOKIE, FILTER_UNSAFE_RAW) : (empty($_COOKIE) ? array() : $_COOKIE); $gpc = (bool) get_magic_quotes_gpc(); // remove fucking quotes, control characters and check encoding if ($gpc || !$this->binary) { $list = array(& $query, & $post, & $cookies); while (list($key, $val) = each($list)) { foreach ($val as $k => $v) { unset($list[$key][$k]); if ($gpc) { $k = stripslashes($k); } if (!$this->binary && is_string($k) && (preg_match(self::NONCHARS, $k) || preg_last_error())) { // invalid key -> ignore } elseif (is_array($v)) { $list[$key][$k] = $v; $list[] = & $list[$key][$k]; } else { if ($gpc && !$useFilter) { $v = stripSlashes($v); } if (!$this->binary && (preg_match(self::NONCHARS, $v) || preg_last_error())) { $v = ''; } $list[$key][$k] = $v; } } } unset($list, $key, $val, $k, $v); } // FILES and create FileUpload objects $files = array(); $list = array(); if (!empty($_FILES)) { foreach ($_FILES as $k => $v) { if (!$this->binary && is_string($k) && (preg_match(self::NONCHARS, $k) || preg_last_error())) { continue; } $v['@'] = & $files[$k]; $list[] = $v; } } while (list(, $v) = each($list)) { if (!isset($v['name'])) { continue; } elseif (!is_array($v['name'])) { if ($gpc) { $v['name'] = stripSlashes($v['name']); } if (!$this->binary && (preg_match(self::NONCHARS, $v['name']) || preg_last_error())) { $v['name'] = ''; } if ($v['error'] !== UPLOAD_ERR_NO_FILE) { $v['@'] = new FileUpload($v); } continue; } foreach ($v['name'] as $k => $foo) { if (!$this->binary && is_string($k) && (preg_match(self::NONCHARS, $k) || preg_last_error())) { continue; } $list[] = array( 'name' => $v['name'][$k], 'type' => $v['type'][$k], 'size' => $v['size'][$k], 'tmp_name' => $v['tmp_name'][$k], 'error' => $v['error'][$k], '@' => & $v['@'][$k], ); } } // HEADERS if (function_exists('apache_request_headers')) { $headers = array_change_key_case(apache_request_headers(), CASE_LOWER); } else { $headers = array(); foreach ($_SERVER as $k => $v) { if (strncmp($k, 'HTTP_', 5) == 0) { $k = substr($k, 5); } elseif (strncmp($k, 'CONTENT_', 8)) { continue; } $headers[ strtr(strtolower($k), '_', '-') ] = $v; } } $remoteAddr = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : NULL; $remoteHost = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : NULL; // proxy foreach ($this->proxies as $proxy) { if (Helpers::ipMatch($remoteAddr, $proxy)) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $remoteAddr = trim(current(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']))); } if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { $remoteHost = trim(current(explode(',', $_SERVER['HTTP_X_FORWARDED_HOST']))); } break; } } $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : NULL; if ($method === 'POST' && isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']) && preg_match('#^[A-Z]+\z#', $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']) ) { $method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']; } return new Request($url, $query, $post, $files, $cookies, $headers, $method, $remoteAddr, $remoteHost); } } src/Http/Session.php 0000666 00000031647 13436756135 0010442 0 ustar 00 '', // must be disabled because PHP implementation is invalid 'use_cookies' => 1, // must be enabled to prevent Session Hijacking and Fixation 'use_only_cookies' => 1, // must be enabled to prevent Session Fixation 'use_trans_sid' => 0, // must be disabled to prevent Session Hijacking and Fixation // cookies 'cookie_lifetime' => 0, // until the browser is closed 'cookie_path' => '/', // cookie is available within the entire domain 'cookie_domain' => '', // cookie is available on current subdomain only 'cookie_secure' => FALSE, // cookie is available on HTTP & HTTPS 'cookie_httponly' => TRUE,// must be enabled to prevent Session Hijacking // other 'gc_maxlifetime' => self::DEFAULT_FILE_LIFETIME,// 3 hours 'cache_limiter' => NULL, // (default "nocache", special value "\0") 'cache_expire' => NULL, // (default "180") 'hash_function' => NULL, // (default "0", means MD5) 'hash_bits_per_character' => NULL, // (default "4") ); /** @var IRequest */ private $request; /** @var IResponse */ private $response; public function __construct(IRequest $request, IResponse $response) { $this->request = $request; $this->response = $response; } /** * Starts and initializes session data. * @throws Nette\InvalidStateException * @return void */ public function start() { if (self::$started) { return; } $this->configure($this->options); $id = & $_COOKIE[session_name()]; if (!is_string($id) || !preg_match('#^[0-9a-zA-Z,-]{22,128}\z#i', $id)) { unset($_COOKIE[session_name()]); } set_error_handler(function($severity, $message) use (& $error) { // session_start returns FALSE on failure only sometimes if (($severity & error_reporting()) === $severity) { $error = $message; restore_error_handler(); } }); session_start(); if (!$error) { restore_error_handler(); } $this->response->removeDuplicateCookies(); if ($error) { @session_write_close(); // this is needed throw new Nette\InvalidStateException("session_start(): $error"); } self::$started = TRUE; /* structure: __NF: BrowserKey, Data, Meta, Time DATA: section->variable = data META: section->variable = Timestamp, Browser, Version */ $nf = & $_SESSION['__NF']; // regenerate empty session if (empty($nf['Time'])) { $nf['Time'] = time(); $this->regenerated = TRUE; } // browser closing detection $browserKey = $this->request->getCookie('nette-browser'); if (!$browserKey) { $browserKey = Nette\Utils\Random::generate(); } $browserClosed = !isset($nf['B']) || $nf['B'] !== $browserKey; $nf['B'] = $browserKey; // resend cookie $this->sendCookie(); // process meta metadata if (isset($nf['META'])) { $now = time(); // expire section variables foreach ($nf['META'] as $section => $metadata) { if (is_array($metadata)) { foreach ($metadata as $variable => $value) { if ((!empty($value['B']) && $browserClosed) || (!empty($value['T']) && $now > $value['T'])) { // whenBrowserIsClosed || Time if ($variable === '') { // expire whole section unset($nf['META'][$section], $nf['DATA'][$section]); continue 2; } unset($nf['META'][$section][$variable], $nf['DATA'][$section][$variable]); } } } } } if ($this->regenerated) { $this->regenerated = FALSE; $this->regenerateId(); } register_shutdown_function(array($this, 'clean')); } /** * Has been session started? * @return bool */ public function isStarted() { return (bool) self::$started; } /** * Ends the current session and store session data. * @return void */ public function close() { if (self::$started) { $this->clean(); session_write_close(); self::$started = FALSE; } } /** * Destroys all data registered to a session. * @return void */ public function destroy() { if (!self::$started) { throw new Nette\InvalidStateException('Session is not started.'); } session_destroy(); $_SESSION = NULL; self::$started = FALSE; if (!$this->response->isSent()) { $params = session_get_cookie_params(); $this->response->deleteCookie(session_name(), $params['path'], $params['domain'], $params['secure']); } } /** * Does session exists for the current request? * @return bool */ public function exists() { return self::$started || $this->request->getCookie($this->getName()) !== NULL; } /** * Regenerates the session ID. * @throws Nette\InvalidStateException * @return void */ public function regenerateId() { if (self::$started && !$this->regenerated) { if (headers_sent($file, $line)) { throw new Nette\InvalidStateException("Cannot regenerate session ID after HTTP headers have been sent" . ($file ? " (output started at $file:$line)." : ".")); } session_regenerate_id(TRUE); session_write_close(); $backup = $_SESSION; session_start(); $_SESSION = $backup; $this->response->removeDuplicateCookies(); } $this->regenerated = TRUE; } /** * Returns the current session ID. Don't make dependencies, can be changed for each request. * @return string */ public function getId() { return session_id(); } /** * Sets the session name to a specified one. * @param string * @return self */ public function setName($name) { if (!is_string($name) || !preg_match('#[^0-9.][^.]*\z#A', $name)) { throw new Nette\InvalidArgumentException('Session name must be a string and cannot contain dot.'); } session_name($name); return $this->setOptions(array( 'name' => $name, )); } /** * Gets the session name. * @return string */ public function getName() { return isset($this->options['name']) ? $this->options['name'] : session_name(); } /********************* sections management ****************d*g**/ /** * Returns specified session section. * @param string * @param string * @return SessionSection * @throws Nette\InvalidArgumentException */ public function getSection($section, $class = 'Nette\Http\SessionSection') { return new $class($this, $section); } /** * Checks if a session section exist and is not empty. * @param string * @return bool */ public function hasSection($section) { if ($this->exists() && !self::$started) { $this->start(); } return !empty($_SESSION['__NF']['DATA'][$section]); } /** * Iteration over all sections. * @return \ArrayIterator */ public function getIterator() { if ($this->exists() && !self::$started) { $this->start(); } if (isset($_SESSION['__NF']['DATA'])) { return new \ArrayIterator(array_keys($_SESSION['__NF']['DATA'])); } else { return new \ArrayIterator; } } /** * Cleans and minimizes meta structures. This method is called automatically on shutdown, do not call it directly. * @internal * @return void */ public function clean() { if (!self::$started || empty($_SESSION)) { return; } $nf = & $_SESSION['__NF']; if (isset($nf['META']) && is_array($nf['META'])) { foreach ($nf['META'] as $name => $foo) { if (empty($nf['META'][$name])) { unset($nf['META'][$name]); } } } if (empty($nf['META'])) { unset($nf['META']); } if (empty($nf['DATA'])) { unset($nf['DATA']); } } /********************* configuration ****************d*g**/ /** * Sets session options. * @param array * @return self * @throws Nette\NotSupportedException * @throws Nette\InvalidStateException */ public function setOptions(array $options) { if (self::$started) { $this->configure($options); } $this->options = $options + $this->options; if (!empty($options['auto_start'])) { $this->start(); } return $this; } /** * Returns all session options. * @return array */ public function getOptions() { return $this->options; } /** * Configurates session environment. * @param array * @return void */ private function configure(array $config) { $special = array('cache_expire' => 1, 'cache_limiter' => 1, 'save_path' => 1, 'name' => 1); foreach ($config as $key => $value) { if (!strncmp($key, 'session.', 8)) { // back compatibility $key = substr($key, 8); } $key = strtolower(preg_replace('#(.)(?=[A-Z])#', '$1_', $key)); if ($value === NULL || ini_get("session.$key") == $value) { // intentionally == continue; } elseif (strncmp($key, 'cookie_', 7) === 0) { if (!isset($cookie)) { $cookie = session_get_cookie_params(); } $cookie[substr($key, 7)] = $value; } else { if (defined('SID')) { throw new Nette\InvalidStateException("Unable to set 'session.$key' to value '$value' when session has been started" . ($this->started ? "." : " by session.auto_start or session_start().")); } if (isset($special[$key])) { $key = "session_$key"; $key($value); } elseif (function_exists('ini_set')) { ini_set("session.$key", $value); } elseif (ini_get("session.$key") != $value) { // intentionally == throw new Nette\NotSupportedException("Unable to set 'session.$key' to '$value' because function ini_set() is disabled."); } } } if (isset($cookie)) { session_set_cookie_params( $cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly'] ); if (self::$started) { $this->sendCookie(); } } } /** * Sets the amount of time allowed between requests before the session will be terminated. * @param string|int|DateTime time, value 0 means "until the browser is closed" * @return self */ public function setExpiration($time) { if (empty($time)) { return $this->setOptions(array( 'gc_maxlifetime' => self::DEFAULT_FILE_LIFETIME, 'cookie_lifetime' => 0, )); } else { $time = Nette\Utils\DateTime::from($time)->format('U') - time(); return $this->setOptions(array( 'gc_maxlifetime' => $time, 'cookie_lifetime' => $time, )); } } /** * Sets the session cookie parameters. * @param string path * @param string domain * @param bool secure * @return self */ public function setCookieParameters($path, $domain = NULL, $secure = NULL) { return $this->setOptions(array( 'cookie_path' => $path, 'cookie_domain' => $domain, 'cookie_secure' => $secure )); } /** * Returns the session cookie parameters. * @return array containing items: lifetime, path, domain, secure, httponly */ public function getCookieParameters() { return session_get_cookie_params(); } /** * Sets path of the directory used to save session data. * @return self */ public function setSavePath($path) { return $this->setOptions(array( 'save_path' => $path, )); } /** * Sets user session storage for PHP < 5.4. For PHP >= 5.4, use setHandler(). * @return self */ public function setStorage(ISessionStorage $storage) { if (self::$started) { throw new Nette\InvalidStateException('Unable to set storage when session has been started.'); } session_set_save_handler( array($storage, 'open'), array($storage, 'close'), array($storage, 'read'), array($storage, 'write'), array($storage, 'remove'), array($storage, 'clean') ); } /** * Sets user session handler. * @return self */ public function setHandler(\SessionHandlerInterface $handler) { if (self::$started) { throw new Nette\InvalidStateException('Unable to set handler when session has been started.'); } session_set_save_handler($handler); } /** * Sends the session cookies. * @return void */ private function sendCookie() { if (!headers_sent() && ob_get_level() && ob_get_length()) { trigger_error('Possible problem: you are starting session while already having some data in output buffer. This may not work if the outputted data grows. Try starting the session earlier.', E_USER_NOTICE); } $cookie = $this->getCookieParameters(); $this->response->setCookie( session_name(), session_id(), $cookie['lifetime'] ? $cookie['lifetime'] + time() : 0, $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly'] )->setCookie( 'nette-browser', $_SESSION['__NF']['B'], Response::BROWSER, $cookie['path'], $cookie['domain'] ); } } src/Http/Url.php 0000666 00000022651 13436756135 0007554 0 ustar 00 * scheme user password host port basePath relativeUrl * | | | | | | | * /--\ /--\ /------\ /-------\ /--\/--\/----------------------------\ * http://john:x0y17575@nette.org:8042/en/manual.php?name=param#fragment <-- absoluteUrl * \__________________________/\____________/^\________/^\______/ * | | | | * authority path query fragment * * * - authority: [user[:password]@]host[:port] * - hostUrl: http://user:password@nette.org:8042 * - basePath: /en/ (everything before relative URI not including the script name) * - baseUrl: http://user:password@nette.org:8042/en/ * - relativeUrl: manual.php * * @author David Grudl * * @property string $scheme * @property string $user * @property string $password * @property string $host * @property string $port * @property string $path * @property string $query * @property string $fragment * @property-read string $absoluteUrl * @property-read string $authority * @property-read string $hostUrl * @property-read string $basePath * @property-read string $baseUrl * @property-read string $relativeUrl */ class Url extends Nette\Object { /** @var array */ public static $defaultPorts = array( 'http' => 80, 'https' => 443, 'ftp' => 21, 'news' => 119, 'nntp' => 119, ); /** @var string */ private $scheme = ''; /** @var string */ private $user = ''; /** @var string */ private $pass = ''; /** @var string */ private $host = ''; /** @var int */ private $port = NULL; /** @var string */ private $path = ''; /** @var string */ private $query = ''; /** @var string */ private $fragment = ''; /** * @param string URL * @throws Nette\InvalidArgumentException */ public function __construct($url = NULL) { if (is_string($url)) { $parts = @parse_url($url); // @ - is escalated to exception if ($parts === FALSE) { throw new Nette\InvalidArgumentException("Malformed or unsupported URI '$url'."); } foreach ($parts as $key => $val) { $this->$key = $val; } if (!$this->port && isset(self::$defaultPorts[$this->scheme])) { $this->port = self::$defaultPorts[$this->scheme]; } if ($this->path === '' && ($this->scheme === 'http' || $this->scheme === 'https')) { $this->path = '/'; } } elseif ($url instanceof self) { foreach ($this as $key => $val) { $this->$key = $url->$key; } } } /** * Sets the scheme part of URI. * @param string * @return self */ public function setScheme($value) { $this->scheme = (string) $value; return $this; } /** * Returns the scheme part of URI. * @return string */ public function getScheme() { return $this->scheme; } /** * Sets the user name part of URI. * @param string * @return self */ public function setUser($value) { $this->user = (string) $value; return $this; } /** * Returns the user name part of URI. * @return string */ public function getUser() { return $this->user; } /** * Sets the password part of URI. * @param string * @return self */ public function setPassword($value) { $this->pass = (string) $value; return $this; } /** * Returns the password part of URI. * @return string */ public function getPassword() { return $this->pass; } /** * Sets the host part of URI. * @param string * @return self */ public function setHost($value) { $this->host = (string) $value; return $this; } /** * Returns the host part of URI. * @return string */ public function getHost() { return $this->host; } /** * Sets the port part of URI. * @param string * @return self */ public function setPort($value) { $this->port = (int) $value; return $this; } /** * Returns the port part of URI. * @return string */ public function getPort() { return $this->port; } /** * Sets the path part of URI. * @param string * @return self */ public function setPath($value) { $this->path = (string) $value; return $this; } /** * Returns the path part of URI. * @return string */ public function getPath() { return $this->path; } /** * Sets the query part of URI. * @param string|array * @return self */ public function setQuery($value) { $this->query = (string) (is_array($value) ? http_build_query($value, '', '&') : $value); return $this; } /** * Appends the query part of URI. * @param string|array * @return Url */ public function appendQuery($value) { $value = (string) (is_array($value) ? http_build_query($value, '', '&') : $value); $this->query .= ($this->query === '' || $value === '') ? $value : '&' . $value; return $this; } /** * Returns the query part of URI. * @return string */ public function getQuery() { return $this->query; } /** * @param string * @param mixed * @return mixed */ public function getQueryParameter($name, $default = NULL) { parse_str($this->query, $params); return isset($params[$name]) ? $params[$name] : $default; } /** * @param string * @param mixed NULL unsets the parameter * @return self */ public function setQueryParameter($name, $value) { parse_str($this->query, $params); if ($value === NULL) { unset($params[$name]); } else { $params[$name] = $value; } $this->setQuery($params); return $this; } /** * Sets the fragment part of URI. * @param string * @return self */ public function setFragment($value) { $this->fragment = (string) $value; return $this; } /** * Returns the fragment part of URI. * @return string */ public function getFragment() { return $this->fragment; } /** * Returns the entire URI including query string and fragment. * @return string */ public function getAbsoluteUrl() { return $this->getHostUrl() . $this->path . ($this->query === '' ? '' : '?' . $this->query) . ($this->fragment === '' ? '' : '#' . $this->fragment); } /** * Returns the [user[:pass]@]host[:port] part of URI. * @return string */ public function getAuthority() { $authority = $this->host; if ($this->port && (!isset(self::$defaultPorts[$this->scheme]) || $this->port !== self::$defaultPorts[$this->scheme])) { $authority .= ':' . $this->port; } if ($this->user !== '' && $this->scheme !== 'http' && $this->scheme !== 'https') { $authority = $this->user . ($this->pass === '' ? '' : ':' . $this->pass) . '@' . $authority; } return $authority; } /** * Returns the scheme and authority part of URI. * @return string */ public function getHostUrl() { return ($this->scheme ? $this->scheme . ':' : '') . '//' . $this->getAuthority(); } /** * Returns the base-path. * @return string */ public function getBasePath() { $pos = strrpos($this->path, '/'); return $pos === FALSE ? '' : substr($this->path, 0, $pos + 1); } /** * Returns the base-URI. * @return string */ public function getBaseUrl() { return $this->getHostUrl() . $this->getBasePath(); } /** * Returns the relative-URI. * @return string */ public function getRelativeUrl() { return (string) substr($this->getAbsoluteUrl(), strlen($this->getBaseUrl())); } /** * URI comparsion (this object must be in canonical form). * @param string * @return bool */ public function isEqual($url) { // compare host + path $part = self::unescape(strtok($url, '?#'), '%/'); if (strncmp($part, '//', 2) === 0) { // absolute URI without scheme if ($part !== '//' . $this->getAuthority() . $this->path) { return FALSE; } } elseif (strncmp($part, '/', 1) === 0) { // absolute path if ($part !== $this->path) { return FALSE; } } else { if ($part !== $this->getHostUrl() . $this->path) { return FALSE; } } // compare query strings $part = preg_split('#[&;]#', self::unescape(strtr((string) strtok('?#'), '+', ' '), '%&;=+')); sort($part); $query = preg_split('#[&;]#', $this->query); sort($query); return $part === $query; } /** * Transform to canonical form. * @return Url */ public function canonicalize() { $this->path = $this->path === '' ? '/' : self::unescape($this->path, '%/'); $this->host = strtolower(rawurldecode($this->host)); $this->query = self::unescape(strtr($this->query, '+', ' '), '%&;=+'); return $this; } /** * @return string */ public function __toString() { return $this->getAbsoluteUrl(); } /** * Similar to rawurldecode, but preserve reserved chars encoded. * @param string to decode * @param string reserved characters * @return string */ public static function unescape($s, $reserved = '%;/?:@&=+$,') { // reserved (@see RFC 2396) = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," // within a path segment, the characters "/", ";", "=", "?" are reserved // within a query component, the characters ";", "/", "?", ":", "@", "&", "=", "+", ",", "$" are reserved. preg_match_all('#(?<=%)[a-f0-9][a-f0-9]#i', $s, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER); foreach (array_reverse($matches) as $match) { $ch = chr(hexdec($match[0][0])); if (strpos($reserved, $ch) === FALSE) { $s = substr_replace($s, $ch, $match[0][1] - 1, 3); } } return $s; } } src/Http/Context.php 0000666 00000004114 13436756135 0010430 0 ustar 00 request = $request; $this->response = $response; } /** * Attempts to cache the sent entity by its last modification date. * @param string|int|DateTime last modified time * @param string strong entity tag validator * @return bool */ public function isModified($lastModified = NULL, $etag = NULL) { if ($lastModified) { $this->response->setHeader('Last-Modified', $this->response->date($lastModified)); } if ($etag) { $this->response->setHeader('ETag', '"' . addslashes($etag) . '"'); } $ifNoneMatch = $this->request->getHeader('If-None-Match'); if ($ifNoneMatch === '*') { $match = TRUE; // match, check if-modified-since } elseif ($ifNoneMatch !== NULL) { $etag = $this->response->getHeader('ETag'); if ($etag == NULL || strpos(' ' . strtr($ifNoneMatch, ",\t", ' '), ' ' . $etag) === FALSE) { return TRUE; } else { $match = TRUE; // match, check if-modified-since } } $ifModifiedSince = $this->request->getHeader('If-Modified-Since'); if ($ifModifiedSince !== NULL) { $lastModified = $this->response->getHeader('Last-Modified'); if ($lastModified != NULL && strtotime($lastModified) <= strtotime($ifModifiedSince)) { $match = TRUE; } else { return TRUE; } } if (empty($match)) { return TRUE; } $this->response->setCode(IResponse::S304_NOT_MODIFIED); return FALSE; } /** * @return IRequest */ public function getRequest() { return $this->request; } /** * @return IResponse */ public function getResponse() { return $this->response; } } src/Http/IResponse.php 0000666 00000005356 13436756135 0010724 0 ustar 00 $max) { return FALSE; } elseif ($ipv4) { $arr = array(ip2long($ip), ip2long($mask)); } else { $arr = unpack('N*', inet_pton($ip) . inet_pton($mask)); $size = $size === '' ? 0 : $max - $size; } $bits = implode('', array_map(function ($n) { return sprintf('%032b', $n); }, $arr)); return substr($bits, 0, $max - $size) === substr($bits, $max, $max - $size); } } src/Http/IRequest.php 0000666 00000005243 13436756135 0010551 0 ustar 00 error = UPLOAD_ERR_NO_FILE; return; // or throw exception? } } $this->name = $value['name']; $this->size = $value['size']; $this->tmpName = $value['tmp_name']; $this->error = $value['error']; } /** * Returns the file name. * @return string */ public function getName() { return $this->name; } /** * Returns the sanitized file name. * @return string */ public function getSanitizedName() { return trim(Nette\Utils\Strings::webalize($this->name, '.', FALSE), '.-'); } /** * Returns the MIME content type of an uploaded file. * @return string */ public function getContentType() { if ($this->isOk() && $this->type === NULL) { $this->type = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->tmpName); } return $this->type; } /** * Returns the size of an uploaded file. * @return int */ public function getSize() { return $this->size; } /** * Returns the path to an uploaded file. * @return string */ public function getTemporaryFile() { return $this->tmpName; } /** * Returns the path to an uploaded file. * @return string */ public function __toString() { return (string) $this->tmpName; } /** * Returns the error code. {@link http://php.net/manual/en/features.file-upload.errors.php} * @return int */ public function getError() { return $this->error; } /** * Is there any error? * @return bool */ public function isOk() { return $this->error === UPLOAD_ERR_OK; } /** * Move uploaded file to new location. * @param string * @return self */ public function move($dest) { @mkdir(dirname($dest), 0777, TRUE); // @ - dir may already exist @unlink($dest); // @ - file may not exists if (!call_user_func(is_uploaded_file($this->tmpName) ? 'move_uploaded_file' : 'rename', $this->tmpName, $dest)) { throw new Nette\InvalidStateException("Unable to move uploaded file '$this->tmpName' to '$dest'."); } chmod($dest, 0666); $this->tmpName = $dest; return $this; } /** * Is uploaded file GIF, PNG or JPEG? * @return bool */ public function isImage() { return in_array($this->getContentType(), array('image/gif', 'image/png', 'image/jpeg'), TRUE); } /** * Returns the image. * @return Nette\Utils\Image */ public function toImage() { return Nette\Utils\Image::fromFile($this->tmpName); } /** * Returns the dimensions of an uploaded image as array. * @return array */ public function getImageSize() { return $this->isOk() ? @getimagesize($this->tmpName) : NULL; // @ - files smaller than 12 bytes causes read error } /** * Get file contents. * @return string */ public function getContents() { // future implementation can try to work around safe_mode and open_basedir limitations return $this->isOk() ? file_get_contents($this->tmpName) : NULL; } } src/Http/UserStorage.php 0000666 00000010751 13436756135 0011253 0 ustar 00 sessionHandler = $sessionHandler; } /** * Sets the authenticated status of this user. * @param bool * @return self */ public function setAuthenticated($state) { $section = $this->getSessionSection(TRUE); $section->authenticated = (bool) $state; // Session Fixation defence $this->sessionHandler->regenerateId(); if ($state) { $section->reason = NULL; $section->authTime = time(); // informative value } else { $section->reason = self::MANUAL; $section->authTime = NULL; } return $this; } /** * Is this user authenticated? * @return bool */ public function isAuthenticated() { $session = $this->getSessionSection(FALSE); return $session && $session->authenticated; } /** * Sets the user identity. * @return self */ public function setIdentity(IIdentity $identity = NULL) { $this->getSessionSection(TRUE)->identity = $identity; return $this; } /** * Returns current user identity, if any. * @return Nette\Security\IIdentity|NULL */ public function getIdentity() { $session = $this->getSessionSection(FALSE); return $session ? $session->identity : NULL; } /** * Changes namespace; allows more users to share a session. * @param string * @return self */ public function setNamespace($namespace) { if ($this->namespace !== $namespace) { $this->namespace = (string) $namespace; $this->sessionSection = NULL; } return $this; } /** * Returns current namespace. * @return string */ public function getNamespace() { return $this->namespace; } /** * Enables log out after inactivity. * @param string|int|DateTime Number of seconds or timestamp * @param int Log out when the browser is closed | Clear the identity from persistent storage? * @return self */ public function setExpiration($time, $flags = 0) { $section = $this->getSessionSection(TRUE); if ($time) { $time = Nette\Utils\DateTime::from($time)->format('U'); $section->expireTime = $time; $section->expireDelta = $time - time(); } else { unset($section->expireTime, $section->expireDelta); } $section->expireIdentity = (bool) ($flags & self::CLEAR_IDENTITY); $section->expireBrowser = (bool) ($flags & self::BROWSER_CLOSED); $section->browserCheck = TRUE; $section->setExpiration(0, 'browserCheck'); $section->setExpiration($time, 'foo'); // time check return $this; } /** * Why was user logged out? * @return int */ public function getLogoutReason() { $session = $this->getSessionSection(FALSE); return $session ? $session->reason : NULL; } /** * Returns and initializes $this->sessionSection. * @return SessionSection */ protected function getSessionSection($need) { if ($this->sessionSection !== NULL) { return $this->sessionSection; } if (!$need && !$this->sessionHandler->exists()) { return NULL; } $this->sessionSection = $section = $this->sessionHandler->getSection('Nette.Http.UserStorage/' . $this->namespace); if (!$section->identity instanceof IIdentity || !is_bool($section->authenticated)) { $section->remove(); } if ($section->authenticated && $section->expireBrowser && !$section->browserCheck) { // check if browser was closed? $section->reason = self::BROWSER_CLOSED; $section->authenticated = FALSE; if ($section->expireIdentity) { unset($section->identity); } } if ($section->authenticated && $section->expireDelta > 0) { // check time expiration if ($section->expireTime < time()) { $section->reason = self::INACTIVITY; $section->authenticated = FALSE; if ($section->expireIdentity) { unset($section->identity); } } $section->expireTime = time() + $section->expireDelta; // sliding expiration } if (!$section->authenticated) { unset($section->expireTime, $section->expireDelta, $section->expireIdentity, $section->expireBrowser, $section->browserCheck, $section->authTime); } return $this->sessionSection; } } src/Http/UrlScript.php 0000666 00000002673 13436756135 0010743 0 ustar 00 * http://nette.org/admin/script.php/pathinfo/?name=param#fragment * \_______________/\________/ * | | * scriptPath pathInfo * * * - scriptPath: /admin/script.php (or simply /admin/ when script is directory index) * - pathInfo: /pathinfo/ (additional path information) * * @author David Grudl * * @property string $scriptPath * @property-read string $pathInfo */ class UrlScript extends Url { /** @var string */ private $scriptPath = '/'; /** * Sets the script-path part of URI. * @param string * @return self */ public function setScriptPath($value) { $this->scriptPath = (string) $value; return $this; } /** * Returns the script-path part of URI. * @return string */ public function getScriptPath() { return $this->scriptPath; } /** * Returns the base-path. * @return string */ public function getBasePath() { $pos = strrpos($this->scriptPath, '/'); return $pos === FALSE ? '' : substr($this->path, 0, $pos + 1); } /** * Returns the additional path information. * @return string */ public function getPathInfo() { return (string) substr($this->path, strlen($this->scriptPath)); } } src/Http/Request.php 0000666 00000015045 13436756135 0010441 0 ustar 00 url = $url; if ($query === NULL) { parse_str($url->query, $this->query); } else { $this->query = (array) $query; } $this->post = (array) $post; $this->files = (array) $files; $this->cookies = (array) $cookies; $this->headers = (array) $headers; $this->method = $method; $this->remoteAddress = $remoteAddress; $this->remoteHost = $remoteHost; } /** * Returns URL object. * @return UrlScript */ public function getUrl() { return $this->url; } /********************* query, post, files & cookies ****************d*g**/ /** * Returns variable provided to the script via URL query ($_GET). * If no key is passed, returns the entire array. * @param string key * @param mixed default value * @return mixed */ public function getQuery($key = NULL, $default = NULL) { if (func_num_args() === 0) { return $this->query; } elseif (isset($this->query[$key])) { return $this->query[$key]; } else { return $default; } } /** * Returns variable provided to the script via POST method ($_POST). * If no key is passed, returns the entire array. * @param string key * @param mixed default value * @return mixed */ public function getPost($key = NULL, $default = NULL) { if (func_num_args() === 0) { return $this->post; } elseif (isset($this->post[$key])) { return $this->post[$key]; } else { return $default; } } /** * Returns uploaded file. * @param string key (or more keys) * @return FileUpload */ public function getFile($key) { return Nette\Utils\Arrays::get($this->files, func_get_args(), NULL); } /** * Returns uploaded files. * @return array */ public function getFiles() { return $this->files; } /** * Returns variable provided to the script via HTTP cookies. * @param string key * @param mixed default value * @return mixed */ public function getCookie($key, $default = NULL) { return isset($this->cookies[$key]) ? $this->cookies[$key] : $default; } /** * Returns variables provided to the script via HTTP cookies. * @return array */ public function getCookies() { return $this->cookies; } /********************* method & headers ****************d*g**/ /** * Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive. * @return string */ public function getMethod() { return $this->method; } /** * Checks if the request method is the given one. * @param string * @return bool */ public function isMethod($method) { return strcasecmp($this->method, $method) === 0; } /** * Checks if the request method is POST. * @return bool */ public function isPost() { return $this->isMethod('POST'); } /** * Return the value of the HTTP header. Pass the header name as the * plain, HTTP-specified header name (e.g. 'Accept-Encoding'). * @param string * @param mixed * @return mixed */ public function getHeader($header, $default = NULL) { $header = strtolower($header); if (isset($this->headers[$header])) { return $this->headers[$header]; } else { return $default; } } /** * Returns all HTTP headers. * @return array */ public function getHeaders() { return $this->headers; } /** * Returns referrer. * @return Url|NULL */ public function getReferer() { return isset($this->headers['referer']) ? new Url($this->headers['referer']) : NULL; } /** * Is the request is sent via secure channel (https). * @return bool */ public function isSecured() { return $this->url->scheme === 'https'; } /** * Is AJAX request? * @return bool */ public function isAjax() { return $this->getHeader('X-Requested-With') === 'XMLHttpRequest'; } /** * Returns the IP address of the remote client. * @return string */ public function getRemoteAddress() { return $this->remoteAddress; } /** * Returns the host of the remote client. * @return string */ public function getRemoteHost() { if (!$this->remoteHost) { $this->remoteHost = $this->remoteAddress ? getHostByAddr($this->remoteAddress) : NULL; } return $this->remoteHost; } /** * Returns raw content of HTTP request body. * @return string */ public function getRawBody() { if (PHP_VERSION_ID >= 50600) { return file_get_contents('php://input'); } elseif ($this->rawBody === NULL) { // can be read only once in PHP < 5.6 $this->rawBody = (string) file_get_contents('php://input'); } return $this->rawBody; } /** * Parse Accept-Language header and returns prefered language. * @param array Supported languages * @return string|null */ public function detectLanguage(array $langs) { $header = $this->getHeader('Accept-Language'); if (!$header) { return NULL; } $s = strtolower($header); // case insensitive $s = strtr($s, '_', '-'); // cs_CZ means cs-CZ rsort($langs); // first more specific preg_match_all('#(' . implode('|', $langs) . ')(?:-[^\s,;=]+)?\s*(?:;\s*q=([0-9.]+))?#', $s, $matches); if (!$matches[0]) { return NULL; } $max = 0; $lang = NULL; foreach ($matches[1] as $key => $value) { $q = $matches[2][$key] === '' ? 1.0 : (float) $matches[2][$key]; if ($q > $max) { $max = $q; $lang = $value; } } return $lang; } } src/Http/SessionSection.php 0000666 00000012115 13436756135 0011754 0 ustar 00 session = $session; $this->name = $name; } /** * Do not call directly. Use Session::getNamespace(). */ private function start() { if ($this->meta === FALSE) { $this->session->start(); $this->data = & $_SESSION['__NF']['DATA'][$this->name]; $this->meta = & $_SESSION['__NF']['META'][$this->name]; } } /** * Returns an iterator over all section variables. * @return \ArrayIterator */ public function getIterator() { $this->start(); if (isset($this->data)) { return new \ArrayIterator($this->data); } else { return new \ArrayIterator; } } /** * Sets a variable in this session section. * @param string name * @param mixed value * @return void */ public function __set($name, $value) { $this->start(); $this->data[$name] = $value; } /** * Gets a variable from this session section. * @param string name * @return mixed */ public function &__get($name) { $this->start(); if ($this->warnOnUndefined && !array_key_exists($name, $this->data)) { trigger_error("The variable '$name' does not exist in session section", E_USER_NOTICE); } return $this->data[$name]; } /** * Determines whether a variable in this session section is set. * @param string name * @return bool */ public function __isset($name) { if ($this->session->exists()) { $this->start(); } return isset($this->data[$name]); } /** * Unsets a variable in this session section. * @param string name * @return void */ public function __unset($name) { $this->start(); unset($this->data[$name], $this->meta[$name]); } /** * Sets a variable in this session section. * @param string name * @param mixed value * @return void */ public function offsetSet($name, $value) { $this->__set($name, $value); } /** * Gets a variable from this session section. * @param string name * @return mixed */ public function offsetGet($name) { return $this->__get($name); } /** * Determines whether a variable in this session section is set. * @param string name * @return bool */ public function offsetExists($name) { return $this->__isset($name); } /** * Unsets a variable in this session section. * @param string name * @return void */ public function offsetUnset($name) { $this->__unset($name); } /** * Sets the expiration of the section or specific variables. * @param string|int|DateTime time, value 0 means "until the browser is closed" * @param mixed optional list of variables / single variable to expire * @return self */ public function setExpiration($time, $variables = NULL) { $this->start(); if (empty($time)) { $time = NULL; $whenBrowserIsClosed = TRUE; } else { $time = Nette\Utils\DateTime::from($time)->format('U'); $max = ini_get('session.gc_maxlifetime'); if ($time - time() > $max + 3) { // bulgarian constant trigger_error("The expiration time is greater than the session expiration $max seconds", E_USER_NOTICE); } $whenBrowserIsClosed = FALSE; } if ($variables === NULL) { // to entire section $this->meta['']['T'] = $time; $this->meta['']['B'] = $whenBrowserIsClosed; } elseif (is_array($variables)) { // to variables foreach ($variables as $variable) { $this->meta[$variable]['T'] = $time; $this->meta[$variable]['B'] = $whenBrowserIsClosed; } } else { // to variable $this->meta[$variables]['T'] = $time; $this->meta[$variables]['B'] = $whenBrowserIsClosed; } return $this; } /** * Removes the expiration from the section or specific variables. * @param mixed optional list of variables / single variable to expire * @return void */ public function removeExpiration($variables = NULL) { $this->start(); if ($variables === NULL) { // from entire section unset($this->meta['']['T'], $this->meta['']['B']); } elseif (is_array($variables)) { // from variables foreach ($variables as $variable) { unset($this->meta[$variable]['T'], $this->meta[$variable]['B']); } } else { unset($this->meta[$variables]['T'], $this->meta[$variables]['B']); } } /** * Cancels the current session section. * @return void */ public function remove() { $this->start(); $this->data = NULL; $this->meta = NULL; } } src/Bridges/HttpTracy/SessionPanel.php 0000666 00000001270 13436756135 0013771 0 ustar 00empty
', htmlspecialchars($k), ' | ', Dumper::toHtml($v), " |
---|