[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.144.37.178: ~ $
<?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);
    }
}

Filemanager

Name Type Size Permission Actions
Exception Folder 0755
AbstractNegotiator.php File 5 KB 0644
Accept.php File 825 B 0644
AcceptCharset.php File 104 B 0644
AcceptEncoding.php File 105 B 0644
AcceptHeader.php File 58 B 0644
AcceptLanguage.php File 1.04 KB 0644
AcceptMatch.php File 1.17 KB 0644
BaseAccept.php File 2.95 KB 0644
CharsetNegotiator.php File 224 B 0644
EncodingNegotiator.php File 226 B 0644
LanguageNegotiator.php File 1.05 KB 0644
Match.php File 1.12 KB 0644
Negotiator.php File 2.81 KB 0644