Example #1
0
 public static function post($path, $arg)
 {
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         return;
     }
     if (self::$isRouteAvailable === true) {
         return;
     }
     if (!isset($_GET['page']) || empty($_GET['page'])) {
         $url = trim($_SERVER['REQUEST_URI'], '/');
     } else {
         $url = $_GET['page'];
     }
     if ($url == $path) {
         $data = explode("@", $arg);
         $file = CONTROLLER_ROOT . $data[0] . '.php';
         $method = $data[1];
         $controller = $data[0];
         if (file_exists($file)) {
             $Class = new $controller();
             if (method_exists($Class, $method)) {
                 call_user_func([$Class, $method]);
                 self::$isRouteAvailable = true;
                 return;
             }
         }
     }
     self::$isRouteAvailable = false;
 }