-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
38 lines (31 loc) · 864 Bytes
/
index.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
<?php
include 'include/context.php';
$posts = get_notes();
if (isset($_GET['p']) and abs($_GET['p'])) {
$page = abs($_GET['p']);
} else {
$page = 1;
}
$limit = 8;
$offset = $limit * ($page - 1);
$count = count($posts);
$pages = ceil($count / $limit);
$posts = array_slice($posts, $offset, $limit, true);
?>
<?php include 'include/header.php'; ?>
<?php include 'include/menu.php'; ?>
<div class="main">
<div class="center">
<?php foreach ($posts as $id => $note): ?>
<?php include 'include/item.php'; ?>
<?php endforeach; ?>
<div class="entry">
<div class="pages">
<?php foreach (range(1, $pages) as $number): ?>
<a class="<?php if ($number == $page): ?>selected<?php endif; ?>" href="/?p=<?= $number ?>"><?= $number ?></a>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
<?php include 'include/footer.php'; ?>