$block_size = 8;
$p = '';
for ($i = 0; $i < strlen($s); $i++) {
- $p .= $s{$i};
+ $p .= $s[$i];
if (($i + 1) % $block_size == 0) {
$p .= '/';
}
# 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;
}
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;
}