From: Erik Lundin Date: Tue, 25 Feb 2020 21:42:40 +0000 (+0100) Subject: Work around LiteSpeed's truncation of large files X-Git-Tag: 4.2.0~64 X-Git-Url: https://git.p6c8.net/jirafeau_project.git/commitdiff_plain/41cde93bc152ccd48b5fc25d652d288a6a0af016 Work around LiteSpeed's truncation of large files --- diff --git a/f.php b/f.php index 9219493..c19232d 100644 --- a/f.php +++ b/f.php @@ -241,9 +241,21 @@ header('Content-Type: ' . $link['mime_type']); if ($cfg['file_hash'] == "md5") { header('Content-MD5: ' . hex_to_base64($link['hash'])); } - +if ($cfg['litespeed_workaround']) { + // Work around that LiteSpeed truncates large files. + // See https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:config:internal-redirect + if ($_GET['litespeed_workaround'] == 'phase2') { + $file_web_path = preg_replace('#^' . $_SERVER['DOCUMENT_ROOT'] . '#', '', VAR_FILES); + header('X-LiteSpeed-Location: ' . $file_web_path . $p . $link['hash']); + } else { + // Since Content-Type isn't forwarded by LiteSpeed, first + // redirect to the same URL but append the file name. + header('Location: ' . $_SERVER['PHP_SELF'] . '/' . $link['file_name'] . '?' . + $_SERVER['QUERY_STRING'] . '&litespeed_workaround=phase2'); + } +} /* Read encrypted file. */ -if ($link['crypted']) { +else if ($link['crypted']) { /* Init module */ $m = mcrypt_module_open('rijndael-256', '', 'ofb', ''); /* Extract key and iv. */ diff --git a/lib/config.original.php b/lib/config.original.php index 736790a..1a2c0cc 100644 --- a/lib/config.original.php +++ b/lib/config.original.php @@ -163,6 +163,19 @@ $cfg['proxy_ip'] = array(); */ $cfg['file_hash'] = 'md5'; +/* Work around that LiteSpeed truncates large files when downloading. + * Only for use with the LiteSpeed web server! + * An internal redirect is made using X-LiteSpeed-Location instead + * of streaming the file from PHP. + * Limitations: + * - The Jirafeau files folder has to be placed under the document root and should be + * protected from unauthorized access using rewrite rules. + * See https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:config:internal-redirect#protection_from_direct_access + * - Incompatible with server side encryption. + * - Incompatible with one time download. + */ +$cfg['litespeed_workaround'] = false; + /* Required flag to test if the installation is already installed * or needs to start the installation script */ diff --git a/lib/functions.php b/lib/functions.php index 1dd03e5..058d53e 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -569,6 +569,14 @@ function check_errors($cfg) if (!is_writable(VAR_ASYNC)) { add_error(t('ASYNC_DIR_W'), VAR_ASYNC); } + + if ($cfg['enable_crypt'] && $cfg['litespeed_workaround']) { + add_error(t('INCOMPATIBLE_OPTIONS_W'), 'enable_crypt=true
litespeed_workaround=true'); + } + + if ($cfg['one_time_download'] && $cfg['litespeed_workaround']) { + add_error(t('INCOMPATIBLE_OPTIONS_W'), 'one_time_download=true
litespeed_workaround=true'); + } } /** diff --git a/lib/locales/ar.json b/lib/locales/ar.json index 5e2d9bc..d8a3299 100644 --- a/lib/locales/ar.json +++ b/lib/locales/ar.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "قد لا يدعم متصفحك HTML5، لذا فإن الحد الأقصى لحجم الملف هو ", "PLURAL_ENDING": "", "ACCESS_KO": "الدخول محظور", diff --git a/lib/locales/be.json b/lib/locales/be.json index d3af668..a8716b5 100644 --- a/lib/locales/be.json +++ b/lib/locales/be.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "Ваш браўзер не падтрымлівае HTML5, таму максімальны памер файла ", "PLURAL_ENDING": "", "JI_WEB_RE": "Jirafeau — ваша вэб-сховішча файлаў", diff --git a/lib/locales/bn_IN.json b/lib/locales/bn_IN.json index 6ee09e0..31a2e09 100644 --- a/lib/locales/bn_IN.json +++ b/lib/locales/bn_IN.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "আপনার ব্রাউজার HTML5 সমর্থন নাও করতে পারে, তাই সর্বোচ্চ ফাইলের আকার ", "PLURAL_ENDING": "", "ACCESS_KO": "", diff --git a/lib/locales/bo.json b/lib/locales/bo.json index f7a06f4..187976f 100644 --- a/lib/locales/bo.json +++ b/lib/locales/bo.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/ca.json b/lib/locales/ca.json index 254484c..b3f9f83 100644 --- a/lib/locales/ca.json +++ b/lib/locales/ca.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "El teu navegador no és compatible amb HTML5, per tant, la mida màxima del fitxers és ", "PLURAL_ENDING": "s", "JI_WEB_RE": "Jirafeau, el teu repositori web de fitxers", diff --git a/lib/locales/cs.json b/lib/locales/cs.json index a9f3b5e..bed93db 100644 --- a/lib/locales/cs.json +++ b/lib/locales/cs.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "Váš prohlížeč nepodporuje HTML5, proto je maximílní velikost souboru ", "PLURAL_ENDING": "", "ACCESS_KO": "Přístup zamítnut", diff --git a/lib/locales/da.json b/lib/locales/da.json index a9deec9..6338a09 100644 --- a/lib/locales/da.json +++ b/lib/locales/da.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/de.json b/lib/locales/de.json index 0cfb4c5..b232f84 100644 --- a/lib/locales/de.json +++ b/lib/locales/de.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "Ihr Browser unterstützt möglicherweise kein HTML5, demnach beträgt die maximale Dateigröße ", "PLURAL_ENDING": "n", "ACCESS_KO": "Zugriff verweigert", diff --git a/lib/locales/el.json b/lib/locales/el.json index 6273fdf..8801a1b 100644 --- a/lib/locales/el.json +++ b/lib/locales/el.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "Χώρος αποθήκευσης των διαδικτυακών σας αρχείων", diff --git a/lib/locales/en.json b/lib/locales/en.json index d8ae980..845743a 100644 --- a/lib/locales/en.json +++ b/lib/locales/en.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "The following configuration options are incompatible:", "NO_BROWSER_SUPPORT": "Your browser may not support HTML5, so the maximum file size is ", "PLURAL_ENDING": "s", "JI_WEB_RE": "Jirafeau, your web file repository", diff --git a/lib/locales/es.json b/lib/locales/es.json index 325dca9..5c0eb21 100644 --- a/lib/locales/es.json +++ b/lib/locales/es.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "Tu navegador puede no soportar HTML5, debido a esto el tamaño máximo de archivo es ", "PLURAL_ENDING": "", "ACCESS_KO": "Acceso denegado", diff --git a/lib/locales/et.json b/lib/locales/et.json index 2b1f751..6a37463 100644 --- a/lib/locales/et.json +++ b/lib/locales/et.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/fi.json b/lib/locales/fi.json index f947b3f..1fa64f5 100644 --- a/lib/locales/fi.json +++ b/lib/locales/fi.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "ACCESS_KO": "Pääsy estetty", diff --git a/lib/locales/fr.json b/lib/locales/fr.json index a2c435c..aa4d3d3 100644 --- a/lib/locales/fr.json +++ b/lib/locales/fr.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "Votre navigateur ne supporte apparemment pas HTML5, la taille maximale de fichier téléchargable est de ", "PLURAL_ENDING": "s", "ACCESS_KO": "Accès interdit", diff --git a/lib/locales/he.json b/lib/locales/he.json index c3eb19c..6e0a569 100644 --- a/lib/locales/he.json +++ b/lib/locales/he.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "Jirafeau , אתר הקבצים שלך", diff --git a/lib/locales/hi.json b/lib/locales/hi.json index cc5564f..172250c 100644 --- a/lib/locales/hi.json +++ b/lib/locales/hi.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "ACCESS_KO": "", diff --git a/lib/locales/hr.json b/lib/locales/hr.json index 1538cac..b4515eb 100644 --- a/lib/locales/hr.json +++ b/lib/locales/hr.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "Jirafeau, Vaše mrežno skladište datoteka", diff --git a/lib/locales/hu.json b/lib/locales/hu.json index 819dbb6..9ff524c 100644 --- a/lib/locales/hu.json +++ b/lib/locales/hu.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "ACCESS_KO": "Hozzáférés megtagadva", diff --git a/lib/locales/id.json b/lib/locales/id.json index f7a06f4..187976f 100644 --- a/lib/locales/id.json +++ b/lib/locales/id.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/it.json b/lib/locales/it.json index 10b761f..b9e0a0c 100644 --- a/lib/locales/it.json +++ b/lib/locales/it.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "Il tuo browser potrebbe non supportare HTML5, quindi la dimensione massima del file è ", "PLURAL_ENDING": "", "ACCESS_KO": "Accesso negato", diff --git a/lib/locales/ja.json b/lib/locales/ja.json index 8e6da02..ba12063 100644 --- a/lib/locales/ja.json +++ b/lib/locales/ja.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "ACCESS_KO": "", diff --git a/lib/locales/ko.json b/lib/locales/ko.json index cc5564f..172250c 100644 --- a/lib/locales/ko.json +++ b/lib/locales/ko.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "ACCESS_KO": "", diff --git a/lib/locales/ku.json b/lib/locales/ku.json index 2b1f751..6a37463 100644 --- a/lib/locales/ku.json +++ b/lib/locales/ku.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/la.json b/lib/locales/la.json index 87e0582..753919b 100644 --- a/lib/locales/la.json +++ b/lib/locales/la.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "Jirafeau, web filibus depositum tuum", diff --git a/lib/locales/mfe.json b/lib/locales/mfe.json index 2b1f751..6a37463 100644 --- a/lib/locales/mfe.json +++ b/lib/locales/mfe.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/ms.json b/lib/locales/ms.json index f7a06f4..187976f 100644 --- a/lib/locales/ms.json +++ b/lib/locales/ms.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/nb_NO.json b/lib/locales/nb_NO.json index e526eb7..2d73630 100644 --- a/lib/locales/nb_NO.json +++ b/lib/locales/nb_NO.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "Det kan hende at nettleseren din ikke støtter HTML5, så største tillatte filstørrelse er ", "PLURAL_ENDING": "er", "JI_WEB_RE": "Jirafeau, din vevfilpakkebrønn", diff --git a/lib/locales/nl.json b/lib/locales/nl.json index 2eaeee1..61dc97a 100644 --- a/lib/locales/nl.json +++ b/lib/locales/nl.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "ACCESS_KO": "Toegang geweigerd", diff --git a/lib/locales/pl.json b/lib/locales/pl.json index 95e8776..b13d75e 100644 --- a/lib/locales/pl.json +++ b/lib/locales/pl.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "Jirafeau, twoje internetowe repozytorium plików", diff --git a/lib/locales/ps.json b/lib/locales/ps.json index 2b1f751..6a37463 100644 --- a/lib/locales/ps.json +++ b/lib/locales/ps.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/pt.json b/lib/locales/pt.json index 25df852..05bf78e 100644 --- a/lib/locales/pt.json +++ b/lib/locales/pt.json @@ -1,5 +1,6 @@ { "NO_BROWSER_SUPPORT": "O seu navegador pode não suportar HTML5, então o tamanho máximo do ficheiro é ", + "INCOMPATIBLE_OPTIONS_W": "", "PLURAL_ENDING": "s", "ACCESS_KO": "Acesso negado", "ACTION": "Acção", diff --git a/lib/locales/pt_BR.json b/lib/locales/pt_BR.json index b247dc1..935e8aa 100644 --- a/lib/locales/pt_BR.json +++ b/lib/locales/pt_BR.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "Seu navegador pode não suportar HTML5, portanto, o tamanho máximo do arquivo é ", "PLURAL_ENDING": "s", "JI_WEB_RE": "Jirafeau, o seu repositório web de arquivos", diff --git a/lib/locales/ro.json b/lib/locales/ro.json index 6cc72f9..3a4922c 100644 --- a/lib/locales/ro.json +++ b/lib/locales/ro.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "ACCESS_KO": "Acces refuzat", diff --git a/lib/locales/ru.json b/lib/locales/ru.json index f2e1259..d8881b4 100644 --- a/lib/locales/ru.json +++ b/lib/locales/ru.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "ACCESS_KO": "Доступ запрещён", diff --git a/lib/locales/sh.json b/lib/locales/sh.json index 2b1f751..6a37463 100644 --- a/lib/locales/sh.json +++ b/lib/locales/sh.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/sk.json b/lib/locales/sk.json index 6349e94..971da4f 100644 --- a/lib/locales/sk.json +++ b/lib/locales/sk.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "Zdá sa, že Váš prehliadač nepodporuje HTML5. Maximálna veľkosť súboru je preto obmedzená na ", "PLURAL_ENDING": "", "ACCESS_KO": "Prístup odoprený", diff --git a/lib/locales/sl.json b/lib/locales/sl.json index 2b1f751..6a37463 100644 --- a/lib/locales/sl.json +++ b/lib/locales/sl.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/sq.json b/lib/locales/sq.json index 2b1f751..6a37463 100644 --- a/lib/locales/sq.json +++ b/lib/locales/sq.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/sr.json b/lib/locales/sr.json index 65e47e9..3bc925a 100644 --- a/lib/locales/sr.json +++ b/lib/locales/sr.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "ACCESS_KO": "Приступ одбијен", diff --git a/lib/locales/sv.json b/lib/locales/sv.json index 8fdfba0..a93481b 100644 --- a/lib/locales/sv.json +++ b/lib/locales/sv.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "Följande inställningar är inkompatibla:", "NO_BROWSER_SUPPORT": "Din webbläsare verkar inte stödja HTML5, så max filstorlek är ", "PLURAL_ENDING": "er", "JI_WEB_RE": "Jirafeau, ditt filutrymme på nätet", diff --git a/lib/locales/ta.json b/lib/locales/ta.json index 2b1f751..6a37463 100644 --- a/lib/locales/ta.json +++ b/lib/locales/ta.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/template.json b/lib/locales/template.json index b76b3a9..a2b8432 100644 --- a/lib/locales/template.json +++ b/lib/locales/template.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/th.json b/lib/locales/th.json index 2b1f751..6a37463 100644 --- a/lib/locales/th.json +++ b/lib/locales/th.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "JI_WEB_RE": "", diff --git a/lib/locales/tr.json b/lib/locales/tr.json index 1304e1b..c5e394a 100644 --- a/lib/locales/tr.json +++ b/lib/locales/tr.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "Tarayıcınız HTML5'i desteklemeyebilir, bu nedenle en fazla dosya boyutu ", "PLURAL_ENDING": "sn", "JI_WEB_RE": "Jirafeau, web dosya deponuz", diff --git a/lib/locales/vi.json b/lib/locales/vi.json index 8e6da02..ba12063 100644 --- a/lib/locales/vi.json +++ b/lib/locales/vi.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "", "PLURAL_ENDING": "", "ACCESS_KO": "", diff --git a/lib/locales/zh.json b/lib/locales/zh.json index 25e96e7..a039407 100644 --- a/lib/locales/zh.json +++ b/lib/locales/zh.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "您的浏览器可能不支持 HTML5,因此文件最大为 ", "PLURAL_ENDING": "s", "ACCESS_KO": "拒绝访问", diff --git a/lib/locales/zh_TW.json b/lib/locales/zh_TW.json index 265afc9..a322bd1 100644 --- a/lib/locales/zh_TW.json +++ b/lib/locales/zh_TW.json @@ -1,4 +1,5 @@ { + "INCOMPATIBLE_OPTIONS_W": "", "NO_BROWSER_SUPPORT": "您的瀏覽器可能不支持 HTML5,因此文件最大為 ", "PLURAL_ENDING": "s", "ACCESS_KO": "拒絕訪問",