X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/blobdiff_plain/b6f423726c6f71c769fc7d7f3b842f623595a808..507be5f97be283db761fdf28f0e403e582fa1186:/lib/functions.php?ds=sidebyside
diff --git a/lib/functions.php b/lib/functions.php
index 3c432b6..6e5c886 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) && strpos($mime, 'image/svg+xml') === false) {
+ 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 '