-
Notifications
You must be signed in to change notification settings - Fork 0
/
dl_list.php
64 lines (63 loc) · 2.35 KB
/
dl_list.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
include "admin/common.php";
if (isset($_POST['code'])) {
$db = get_PDO();
$qry = "SELECT * FROM dl_list
INNER JOIN dl_code
ON dl_list.id = dl_code.id
WHERE dl_code.code = {$_POST['code']}
AND dl_list.date_expr >= NOW();";
$ret = $db->query($qry) -> fetch(PDO::FETCH_ASSOC);
header("Content-type: text/html");
if (!$ret || count($ret) == 0) {
echo '<h5>ไม่พบรหัสดังกล่าว กรุณาตรวจสอบดูอีกครั้งค่ะ</h5>';
return;
}
$json = file_get_contents("admin/filemap.json");
$filemap = json_decode($json, true);
$output = [];
$map = [];
// Collection (Grouping) > Set (Entry)> Tone (Dropdown)
// Loop through possible collection sets
foreach ($filemap as $coll) {
// Loop through possible smaller sets
foreach ($coll['content'] as $set) {
// Check if the set is available for download
if ($ret[$set['id']] === "1" && !isset($map[$set['id']])) {
$entry['title'] = $set['name'];
// Check if the tone has a custom name
$mobile_urls = glob("admin/presets/{$set['id']}/*.dng");
$pc_url = glob("admin/presets/{$set['id']}/*.zip")[0];
$i = 0;
$mobile = [];
if (!isset($set['index'])) {
foreach($mobile_urls as $url) {
$i++;
$mobile[] = array(
"url" => substr($url, 14),
"name" => "โทน {$i}"
);
}
} else {
foreach($mobile_urls as $url) {
$baseurl = basename($url,".dng");
$mobile[] = array(
"url" => substr($url, 14),
"name" => $baseurl
// "name" => substr($baseurl, strpos($baseurl, "-") + 1)
);
}
}
$entry['mobile'] = $mobile;
$entry['pc_url'] = substr($pc_url, 14);
$output[] = $entry;
}
$map[$set['id']] = 1;
}
}
header('Content-Type: application/json');
echo json_encode($output);
} else {
echo '<h5>ไม่พบรหัสดังกล่าว กรุณาตรวจสอบดูอีกครั้งค่ะ</h5>';
}
?>