1
0
Fork 0
deeptwisty.com/v3/img/index.php
will 5aa0bc7890 Created v3 of the site in a subdir, bouta migrate
I guess I also haven't made a commit since doing a
couple normal changes. huh
2024-08-08 01:13:36 -06:00

82 lines
2.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<title>/log/img</title>
<link href="../style.css" rel="stylesheet" type="text/css" media="all">
<style>
.dir {
padding: 1rem;
padding-top: 2rem;
}
article.imgs {
display: flex;
flex-wrap: wrap;
border-bottom: none;
}
a.img {
display: flex;
flex-direction: column;
}
a.img :is(img, span) {
margin: 1rem;
}
h2 {
margin: 1rem;
margin-bottom: 0;
}
</style>
</head>
<body>
<nav><a href="../"><<<</a></nav>
<p>$ pwd</p>
<h1 class="title">/log/img</h1>
<p>$ ls -t</p>
<section class="dir">
<?php
$imagetimes = Array();
function test_image($name) { // Returns true if a file is an image (png or gif), false otherwise
return (strpos($name, ".png") > 0 or strpos($name, ".gif") > 0 or strpos($name, ".jxl") > 0);
}
function imagetime($file) { // This needs to return a Unix timestamp.
global $imagetimes;
if(!$imagetimes[$file]) {
$imagetimes[$file] = filemtime("../../art/".$file);
}
return $imagetimes[$file];
}
$images = array_filter(scandir("../../art"), "test_image"); // Generate array of every image in the directory by filename
usort($images, function($a, $b) { // Sort images by modification date of the files
return imagetime("$b") - imagetime("$a");
});
$pmt = "";
foreach($images as $im) { // Loops through each image and echoes it to the page
$no = substr($im, 0, strpos($im, ".")); // Filename with extension stripped
$mt = date("Y-m-d", imagetime("$im")); // File modification date in ISO format
$is = getimagesize("../../art/$im");
$ist = $is[0] . "×" . $is[1]; // Image size formatted as X×Ypx
if($pmt != $mt) {
$pmt = $mt;
if($pmt != "") {
echo "</article>";
}
echo "<h2>$mt</h2><article class='imgs'>";
}
echo("<a class='img' href='/img/$im'><img src='/img/thumbs/$no.jpg'><span>$im >> $ist</span></a>");
}
?>
</section>
<p>$</p>
</body>
</html>