summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcflip <36554078+cflip@users.noreply.github.com>2021-06-06 09:05:53 -0600
committercflip <36554078+cflip@users.noreply.github.com>2021-06-06 09:05:53 -0600
commit8b44cecf9637e77cf0495e5ad08fdd033b39f06f (patch)
tree4737a4eaba37e00419a2e19e613efa02c743b115
parent08fc47935c3793a28359d185d13abba8aa075889 (diff)
Remove manage post and search pages
-rw-r--r--includes/model/Post.php12
-rw-r--r--includes/templates/header.php2
-rw-r--r--manage_post.php80
-rw-r--r--search.php66
4 files changed, 0 insertions, 160 deletions
diff --git a/includes/model/Post.php b/includes/model/Post.php
index 42add02..49fd640 100644
--- a/includes/model/Post.php
+++ b/includes/model/Post.php
@@ -94,18 +94,6 @@ class Post
$result = '<div class="header" id="p' . $this->id . '"><b>#' . $this->id . '</b>';
$result .= ' Posted by <a href="viewuser.php?id=' . $this->author->id . '">' . $this->author->name . '</a>';
$result .= ' on ' . date('m/d/Y g:ia', strtotime($this->date_created));
-
- // If the post has a edit date, display it
- if (!is_null($this->date_edited)) {
- $result .= ' <small>edited ' . date('m/d/Y g:ia', strtotime($this->date_edited)) . '</small>';
- }
-
- // Append a manage post button if the user is signed in and is the post's creator
- if (Session::get()->is_signed_in() && Session::get()->get_current_user()->id == $this->author->id) {
- $result .= '<span style="float:right;">';
- $result .= '[<a href="manage_post.php?id=' . $this->id . '">Edit/Delete</a>]';
- $result .= '</span>';
- }
$result .= '</div>';
// Append the formatted post content
diff --git a/includes/templates/header.php b/includes/templates/header.php
index 5070cfe..f1c2c94 100644
--- a/includes/templates/header.php
+++ b/includes/templates/header.php
@@ -2,8 +2,6 @@
<h1>cflip.net forum<sup style="font-size: small;">beta</sup></h1>
<p>
[<a href="/">Home</a>]
-[<a href="/search.php?type=thread&sort=lr">All Threads</a>]
-[<a href="/search.php?type=post&sort=cd">All Posts</a>]
[<a href="/create_thread.php">Create a thread</a>]
<span style="float:right;">
<?php
diff --git a/manage_post.php b/manage_post.php
deleted file mode 100644
index 99f0ad4..0000000
--- a/manage_post.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-include_once './includes/functions_post.php';
-include_once './includes/model/Post.php';
-
-session_start();
-
-if ($_SERVER['REQUEST_METHOD'] == 'GET') {
- $current = new Post();
-
- if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) {
- http_response_code(404);
- include_once './includes/templates/404.php';
- die();
- } else {
- $result = $current->get_from_database($_GET['id']);
- if ($result == 0) {
- http_response_code(404);
- include_once './includes/templates/404.php';
- die();
- }
- }
-} else {
- $id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
- $delete = filter_input(INPUT_POST, 'delete', FILTER_SANITIZE_STRING);
- $post_content = filter_input(INPUT_POST, 'post_content', FILTER_SANITIZE_STRING);
-
- $post = new Post();
- $post->get_from_database($id);
-
- if (strcasecmp($delete, "on") == 0) {
- delete_post($post);
- } else {
- edit_post($post, $post_content);
- }
-
- header("Location: /viewthread.php?id=" . $post->thread->id);
-}
-?>
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <title>Manage a post - cflip.net forum</title>
- <link rel="stylesheet" href="/styles/style.css">
-</head>
-<body>
-<?php include('includes/templates/header.php'); ?>
-<h1>Manage a post</h1>
-<?php
-echo get_post_content($current);
-echo '<hr>';
-
-$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
-
-if (!Session::get()->is_signed_in()) {
- echo '<p class="error">You must be <a href="signin.php">signed in</a> to manage a post.</p>';
- return;
-}
-
-// Admin users should be able to delete posts, but they should not be able to edit them
-// Or should they??
-if (Session::get()->get_current_user()->id != $current->author->id) {
- echo '<p class="error">You can\'t manage another user\'s post!</p>';
- return;
-}
-
-// TODO: Disallow editing/deleting posts if they have been around for a while
-?>
-<form action="manage_post.php" method="post">
- <h3>Edit post</h3>
- <input type="hidden" name="id" value="<?= $current->id ?>">
- <textarea name="post_content" rows="10" cols="50"><?= $current->content; ?></textarea>
- <p>Edited posts will show a timestamp above the post showing when the last edit was made.</p>
- <p>
- <input type="checkbox" id="delete" name="delete">
- <label for="delete">Delete this post</label>
- </p>
- <input type="submit" value="Apply Changes">
-</form>
-</body>
-</html>
diff --git a/search.php b/search.php
deleted file mode 100644
index e5ef9db..0000000
--- a/search.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php session_start() ?>
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <title>Search - cflip.net forum</title>
- <link rel="stylesheet" href="styles/style.css">
-</head>
-<body>
-<?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/functions_thread.php';
-include_once './includes/functions_post.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();
- 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();
-
- foreach ($posts as $post) {
- echo '<h3>From <a href="viewthread.php?id=' . $post->thread->id . '">' . $post->thread->subject . '</a></h3>';
- echo get_post_content($post);
- echo '<hr>';
- }
- break;
- case 'user':
- break;
- default:
- echo '<h3>Could not search: Invalid type!</h3>';
- break;
- }
-}
-?>
-</body>
-</html>