From d61a18a93bc1b39d91725497ebb2fe85c4785ead Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Wed, 7 Apr 2021 11:44:11 -0600 Subject: Update links, rename files --- category.php | 69 --------------------------------------------------- index.php | 12 ++++++--- model/Post.php | 4 +-- templates/header.php | 12 ++++----- thread.php | 70 ---------------------------------------------------- user.php | 24 ------------------ viewcategory.php | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ viewthread.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ viewuser.php | 24 ++++++++++++++++++ 9 files changed, 179 insertions(+), 175 deletions(-) delete mode 100644 category.php delete mode 100644 thread.php delete mode 100644 user.php create mode 100644 viewcategory.php create mode 100644 viewthread.php create mode 100644 viewuser.php diff --git a/category.php b/category.php deleted file mode 100644 index b149237..0000000 --- a/category.php +++ /dev/null @@ -1,69 +0,0 @@ -get_from_database($_GET['id'], $dbc); - if ($result == 0) { - http_response_code(404); - include_once 'templates/404.php'; - die(); - } -} -?> - - - - <?php echo $current->name; ?> - cflip.net forum - - - -

name; ?>

-

description; ?>

- thread_count . ' threads, ' . $current->post_count . ' posts'; ?> -

Threads

- - - - - - date_lastpost); - $db = strtotime($b->date_lastpost); - - if ($da == $db) return 0; - - return ($da > $db) ? -1 : 1; - } - - $threads = $current->get_threads($dbc); - usort($threads, "cmp"); - - foreach ($threads as $thread) { - $latest_post = $thread->get_latest_post($dbc); - - echo ''; - echo ''; - - if (!is_null($latest_post)) { - echo ''; - } else { - echo ''; - } - - echo ''; - } - ?> -
Thread NameLatest Post
' . $thread->subject . '
'; - echo 'by ' . $thread->author->name . ' on ' . date('M d, Y', strtotime($thread->date_created)) . '
by ' . $latest_post->author->name . '
on ' . $latest_post->date . '
No posts yet!
- - \ No newline at end of file diff --git a/index.php b/index.php index dcad956..e27a155 100644 --- a/index.php +++ b/index.php @@ -42,16 +42,20 @@ echo ''; echo ''; - echo '' . $category->name . ''; + echo '' . $category->name . ''; echo '
' . $category->description; echo ''; echo '' . $category->thread_count . ''; echo '' . $category->post_count . ''; - echo '' . $latest_thread->subject . '
'; - echo 'by ' . $latest_thread->author->name . ', ' . $latest_thread->date_created . ''; + if (!is_null($latest_thread)) { + echo '' . $latest_thread->subject . '
'; + echo 'by ' . $latest_thread->author->name . ', ' . $latest_thread->date_created . ''; + } else { + echo 'No threads yet!'; + } echo ''; } ?> - \ No newline at end of file + diff --git a/model/Post.php b/model/Post.php index bcaff29..d10a505 100644 --- a/model/Post.php +++ b/model/Post.php @@ -37,7 +37,7 @@ class Post { } function display_content() { - echo '
#' . $this->id . ' Posted by ' . $this->author->name . ' on ' . date('m/d/Y g:ia', strtotime($this->date)) . '
'; + echo '
#' . $this->id . ' Posted by ' . $this->author->name . ' on ' . date('m/d/Y g:ia', strtotime($this->date)) . '
'; $post_content = $this->content; @@ -79,4 +79,4 @@ function get_all_posts($dbc) { mysqli_free_result($result); return $posts; -} \ No newline at end of file +} diff --git a/templates/header.php b/templates/header.php index d7b8b78..4eb17e3 100644 --- a/templates/header.php +++ b/templates/header.php @@ -1,14 +1,14 @@

cflip.net forumbeta

-[Home] -[All Threads] -[All Posts] -[Create a thread] +[Home] +[All Threads] +[All Posts] +[Create a thread] ' . $_SESSION['user_name'] . '\'s Profile] [Log out]'; + echo '[' . $_SESSION['user_name'] . '\'s Profile] [Log out]'; } else { echo '[Sign in] or [Register an account]'; } ?> - \ No newline at end of file + diff --git a/thread.php b/thread.php deleted file mode 100644 index f784e40..0000000 --- a/thread.php +++ /dev/null @@ -1,70 +0,0 @@ -get_from_database($_GET['id'], $dbc); - if ($result == 0) { - http_response_code(404); - include_once 'templates/404.php'; - die(); - } -} -?> - - - - <?php echo $current->subject; ?> - cflip.net forum - - - -

subject; ?>

- created by author->name; ?> - in category->name; ?> - 3 days ago -
- get_posts($dbc); - - foreach ($posts as $post) { - $post->display_content(); - } - ?> -
-

Reply to this thread

-
- -
- -
- - -signed in to reply to this thread.'; - return; - } - - $post_content = filter_input(INPUT_POST, 'post_content', FILTER_SANITIZE_STRING); - $user_id = filter_var($_SESSION['user_id'], FILTER_SANITIZE_NUMBER_INT); - - if (empty($post_content) or !$post_content) { - echo 'Thread subject cannot be empty'; - } else { - insert_post($dbc, $post_content, $current->id, $user_id, $current->category->id); - } -} - -?> \ No newline at end of file diff --git a/user.php b/user.php deleted file mode 100644 index 8685fcf..0000000 --- a/user.php +++ /dev/null @@ -1,24 +0,0 @@ -get_by_name($_GET['name'], $dbc); -} -?> - - - - <?php echo $current->name; ?>'s Profile - cflip.net forum - - - -

name; ?>

- member since date)); ?> - - \ No newline at end of file diff --git a/viewcategory.php b/viewcategory.php new file mode 100644 index 0000000..ebdc03f --- /dev/null +++ b/viewcategory.php @@ -0,0 +1,69 @@ +get_from_database($_GET['id'], $dbc); + if ($result == 0) { + http_response_code(404); + include_once 'templates/404.php'; + die(); + } +} +?> + + + + <?php echo $current->name; ?> - cflip.net forum + + + +

name; ?>

+

description; ?>

+ thread_count . ' threads, ' . $current->post_count . ' posts'; ?> +

Threads

+ + + + + + date_lastpost); + $db = strtotime($b->date_lastpost); + + if ($da == $db) return 0; + + return ($da > $db) ? -1 : 1; + } + + $threads = $current->get_threads($dbc); + usort($threads, "cmp"); + + foreach ($threads as $thread) { + $latest_post = $thread->get_latest_post($dbc); + + echo ''; + echo ''; + + if (!is_null($latest_post)) { + echo ''; + } else { + echo ''; + } + + echo ''; + } + ?> +
Thread NameLatest Post
' . $thread->subject . ''; + echo ' by ' . $thread->author->name . ' on ' . date('M d, Y', strtotime($thread->date_created)) . 'by ' . $latest_post->author->name . ' on ' . $latest_post->date . 'No posts yet!
+ + diff --git a/viewthread.php b/viewthread.php new file mode 100644 index 0000000..f784e40 --- /dev/null +++ b/viewthread.php @@ -0,0 +1,70 @@ +get_from_database($_GET['id'], $dbc); + if ($result == 0) { + http_response_code(404); + include_once 'templates/404.php'; + die(); + } +} +?> + + + + <?php echo $current->subject; ?> - cflip.net forum + + + +

subject; ?>

+ created by author->name; ?> + in category->name; ?> + 3 days ago +
+ get_posts($dbc); + + foreach ($posts as $post) { + $post->display_content(); + } + ?> +
+

Reply to this thread

+
+ +
+ +
+ + +signed in to reply to this thread.'; + return; + } + + $post_content = filter_input(INPUT_POST, 'post_content', FILTER_SANITIZE_STRING); + $user_id = filter_var($_SESSION['user_id'], FILTER_SANITIZE_NUMBER_INT); + + if (empty($post_content) or !$post_content) { + echo 'Thread subject cannot be empty'; + } else { + insert_post($dbc, $post_content, $current->id, $user_id, $current->category->id); + } +} + +?> \ No newline at end of file diff --git a/viewuser.php b/viewuser.php new file mode 100644 index 0000000..5a6afbc --- /dev/null +++ b/viewuser.php @@ -0,0 +1,24 @@ +get_by_id($_GET['id'], $dbc); +} +?> + + + + <?php echo $current->name; ?>'s Profile - cflip.net forum + + + +

name; ?>

+ member since date)); ?> + + -- cgit v1.2.3