| Server IP : 185.252.147.100 / Your IP : 216.73.217.33 Web Server : nginx/1.27.3 System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 User : mitr ( 1000) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/html/kanboard/app/Core/Http/ |
Upload File : |
<?php
namespace Kanboard\Core\Http;
use Kanboard\Core\Base;
/**
* Route Dispatcher
*
* @package http
* @author Frederic Guillot
*/
class Router extends Base
{
const DEFAULT_CONTROLLER = 'DashboardController';
const DEFAULT_METHOD = 'show';
/**
* Plugin name
*
* @access private
* @var string
*/
private $currentPluginName = '';
/**
* Controller
*
* @access private
* @var string
*/
private $currentControllerName = '';
/**
* Action
*
* @access private
* @var string
*/
private $currentActionName = '';
/**
* Get plugin name
*
* @access public
* @return string
*/
public function getPlugin()
{
return $this->currentPluginName;
}
/**
* Get controller
*
* @access public
* @return string
*/
public function getController()
{
return $this->currentControllerName;
}
/**
* Get action
*
* @access public
* @return string
*/
public function getAction()
{
return $this->currentActionName;
}
/**
* Get the path to compare patterns
*
* @access public
* @return string
*/
public function getPath()
{
$path = substr($this->request->getUri(), strlen($this->helper->url->dir()));
if ($this->request->getQueryString() !== '') {
$path = substr($path, 0, - strlen($this->request->getQueryString()) - 1);
}
if ($path !== '' && $path[0] === '/') {
$path = substr($path, 1);
}
return $path;
}
/**
* Find controller/action from the route table or from get arguments
*
* @access public
*/
public function dispatch()
{
$controller = $this->request->getStringParam('controller');
$action = $this->request->getStringParam('action');
$plugin = $this->request->getStringParam('plugin');
if ($controller === '') {
$route = $this->route->findRoute($this->getPath());
$controller = $route['controller'];
$action = $route['action'];
$plugin = $route['plugin'];
}
$this->currentControllerName = ucfirst($this->sanitize($controller, self::DEFAULT_CONTROLLER));
$this->currentActionName = $this->sanitize($action, self::DEFAULT_METHOD);
$this->currentPluginName = ucfirst($this->sanitize($plugin));
}
/**
* Check controller and action parameter
*
* @access public
* @param string $value
* @param string $default
* @return string
*/
public function sanitize($value, $default = '')
{
return preg_match('/^[a-zA-Z_0-9]+$/', $value) ? $value : $default;
}
}