summaryrefslogtreecommitdiff
path: root/index.php
blob: 9545e4331603fb3d2d91fbcaf4e079214a3839b0 (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
53
54
55
56
57
58
59
60
<?php include_once './includes/model/Category.php'; ?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<title>cflip.net forum</title>
<?php include_once 'includes/templates/head.php'; ?>
	</head>
	<body>
<?php include_once 'includes/templates/header.php'; ?>
		<h2>Categories</h2>
		<table>
			<tr>
				<th>Category</th>
				<th>Latest Thread</th>
			</tr>
<?php foreach (Category::get_all_categories() as $category): ?>
			<tr>
				<td>
					<a style="font-size: larger;" href="viewcategory.php?id=<?= $category->id ?>"><?= $category->name ?></a>
					<br><?= $category->description ?>
				</td>
<?php $latest_thread = $category->get_latest_thread(); if ($latest_thread->has_value()): ?>
				<td>
					<b><a href="viewthread.php?id=<?= $latest_thread->id ?>"><?= $latest_thread->subject ?></a></b>
					<br>
					<small>by <b><a href="viewuser.php?id=<?= $latest_thread->author_id ?>"><?= $latest_thread->get_author()->name ?></a></b>, <?= $latest_thread->date_created ?></small>
				</td>
<?php else: ?>
				<td>No threads yet!</td>
<?php endif ?>
			</tr>
<?php endforeach ?>
		</table>
		<h2>Latest Threads</h2>
		<table>
			<tr>
				<th>Thread</th>
				<th>Category</th>
				<th>Latest Post</th>
			</tr>
<?php foreach (Thread::get_latest() as $thread): ?>
			<tr>
				<td>
					<b><a href="viewthread.php?id=<?= $thread->id ?>"><?= $thread->subject ?></a></b>
					<small>on <?= date('M d, Y', strtotime($thread->date_created)); ?></small>
				</td>
				<td><a href="viewcategory.php?id=<?= $thread->category_id ?>"><?= $thread->get_parent_category()->name ?></a></td>
<?php $latest_post = $thread->get_latest_post(); if ($latest_post->has_value()): ?>
				<td>
					<small>by <b><a href="viewuser.php?id=<?= $latest_post->author_id ?>"><?= $latest_post->get_author()->name ?></a></b>
					on <?= $latest_post->date_created ?></small>
				</td>
<?php else: ?>
				<td>No posts yet!</td>
<?php endif ?>
			</tr>
<?php endforeach ?>
		</table>
	</body>
</html>