summaryrefslogtreecommitdiff
path: root/src/frontend_lib/util.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend_lib/util.php')
-rw-r--r--src/frontend_lib/util.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/frontend_lib/util.php b/src/frontend_lib/util.php
new file mode 100644
index 00000000..103838cc
--- /dev/null
+++ b/src/frontend_lib/util.php
@@ -0,0 +1,20 @@
+<?php
+
+function get(&$var, $default=null) {
+ return isset($var) ? $var : $default;
+}
+
+function url_join($base, $path) {
+ $url = (new http\URL($base))
+ ->mod(array ("path" => $path), http\Url::JOIN_PATH|http\URL::SANITIZE_PATH);
+ return $url->toString();
+}
+
+// Get a url with a path relative to the
+// current script's path.
+function url_rel($path) {
+ return url_join(
+ $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],
+ $path);
+}
+?>