コード例 #1
0
ファイル: Route.php プロジェクト: aufa/Enproject
 /**
  * Set request route
  *
  * Takes an array of URI segments as input and sets the callable method
  * to be called.
  *
  * @access private
  * @param   array   $segments   URI segments
  * @return  object
  */
 protected function setRequest($segments = array())
 {
     if (!static::isBlocked()) {
         $method = $this->x_default_view;
         if (!empty($segments)) {
             if (is_array($segments) && is_callable(reset($segments))) {
                 $method = reset($segments);
             } elseif (is_callable($segments)) {
                 $method = $segments;
             }
         }
         if ($this->x_is_no_match) {
             Response::setStatus(404);
             $method = $this->x_default_notfound;
         }
         if (!is_callable($method)) {
             Response::setStatus(500);
             $method = $this->x_default_500;
         }
     } else {
         // blocked is same as 404
         Response::setStatus(404);
         static::setNotfound();
         $method = $this->x_default_blocked;
     }
     $this->x_method = $method;
     // end benchmark
     Benchmark::set('route', 'end');
     return $this;
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: aufa/Enproject
 /**
  * Default Blocked URL output Handler
  */
 public static function errorBlocked()
 {
     // set 400 Bad Request
     Response::setStatus(400);
     $template = Template::singleton();
     $template_dir = $template->getActiveTemplateDirectory();
     $file_blocked = $template->x_blocked_file;
     if ($template_dir && $file_blocked && is_string($file_blocked)) {
         if (is_file("{$template_dir}/{$file_blocked}")) {
             // using callback to prevent direct access
             return call_user_func(function ($a) {
                 ob_start();
                 require $a;
                 $content = ob_get_clean();
                 Response::setBody($content);
             }, "{$template_dir}/{$file_blocked}");
         }
     }
     Response::setBody(Html::create('Bad Gateway', "<h1 class=\"big\">400</h1>\n" . "<h2 class=\"desc\">Bad Gateway</h2>\n" . "<p>Please try another URL</p>", array('style' => "body{font-size: 14px;font-family: helvetica, arial, sans-serif;color: #555;line-height: normal;background: #f1f1f1;}\n" . ".wrap{margin: 0 auto;max-width: 700px;text-align: center;}\n" . ".big{font-size: 180px;margin: .7em 0 20px;}.desc{font-size: 28px;margin: .3em 0 0;}")));
     // doing display
     static::displayRender();
 }