summaryrefslogtreecommitdiff
path: root/search.php
diff options
context:
space:
mode:
Diffstat (limited to 'search.php')
-rw-r--r--search.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/search.php b/search.php
new file mode 100644
index 0000000..d90d0e6
--- /dev/null
+++ b/search.php
@@ -0,0 +1,61 @@
+<?php session_start()?>
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Search - cflip.net forum</title>
+</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><b>' . $thread->subject . '</b> by <b>' . $thread->author->name . '</b></p>';
+ }
+ break;
+ case 'post':
+ $posts = get_all_posts($dbc);
+
+ foreach ($posts as $post) {
+ echo '<h4>From ' . $post->thread->subject . '</h4>';
+ $post->display_content();
+ }
+ break;
+ case 'user':
+ break;
+ default:
+ echo '<h3>Could not search: Invalid type!</h3>';
+ break;
+ }
+ }
+ ?>
+</body>
+</html> \ No newline at end of file