-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
39 lines (38 loc) · 957 Bytes
/
index.php
File metadata and controls
39 lines (38 loc) · 957 Bytes
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
<?php
require_once(__DIR__."/lib/autoload.php");
$posts = $auth->getAllPosts();
?>
<!DOCTYPE html>
<html lang="en">
<?php
$title = "Startseite";
require_once(__DIR__."/inc/head.php");
?>
<body>
<?php require_once(__DIR__."/inc/nav.php"); ?>
<section class="main">
<h2>Beiträge</h2>
<?php
if ($posts) {
foreach($posts as $post) {
?>
<article class="card">
<header>
<h2><a href="/post.php?view=<?= $post['id'] ?>"><?= $post['title'] ?></a></h2>
</header>
<p>
<?= substr($post['text'], 0, 512) ?><?= (substr($post['text'], 0, 512) !== $post['text']) ? '... <br><a href="/post.php?view='.$post["id"].'">Weiterlesen...</a>' : '' ?>
</p>
<footer>
<p><small>von <?= $post['user'] ?> am <?= date('d.m.Y H:i', $post['created_at']) ?></small></p>
</footer>
</article>
<?php
}
} else {
echo 'Noch kein Beitrag vorhanden. :(';
}
?>
</section>
</body>
</html>