updated backend

This commit is contained in:
Torsten 2020-01-17 10:58:01 +01:00
parent 1fea0f4fe7
commit 11521c2339
3459 changed files with 72735 additions and 168535 deletions

View file

@ -88,7 +88,7 @@ class Response
const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; // RFC6585
/**
* @var \Symfony\Component\HttpFoundation\ResponseHeaderBag
* @var ResponseHeaderBag
*/
public $headers;
@ -121,14 +121,14 @@ class Response
* Status codes translation table.
*
* The list of codes is complete according to the
* {@link http://www.iana.org/assignments/http-status-codes/ Hypertext Transfer Protocol (HTTP) Status Code Registry}
* {@link https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml Hypertext Transfer Protocol (HTTP) Status Code Registry}
* (last updated 2016-03-01).
*
* Unless otherwise noted, the status code is defined in RFC2616.
*
* @var array
*/
public static $statusTexts = array(
public static $statusTexts = [
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing', // RFC2518
@ -191,16 +191,12 @@ class Response
508 => 'Loop Detected', // RFC5842
510 => 'Not Extended', // RFC2774
511 => 'Network Authentication Required', // RFC6585
);
];
/**
* @param mixed $content The response content, see setContent()
* @param int $status The response status code
* @param array $headers An array of response headers
*
* @throws \InvalidArgumentException When the HTTP status code is not valid
*/
public function __construct($content = '', $status = 200, $headers = array())
public function __construct($content = '', int $status = 200, array $headers = [])
{
$this->headers = new ResponseHeaderBag($headers);
$this->setContent($content);
@ -222,7 +218,7 @@ class Response
*
* @return static
*/
public static function create($content = '', $status = 200, $headers = array())
public static function create($content = '', $status = 200, $headers = [])
{
return new static($content, $status, $headers);
}
@ -274,7 +270,7 @@ class Response
} else {
// Content-type based on the Request
if (!$headers->has('Content-Type')) {
$format = $request->getRequestFormat();
$format = $request->getPreferredFormat();
if (null !== $format && $mimeType = $request->getMimeType($format)) {
$headers->set('Content-Type', $mimeType);
}
@ -310,13 +306,19 @@ class Response
}
// Check if we need to send extra expire info headers
if ('1.0' == $this->getProtocolVersion() && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) {
$this->headers->set('pragma', 'no-cache');
$this->headers->set('expires', -1);
if ('1.0' == $this->getProtocolVersion() && false !== strpos($headers->get('Cache-Control'), 'no-cache')) {
$headers->set('pragma', 'no-cache');
$headers->set('expires', -1);
}
$this->ensureIEOverSSLCompatibility($request);
if ($request->isSecure()) {
foreach ($headers->getCookies() as $cookie) {
$cookie->setSecureDefault(true);
}
}
return $this;
}
@ -334,14 +336,15 @@ class Response
// headers
foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) {
$replace = 0 === strcasecmp($name, 'Content-Type');
foreach ($values as $value) {
header($name.': '.$value, false, $this->statusCode);
header($name.': '.$value, $replace, $this->statusCode);
}
}
// cookies
foreach ($this->headers->getCookies() as $cookie) {
header('Set-Cookie: '.$cookie->getName().strstr($cookie, '='), false, $this->statusCode);
header('Set-Cookie: '.$cookie, false, $this->statusCode);
}
// status
@ -374,7 +377,7 @@ class Response
if (\function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
} elseif (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
} elseif (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
static::closeOutputBuffers(0, true);
}
@ -394,7 +397,7 @@ class Response
*/
public function setContent($content)
{
if (null !== $content && !\is_string($content) && !is_numeric($content) && !\is_callable(array($content, '__toString'))) {
if (null !== $content && !\is_string($content) && !is_numeric($content) && !\is_callable([$content, '__toString'])) {
throw new \UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', \gettype($content)));
}
@ -406,7 +409,7 @@ class Response
/**
* Gets the current response content.
*
* @return string Content
* @return string|false
*/
public function getContent()
{
@ -416,13 +419,11 @@ class Response
/**
* Sets the HTTP protocol version (1.0 or 1.1).
*
* @param string $version The HTTP protocol version
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setProtocolVersion($version)
public function setProtocolVersion(string $version)
{
$this->version = $version;
@ -432,11 +433,9 @@ class Response
/**
* Gets the HTTP protocol version.
*
* @return string The HTTP protocol version
*
* @final since version 3.2
* @final
*/
public function getProtocolVersion()
public function getProtocolVersion(): string
{
return $this->version;
}
@ -447,18 +446,15 @@ class Response
* If the status text is null it will be automatically populated for the known
* status codes and left empty otherwise.
*
* @param int $code HTTP status code
* @param mixed $text HTTP status text
*
* @return $this
*
* @throws \InvalidArgumentException When the HTTP status code is not valid
*
* @final since version 3.2
* @final
*/
public function setStatusCode($code, $text = null)
public function setStatusCode(int $code, $text = null)
{
$this->statusCode = $code = (int) $code;
$this->statusCode = $code;
if ($this->isInvalid()) {
throw new \InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $code));
}
@ -483,11 +479,9 @@ class Response
/**
* Retrieves the status code for the current web response.
*
* @return int Status code
*
* @final since version 3.2
* @final
*/
public function getStatusCode()
public function getStatusCode(): int
{
return $this->statusCode;
}
@ -495,13 +489,11 @@ class Response
/**
* Sets the response charset.
*
* @param string $charset Character set
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setCharset($charset)
public function setCharset(string $charset)
{
$this->charset = $charset;
@ -511,11 +503,9 @@ class Response
/**
* Retrieves the response charset.
*
* @return string Character set
*
* @final since version 3.2
* @final
*/
public function getCharset()
public function getCharset(): ?string
{
return $this->charset;
}
@ -535,13 +525,11 @@ class Response
* can be reused by a cache with heuristic expiration unless otherwise indicated"
* (https://tools.ietf.org/html/rfc7231#section-6.1)
*
* @return bool true if the response is worth caching, false otherwise
*
* @final since version 3.3
* @final
*/
public function isCacheable()
public function isCacheable(): bool
{
if (!\in_array($this->statusCode, array(200, 203, 300, 301, 302, 404, 410))) {
if (!\in_array($this->statusCode, [200, 203, 300, 301, 302, 404, 410])) {
return false;
}
@ -559,11 +547,9 @@ class Response
* origin. A response is considered fresh when it includes a Cache-Control/max-age
* indicator or Expires header and the calculated age is less than the freshness lifetime.
*
* @return bool true if the response is fresh, false otherwise
*
* @final since version 3.3
* @final
*/
public function isFresh()
public function isFresh(): bool
{
return $this->getTtl() > 0;
}
@ -572,11 +558,9 @@ class Response
* Returns true if the response includes headers that can be used to validate
* the response with the origin server using a conditional GET request.
*
* @return bool true if the response is validateable, false otherwise
*
* @final since version 3.3
* @final
*/
public function isValidateable()
public function isValidateable(): bool
{
return $this->headers->has('Last-Modified') || $this->headers->has('ETag');
}
@ -588,7 +572,7 @@ class Response
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setPrivate()
{
@ -605,7 +589,7 @@ class Response
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setPublic()
{
@ -618,13 +602,11 @@ class Response
/**
* Marks the response as "immutable".
*
* @param bool $immutable enables or disables the immutable directive
*
* @return $this
*
* @final
*/
public function setImmutable($immutable = true)
public function setImmutable(bool $immutable = true)
{
if ($immutable) {
$this->headers->addCacheControlDirective('immutable');
@ -638,11 +620,9 @@ class Response
/**
* Returns true if the response is marked as "immutable".
*
* @return bool returns true if the response is marked as "immutable"; otherwise false
*
* @final
*/
public function isImmutable()
public function isImmutable(): bool
{
return $this->headers->hasCacheControlDirective('immutable');
}
@ -655,11 +635,9 @@ class Response
* When present, the TTL of the response should not be overridden to be
* greater than the value provided by the origin.
*
* @return bool true if the response must be revalidated by a cache, false otherwise
*
* @final since version 3.3
* @final
*/
public function mustRevalidate()
public function mustRevalidate(): bool
{
return $this->headers->hasCacheControlDirective('must-revalidate') || $this->headers->hasCacheControlDirective('proxy-revalidate');
}
@ -667,13 +645,11 @@ class Response
/**
* Returns the Date header as a DateTime instance.
*
* @return \DateTime A \DateTime instance
*
* @throws \RuntimeException When the header is not parseable
*
* @final since version 3.2
* @final
*/
public function getDate()
public function getDate(): ?\DateTimeInterface
{
return $this->headers->getDate('Date');
}
@ -683,30 +659,32 @@ class Response
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setDate(\DateTime $date)
public function setDate(\DateTimeInterface $date)
{
$date->setTimezone(new \DateTimeZone('UTC'));
if ($date instanceof \DateTime) {
$date = \DateTimeImmutable::createFromMutable($date);
}
$date = $date->setTimezone(new \DateTimeZone('UTC'));
$this->headers->set('Date', $date->format('D, d M Y H:i:s').' GMT');
return $this;
}
/**
* Returns the age of the response.
* Returns the age of the response in seconds.
*
* @return int The age of the response in seconds
*
* @final since version 3.2
* @final
*/
public function getAge()
public function getAge(): int
{
if (null !== $age = $this->headers->get('Age')) {
return (int) $age;
}
return max(time() - $this->getDate()->format('U'), 0);
return max(time() - (int) $this->getDate()->format('U'), 0);
}
/**
@ -718,6 +696,7 @@ class Response
{
if ($this->isFresh()) {
$this->headers->set('Age', $this->getMaxAge());
$this->headers->remove('Expires');
}
return $this;
@ -726,17 +705,15 @@ class Response
/**
* Returns the value of the Expires header as a DateTime instance.
*
* @return \DateTime|null A DateTime instance or null if the header does not exist
*
* @final since version 3.2
* @final
*/
public function getExpires()
public function getExpires(): ?\DateTimeInterface
{
try {
return $this->headers->getDate('Expires');
} catch (\RuntimeException $e) {
// according to RFC 2616 invalid date formats (e.g. "0" and "-1") must be treated as in the past
return \DateTime::createFromFormat(DATE_RFC2822, 'Sat, 01 Jan 00 00:00:00 +0000');
return \DateTime::createFromFormat('U', time() - 172800);
}
}
@ -745,22 +722,25 @@ class Response
*
* Passing null as value will remove the header.
*
* @param \DateTime|null $date A \DateTime instance or null to remove the header
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setExpires(\DateTime $date = null)
public function setExpires(\DateTimeInterface $date = null)
{
if (null === $date) {
$this->headers->remove('Expires');
} else {
$date = clone $date;
$date->setTimezone(new \DateTimeZone('UTC'));
$this->headers->set('Expires', $date->format('D, d M Y H:i:s').' GMT');
return $this;
}
if ($date instanceof \DateTime) {
$date = \DateTimeImmutable::createFromMutable($date);
}
$date = $date->setTimezone(new \DateTimeZone('UTC'));
$this->headers->set('Expires', $date->format('D, d M Y H:i:s').' GMT');
return $this;
}
@ -771,11 +751,9 @@ class Response
* First, it checks for a s-maxage directive, then a max-age directive, and then it falls
* back on an expires header. It returns null when no maximum age can be established.
*
* @return int|null Number of seconds
*
* @final since version 3.2
* @final
*/
public function getMaxAge()
public function getMaxAge(): ?int
{
if ($this->headers->hasCacheControlDirective('s-maxage')) {
return (int) $this->headers->getCacheControlDirective('s-maxage');
@ -786,8 +764,10 @@ class Response
}
if (null !== $this->getExpires()) {
return $this->getExpires()->format('U') - $this->getDate()->format('U');
return (int) $this->getExpires()->format('U') - (int) $this->getDate()->format('U');
}
return null;
}
/**
@ -795,13 +775,11 @@ class Response
*
* This methods sets the Cache-Control max-age directive.
*
* @param int $value Number of seconds
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setMaxAge($value)
public function setMaxAge(int $value)
{
$this->headers->addCacheControlDirective('max-age', $value);
@ -813,13 +791,11 @@ class Response
*
* This methods sets the Cache-Control s-maxage directive.
*
* @param int $value Number of seconds
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setSharedMaxAge($value)
public function setSharedMaxAge(int $value)
{
$this->setPublic();
$this->headers->addCacheControlDirective('s-maxage', $value);
@ -835,29 +811,25 @@ class Response
* When the responses TTL is <= 0, the response may not be served from cache without first
* revalidating with the origin.
*
* @return int|null The TTL in seconds
*
* @final since version 3.2
* @final
*/
public function getTtl()
public function getTtl(): ?int
{
if (null !== $maxAge = $this->getMaxAge()) {
return $maxAge - $this->getAge();
}
$maxAge = $this->getMaxAge();
return null !== $maxAge ? $maxAge - $this->getAge() : null;
}
/**
* Sets the response's time-to-live for shared caches.
* Sets the response's time-to-live for shared caches in seconds.
*
* This method adjusts the Cache-Control/s-maxage directive.
*
* @param int $seconds Number of seconds
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setTtl($seconds)
public function setTtl(int $seconds)
{
$this->setSharedMaxAge($this->getAge() + $seconds);
@ -865,17 +837,15 @@ class Response
}
/**
* Sets the response's time-to-live for private/client caches.
* Sets the response's time-to-live for private/client caches in seconds.
*
* This method adjusts the Cache-Control/max-age directive.
*
* @param int $seconds Number of seconds
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setClientTtl($seconds)
public function setClientTtl(int $seconds)
{
$this->setMaxAge($this->getAge() + $seconds);
@ -885,13 +855,11 @@ class Response
/**
* Returns the Last-Modified HTTP header as a DateTime instance.
*
* @return \DateTime|null A DateTime instance or null if the header does not exist
*
* @throws \RuntimeException When the HTTP header is not parseable
*
* @final since version 3.2
* @final
*/
public function getLastModified()
public function getLastModified(): ?\DateTimeInterface
{
return $this->headers->getDate('Last-Modified');
}
@ -901,33 +869,34 @@ class Response
*
* Passing null as value will remove the header.
*
* @param \DateTime|null $date A \DateTime instance or null to remove the header
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setLastModified(\DateTime $date = null)
public function setLastModified(\DateTimeInterface $date = null)
{
if (null === $date) {
$this->headers->remove('Last-Modified');
} else {
$date = clone $date;
$date->setTimezone(new \DateTimeZone('UTC'));
$this->headers->set('Last-Modified', $date->format('D, d M Y H:i:s').' GMT');
return $this;
}
if ($date instanceof \DateTime) {
$date = \DateTimeImmutable::createFromMutable($date);
}
$date = $date->setTimezone(new \DateTimeZone('UTC'));
$this->headers->set('Last-Modified', $date->format('D, d M Y H:i:s').' GMT');
return $this;
}
/**
* Returns the literal value of the ETag HTTP header.
*
* @return string|null The ETag HTTP header or null if it does not exist
*
* @final since version 3.2
* @final
*/
public function getEtag()
public function getEtag(): ?string
{
return $this->headers->get('ETag');
}
@ -940,9 +909,9 @@ class Response
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setEtag($etag = null, $weak = false)
public function setEtag(string $etag = null, bool $weak = false)
{
if (null === $etag) {
$this->headers->remove('Etag');
@ -962,18 +931,16 @@ class Response
*
* Available options are: etag, last_modified, max_age, s_maxage, private, public and immutable.
*
* @param array $options An array of cache options
*
* @return $this
*
* @throws \InvalidArgumentException
*
* @final since version 3.3
* @final
*/
public function setCache(array $options)
{
if ($diff = array_diff(array_keys($options), array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public', 'immutable'))) {
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', array_values($diff))));
if ($diff = array_diff(array_keys($options), ['etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public', 'immutable'])) {
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', $diff)));
}
if (isset($options['etag'])) {
@ -1023,9 +990,9 @@ class Response
*
* @return $this
*
* @see http://tools.ietf.org/html/rfc2616#section-10.3.5
* @see https://tools.ietf.org/html/rfc2616#section-10.3.5
*
* @final since version 3.3
* @final
*/
public function setNotModified()
{
@ -1033,7 +1000,7 @@ class Response
$this->setContent(null);
// remove headers that MUST NOT be included with 304 Not Modified responses
foreach (array('Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified') as $header) {
foreach (['Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified'] as $header) {
$this->headers->remove($header);
}
@ -1043,11 +1010,9 @@ class Response
/**
* Returns true if the response includes a Vary header.
*
* @return bool true if the response includes a Vary header, false otherwise
*
* @final since version 3.2
* @final
*/
public function hasVary()
public function hasVary(): bool
{
return null !== $this->headers->get('Vary');
}
@ -1055,17 +1020,15 @@ class Response
/**
* Returns an array of header names given in the Vary header.
*
* @return array An array of Vary names
*
* @final since version 3.2
* @final
*/
public function getVary()
public function getVary(): array
{
if (!$vary = $this->headers->get('Vary', null, false)) {
return array();
if (!$vary = $this->headers->all('Vary')) {
return [];
}
$ret = array();
$ret = [];
foreach ($vary as $item) {
$ret = array_merge($ret, preg_split('/[\s,]+/', $item));
}
@ -1081,9 +1044,9 @@ class Response
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setVary($headers, $replace = true)
public function setVary($headers, bool $replace = true)
{
$this->headers->set('Vary', $headers, $replace);
@ -1099,9 +1062,9 @@ class Response
*
* @return bool true if the Response validators match the Request, false otherwise
*
* @final since version 3.3
* @final
*/
public function isNotModified(Request $request)
public function isNotModified(Request $request): bool
{
if (!$request->isMethodCacheable()) {
return false;
@ -1129,13 +1092,11 @@ class Response
/**
* Is response invalid?
*
* @return bool
* @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
*
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
*
* @final since version 3.2
* @final
*/
public function isInvalid()
public function isInvalid(): bool
{
return $this->statusCode < 100 || $this->statusCode >= 600;
}
@ -1143,11 +1104,9 @@ class Response
/**
* Is response informative?
*
* @return bool
*
* @final since version 3.3
* @final
*/
public function isInformational()
public function isInformational(): bool
{
return $this->statusCode >= 100 && $this->statusCode < 200;
}
@ -1155,11 +1114,9 @@ class Response
/**
* Is response successful?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isSuccessful()
public function isSuccessful(): bool
{
return $this->statusCode >= 200 && $this->statusCode < 300;
}
@ -1167,11 +1124,9 @@ class Response
/**
* Is the response a redirect?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isRedirection()
public function isRedirection(): bool
{
return $this->statusCode >= 300 && $this->statusCode < 400;
}
@ -1179,11 +1134,9 @@ class Response
/**
* Is there a client error?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isClientError()
public function isClientError(): bool
{
return $this->statusCode >= 400 && $this->statusCode < 500;
}
@ -1191,11 +1144,9 @@ class Response
/**
* Was there a server side error?
*
* @return bool
*
* @final since version 3.3
* @final
*/
public function isServerError()
public function isServerError(): bool
{
return $this->statusCode >= 500 && $this->statusCode < 600;
}
@ -1203,11 +1154,9 @@ class Response
/**
* Is the response OK?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isOk()
public function isOk(): bool
{
return 200 === $this->statusCode;
}
@ -1215,11 +1164,9 @@ class Response
/**
* Is the response forbidden?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isForbidden()
public function isForbidden(): bool
{
return 403 === $this->statusCode;
}
@ -1227,11 +1174,9 @@ class Response
/**
* Is the response a not found error?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isNotFound()
public function isNotFound(): bool
{
return 404 === $this->statusCode;
}
@ -1239,27 +1184,21 @@ class Response
/**
* Is the response a redirect of some form?
*
* @param string $location
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isRedirect($location = null)
public function isRedirect(string $location = null): bool
{
return \in_array($this->statusCode, array(201, 301, 302, 303, 307, 308)) && (null === $location ?: $location == $this->headers->get('Location'));
return \in_array($this->statusCode, [201, 301, 302, 303, 307, 308]) && (null === $location ?: $location == $this->headers->get('Location'));
}
/**
* Is the response empty?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isEmpty()
public function isEmpty(): bool
{
return \in_array($this->statusCode, array(204, 304));
return \in_array($this->statusCode, [204, 304]);
}
/**
@ -1267,17 +1206,13 @@ class Response
*
* Resulting level can be greater than target level if a non-removable buffer has been encountered.
*
* @param int $targetLevel The target output buffering level
* @param bool $flush Whether to flush or clean the buffers
*
* @final since version 3.3
* @final
*/
public static function closeOutputBuffers($targetLevel, $flush)
public static function closeOutputBuffers(int $targetLevel, bool $flush): void
{
$status = ob_get_status(true);
$level = \count($status);
// PHP_OUTPUT_HANDLER_* are not defined on HHVM 3.3
$flags = \defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1;
$flags = PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE);
while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || ($s['flags'] & $flags) === $flags : $s['del'])) {
if ($flush) {
@ -1293,9 +1228,9 @@ class Response
*
* @see http://support.microsoft.com/kb/323308
*
* @final since version 3.3
* @final
*/
protected function ensureIEOverSSLCompatibility(Request $request)
protected function ensureIEOverSSLCompatibility(Request $request): void
{
if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && 1 == preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) && true === $request->isSecure()) {
if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) {