diff options
| author | Ada Isopods <me@bathynomus.xyz> | 2024-08-08 01:13:36 -0600 |
|---|---|---|
| committer | Ada Isopods <me@bathynomus.xyz> | 2026-10-21 23:30:20 -0600 |
| commit | b58b9832183c5dec8af2dfd580abf3d5d9bdc086 (patch) | |
| tree | 233b86f73b6cccd20d4b808812d8381335e4a3ec /v3/img/index.php | |
| parent | 683dfaab7247bfe6fdd989de203f91e68b509a22 (diff) | |
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
Diffstat (limited to 'v3/img/index.php')
| -rw-r--r-- | v3/img/index.php | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/v3/img/index.php b/v3/img/index.php new file mode 100644 index 0000000..a6cc9fa --- /dev/null +++ b/v3/img/index.php @@ -0,0 +1,82 @@ +<!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> |
