Repository navigation
Expand file tree
/
Copy path_generator.php
More file actions
54 lines (43 loc) · 1.51 KB
/
Copy path_generator.php
File metadata and controls
54 lines (43 loc) · 1.51 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
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
include 'includes/database.php';
session_start();
if ($_SERVER ['REQUEST_METHOD'] == "POST") {
if (!isset($_POST ['c'])) {
header('Location: index.php');
die();
}
$files = $_POST['c'];
$version = $_POST['submit'];
$zip = new ZipArchive();
$tmp_file = tempnam('.', '');
$sound_file = file_get_contents('zipfiles/sound.ogg');
$zip->open($tmp_file, ZipArchive::CREATE);
$mcmeta = json_encode([
'pack' => [
'pack_format' => $version == '1.9' ? 2 : 1,
'description' => 'Generated by Mute Pack Generator! (http://mc.rgghgh.com)'
]
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
$zip->addFromString('pack.mcmeta', $mcmeta);
$zip->addFromString('pack.png', file_get_contents('zipfiles/pack.png'));
$zip->addFromString('import.txt', json_encode($files));
foreach ($files as $file) {
$paths = explode(';', $file);
foreach ($paths as $value) {
$zip->addFromString("assets/minecraft/sounds/" . $value, $sound_file);
}
}
$zip->close();
header('Content-disposition: attachment; filename=Pack.zip');
header('Content-type: application/zip');
readfile($tmp_file);
unlink($tmp_file);
$db = new Database();
$db->updateStats($files);
$milestone = $db->checkMilestone();
if ($milestone) {
$db->setMilestone($milestone, null);
$_SESSION['milestone'] = $milestone;
}
$db->end();
}