diff --git a/src/Jirafeau/f.php b/src/Jirafeau/f.php index 8e9ec5e..a2d6f0d 100644 --- a/src/Jirafeau/f.php +++ b/src/Jirafeau/f.php @@ -89,6 +89,8 @@ if (!empty($delete_code) && $delete_code == $link['link_code']) { '
'; } else { ?>' . t('GIMME_PSW') . ' : ' . - '' . + '' . ' |
' . t('USING_SERVICE'). ' ' . t('TOS') . '.' . @@ -276,11 +276,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') { diff --git a/src/Jirafeau/t.php b/src/Jirafeau/t.php deleted file mode 100644 index 138d4e3..0000000 --- a/src/Jirafeau/t.php +++ /dev/null @@ -1,121 +0,0 @@ -open ($tmpFileName.".zip", ZipArchive::CREATE) !== TRUE) - die ("can't create tmp"); - -if ($notFoundCount) { - $zip->addFromString ($dirname."-Avertissement.txt", $notFoundCount. ($notFoundCount ? " fichier est expiré." : " fichiers sont expirés.")); -} -$single_name=[]; -foreach ($map as $link_name => $crypt_key) { - $link = jirafeau_get_link ($link_name); - $p = s2p ($link ['hash']); - - $src_name = $dst_name = $link['file_name']; - if (in_array ($src_name, $single_name)) - for ($i = 0; $i < 10000; ++$i) { - $dst_name = sprintf ("%s-%2d", $src_name, $i); - if (!in_array ($dst_name, $single_name)) - break; - } - $single_name[]=$dst_name; - - // send - if ($link['crypted']) { - $m = mcrypt_module_open ('rijndael-256', '', 'ofb', ''); - $md5_key = md5 ($crypt_key); - $iv = jirafeau_crypt_create_iv ($md5_key, mcrypt_enc_get_iv_size ($m)); - mcrypt_generic_init ($m, $md5_key, $iv); - $r = fopen (VAR_FILES . $p . $link['hash'], 'r'); - $content = ""; - while (!feof ($r)) { - $dec = mdecrypt_generic ($m, fread ($r, 1024)); - $content .= $dec; - ob_flush (); - } - fclose ($r); - $zip->addFromString ($dirname."/".$dst_name, $content); - - mcrypt_generic_deinit ($m); - mcrypt_module_close ($m); - continue; - } - $zip->addFile (VAR_FILES . $p . $link['hash'], $dirname."/".$dst_name); -} -$zip->close (); - - -if (!is_file ($tmpFileName.".zip")) - die ("can't retreive tmp"); - -header ("HTTP/1.0 200 OK"); -header ("Content-Type: application/zip"); -header ('Content-Disposition: filename="'.$dirname.'.zip"'); -$r = fopen($tmpFileName.".zip", 'r'); -while (!feof ($r)) { - print fread ($r, 1024); - ob_flush (); -} -fclose ($r); - -unlink ($tmpFileName.".zip"); -unlink ($tmpFileName); |