From a91c916248f967da2d4218b575e665242b7c975b Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Thu, 25 Oct 2018 20:25:05 +0200 Subject: phoenixreborn\'NWY --- w/class/router.php | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 w/class/router.php (limited to 'w/class/router.php') diff --git a/w/class/router.php b/w/class/router.php new file mode 100644 index 0000000..4d9d718 --- /dev/null +++ b/w/class/router.php @@ -0,0 +1,63 @@ + ['art', 'read'], + 'art aff=read' => ['art', 'read'], + 'art aff=edit' => ['art', 'edit'], + 'art action=update home' => ['art', 'update', 'home'], + 'art action=add' => ['art', 'add'], + 'art action=delete' => ['art', 'delete'], + 'aff=home action=massedit', + 'aff=home' => ['home', 'desktop'], + '' => ['home', 'desktop'], + 'aff=home action=massedit' => ['home', 'massedit'], + 'action=massedit' => ['home', 'massedit'], + 'art action=login' => ['art', 'login'], + 'home action=login' => ['home', 'login'], + 'action=login' => ['home', 'login'], + 'aff=media' => ['media', 'desktop'], + 'aff=media action=addmedia' => ['media', 'addmedia'], + ]; + + public function __construct() { + if($this->matchroute()) { + $this->callmethod(); + } else { + echo '

404 Error

'; + } + } + + public function matchroute() + { + $this->route = new route($_GET); + $match = array_key_exists($this->route->tostring(), self::ROUTES); + return $match; + + } + + public function callmethod() + { + $method = self::ROUTES[$this->route->tostring()]; + + $class = 'controller' . $method[0]; + $function = $method[1]; + $controller = new $class($this->route->artid()); + $params = array_slice($method, 2); + $controller->$function(...$params); + } + + + +} + + + + + + +?> \ No newline at end of file -- cgit v1.2.3