Ejemplo n.º 1
0
 /**
  * Helper: Get current php script url
  */
 public function scriptUrl($append = null)
 {
     return Server::getScriptUrl($append);
 }
Ejemplo n.º 2
0
 /**
  * Redirect to another URL or path safely
  */
 public function redirect($location)
 {
     // build possible versions of current route
     $cur_file = Server::getScriptFile();
     $cur_address = Server::getUrl();
     $cur_clean = str_replace("/" . basename($cur_file), "", $cur_address);
     // convert route path to full URL address
     if (preg_match("/^\\/{1}.*\$/ui", $location)) {
         $location = Server::getScriptUrl($location);
     }
     // new location matches current url/route
     if ($location === $cur_address || $location === $cur_clean) {
         $this->sendDefault(500, "Possible redirect loop detected for new location (" . $location . ").");
     }
     // go for it
     $this->setStatus(302);
     $this->setHeader("Location", $location);
     $this->setHeader("Connection", "close");
     $this->send();
 }