-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrabmkb.php
More file actions
41 lines (37 loc) · 1.34 KB
/
grabmkb.php
File metadata and controls
41 lines (37 loc) · 1.34 KB
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
<?php
$titleid = $_GET['titleid'];
$myconn = mysql_connect('localhost','user','password');
if (!$myconn) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("ps3mkb", $myconn);
$sql = "select uncompress(mkbdata) as mkbdata from mkbfiles_autoincrement where id = '$titleid'";
$result = mysql_query($sql, $myconn);
$row = mysql_fetch_row($result);
$mkb = $row[0];
mysql_close($myconn);
$zip = new ZipArchive();
$zipfilename = tempnam("tmp", "zip");
$zip->open($zipfilename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
$zip->addFromString("MKB_RO.inf", $mkb);
$zip->close();
$size = filesize($zipfilename);
$name = $titleid;
$name .= "_mkb.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();
?>