-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupload.zip.php
43 lines (27 loc) · 1.15 KB
/
upload.zip.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog.php");
$APPLICATION->RestartBuffer();
include dirname(__FILE__) . '/pclzip.lib.php';
set_time_limit(0);
@mkdir(BASE_PATH . '/temp', 0777);
$filename = 'upload.' . date('Ymd') . '.zip';
$filepath = BASE_PATH . "/temp/$filename";
@unlink($filepath);
//$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(BASE_PATH . '/upload'), RecursiveIteratorIterator::CHILD_FIRST);
$archive = new PclZip($filepath);
$archive->add(BASE_PATH . DIRECTORY_SEPARATOR . 'upload', PCLZIP_OPT_REMOVE_PATH, BASE_PATH);
while (@ob_implicit_flush());
if (file_exists($filepath))
{
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache"); //keeps ie happy
header("Content-Disposition: attachment; filename=$filename");
header("Content-type: application/octet-stream");
header("Content-Length: " .(filesize($filepath)));
header('Content-Transfer-Encoding: binary');
chmod($filepath, 0666);
$handle = @fopen($filepath, "rb");
fpassthru($handle);
fclose($handle);
}
unlink($filepath);