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 From 2098bf444afadcf0363d89b4cc1dca5d2213d754 Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Sat, 24 Apr 2021 19:40:50 -0600 Subject: Remove all uses of db_inc.php This method of importing the database login every time wasn't very good. Now everything uses the new Database singleton class. --- search.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'search.php') diff --git a/search.php b/search.php index 0732129..e5ef9db 100644 --- a/search.php +++ b/search.php @@ -27,7 +27,8 @@
'; echo '' . $thread->subject . ''; @@ -45,11 +46,11 @@ if (!isset($_GET['type'])) { } break; case 'post': - $posts = get_all_posts($dbc); + $posts = get_all_posts(); foreach ($posts as $post) { echo '

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

'; - $post->display_content($dbc); + echo get_post_content($post); echo '
'; } break; -- cgit v1.2.3