X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/blobdiff_plain/ce571122a5b6866835a9313e599bcad57bc790ff..a9248c01e37d3085a832671e795754e780e831c9:/lib/functions.php
diff --git a/lib/functions.php b/lib/functions.php
index 50ab345..7d15e1b 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -128,6 +128,13 @@ function jirafeau_get_datetimefield($timestamp)
return $content;
}
+function jirafeau_fatal_error($errorText, $cfg = array())
+{
+ echo '
';
+ require(JIRAFEAU_ROOT . 'lib/template/footer.php');
+ exit;
+}
+
function jirafeau_clean_rm_link($link)
{
$p = s2p("$link");
@@ -1063,22 +1070,26 @@ function jirafeau_challenge_upload_password($cfg, $password)
/**
* Test if visitor's IP is authorized to upload.
- * @param $ip IP to be challenged
+ *
+ * @param $allowedIpList array of allowed IPs
+ * @param $challengedIp IP to be challenged
* @return true if IP is authorized, false otherwise.
*/
-function jirafeau_challenge_upload_ip($cfg, $ip)
+function jirafeau_challenge_upload_ip($allowedIpList, $challengedIp)
{
- if (count($cfg['upload_ip']) == 0) {
+ // skip if list is empty = all IPs allowed
+ if (count($allowedIpList) == 0) {
return true;
}
- foreach ($cfg['upload_ip'] as $i) {
- if ($i == $ip) {
+ // test given IP against each allowed IP
+ foreach ($allowedIpList as $i) {
+ if ($i == $challengedIp) {
return true;
}
// CIDR test for IPv4 only.
if (strpos($i, '/') !== false) {
list($subnet, $mask) = explode('/', $i);
- if ((ip2long($ip) & ~((1 << (32 - $mask)) - 1)) == ip2long($subnet)) {
+ if ((ip2long($challengedIp) & ~((1 << (32 - $mask)) - 1)) == ip2long($subnet)) {
return true;
}
}