aboutsummaryrefslogtreecommitdiff
path: root/sticky.php
blob: abf66509f28d2183cbe2bc671d8b18c34a4bd825 (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
<!doctype html>
<html>
<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">
 <title>Bloggings</title>
</head>
<body>
 <header>
   <h1>Bloggings</h1>
   <p><a href="index.php">Blog</a>&nbsp;|&nbsp;<b>Sticky</b>&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="rss.xml">RSS</a>&nbsp;|&nbsp;<a
      href="https://bsky.app/profile/wittamore.com" target="_blank">Bluesky</a></p>
  <hr />
 </header>
 <h2>Sticky pages</h2>
 <!-- list start -->
<?php
// iterate through years
$items = [];
echo "<ul>";
// iterate through files
$i = 0;
$thisdir = new DirectoryIterator("./sticky");
foreach ($thisdir as $file) {
    if ((!$file->isDot()) && (!$file->isDir())) { 
        $i++;
        $content = file_get_contents($file->getPathname());
        preg_match("/<h5>(.*?)<\/h5>/s", $content, $date);
        $filedate = date("Y-m-d");

        if (isset($date[1]) && strtotime($date[1])) {
            $filedate = date("Y-m-d", strtotime($date[1]));
        }

        preg_match("/<h2>(.*?)<\/h2>/s", $content, $titre);
        $title = "?";

        if (isset($titre[1])) {
            $title = ucfirst($titre[1]);
        }
        $items[$i][0] = $i;
        $items[$i][1] = $file->getPathname();
        $items[$i][2] = $title;
    }
}
$values = array_column($items, 2);
array_multisort($values, SORT_ASC, $items);

$i = 0;
while ($i < count($items)) {
    echo "<li>" .
        '<a href="' .
        $items[$i][1] .
        '">' .
        ucfirst($items[$i][2]) .
        "</a></li>";
    $i++;
}
echo "</ul>";
?>
<!-- list end -->
 <p>&nbsp;</p>
 <hr />
 <p>§</p>
 </body>
</html>