summaryrefslogtreecommitdiffstats
path: root/lib/kolab_utils.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-02-23 14:38:05 +0100
committerAleksander Machniak <alec@alec.pl>2012-02-23 14:38:05 +0100
commit780cc50f5f1acd9963edc0ccff1ebee9f612827a (patch)
tree4ae40c82eb2107a2548d8123360627226d1b3388 /lib/kolab_utils.php
parent4bf2d1c7d09bd20bccc0b6449486804899e53b91 (diff)
downloadwebadmin-780cc50f5f1acd9963edc0ccff1ebee9f612827a.tar.gz
Added protocol detection to build proper API URL
Diffstat (limited to 'lib/kolab_utils.php')
-rw-r--r--lib/kolab_utils.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/kolab_utils.php b/lib/kolab_utils.php
index 167c9d2..390b9eb 100644
--- a/lib/kolab_utils.php
+++ b/lib/kolab_utils.php
@@ -103,6 +103,10 @@ class kolab_utils
/**
* Make sure the string ends with a slash
+ *
+ * @param string $str String to parse
+ *
+ * @return string String with one slash at the end
*/
public static function slashify($str)
{
@@ -111,10 +115,31 @@ class kolab_utils
/**
* Remove slash at the end of the string
+ *
+ * @param string $str String to parse
+ *
+ * @return string String without any slashes at the end
*/
public static function unslashify($str)
{
return preg_replace('/\/$/', '', $str);
}
+ /**
+ * Check if secure protocol is being used.
+ *
+ * @return bool True when using https protocol, False otherwise
+ */
+ public static function https_check()
+ {
+ if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') {
+ return true;
+ }
+
+ if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') {
+ return true;
+ }
+
+ return false;
+ }
}