summaryrefslogtreecommitdiff
path: root/search.php
diff options
context:
space:
mode:
Diffstat (limited to 'search.php')
-rw-r--r--search.php115
1 files changed, 58 insertions, 57 deletions
diff --git a/search.php b/search.php
index c09ae53..e5ef9db 100644
--- a/search.php
+++ b/search.php
@@ -1,65 +1,66 @@
-<?php session_start()?>
+<?php session_start() ?>
<!DOCTYPE html>
-<html>
+<html lang="en">
<head>
- <title>Search - cflip.net forum</title>
- <link rel="stylesheet" href="styles/style.css">
+ <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';
+<?php include_once './includes/templates/header.php'; ?>
+<h2>Search cflip.net forum</h2>
+<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="get">
+ <label for="type">Type:</label>
+ <select id="type" name="type">
+ <option value="thread">Thread</option>
+ <option value="post">Post</option>
+ <option value="user">User</option>
+ </select>
+ <label for="sort">Sort By:</label>
+ <select id="sort" name="sort">
+ <option value="lr">Last Reply</option>
+ <option value="cd">Creation Date</option>
+ <option value="rc">Reply Count</option>
+ </select>
+ <label for="text">With Name:</label>
+ <input id="text" type="text" name="query">
+ <input type="submit" value="Search!">
+</form>
+<hr>
+<?php
+include_once './includes/functions_thread.php';
+include_once './includes/functions_post.php';
+include_once './includes/model/Thread.php';
+include_once './includes/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;
+if (!isset($_GET['type'])) {
+ echo 'Specify a type to search.';
+} else {
+ switch ($_GET['type']) {
+ case 'thread':
+ $threads = get_all_threads();
+ 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();
+
+ foreach ($posts as $post) {
+ echo '<h3>From <a href="viewthread.php?id=' . $post->thread->id . '">' . $post->thread->subject . '</a></h3>';
+ echo get_post_content($post);
+ echo '<hr>';
+ }
+ break;
+ case 'user':
+ break;
+ default:
+ echo '<h3>Could not search: Invalid type!</h3>';
+ break;
+ }
+}
+?>
</body>
</html>