+function is_ssl()
+{
+ if (isset($_SERVER['HTTPS'])) {
+ if ('on' == strtolower($_SERVER['HTTPS']) ||
+ '1' == $_SERVER['HTTPS']) {
+ return true;
+ }
+ } elseif (isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'])) {
+ return true;
+ } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
+ if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
+ return true;
+ }
+ }
+ return false;
+}
+
+function jirafeau_human_size($octets)
+{
+ $u = array('B', 'KB', 'MB', 'GB', 'TB');
+ $o = max($octets, 0);
+ $p = min(floor(($o ? log($o) : 0) / log(1024)), count($u) - 1);
+ $o /= pow(1024, $p);
+ return round($o, 1) . $u[$p];
+}
+
+// Convert UTC timestamp to a datetime field
+function jirafeau_get_datetimefield($timestamp)
+{
+ $content = '<span class="datetime" data-datetime="' . strftime('%Y-%m-%d %H:%M', $timestamp) . '">'
+ . strftime('%Y-%m-%d %H:%M', $timestamp) . ' (GMT)</span>';
+ return $content;
+}
+
+function jirafeau_fatal_error($errorText, $cfg = array())