-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
executable file
·104 lines (97 loc) · 2.44 KB
/
index.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* Get table rows for database and files backups.
*/
function table_rows() {
$paths = array(
'backdropcms.org' => 'BackdropCMS',
'docs.backdropcms.org' => 'Docs',
'forum.backdropcms.org' => 'Forum',
'events.backdropcms.org' => 'Events',
);
foreach ($paths as $path => $name) {
$databases = array();
$files = array();
exec("ls $path/sanitized/*.sql.gz", $databases);
exec("ls $path/files_backups/*.tar.gz", $files);
foreach (array_reverse($databases) as $id => $database) {
create_row($name, $database, array_reverse($files)[$id]);
}
}
}
/**
* Print the HTML for a single table row.
*/
function create_row($name, $db_path, $file_path) {
$class = '';
$db_path_parts = explode('/', $db_path);
$db_filename_parts = explode('-', $db_path_parts[2]);
if ($db_filename_parts[1] == 'latest') {
$date = 'Latest';
$class = 'latest';
}
else {
$date = $db_filename_parts[1] . ' ' . $db_filename_parts[2] . ' ' . $db_filename_parts[3];
}
$host = filter_input(INPUT_SERVER, 'HTTP_HOST');
$db_link = sprintf('<a href="https://%s/%s">Database</a>', $host, $db_path);
$file_link = sprintf('<a href="https://%s/%s">Files</a>', $host, $file_path);
print '<tr class="' . $class . '">
<td>' . $name . '</td>
<td>' . $date . '</td>
<td>' . $db_link . ' :: ' . $file_link . '</td>
</tr>';
}
?>
<html>
<head>
<title>Top Secret backdropcms.org Sanitized Databases</title>
<style>
body {
text-align: center;
}
table {
border-collapse: collapse;
margin: 30px auto;
min-width: 800px;
}
thead {
background: #ccc;
text-transform: uppercase;
}
thead tr:hover {
background: #ccc;
}
tr:nth-of-type(2n) {
background: #f7f7f7;
}
tr.latest {
border-top: 1px solid #ccc;
font-weight: bold;
}
tr:hover {
background: #e7e7e7;
}
th,
td {
padding: 0.5em 1em;
}
</style>
</head>
<body>
<h1>Download sanitized backups of BackdropCMS.org websites</h1>
<img src="https://backdropcms.org/themes/borg/images/drop-lounging.png"/>
<table>
<thead>
<tr>
<th>Website</th>
<th>Date</th>
<th>Download</th>
</tr>
</thead>
<tbody>
<?php table_rows(); ?>
</tbody>
</table>
</body>
</html>