X-Git-Url: https://git.p6c8.net/jirafeau.git/blobdiff_plain/b6f423726c6f71c769fc7d7f3b842f623595a808..03f216f58de659215008347947a754096902771e:/lib/functions.php
diff --git a/lib/functions.php b/lib/functions.php
index 3c432b6..c831b73 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -28,7 +28,7 @@ function s2p($s)
$block_size = 8;
$p = '';
for ($i = 0; $i < strlen($s); $i++) {
- $p .= $s{$i};
+ $p .= $s[$i];
if (($i + 1) % $block_size == 0) {
$p .= '/';
}
@@ -68,16 +68,16 @@ function base_16_to_64($num)
# Convert long hex string to bin.
$size = strlen($num);
for ($i = 0; $i < $size; $i++) {
- $b .= $hex2bin{hexdec($num{$i})};
+ $b .= $hex2bin[hexdec($num[$i])];
}
# Convert long bin to base 64.
$size *= 4;
for ($i = $size - 6; $i >= 0; $i -= 6) {
- $o = $m{bindec(substr($b, $i, 6))} . $o;
+ $o = $m[bindec(substr($b, $i, 6))] . $o;
}
# Some few bits remaining ?
if ($i < 0 && $i > -6) {
- $o = $m{bindec(substr($b, 0, $i + 6))} . $o;
+ $o = $m[bindec(substr($b, 0, $i + 6))] . $o;
}
return $o;
}
@@ -509,10 +509,15 @@ function jirafeau_upload($file, $one_time_download, $key, $time, $ip, $crypt, $l
function jirafeau_is_viewable($mime)
{
if (!empty($mime)) {
- /* Actually, verify if mime-type is an image or a text. */
- $viewable = array('image', 'text', 'video', 'audio');
+ $viewable = array('image', 'video', 'audio');
$decomposed = explode('/', $mime);
- return in_array($decomposed[0], $viewable);
+ if (in_array($decomposed[0], $viewable)) {
+ return true;
+ }
+ $viewable = array('text/plain');
+ if (in_array($mime, $viewable)) {
+ return true;
+ }
}
return false;
}
@@ -680,7 +685,9 @@ function jirafeau_admin_list($name, $file_hash, $link_hash)
echo t('EXPIRE') . ': ' . ($l['time'] == -1 ? 'â' : jirafeau_get_datetimefield($l['time'])) . '
';
echo t('ONETIME') . ': ' . ($l['onetime'] == 'O' ? 'Yes' : 'No') . '
';
echo t('UPLOAD_DATE') . ': ' . jirafeau_get_datetimefield($l['upload_date']) . '
';
- echo t('ORIGIN') . ': ' . $l['ip'] . '
';
+ if (strlen($l['ip']) > 0) {
+ echo t('ORIGIN') . ': ' . $l['ip'] . '
';
+ }
echo '