aboutsummaryrefslogtreecommitdiff
path: root/index.php
blob: 9fdc8f3df29b49ebe3d524be049722181d56c6bc (plain) (blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!doctype html>
<html lang="en">
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="stylesheet" href="/style.css">
 <link rel="icon" type="image/x-icon" href="/favicon.ico">
 <meta property="og:image" content="https://wittamore.com/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>
   <p><b>Blog</b>&nbsp;|&nbsp;<a href="sticky.php">Sticky</a>&nbsp;|&nbsp;<a
    href="search.php">Search</a>&nbsp;|&nbsp;<a
    href="https://wittamore-com.translate.goog/?_x_tr_sl=auto&_x_tr_tl=fr&_x_tr_hl=en-GB&_x_tr_pto=wapp">Français</a>&nbsp;|&nbsp;<a 
    href="https://git.wittamore.com" target="_blank" title="Git">Git</a>&nbsp;|&nbsp;<a
    href="https://wittamore.com/rss.xml" target="_blank" title="RSS">RSS</a>&nbsp;|&nbsp;<a
    href="https://bsky.app/profile/wittamore.com" target="_blank">Bluesky</a></p>
  <hr>
 <p>This is my personal <a href="/articles/2023/minimalist-blog.html">minimalist blog</a>. 
    It has no Javascript, cookies or bloat, it won't track you or sell your soul and can be viewed in any browser.  
    <a href="/sticky/Mention-Legal.html">GDPR notice</a></p>
 </header>
    <!-- list start -->
<?php
// build reverse article subdirs (years)
$yeardirs = [];
$revyeardirs = [];
$articlesubdir = new DirectoryIterator("./articles/");
foreach ($articlesubdir as $dirinfo) {
    if ($dirinfo->isDir() && !$dirinfo->isDot()) {
        $yeardirs[] = $dirinfo->getFilename();
    }
}
rsort($yeardirs);
// iterate through years
if (is_array($yeardirs)) {
    foreach ($yeardirs as $key => $dirname) {
        echo "<h2>" . $dirname . "</h2>";
        echo "<ul>";
        $items = [];
        $thisdir = new DirectoryIterator("./articles/" . $dirname);
        // iterate through files
        foreach ($thisdir as $file) {
            if (!$file->isDot()) { 
                $flag = "";
                $articledate = date("Y-m-d");
                $filemodified =  date("Y-m-d", filemtime("./articles/".$dirname."/".$file));
                $content = file_get_contents($file->getPathname());
                preg_match("/<h5>(.*?)<\/h5>/s", $content, $date);
                if (isset($date[1]) && strtotime($date[1])) {
                    $articledate = date("Y-m-d", strtotime($date[1]));
                }
                // 2025-04-18 was the last global update
                if (($filemodified > $articledate) && 
                    ($filemodified != "2025-04-18") &&
                    ($filemodified >= date('Y-m-d', strtotime(date("Y-m-d"). ' - 7 days')))) $flag = "Updated";
                if ($articledate >= date('Y-m-d', strtotime(date("Y-m-d"). ' - 2 days'))) $flag = "New";
                preg_match("/<h2>(.*?)<\/h2>/s", $content, $titre);
                $title = "?";
                if (isset($titre[1])) {
                    $title = ucfirst($titre[1]);
                }

                $items[] =
                    '<li style="list-style-type:none;">' .
                    substr($articledate, -5 ) . '&nbsp;' .
                    '<a target="blank" href="' .
                    $file->getPathname() .
                    '">' .
                    $title .
                    "</a><small><i>&nbsp;" . $flag . "</i></small></li>";
            }
        }

        rsort($items);
        foreach ($items as $key => $val) {
            echo $val;
        }
        echo "</ul>";
    }
} else {
    echo "Not an array";
}
?>
<!-- list end -->
 <p>&nbsp;</p>
 <hr>
 <p>§</p>
</body>
</html>