summaryrefslogtreecommitdiff
path: root/thread.php
blob: 9c43217bc6dc50ce2c82a3bce6b8a1bccf6249e5 (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
<?php
include_once 'includes/db_inc.php';
include_once 'model/Thread.php';

session_start();

$current = new Thread();

if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) {
} else {
	$current->get_from_database($_GET['id'], $dbc);
}
?>
<!DOCTYPE html>
<html>
<head>
	<title><?php echo $current->subject; ?> - cflip.net forum</title>
</head>
<body>
	<?php include_once 'templates/header.php';?>
	<h1><?php echo $current->subject; ?></h1>
	created by <b><?php echo '$current->user->name'; ?></b>
	in <b><?php echo $current->category->name; ?></b>
	<abbr title="<?php echo date('M d, Y g:ia', strtotime($current->date_created));?>">3 days ago</abbr>
	<hr>
	<?php
		include_once 'includes/functions_display.php';

		$sql = "SELECT post_id, post_content, post_date, post_author, user_id, user_name FROM posts LEFT JOIN users ON post_author = user_id WHERE post_thread = " . mysqli_real_escape_string($dbc, $_GET['id']);
		$result = mysqli_query($dbc, $sql);
	
		if (!$result) {
			die('Error trying to display posts: ' . mysqli_error($dbc));
		}
	
		if (mysqli_num_rows($result) == 0) {
			echo '<section>This thread has no posts</section>';
		} else {
			display_posts($dbc, $_GET['id'], $result);
		}
	?>
</body>
</html>