-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforum.php
128 lines (121 loc) · 5.8 KB
/
forum.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
include_once('includes/connect.php');
include_once('includes/session.php');
include_once('includes/login.php');
?>
<!doctype html>
<html>
<head>
<title>Forum - ChronicleGE</title>
<link rel='stylesheet' href='css/reset.css' type='text/css'/>
<link rel='stylesheet' href='css/main.css' type='text/css'/>
<link rel='stylesheet' href='css/header.css' type='text/css'/>
<link rel='stylesheet' href='css/forum.css' type='text/css'/>
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Crimson+Text' type='text/css'/>
</head>
<body>
<?php include_once("includes/header.php") ?>
<div class="mainContainer">
<?php include_once('includes/nav.php'); ?>
<div class="forumContainer">
<h2>Chronicle General</h2>
<div class="forumGroup" id="header">
<div class="fBox1">
Forum
</div>
<div class="fBox2">
Last Post
</div>
<div class="fBox3">
Threads
</div>
<div class="fBox4">
Posts
</div>
</div>
<?php
$query = mysql_query("SELECT * FROM sections");
while ($row = mysql_fetch_array($query)){
?>
<div class="forumGroup">
<div class="fBox1">
<?php echo "<a href='section.php?id=".$row['id']."'>".$row['name']."</a>"; ?>
<div class="subRow">
<?php echo $row['description']; ?>
</div>
</div>
<div class="fBox2">
<?php
$query2 = mysql_query('
SELECT username, posts.date
FROM posts
INNER JOIN users ON posts.user_id = users.id
WHERE posts.thread_id = (SELECT id FROM threads WHERE section_id = '.$row["id"].' ORDER BY id DESC LIMIT 1)
ORDER BY posts.id DESC
LIMIT 1
');
while($row2 = mysql_fetch_array($query2)) {
$lastPostBy = $row2['username'];
$lastPostDate = $row2['date'];
}
date_default_timezone_set('Europe/London');
$currentDate = new DateTime();
$postDate = new DateTime($lastPostDate);
$interval = $currentDate->diff($postDate);
$timeString = $interval->s." seconds ago";
if ($interval->m!=null) {
$timeString = "Over a month ago";
} else {
if ($interval->i!=null) {
if ($interval->i == 1){
$timeString = $interval->i." minute ago";
} else {
$timeString = $interval->i." minutes ago";
}
}
if ($interval->h!=null) {
if ($interval->h == 1){
$timeString = $interval->h." hour ago";
} else {
$timeString = $interval->h." hours ago";
}
}
if ($interval->d!=null) {
if ($interval->d == 1){
$timeString = $interval->d." day ago";
} else {
$timeString = $interval->d." days ago";
}
}
}
?>
<div class="subRow">
by <a href="#"><?php echo $lastPostBy; ?></a>
<br>
<span style="float: right; margin-top: 10px;">
<?php echo $timeString; ?>
</span>
</div>
</div>
<div class="fBox3" id="lowerBy10">
<?php
$threadQuery = mysql_query("SELECT COUNT(id) AS count FROM threads WHERE section_id = ".$row['id']);
$result = mysql_fetch_array($threadQuery);
echo $result['count'];
?>
</div>
<div class="fBox4" id="lowerBy10">
<?php
$query3 = mysql_query('SELECT COUNT(*) FROM posts, threads WHERE posts.thread_id = threads.id AND threads.section_id = '.$row["id"].';');
echo mysql_result($query3, 0);
?>
</div>
</div>
<?php
}
?>
<div class="clear"></div>
</div>
</div>
</body>
</html>