-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·80 lines (69 loc) · 2.29 KB
/
index.php
File metadata and controls
executable file
·80 lines (69 loc) · 2.29 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
header('Content-Type: application/json; charset=utf-8');
// API vars
$device_name = '';
$link = '';
$zips_dir_name = 'zips/';
$zips_list = array();
$explode_by = '-';
$current_date = date("yyymd");
// Get Device Name.
if (isset($_GET['d'])) {
$device_name = $_GET['d'];
// Program to display URL of current page.
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') $link = "https";
else $link = "http";
// Here append the common URL characters.
$link .= "://";
// Append the host(domain name, ip) to the URL.
$link .= $_SERVER['HTTP_HOST'];
// Append the requested resource location to the URL
$link .= '/' . basename(__DIR__) . '/' . $zips_dir_name;
// Loop Through all the zip files in the zips/ dir
foreach (new DirectoryIterator($zips_dir_name) as $file) {
if ($file == '.' || $file == '..') {
continue;
}
$file_name_parts = explode($explode_by, $file);
$zip_file_url = $link . $file;
$md5sum_file = $file.'.md5sum';
$changelog_file = $zip_file_url.".txt";
if(!contains('.md5sum', $file)) {
if(!contains('.txt', $file) ) {
if(contains($device_name, $file)) {
$zips_list1 = Array(
'datetime' => time("s"),
'filename' => basename($zip_file_url),
'id' => md5(file_get_contents($zips_dir_name.$md5sum_file)),
'romtype' => $file_name_parts[3],
'size' => filesize($zips_dir_name.$file_name),
'url' => $zip_file_url,
'changelog' => $changelog_file,
'version' => $file_name_parts[1],
);
array_push($zips_list, $zips_list1);
} else {
continue;
}
} else {
continue;
}
} else {
continue;
}
}
} else {
}
$array = Array('response' => $zips_list);
// encode array to json
$json = json_encode($array);
echo "$json";
function contains($needle, $haystack)
{
return strpos($haystack, $needle) !== false;
}
function getFileNameFormURL($needle, $haystack)
{
return preg_replace($needle, "", $haystack);
}
?>