blob: a12c4a2cea23728d5aca955103c34c3b2b6f9c2c (
plain)
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
|
<!DOCTYPE html>
<html>
<head>
<?php include("../boilerplate.php"); ?>
<title>/log/aud</title>
<meta name="description" content="musical junk pile">
<style>
.dir > article {
display: flex;
align-items: center;
justify-content: space-between;
}
@media only screen and (hover: none) {
article {
flex-direction: column;
align-items: initial;
}
audio {
margin: 0.5rem;
}
}
</style>
</head>
<body>
<nav><a href="../"><<<</a></nav>
<p>$ pwd</p>
<h1 class="title">/log/aud</h1>
<p>$ ls -t</p>
<section class="dir">
<?php
// Code to automatically populate the page with every mp3 file in the directory.
// Should display filename - and date of creation and id3 comment if possible.
function test_audio($name) { // Returns true if a file is an mp3, false otherwise
return (preg_match('/\.(mp3|ogg|opus|wav|flac|m4a)/', $name) > 0);
}
$audiodir = "../../data/deeptwisty/aud";
$files = array_filter(scandir($audiodir), "test_audio");
usort($files, function($a, $b) { // Sort files by modification date of the files
global $audiodir;
return filemtime("$audiodir/$b") - filemtime("$audiodir/$a");
});
foreach($files as $fi) {
//$fitime = filemtime("$fi");
$fisize = filesize("$audiodir/$fi");
echo "<article><span>$fi</span><audio controls><source src='$fi' type='audio/mpeg'>your browser does not support embedded audio.</audio></article>";
}
?>
</section>
<p>$</p>
</body>
</html>
|