mirror of
https://gitlab.com/mojo42/Jirafeau.git
synced 2025-01-16 20:38:29 +01:00
Add support for the X-Sendfile header/module to offload downloads.
With the appropriate config option enabled, Jirafeau will send the X-Sendfile header instead of sending the file itself. As a result, Apache/lighttpd will send the file without the intervention of Jirafeau, and download resumes/seeking will also be enabled for this download. If the user requested an encrypted file then this will not work, but it should work in all other cases.
This commit is contained in:
parent
5058cbd048
commit
d00ef4f1b8
13
f.php
13
f.php
@ -272,11 +272,16 @@ elseif ($link['crypted']) {
|
||||
}
|
||||
/* Read file. */
|
||||
else {
|
||||
$r = fopen(VAR_FILES . $p . $link['hash'], 'r');
|
||||
while (!feof($r)) {
|
||||
print fread($r, 1024);
|
||||
if ($cfg['use_xsendfile']) {
|
||||
$file_web_path = preg_replace('#^' . $_SERVER['DOCUMENT_ROOT'] . '#', '', VAR_FILES);
|
||||
header('X-Sendfile: ' . $file_web_path . $p . $link['hash']);
|
||||
} else {
|
||||
$r = fopen(VAR_FILES . $p . $link['hash'], 'r');
|
||||
while (!feof($r)) {
|
||||
print fread($r, 1024);
|
||||
}
|
||||
fclose($r);
|
||||
}
|
||||
fclose($r);
|
||||
}
|
||||
|
||||
if ($link['onetime'] == 'O') {
|
||||
|
@ -183,6 +183,16 @@ $cfg['file_hash'] = 'md5';
|
||||
*/
|
||||
$cfg['litespeed_workaround'] = false;
|
||||
|
||||
/* Use the X-Sendfile header which should cause your webserver to handle
|
||||
* the sending of the file. The webserver must be configured to do this
|
||||
* using the mod_xsendfile module in Apache or the appropriate config in
|
||||
* lighttpd. The offload will not happen in the case of server-side encrypted
|
||||
* files, but all other cases should work. Benefits include being able
|
||||
* to resume downloads and seek instantly in media players like VLC or
|
||||
* the Firefox/Discord/Chrome embedded player.
|
||||
*/
|
||||
$cfg['use_xsendfile'] = false;
|
||||
|
||||
/* Store uploader's IP along with 'link' file.
|
||||
* Depending of your legislation, you may have to adjust this parameter.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user