示例#1
0
 public function buildPage()
 {
     $user = Services\FacebookAPI::getInstance()->getUser();
     if (!$user || $user && !$user->isAdmin()) {
         Page404::getInstance()->buildPage();
         exit;
     }
     $params = $this->params;
     if (isset($params["sub_page"])) {
         foreach ($this->subpages as $subpage) {
             if ($params["sub_page"] == $subpage["slug"] && method_exists($this, $subpage["action"])) {
                 $this->current_subpage = $subpage;
                 $this->{$subpage}["action"]($params);
                 echo $this->getHtml();
                 return;
             }
         }
     }
     if (isset($params["action"]) && method_exists($this, $params["action"])) {
         $this->{$params}["action"]($params);
     }
     $this->current_subpage["action"] = "";
     $this->dashboardSubpage($params);
     echo $this->getHtml();
 }
示例#2
0
 public function routing()
 {
     $result = false;
     foreach ($this->routes as $path) {
         if (preg_match($path["pattern"], $_SERVER['REDIRECT_URL'], $match) && method_exists('\\SCPV\\Controllers\\' . $path["controller"], "getInstance")) {
             $result = call_user_func(['\\SCPV\\Controllers\\' . $path["controller"], "getInstance"], $match);
         }
     }
     if (!$result) {
         $sapi_type = php_sapi_name();
         if (substr($sapi_type, 0, 3) == 'cgi') {
             header("Status: 404 Not Found");
         } else {
             header("HTTP/1.1 404 Not Found");
         }
         // call 404 controller
         $page = Controllers\Page404::getInstance();
         $page->buildPage();
     } else {
         //header("HTTP/1.1 200 OK");
         $result->buildpage();
     }
 }