Exemplo n.º 1
0
 public static function ini($root = null)
 {
     //
     self::$r_400 = Config::get("error.400");
     self::$r_401 = Config::get("error.401");
     self::$r_402 = Config::get("error.402");
     self::$r_403 = Config::get("error.403");
     self::$r_404 = Config::get("error.404");
     self::$r_405 = Config::get("error.405");
     self::$r_406 = Config::get("error.406");
     self::$r_407 = Config::get("error.407");
     self::$r_408 = Config::get("error.408");
     self::$r_409 = Config::get("error.409");
     self::$r_410 = Config::get("error.410");
     self::$r_411 = Config::get("error.411");
     self::$r_412 = Config::get("error.412");
     self::$r_413 = Config::get("error.413");
     self::$r_414 = Config::get("error.414");
     self::$r_415 = Config::get("error.415");
     self::$r_416 = Config::get("error.416");
     self::$r_417 = Config::get("error.417");
     self::$r_418 = Config::get("error.418");
     self::$r_422 = Config::get("error.422");
     self::$r_423 = Config::get("error.423");
     self::$r_424 = Config::get("error.424");
     self::$r_425 = Config::get("error.425");
     self::$r_426 = Config::get("error.426");
     //
     self::$r_500 = Config::get("error.500");
     self::$r_501 = Config::get("error.501");
     self::$r_502 = Config::get("error.502");
     self::$r_503 = Config::get("error.503");
     self::$r_504 = Config::get("error.504");
     self::$r_505 = Config::get("error.505");
     self::$r_507 = Config::get("error.507");
     self::$r_509 = Config::get("error.509");
     self::$r_db = Config::get("error.database");
     //
 }
Exemplo n.º 2
0
 public static function run()
 {
     //
     $url = isset($_GET['url']) ? '/' . $_GET['url'] : '/';
     //echo $url;
     if (!Config::get("maintenance.activate") || in_array($url, Config::get("maintenance.outRoutes"))) {
         for ($i = 0; $i < count(self::$_uri); $i++) {
             if (strpos(self::$_uri[$i], '{}') !== false) {
                 self::$_uri[$i] = str_replace('{}', '(.*)?', self::$_uri[$i]);
             }
         }
         //
         $ok = 0;
         foreach (self::$_uri as $key => $value) {
             if (preg_match("#^{$value}\$#", $url, $params)) {
                 if (self::$_type[$key] == "post" && Res::isPost()) {
                     array_shift($params);
                     //
                     //before filter
                     //
                     call_user_func(App::$Callbacks['before']);
                     //
                     //new filter
                     //
                     $ok = true;
                     $falseok = null;
                     $oks = array();
                     //
                     if (is_string(self::$_request[$key])) {
                         if (!empty(self::$_request[$key])) {
                             $call = self::$_filters[self::$_request[$key]];
                             $ok = call_user_func($call);
                             if (!$ok) {
                                 $falseok = self::$_request[$key];
                             }
                         }
                     } else {
                         if (is_array(self::$_request[$key])) {
                             if (!empty(self::$_request[$key])) {
                                 foreach (self::$_request[$key] as $key2 => $value2) {
                                     $call = self::$_filters[$value2];
                                     $ok = call_user_func($call);
                                     if (!$ok) {
                                         $falseok = $value2;
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                     // run the route callback
                     if ($ok) {
                         self::$current = $value;
                         call_user_func_array(self::$_callback[$key], $params);
                     } else {
                         if (isset(self::$_falsecall[$falseok]) && !empty(self::$_falsecall[$falseok])) {
                             $call = self::$_falsecall[$falseok];
                             $ok = call_user_func($call);
                         }
                     }
                     //
                     //after filter
                     //
                     call_user_func(App::$Callbacks['after']);
                     $ok = 1;
                     break;
                     //
                     // old
                     // array_shift($params);
                     // call_user_func_array(self::$_callback[$key], $params);
                     // $ok=1;
                 } else {
                     if (self::$_type[$key] == "post" && !Res::isPost()) {
                         $ok = 0;
                     } else {
                         if (self::$_type[$key] == "get") {
                             array_shift($params);
                             //
                             //before filter
                             //
                             call_user_func(App::$Callbacks['before']);
                             //
                             //new filter
                             //
                             $ok = true;
                             $falseok = null;
                             $oks = array();
                             //
                             if (is_string(self::$_request[$key])) {
                                 if (!empty(self::$_request[$key])) {
                                     $call = self::$_filters[self::$_request[$key]];
                                     $ok = call_user_func($call);
                                     if (!$ok) {
                                         $falseok = self::$_request[$key];
                                     }
                                 }
                             } else {
                                 if (is_array(self::$_request[$key])) {
                                     if (!empty(self::$_request[$key])) {
                                         foreach (self::$_request[$key] as $key2 => $value2) {
                                             $call = self::$_filters[$value2];
                                             $ok = call_user_func($call);
                                             if (!$ok) {
                                                 $falseok = $value2;
                                                 break;
                                             }
                                         }
                                     }
                                 }
                             }
                             // run the route callback
                             if ($ok) {
                                 self::$current = $value;
                                 call_user_func_array(self::$_callback[$key], $params);
                             } else {
                                 if (isset(self::$_falsecall[$falseok]) && !empty(self::$_falsecall[$falseok])) {
                                     $call = self::$_falsecall[$falseok];
                                     $ok = call_user_func($call);
                                 }
                             }
                             //
                             //after filter
                             //
                             call_user_func(App::$Callbacks['after']);
                             $ok = 1;
                             break;
                         }
                     }
                 }
             }
         }
         if ($ok == 0) {
             Errors::r_404();
         }
     } else {
         if (Config::get("maintenance.maintenanceEvent") == "string") {
             echo Config::get("maintenance.maintenanceResponse");
         } else {
             if (Config::get("maintenance.maintenanceEvent") == "link") {
                 Url::redirect(Config::get("maintenance.maintenanceResponse"));
             }
         }
     }
 }
Exemplo n.º 3
0
 public static function run()
 {
     $currentUrl = self::CheckUrl();
     //
     if (self::CheckMaintenance($currentUrl)) {
         self::ReplaceParams();
         self::Replace();
         //
         $ok = false;
         //
         foreach (self::$requests as $value) {
             $requestsUrl = $value["url"];
             //var_dump($value);
             //
             if (preg_match("#^{$requestsUrl}\$#", $currentUrl, $params)) {
                 if (!is_null($value["subdomain"])) {
                     if (Table::contains($value["subdomain"], self::getDomain())) {
                         if ($value["methode"] == "post" && Res::isPost()) {
                             $ok = self::exec($params, $value);
                             break;
                         } else {
                             if ($value["methode"] == "post" && !Res::isPost()) {
                                 $ok = 0;
                             } else {
                                 if ($value["methode"] == "get") {
                                     $ok = self::exec($params, $value);
                                     break;
                                 } else {
                                     if ($value["methode"] == "resource") {
                                         $ok = self::exec($params, $value);
                                         break;
                                     } else {
                                         if ($value["methode"] == "object") {
                                             $ok = self::exec($params, $value);
                                             //var_dump($value);
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                     } else {
                         $ok = 0;
                     }
                 } else {
                     if ($value["methode"] == "post" && Res::isPost()) {
                         $ok = self::exec($params, $value);
                         break;
                     } else {
                         if ($value["methode"] == "post" && !Res::isPost()) {
                             $ok = 0;
                         } else {
                             if ($value["methode"] == "get") {
                                 $ok = self::exec($params, $value);
                                 break;
                             } else {
                                 if ($value["methode"] == "resource") {
                                     $ok = self::exec($params, $value);
                                     break;
                                 } else {
                                     if ($value["methode"] == "object") {
                                         $ok = self::exec($params, $value);
                                         //var_dump($value);
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($ok == 0) {
             if (Config::get('app.unrouted')) {
                 throw new invalidArgumentException("There is no route call's " . $currentUrl . " in your route file");
             } else {
                 Errors::r_404();
             }
         }
     } else {
         self::showMaintenance();
     }
 }
Exemplo n.º 4
0
 public static function run()
 {
     $currentUrl = self::CheckUrl();
     //
     if (\Maintenance::check()) {
         self::ReplaceParams();
         self::Replace();
         //
         $ok = false;
         //
         foreach (self::$requests as $value) {
             $requestsUrl = $value["url"];
             //var_dump($value);
             //
             if (preg_match("#^{$requestsUrl}\$#", $currentUrl, $params)) {
                 if (!is_null($value["subdomain"])) {
                     if (\Table::contains($value["subdomain"], self::getDomain())) {
                         if ($value["methode"] == "post" && \Res::isPost()) {
                             $ok = self::exec($params, $value);
                             break;
                         } else {
                             if ($value["methode"] == "post" && !\Res::isPost()) {
                                 $ok = 0;
                             } else {
                                 if ($value["methode"] == "get") {
                                     $ok = self::exec($params, $value);
                                     break;
                                 } else {
                                     if ($value["methode"] == "resource") {
                                         $ok = self::exec($params, $value);
                                         break;
                                     } else {
                                         if ($value["methode"] == "object") {
                                             $ok = self::exec($params, $value);
                                             //var_dump($value);
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                     } else {
                         $ok = 0;
                     }
                 } else {
                     if ($value["methode"] == "post" && \Res::isPost()) {
                         $ok = self::exec($params, $value);
                         break;
                     } else {
                         if ($value["methode"] == "post" && !\Res::isPost()) {
                             $ok = 0;
                         } else {
                             if ($value["methode"] == "get") {
                                 $ok = self::exec($params, $value);
                                 break;
                             } else {
                                 if ($value["methode"] == "resource") {
                                     $ok = self::exec($params, $value);
                                     break;
                                 } else {
                                     if ($value["methode"] == "object") {
                                         $ok = self::exec($params, $value);
                                         //var_dump($value);
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($ok == 0) {
             if (\Config::get('app.unrouted')) {
                 throw new RouteNotFoundException($currentUrl);
             } else {
                 \Errors::r_404();
             }
         }
     } else {
         \Maintenance::show();
     }
 }