use anonymous image
[phorkie.git] / src / phorkie / Tools.php
index c6e4db5093007ed0c17292a6d53efc9dc058696d..d9b7637f7120b3f3fdd09e20ae2d2085579bd688 100644 (file)
@@ -21,6 +21,22 @@ class Tools
         return rmdir($path);
     }
 
+    /**
+     * Create a full URL with protocol and host name
+     *
+     * @param string $path Path to the file, with leading /
+     *
+     * @return string Full URL
+     */
+    public static function fullUrl($path)
+    {
+        if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) {
+            $prot = 'https';
+        } else {
+            $prot = 'http';
+        }
+        return $prot . '://' . $_SERVER['HTTP_HOST'] . $path;
+    }
 }
 
 ?>
\ No newline at end of file