From 7c3f2e348c015ea93563d866f89ec8cea9159ea0 Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Sat, 24 Apr 2021 09:40:20 -0600 Subject: 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. --- search.php | 114 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) (limited to 'search.php') diff --git a/search.php b/search.php index c09ae53..0732129 100644 --- a/search.php +++ b/search.php @@ -1,65 +1,65 @@ - + - + - Search - cflip.net forum - + Search - cflip.net forum + - -

Search cflip.net forum

-
" method="get"> - Type: - - Sort By: - - With Name: - - -
-
- +

Search cflip.net forum

+
" method="get"> + + + + + + + +
+
+'; - echo '' . $thread->subject . ''; - echo ' created by ' . $thread->author->name . ' on ' . date('M d, Y', strtotime($thread->date_created)) . ''; - echo '

'; - } - break; - case 'post': - $posts = get_all_posts($dbc); - - foreach ($posts as $post) { - echo '

From ' . $post->thread->subject . '

'; - $post->display_content($dbc); - echo '
'; - } - break; - case 'user': - break; - default: - echo '

Could not search: Invalid type!

'; - 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 '

'; + echo '' . $thread->subject . ''; + echo ' created by ' . $thread->author->name . ' on ' . date('M d, Y', strtotime($thread->date_created)) . ''; + echo '

'; } - } - ?> + break; + case 'post': + $posts = get_all_posts($dbc); + + foreach ($posts as $post) { + echo '

From ' . $post->thread->subject . '

'; + $post->display_content($dbc); + echo '
'; + } + break; + case 'user': + break; + default: + echo '

Could not search: Invalid type!

'; + break; + } +} +?> -- cgit v1.2.3