| Server IP : 121.121.20.254 / Your IP : 216.73.216.202 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/StockAdjust/wp-content/plugins/wp-all-export/src/Http/ |
Upload File : |
<?php
namespace Wpae\Http;
class Router
{
public function route($route, $secure = true)
{
$container = new \Wpae\Di\WpaeDi(array());
$request = new Request(file_get_contents('php://input'));
$q = $route;
$routeParts = explode('/', $q);
if($secure){
$controller = 'Wpae\\App\\Controller\\'.ucwords($routeParts[0]).'Controller';
} else {
$controller = 'Wpae\\App\\UnsecuredController\\'.ucwords($routeParts[0]).'Controller';
}
$action = ucwords($routeParts[1]).'Action';
$controller = new $controller($container);
$response = $controller->$action($request);
if(!$response instanceof \Wpae\Http\Response) {
throw new \Exception('The controller must return an HttpResponse instance.');
}
$response->render();
}
}