-
Notifications
You must be signed in to change notification settings - Fork 7
/
header.php
67 lines (58 loc) · 1.76 KB
/
header.php
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
<?php
if (!isset($out)) exit;
require 'config/config.php';
require 'config/language.php';
require 'include/db.php';
require 'include/util.php';
require 'include/ui.php';
session_start();
if (!isset($_SESSION['role']))
$_SESSION['role'] = '';
function home() {
redirect('.');
}
// $_GET = urlPath();
$out['baseURL'] = baseURL();
$out['content'] = '';
$out['error'] = '';
// Links
$out['addLink'] .= isAdmin() ? '<a href="./add.php?link" class="add"></a>' : '';
$out['linkListItems'] .= '';
$links = listEntry('links');
if ($links) {
foreach ($links as $link) {
$linkEntry = readEntry('links', $link);
$out['linkListItems'] .= '<li><a href="' . $linkEntry['url'] . '">' . $linkEntry['name'] . '</a>' . manageLink($link) . '</li>';
}
}
// Tags
$out['addTag'] .= isAdmin() ? '<a href="./add.php?tag" class="add"></a>' : '';
$out['tagLinks'] .= '';
$tags = listEntry('tags');
foreach ($tags as $tag) {
$tagEntry = readEntry('tags', $tag);
$out['tagLinks'] .= ' <a href="./view.php?tag=' . $tag . '">' . $tagEntry['name'] . ' (' . count($tagEntry['posts']) . ')</a>';
}
// Archive
$out['archiveListItems'] .= '';
$archives = array();
foreach (listEntry('posts') as $post) {
$year = substr($post, 0, 4);
$month = substr($post, 5, 2);
if (isset($archives[$year][$month])) {
$archives[$year][$month]++;
} else {
$archives[$year][$month] = 1;
}
}
if ($archives) {
foreach ($archives as $year => $months) {
$out['archiveListItems'] .= '<li>' . $year . ' ';
foreach ($months as $month => $count) {
$yearMonth = $year . '-' . $month;
$out['archiveListItems'] .= ' <a href="./view.php?archive=' . $yearMonth . '">' . date('M', strtotime($yearMonth)) . ' (' . $count . ')</a>';
}
$out['archiveListItems'] .= '</li>';
}
}
?>