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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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>
|