示例#1
0
 /**
  * Redirect to given URL
  *
  * @param string $to
  */
 public function redirect($to = "/")
 {
     if (!is_scalar($to)) {
         throw new InvalidArgumentException("To must be a string value");
     }
     $to = $this->router->getBaseURI() . (is_string($to) ? $to : "");
     ob_start();
     ob_clean();
     header("Location: " . $to);
     ob_flush();
 }
示例#2
0
 /**
  * Constructor
  *
  * @param Router $router : Router object
  */
 private function __construct(Router $router)
 {
     $this->router = $router;
     $u = $this->uri = urldecode($_SERVER["REQUEST_URI"]);
     $q = $this->query_string = $_SERVER["QUERY_STRING"];
     $this->page = trim(substr($u, 0, strlen($u) - strlen($q)), '?');
     $this->method = $_SERVER["REQUEST_METHOD"];
     $this->protocol = $_SERVER["SERVER_PROTOCOL"];
     $this->ip = $_SERVER["REMOTE_ADDR"];
     $this->website = $_SERVER["SERVER_NAME"];
     $this->port = $_SERVER["REMOTE_PORT"];
     $this->referer = empty($_SERVER["HTTP_REFERER"]) ? null : $_SERVER["HTTP_REFERER"];
     $this->get = $_GET;
     $this->post = $_POST;
     $this->base_uri = $router->getBaseURI();
     $lu = $this->page;
     if (substr($lu, 0, strlen($this->base_uri)) == $this->base_uri) {
         $lu = substr($lu, strlen($this->base_uri));
     }
     $this->local_uri = $lu;
     $this->url = $this->website . $this->uri;
 }