cleanup
This commit is contained in:
parent
664edcc1cb
commit
5149869952
|
@ -14,7 +14,7 @@ require_once './autolink.php';
|
||||||
require_once './pages.php';
|
require_once './pages.php';
|
||||||
require_once './router.php';
|
require_once './router.php';
|
||||||
|
|
||||||
$router = Router::init();
|
$router = new Router($_SERVER['REQUEST_METHOD'], $_GET['action'] ?? NULL, $_GET, $_POST, $_SERVER['QUERY_STRING'], $config);
|
||||||
$page = $router->route();
|
$page = $router->route();
|
||||||
$page->invoke();
|
$page->invoke();
|
||||||
|
|
||||||
|
|
|
@ -20,22 +20,21 @@ class Router {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function init(): Router {
|
|
||||||
global $config;
|
|
||||||
return new Router($_SERVER['REQUEST_METHOD'], $_GET['action'] ?? NULL, $_GET, $_POST, $_SERVER['QUERY_STRING'], $config);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function route(): Page {
|
function route(): Page {
|
||||||
// TODO: use $this->action
|
if ($this->action === "redirect"
|
||||||
if ($this->action === "redirect" && isset($this->post_vars['username']) && isset($this->post_vars['domain'])) {
|
&& isset($this->post_vars['username'])
|
||||||
|
&& isset($this->post_vars['domain'])) {
|
||||||
return new RedirectToAddressPage($this->post_vars['username'], $this->post_vars['domain']);
|
return new RedirectToAddressPage($this->post_vars['username'], $this->post_vars['domain']);
|
||||||
|
|
||||||
} elseif ($this->action === "download_email" && isset($this->get_vars['download_email_id']) && isset($this->get_vars['address'])) {
|
} elseif ($this->action === "download_email"
|
||||||
|
&& isset($this->get_vars['download_email_id'])
|
||||||
|
&& isset($this->get_vars['address'])) {
|
||||||
return new DownloadEmailPage($this->get_vars['download_email_id'], $this->get_vars['address'], $this->config['domains']);
|
return new DownloadEmailPage($this->get_vars['download_email_id'], $this->get_vars['address'], $this->config['domains']);
|
||||||
|
|
||||||
} elseif ($this->action === "delete_email" && isset($this->get_vars['delete_email_id']) && isset($this->get_vars['address'])) {
|
} elseif ($this->action === "delete_email"
|
||||||
|
&& isset($this->get_vars['delete_email_id'])
|
||||||
|
&& isset($this->get_vars['address'])) {
|
||||||
return new DeleteEmailPage($this->get_vars['delete_email_id'], $this->get_vars['address'], $this->config['domains']);
|
return new DeleteEmailPage($this->get_vars['delete_email_id'], $this->get_vars['address'], $this->config['domains']);
|
||||||
|
|
||||||
} elseif ($this->action === 'random') {
|
} elseif ($this->action === 'random') {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user