summaryrefslogtreecommitdiff
path: root/search.php
diff options
context:
space:
mode:
authorcflip <36554078+cflip@users.noreply.github.com>2021-04-24 09:40:20 -0600
committercflip <36554078+cflip@users.noreply.github.com>2021-04-24 09:40:20 -0600
commit7c3f2e348c015ea93563d866f89ec8cea9159ea0 (patch)
treeb7b6b18cf9087f42300f621d15101628a8d214e4 /search.php
parent6c9369ad85f2fb3dc61234b54db7e7079cdc0c4e (diff)
Refactoring part 2
Starting to move some functionality such as the session and database connection into singleton classes to manage them. Functions for modifying posts and threads are being put in one place as well.
Diffstat (limited to 'search.php')
-rw-r--r--search.php114
1 files changed, 57 insertions, 57 deletions
diff --git a/search.php b/search.php
index c09ae53..0732129 100644
--- a/search.php
+++ b/search.php
@@ -1,65 +1,65 @@
-<?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/db_inc.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($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>