-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrlfetch_gen.php
44 lines (41 loc) · 1.22 KB
/
drlfetch_gen.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
44
<?php
function hextoobin($str) {
return pack("H*" , $str);
}
$drl = $_POST[drl];
$bytes = str_split($drl, 2);
$drlbig = '';
for($i = 0; $i < 32768; $i++){
if($i < count($bytes)) {
$drlbig .= $bytes[$i];
}
if($i >= count($bytes)) {
$drlbig .= "00";
}
}
$drlbin = hextoobin($drlbig);
$zip = new ZipArchive();
$zipfilename = tempnam("tmp", "zip");
$zip->open($zipfilename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
$zip->addFromString("DRL1", $drlbin);
$zip->addFromString("DRL2", $drlbin);
$zip->close();
$size = filesize($zipfilename);
$name = "gen_drls.zip";
$mime_type = "multipart/x-zip";
// required for IE, otherwise Content-Disposition may be ignored
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
header('Content-Type: ' . $mime_type);
header('Content-Disposition: attachment; filename="'.$name.'"');
header("Content-Transfer-Encoding: binary");
header('Accept-Ranges: bytes');
/* The three lines below basically make the
download non-cacheable */
header("Cache-control: private");
header('Pragma: private');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Length: ".$size);
readfile($zipfilename); //echo($buffer); // is also possible
flush();
?>