Example #1
0
 public function process()
 {
     if (Config::log_level_at_least("short")) {
         register_shutdown_function(array("\\HalfMoon\\Request", "log_runtime"), $this);
     }
     try {
         ob_start();
         Router::instance()->takeRouteForRequest($this);
         /* if we received an If-None-Match header from the client and our
          * generated etag matches it, send a not-modified header and no
          * data */
         if (empty($this->redirected_to) && $this->etag_matches_inm()) {
             $headers = (array) headers_sent();
             ob_end_clean();
             foreach ($headers as $header) {
                 header($header);
             }
             Request::send_status_header(304);
         } else {
             if (empty($this->redirected_to)) {
                 $this->send_etag_header();
             }
             if (ob_get_level()) {
                 ob_end_flush();
             }
         }
     } catch (\Exception $e) {
         /* rescue, log, notify (if necessary), exit */
         if (class_exists("\\HalfMoon\\Rescuer")) {
             Rescuer::rescue_exception($e, $this);
         } else {
             throw $e;
         }
     }
 }
Example #2
0
 private function process_before_filters($action)
 {
     $filters = Utils::options_for_key_from_options_hash($action, $this::$before_filter);
     foreach ($filters as $filter) {
         if (!method_exists($this, $filter)) {
             throw new UndefinedFunction("before_filter \"" . $filter . "\" function does not exist");
         }
         if (!call_user_func_array(array($this, $filter), array())) {
             if (Config::log_level_at_least("short")) {
                 Log::info("Filter chain halted as " . $filter . " did not return true.");
             }
             return false;
         }
         if (isset($this->redirected_to)) {
             return false;
         }
     }
     return true;
 }