aboutsummaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rwxr-xr-xindex.php149
1 files changed, 149 insertions, 0 deletions
diff --git a/index.php b/index.php
new file mode 100755
index 0000000..433c0ee
--- /dev/null
+++ b/index.php
@@ -0,0 +1,149 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" >
+ <link rel="stylesheet" href="/style.css" />
+ <link rel="icon" type="image/x-icon" href="/favicon.ico">
+ <meta property="og:image" content="https://wittamore.fr/images/bloggings.jpg">
+ <meta property="og:image:type" content="image/jpg">
+ <meta property="og:image:width" content="1024">
+ <meta property="og:image:height" content="640">
+ <title>Bloggings</title>
+</head>
+<body>
+ <header>
+ <h1>Bloggings</h1>
+ <nav>
+ <p>
+ <b>Blog</b> | <a
+ href="/static/index.php">Static</a> | <a
+ href="/search.php">Search</a> | <a
+ href="https://git.wittamore.fr" target="_blank" title="Git">Git</a> | <a
+ href="https://social.wittamore.fr/philip" target="_blank" title="Fediverse">Fedi</a> | <a
+ href="/feeds/index.php" target="_blank" title="Feeds">Feeds</a> | <a
+ href="/rss.xml">RSS</a>
+ </p>
+ </nav>
+ <div class="banner">
+ <img src="/images/me.jpg" alt="logo">
+ <p>Comments: <a href="https://social.wittamore.fr/philip">@philip</a><br>
+ Contact: <a href="/images/deltachatqr.jpg">Deltachat</a>
+ </p>
+ </div>
+ </header>
+ <main>
+<!-- list start -->
+<?php
+// build reverse article subdirs (years)
+$years = [];
+$revyears = [];
+$articlesubdir = new DirectoryIterator("./articles/");
+foreach ($articlesubdir as $dirinfo) {
+ if ($dirinfo->isDir() && !$dirinfo->isDot()) {
+ $years[] = $dirinfo->getFilename();
+ }
+}
+rsort($years);
+// iterate through years
+if (is_array($years)) {
+ foreach ($years as $key => $year) {
+ $items = [];
+ $thisdir = new DirectoryIterator("./articles/" . $year);
+ // iterate through files
+ foreach ($thisdir as $file) {
+ if (!$file->isDot()) {
+ $flag = "";
+ $articledate = date("Y-m-d");
+ $filemodified = date(
+ "Y-m-d",
+ filemtime("./articles/" . $year . "/" . $file),
+ );
+ $content = file_get_contents($file->getPathname());
+ # get first h3
+ preg_match("/<h3>(.*?)<\/h3>/s", $content, $date);
+ if (isset($date[1]) && strtotime($date[1])) {
+ $articledate = date("Y-m-d", strtotime($date[1]));
+ }
+ if (
+ $articledate >=
+ date("Y-m-d", strtotime(date("Y-m-d") . " - 2 days"))
+ ) {
+ $flag = "<small><i> New</i></small>";
+ }
+ preg_match("/<h2>(.*?)<\/h2>/s", $content, $titre);
+ $title = "?";
+ if (isset($titre[1])) {
+ $title = ucfirst($titre[1]);
+ }
+
+ $items[] =
+ '<li class="articlelink">' .
+ substr($articledate, -5) .
+ ' <a href="' .
+ htmlentities($file->getPathname()) .
+ '">' .
+ $title . "</a>" .
+ $flag .
+ "</li>\n";
+ }
+ }
+
+ rsort($items);
+
+ echo "<article>\n";
+ echo "<h2 class=\"blogyear\">" . $year . "</h2>\n";
+
+ foreach ($items as $key => $val) {
+ if ($key == 0) {
+ if ($year == date("Y")) {
+ preg_match("'href=\"(.*?)\"'si", $val, $match);
+ if ($match) {
+ $content = file_get_contents($match[1], false, null, 1);
+ preg_match(
+ "'\<article\>(.*?)<\/article\>'si",
+ $content,
+ $article,
+ );
+ if ($article) {
+ # print latest article contents
+ echo $article[1] . "\n<p> </p>\n";
+ }
+ }
+ }
+ echo "<ul>\n";
+ }
+ # print link to article
+ echo $val;
+ }
+ echo "</ul>\n";
+ echo "</article>\n";
+ }
+} else {
+ echo "Not an array";
+}
+?>
+<!-- list end -->
+ </main>
+ <footer>
+ <p><a href="/static/Mention-Legal.html">GDPR notice</a></p>
+ </footer>
+</body>
+</html>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+