blob: c09ae53c5e29e1d1ba7a3a83f44a66b2997fa36d (
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
61
62
63
64
65
|
<?php session_start()?>
<!DOCTYPE html>
<html>
<head>
<title>Search - cflip.net forum</title>
<link rel="stylesheet" href="styles/style.css">
</head>
<body>
<?php include_once 'templates/header.php'; ?>
<h2>Search cflip.net forum</h2>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="get">
Type:
<select name="type">
<option value="thread">Thread</option>
<option value="post">Post</option>
<option value="user">User</option>
</select>
Sort By:
<select name="sort">
<option value="lr">Last Reply</option>
<option value="cd">Creation Date</option>
<option value="rc">Reply Count</option>
</select>
With Name:
<input type="text" name="query">
<input type="submit" value="Search!">
</form>
<hr>
<?php
include_once 'includes/db_inc.php';
include_once 'model/Thread.php';
include_once 'model/Post.php';
if (!isset($_GET['type'])) {
echo 'Specify a type to search.';
} else {
switch ($_GET['type']) {
case 'thread':
$threads = get_all_threads($dbc);
foreach ($threads as $thread) {
echo '<p>';
echo '<td><b><a href="viewthread.php?id=' . $thread->id . '">' . $thread->subject . '</a></b>';
echo '<small> created by <b><a href="viewuser.php?id=' . $thread->author->id . '">' . $thread->author->name . '</a></b> on ' . date('M d, Y', strtotime($thread->date_created)) . '</small></td>';
echo '</p>';
}
break;
case 'post':
$posts = get_all_posts($dbc);
foreach ($posts as $post) {
echo '<h3>From <a href="viewthread.php?id=' . $post->thread->id . '">' . $post->thread->subject . '</a></h3>';
$post->display_content($dbc);
echo '<hr>';
}
break;
case 'user':
break;
default:
echo '<h3>Could not search: Invalid type!</h3>';
break;
}
}
?>
</body>
</html>
|