X-Git-Url: https://git.p6c8.net/jirafeau_project.git/blobdiff_plain/d476bcd5e359b590b36e7372833e0e6ebd419587..2008a343c9d4bfa2c949ec3870875630eea5fb5c:/lib/functions.php
diff --git a/lib/functions.php b/lib/functions.php
index cf89593..064d3a1 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -143,8 +143,11 @@ function jirafeau_human_size($octets)
// Convert UTC timestamp to a datetime field
function jirafeau_get_datetimefield($timestamp)
{
- $content = ''
- . strftime('%Y-%m-%d %H:%M', $timestamp) . ' (GMT)';
+
+ $ts = date_create("@" . $timestamp);
+ $content = ''
+ . date_format($ts, 'Y-m-d H:i') . ' (GMT)';
+
return $content;
}
@@ -1382,6 +1385,31 @@ function jirafeau_challenge_upload($cfg, $ip, $password)
(jirafeau_challenge_upload_password($cfg, $password) && jirafeau_challenge_upload_ip($cfg, $ip));
}
+/**
+ * Check if Jirafeau has a restriction on the IP address for accessing the admin interface.
+ * @return true if admin interface is IP restricted, false otherwise.
+ */
+function jirafeau_admin_has_ip_restriction($cfg)
+{
+ return count($cfg['admin_ip']) > 0;
+}
+
+/**
+ * Test if visitor's IP is authorized to access the admin interface.
+ *
+ * @param $cfg configuration
+ * @param $challengedIp IP to be challenged
+ * @return true if IP is authorized, false otherwise.
+ */
+function jirafeau_challenge_admin_ip($cfg, $challengedIp)
+{
+ // If no IP address have been listed, allow upload from any IP
+ if (!jirafeau_admin_has_ip_restriction($cfg)) {
+ return true;
+ }
+ return jirafeau_challenge_ip($cfg['admin_ip'], $challengedIp);
+}
+
/** Tell if we have some HTTP headers generated by a proxy */
function has_http_forwarded()
{