blob: 13d54052a5a3a828f2f2e3084ae0e60752310d5e (
plain)
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
|
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/time.php';
$db = new PDO("sqlite:{$_SERVER['DOCUMENT_ROOT']}/database.db");
if (isset($_GET['id']) && !empty(trim($_GET['id']))) {
$stmt = $db->prepare('SELECT * FROM statuses WHERE id = ?');
$stmt->execute([$_GET['id']]);
$status = $stmt->fetch(PDO::FETCH_ASSOC) ?: null;
} else {
$stmt = $db->query('SELECT id, title, posted_at FROM statuses ORDER BY posted_at DESC');
$statuses = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>statuses - ilt.su</title>
<meta name="description" content="my statuses.">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<link rel="stylesheet" href="/static/style.css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<meta name="robots" content="noindex, nofollow">
</head>
<body>
<main>
<p><a href="/">ilt.su</a> - <a href="/status/">statuses</a></p>
<?php if (isset($status)): ?>
<h1><?= $status['title'] ?? '<i>No title.</i>' ?></h1>
<div>
<?= $status['contents'] ?? '<i>No contents.</i>' ?>
</div>
<p><i>Posted <?= format_timestamp(time() - strtotime($status['posted_at'])) ?> ago</i></p>
<?php endif; ?>
<?php if (isset($statuses)): ?>
<h1>Statuses</h1>
<ul>
<?php foreach ($statuses as $s): ?>
<li><a href="/status/?id=<?= $s['id'] ?>"><?= $s['title'] ?></a>
<i><?= format_timestamp(time() - strtotime($s['posted_at'])) ?>
ago</i>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</main>
</body>
</html>
|