-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlatestUpdates.php
More file actions
70 lines (64 loc) · 1.67 KB
/
Copy pathlatestUpdates.php
File metadata and controls
70 lines (64 loc) · 1.67 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
<html>
<head>
<title>Últimas actualizações</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<style>
html {
font-family: monospace;
background: black;
color: white;
line-height: 1.4;
}
</style>
<body>
<?php
$userList = scandir("/home");
$files = [];
echo "<h1>Últimas Actualizações</h1>";
function searchDir($target) {
global $files;
if(is_dir($target) && is_readable($target)) {
if (strpos($target, '/./') === false && strpos($target, '/../') === false) {
echo "<!-- DEBUG: going to scandir($target) -->\n";
$results = scandir($target);
forEach($results as $item) {
if(is_file($target.$item)) {
//echo filemtime($target.$item).' '.$target.$item;
$ext = pathinfo($target.$item, PATHINFO_EXTENSION);
// excluded extentions
if(!in_array($ext, ["swp"])) {
array_push($files, ['modified' => filemtime($target.$item), 'path' => $target.$item]);
}
} else if(is_dir($target.$item)){
// excluded dirs
if(!in_array($item, [".git"])) {
searchDir($target.$item."/");
}
}
}
}
} else {
echo "<!-- DEBUG: chose not scan $target -->\n";
}
}
forEach($userList as $user) {
if(!in_array($user, ['.', '..', 'pi'])) {
searchDir('/home/'.$user.'/public_html/');
}
}
usort($files, function($a, $b) {
return $b['modified'] <=> $a['modified'];
});
echo "<ul>";
for($i = 0; $i<=30; $i++) {
$path = $files[$i]['path'];
$path = str_replace('/home/', '/~', $path);
$path = str_replace('/public_html', '', $path);
echo "<li><a href=\"".$path."\">". $path .'</a> | '. date(DATE_RFC2822, $files[$i]['modified']). '</li>';
}
echo "</ul>";
?>
</body>
</html>