diff options
Diffstat (limited to 'misc/tools.php')
-rw-r--r-- | misc/tools.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/misc/tools.php b/misc/tools.php new file mode 100644 index 0000000..e301c55 --- /dev/null +++ b/misc/tools.php @@ -0,0 +1,27 @@ +<?php + function entries($path = "blog", $limit = false) { + $files = scandir($path."/"); + $entries = []; + $i = 0; + + foreach ($files as $file) { + if (is_dir($path.'/'.$file) && $file[0] != ".") { + $tags = get_meta_tags($path.'/'.$file.'/index.html'); + $entries[$i][0] = preg_replace("/\//", "", $tags["date"]); + $entries[$i][1] = $file; + $entries[$i][2] = $tags["date"]; + $i++; + } + } + rsort($entries); + for ($i = 0; $i < count($entries); $i++) { + if ($limit && $i > $limit - 1) + break; + $file = $entries[$i][1]; + $age = $entries[$i][2]; + printf('<a href=/%s/%s>%s</a><span>%s</span><br>', + $path, $file, str_replace("-", " ", $file), + $age ? $age : "¯\_(ツ)_/¯"); + } + } +?> |