__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Negotiation;
abstract class BaseAccept
{
/**
* @var float
*/
private $quality = 1.0;
/**
* @var string
*/
private $normalized;
/**
* @var string
*/
private $value;
/**
* @var array
*/
private $parameters;
/**
* @var string
*/
protected $type;
/**
* @param string $value
*/
public function __construct($value)
{
list($type, $parameters) = $this->parseParameters($value);
if (isset($parameters['q'])) {
$this->quality = (float) $parameters['q'];
unset($parameters['q']);
}
$type = trim(strtolower($type));
$this->value = $value;
$this->normalized = $type . ($parameters ? "; " . $this->buildParametersString($parameters) : '');
$this->type = $type;
$this->parameters = $parameters;
}
/**
* @return string
*/
public function getNormalizedValue()
{
return $this->normalized;
}
/**
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @return float
*/
public function getQuality()
{
return $this->quality;
}
/**
* @return array
*/
public function getParameters()
{
return $this->parameters;
}
/**
* @param string $key
* @param mixed $default
*
* @return string|null
*/
public function getParameter($key, $default = null)
{
return isset($this->parameters[$key]) ? $this->parameters[$key] : $default;
}
/**
* @param string $key
*
* @return boolean
*/
public function hasParameter($key)
{
return isset($this->parameters[$key]);
}
/**
*
* @param string|null $acceptPart
* @return array
*/
private function parseParameters($acceptPart)
{
if ($acceptPart === null) {
return ['', []];
}
$parts = explode(';', $acceptPart);
$type = array_shift($parts);
$parameters = [];
foreach ($parts as $part) {
$part = explode('=', $part);
if (2 !== count($part)) {
continue; // TODO: throw exception here?
}
$key = strtolower(trim($part[0])); // TODO: technically not allowed space around "=". throw exception?
$parameters[$key] = trim($part[1], ' "');
}
return [ $type, $parameters ];
}
/**
* @param string $parameters
*
* @return string
*/
private function buildParametersString($parameters)
{
$parts = [];
ksort($parameters);
foreach ($parameters as $key => $val) {
$parts[] = sprintf('%s=%s', $key, $val);
}
return implode('; ', $parts);
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Exception | Folder | 0775 |
|
|
| AbstractNegotiator.php | File | 5 KB | 0664 |
|
| Accept.php | File | 825 B | 0664 |
|
| AcceptCharset.php | File | 104 B | 0664 |
|
| AcceptEncoding.php | File | 105 B | 0664 |
|
| AcceptHeader.php | File | 58 B | 0664 |
|
| AcceptLanguage.php | File | 1.04 KB | 0664 |
|
| AcceptMatch.php | File | 1.17 KB | 0664 |
|
| BaseAccept.php | File | 2.95 KB | 0664 |
|
| CharsetNegotiator.php | File | 224 B | 0664 |
|
| EncodingNegotiator.php | File | 226 B | 0664 |
|
| LanguageNegotiator.php | File | 1.05 KB | 0664 |
|
| Negotiator.php | File | 2.81 KB | 0664 |
|