$modifier = substr($value, -1);
$bytes = substr($value, 0, -1);
switch (strtoupper($modifier)) {
+ default:
+ return intval($value);
+ break;
case 'P':
$bytes *= 1024;
// no break
return jirafeau_human_size(jirafeau_get_max_upload_size_bytes());
}
+/**
+ * get the maximal upload size for a data chunk in async uploads
+ * @param max_upload_chunk_size_bytes
+ */
+function jirafeau_get_max_upload_chunk_size_bytes($max_upload_chunk_size_bytes = 0)
+{
+ if ($max_upload_chunk_size_bytes == 0) {
+ $size = jirafeau_get_max_upload_size_bytes();
+ // Jirafeau must choose an arbitrary number as PHP config does not give any limit nor $max_upload_chunk_size_bytes
+ if ($size == 0) {
+ return 10000000; // 10MB
+ }
+ return $size;
+ }
+ $size = min(
+ jirafeau_get_max_upload_size_bytes(),
+ $max_upload_chunk_size_bytes
+ );
+ if ($size == 0) {
+ return $max_upload_chunk_size_bytes;
+ }
+ return $size;
+}
+
/**
* gets a string explaining the error
* @param $code the error code
function check_errors($cfg)
{
- if (file_exists(JIRAFEAU_ROOT . 'install.php')
- && !($cfg['installation_done'] === true)) {
- header('Location: install.php');
- exit;
+ if (!($cfg['installation_done'] === true)) {
+ if (file_exists(JIRAFEAU_ROOT . 'install.php')) {
+ header('Location: install.php');
+ exit;
+ } else {
+ add_error(t('INSTALL_FILE_NOT_FOUND_TITLE'), t('INSTALL_FILE_NOT_FOUND_DESC'));
+ }
}
- /* Checking for errors. */
if (!is_writable(VAR_FILES)) {
add_error(t('FILE_DIR_W'), VAR_FILES);
}
'enable_crypt',
'preview',
'maximal_upload_size',
- 'store_uploader_ip'
+ 'store_uploader_ip',
+ 'max_upload_chunk_size_bytes'
];
foreach ($jirafeau_options as &$o) {
$v = $cfg[$o];
function jirafeau_default_web_root()
{
- return $_SERVER['HTTP_HOST'] . str_replace(basename(__FILE__), '', $_SERVER['REQUEST_URI']);
+ return $_SERVER['HTTP_HOST'] . str_replace('install.php', '', $_SERVER['REQUEST_URI']);
}