URL compatible Base64 Decode

@param string $input           A base64 encoded string
@return mixed                  Decoded data
760039
public static function base64url_decode($input)
  {
    $remainder = strlen($input) % 4;
    if ($remainder) {
        $padlen = 4 - $remainder;
        $input .= str_repeat('=', $padlen);
    }

    return base64_decode(strtr($input, '-_', '+/'));
  }
1177690
protected function transformWalletPassword($input = '')
    {
        if (!\Genesis\Utils\Common::isBase64Encoded($input)) {
            return base64_encode($input);
        }

        return $input;
    }
599813
public function decode($input)
    {
        $this->value = trim(
            mcrypt_decrypt(
                MCRYPT_RIJNDAEL_256,
                $this->secureKey,
                base64_decode($input),
                MCRYPT_MODE_ECB,
                $this->iv
            )
        );

        return $this->value;
    }
741836
private function withParam( string$input )
	{
		return str_replace('$_FLAG_$',"__HTSL_CTRL_FLAG_{$this->id}__",preg_replace_callback('/(?<!%)%s((?:\\/.+?(?<!\\\\)\\/.+?(?<!\\\\)\\/)+)?/',function( array$matches ){
			$param= $this->param;

			if( isset($matches[1]) ){
				array_map(...[
					function($replacer)use(&$param){
						list($pattern,$replacement,)= preg_split('/(?<!\\\\)\\//',$replacer);
						$param= preg_replace(...[
							"/$pattern/",
							preg_replace('/^\\\\_$/','',$replacement),
							$param,
						]);
					},
					preg_split(
						'/(?<!\\\\)\\/\\//'
						,
						trim($matches[1],'/')
					),
				]);
			}
			return $param;
		},$input));
	}
920119
public function encode($input)
    {
        $parts = explode('.', $input);

        foreach ($parts as &$part) {
            $part = $this->_encodePart($part);
        }

        return implode('.', $parts);
    }
1091376
public static function parseParameters( $input ) {
		if ( !isset( $input ) || !$input ) {
			return [];
		}

		$pairs = explode( '&', $input );

		$parsed = [];
		foreach ( $pairs as $pair ) {
			$split = explode( '=', $pair, 2 );
			$parameter = static::urldecode( $split[0] );
			$value = isset( $split[1] ) ? static::urldecode( $split[1] ) : '';

			if ( isset( $parsed[$parameter] ) ) {
				// We have already recieved parameter(s) with this name, so
				// add to the list of parameters with this name

				if ( is_scalar( $parsed[$parameter] ) ) {
					// This is the first duplicate, so transform scalar
					// (string) into an array so we can add the duplicates
					$parsed[$parameter] = [ $parsed[$parameter] ];
				}

				$parsed[$parameter][] = $value;
			} else {
				$parsed[$parameter] = $value;
			}
		}
		return $parsed;
	}
1159981
public function base64UrlDecode(string $data): string
    {
        return \base64_decode(\str_pad(\strtr($data, '-_', '+/'), \strlen($data)%4, '=', \STR_PAD_RIGHT));
    }
270151
protected function decodeToData($input)
    {
        $output = [];

        if (is_array($input)) {
            $output = $this->arrayToData($input);
        } elseif (is_int($input)) {
            $output = $this->intToData($input);
        } elseif (is_numeric($input)) {
            $output = $this->numericToData($input);
        } elseif (is_string($input)) {
            $output = $this->stringToData($input, $this->encoding);
        }
        return $output;
    }
1368304
public static function url($input, $domain = false)
    {
        if (!trim((string)$input)) {
            $input = '/';
        }

        if (Grav::instance()['config']->get('system.absolute_urls', false)) {
            $domain = true;
        }

        if (Grav::instance()['uri']->isExternal($input)) {
            return $input;
        }

        /** @var Uri $uri */
        $uri = Grav::instance()['uri'];

        $root = $uri->rootUrl();
        $input = Utils::replaceFirstOccurrence($root, '', $input);

        $input = ltrim((string)$input, '/');

        if (Utils::contains((string)$input, '://')) {
            /** @var UniformResourceLocator $locator */
            $locator = Grav::instance()['locator'];

            $parts = Uri::parseUrl($input);

            if ($parts) {
                $resource = $locator->findResource("{$parts['scheme']}://{$parts['host']}{$parts['path']}", false);

                if (isset($parts['query'])) {
                    $resource = $resource . '?' . $parts['query'];
                }
            } else {
                // Not a valid URL (can still be a stream).
                $resource = $locator->findResource($input, false);
            }


        } else {
            $resource = $input;
        }



        return rtrim($uri->rootUrl($domain), '/') . '/' . ($resource ?? '');
    }
1128337
def base64url_decode(input):
    
    rem = len(input) % 4

    if rem > 0:
        input += b'=' * (4 - rem)

    return base64.urlsafe_b64decode(input)
1081847
public static function parseFormData($input)
    {
        $boundary = substr($input, 0, strpos($input, "\r\n"));

        // Fetch each part
        $parts = array_slice(explode($boundary, $input), 1);
        $data = [];
        $files = [];

        foreach ($parts as $part) {
            // If this is the last part, break
            if (strpos($part, '--') === 0) {
                break;
            }

            // Separate content from headers
            $part = ltrim($part, "\r\n");

            list($rawHeaders, $content) = explode("\r\n\r\n", $part, 2);

            $content = substr($content, 0, strlen($content) - 2);

            // Parse the headers list
            $rawHeaders = explode("\r\n", $rawHeaders);
            $headers = [];

            foreach ($rawHeaders as $header) {
                list($name, $value) = explode(':', $header, 2);

                $headers[strtolower($name)] = ltrim($value, ' ');
            }

            // Parse the Content-Disposition to get the field name, etc.
            if (isset($headers['content-disposition'])) {
                $filename = null;

                preg_match(
                    '/^form-data; *name="([^"]+)"(?:; *filename="([^"]+)")?/',
                    $headers['content-disposition'],
                    $matches
                );

                $field = $matches[1];
                $fileName = (isset($matches[2]) ? $matches[2] : null);

                $fieldName = str_replace(['[', '][', ']'], ['.', '.', ''], $field);

                // If we have no filename, save the data. Otherwise, save the file.
                if ($fileName === null) {
                    static::setByPath($data, $fieldName, $content);
                } else {
                    $tempFile = tempnam(sys_get_temp_dir(), 'sfy');

                    file_put_contents($tempFile, $content);

                    $content = [
                        'name' => $fileName,
                        'type' => $headers['content-type'],
                        'tmp_name' => $tempFile,
                        'error' => 0,
                        'size' => filesize($tempFile),
                    ];

                    static::setByPath($files, $fieldName, $content);

                    register_shutdown_function(
                        function () use ($tempFile) {
                            @unlink($tempFile);
                        }
                    );
                }
            }
        }

        return [
            'data' => $data,
            'files' => $files,
        ];
    }
439301
protected function decode($string)
    {
        // decode if specified
        if (($pos = strpos($string, ':')) !== false) {
            if (!strncmp($string, 'base64', 6)) {
                return base64_decode(substr($string, 7));
            } elseif (!strncmp($string, 'urlencode', 9)) {
                return urldecode(substr($string, 10));
            }
        }

        return $string;
    }
7994
protected function _buildBinaryBody($input)
  {
    if (// is it a file, a readable one?
      @file_exists($input)
      && @is_readable($input)
    ) {
      // try to read the file
      $data = @file_get_contents($input);
      if ($data !== false && strlen($data) !== 0) {
        return $data;
      }
    } elseif (// is it a remote file?
      filter_var($input, FILTER_VALIDATE_URL)
      && preg_match('/^https?:\/\//', $input)
    ) {
      $data = $this->_fetchRemoteFile($input);
      if ($data !== false) {
        return $data;
      }
    }
    return $input;
  }
643296
protected function decodeSingleHeader($input)
    {
        // For each encoded-word...
        while (preg_match('/(=\?([^?]+)\?(q|b)\?([^?]*)\?=)((\s+)=\?)?/i', $input, $matches)) {
            $encoded = $matches[1];
            $charset = $matches[2];
            $encoding = $matches[3];
            $text = $matches[4];
            $space = isset($matches[6]) ? $matches[6] : '';

            switch (strtolower($encoding)) {
                case 'b':
                    $text = $this->decodeContentTransfer($text, 'base64');
                    break;

                case 'q':
                    $text = str_replace('_', ' ', $text);
                    preg_match_all('/=([a-f0-9]{2})/i', $text, $matches);
                    foreach ($matches[1] as $value) {
                        $text = str_replace('='.$value, chr(hexdec($value)), $text);
                    }
                    break;
            }

            $text = $this->charset->decodeCharset($text, $this->charset->getCharsetAlias($charset));
            $input = str_replace($encoded.$space, $text, $input);
        }

        return $input;
    }
638761
public static function base64Decode($data, $url = true)
    {
        if ($url) {
            return base64_decode(strtr($data, '-_', '+/'));
        } else {
            return base64_decode($data);
        }
    }
1370375
public function decode(string $input)
    {
        // if (!is_string($input)) {
        //     throw new InvalidArgumentException('Input must be string when call decode.');
        // }
        $input = $this->toBuffer($input);
        $decoded = $this->decodeData($input);

        return $decoded['data'];
    }
912576
protected function _unserialize($input)
	{
		$data = @unserialize($input);

		if (is_array($data))
		{
			foreach ($data as $key => $val)
			{
				if (is_string($val))
				{
					$data[$key] = str_replace('{{slash}}', '\\', $val);
				}
			}

			return $data;
		}

		elseif ($data === false)
		{
			is_string($input) and $data = array($input);
		}

		return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data;
	}