/* Print link informations. */
echo '<tr>';
echo '<td>' .
- '<strong><a id="upload_link" href="/f.php?h='. htmlspecialchars($node) .'" title="' .
+ '<strong><a id="upload_link" href="' . JIRAFEAU_ABSPREFIX . 'f.php?h='. htmlspecialchars($node) .'" title="' .
t('Download page') . '">' . htmlspecialchars($l['file_name']) . '</a></strong>';
echo '</td>';
echo '<td>' . $l['mime_type'] . '</td>';
echo '<td>' . strftime('%c', $l['upload_date']) . '</td>';
echo '<td>' . $l['ip'] . '</td>';
echo '<td>' .
- '<form action = "admin.php" method = "post">' .
+ '<form method="post">' .
'<input type = "hidden" name = "action" value = "download"/>' .
'<input type = "hidden" name = "link" value = "' . $node . '"/>' .
'<input type = "submit" value = "' . t('Download') . '" />' .
'</form>' .
- '<form action = "admin.php" method = "post">' .
+ '<form method="post">' .
'<input type = "hidden" name = "action" value = "delete_link"/>' .
'<input type = "hidden" name = "link" value = "' . $node . '"/>' .
'<input type = "submit" value = "' . t('Del link') . '" />' .
'</form>' .
- '<form action = "admin.php" method = "post">' .
+ '<form method="post">' .
'<input type = "hidden" name = "action" value = "delete_file"/>' .
'<input type = "hidden" name = "md5" value = "' . $l['md5'] . '"/>' .
'<input type = "submit" value = "' . t('Del file and links') . '" />' .
return false;
}
+/**
+ * Test if visitor's IP is authorized or password is supplied and authorized
+ * @param $ip IP to be challenged
+ * @param $password password to be challenged
+ * @return true if access is valid, false otherwise.
+ */
+function jirafeau_challenge_upload ($cfg, $ip, $password)
+{
+ // Allow if no ip restrictaion and no password restriction
+ if ((count ($cfg['upload_ip']) == 0) and (count ($cfg['upload_password']) == 0)) {
+ return true;
+ }
+
+ // Allow if ip is in array
+ foreach ($cfg['upload_ip'] as $i) {
+ if ($i == $ip) {
+ 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)) {
+ return true;
+ }
+ }
+ }
+ if (!jirafeau_has_upload_password($cfg)) {
+ return false;
+ }
+
+ foreach ($cfg['upload_password'] as $p) {
+ if ($password == $p) {
+ return true;
+ }
+ }
+ return false;
+}
+
/** Tell if we have some HTTP headers generated by a proxy */
function has_http_forwarded()
{