Файл: system/classes/Router.php
Строк: 39
<?php
class Router
{
private $class;
private $action;
public function __construct ($RouteGet)
{
$exp = explode ('/', $RouteGet);
$this->Controller = $exp[0];
$this->Action = !empty ($exp[1]) ? $exp[1] : NULL;
$file = H . 'app/' . $this->Controller . '/index.php';
if (!ROUTER)
{
$this->Controller = 'index';
$this->Action = 'main';
$this->run().exit();
}
if (!file_exists($file))
{
$this->Controller = 'error';
$this->Action = 'main';
$this->run().exit();
}
$this->run().exit();
}
public function run()
{
$class = $this->Controller;
$action = $this->Action;
$file = H . 'app/'.$this->Controller . '/index.php';
if (!file_exists ($file))
{
$class = 'index';
$action = 'main';
}
require_once $file;
$controller = new $class;
if (is_callable([$controller, $action]) == false)
{
$action = 'main';
}
$controller->$action();
}
}