X-Git-Url: https://git.p6c8.net/jirafeau_project.git/blobdiff_plain/9a51f6fc76ce0b60829cc31ccab9643c73b26440..03f216f58de659215008347947a754096902771e:/lib/functions.php?ds=inline
diff --git a/lib/functions.php b/lib/functions.php
index e72359e..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;
}
@@ -843,12 +848,16 @@ function jirafeau_admin_bug_report($cfg)
$out .= "- mcrypt version: " . phpversion('mcrypt') . "
";
$php_options = [
'post_max_size',
- 'upload_max_filesize'
+ 'upload_max_filesize',
+ 'safe_mode',
+ 'max_execution_time',
+ 'max_input_time'
];
foreach ($php_options as &$o) {
$v = ini_get($o);
$out .= "- $o: " . jirafeau_strval($v) . " (" . gettype($v). ")
";
}
+ $out .= "- can set_time_limit: " . (set_time_limit(0) ? "yes" : "no") . "
";
$out .= "
";
$out .= "# File permissions
";
@@ -869,10 +878,15 @@ function jirafeau_admin_bug_report($cfg)
$out .= "# Browser details
";
$out .= "";
+ $out .= "
";
+
+ $out .= "# Memory
";
+ $out .= "- memory_get_peak_usage: " . jirafeau_human_size(memory_get_peak_usage()) . "
";
+
$out .= "";
return $out;
}
@@ -1517,3 +1531,8 @@ function jirafeau_add_ending_slash($path)
{
return $path . ((substr($path, -1) == '/') ? '' : '/');
}
+
+function jirafeau_default_web_root()
+{
+ return $_SERVER['HTTP_HOST'] . str_replace(basename(__FILE__), '', $_SERVER['REQUEST_URI']);
+}