Browse code

getServerURL, getURL

RafaƂ Szklarczyk authored on 04/07/2019 09:28:23
Showing 2 changed files
... ...
@@ -48,6 +48,14 @@ class Application{
48 48
         return strstr($_SERVER['REQUEST_URI'], $this->request->path, true);
49 49
     }
50 50
 
51
+    public function getServerURL(){
52
+        return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}";
53
+    }
54
+
55
+    public function getURL(){
56
+        return $this->getServerURL().$_SERVER['REQUEST_URI'];
57
+    }
58
+
51 59
     public function relPath($file){
52 60
         return ($this->router->depth>0 ? str_repeat("../", substr($this->request->path,-1)=='/'?$this->router->depth:$this->router->depth-1) : "" ).$file; 
53 61
     }
... ...
@@ -49,10 +49,10 @@ class Request{
49 49
             $type = explode(";", $acceptParts);
50 50
             $result[] = $type[0];
51 51
             if(count($type)>1){
52
-                if($type[1][0].$type[1][1] == "q="){
52
+                if(isset($type[1]) && $type[1][0].$type[1][1] == "q="){
53 53
                     $quality_factors[] = substr($type[1],2);
54 54
                 }
55
-                else if($type[2][0].$type[2][1] == "q="){
55
+                else if(isset($type[2]) && $type[2][0].$type[2][1] == "q="){
56 56
                     $quality_factors[] = substr($type[2],2);
57 57
                 }
58 58
                 else{