From 6c9369ad85f2fb3dc61234b54db7e7079cdc0c4e Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Fri, 23 Apr 2021 18:43:12 -0600 Subject: Refactoring part 1 --- model/Post.php | 121 --------------------------------------------------------- 1 file changed, 121 deletions(-) delete mode 100644 model/Post.php (limited to 'model/Post.php') diff --git a/model/Post.php b/model/Post.php deleted file mode 100644 index 34d6a79..0000000 --- a/model/Post.php +++ /dev/null @@ -1,121 +0,0 @@ -'; - } - - $reply = mysqli_fetch_assoc($result); - - if (empty($reply)) { - return '
This post has been deleted'; - } - - return '
Quote from ' . $reply['user_name'] . ''; - } -} - -class Post { - public $id; - public $content; - public $date_created; - public $date_edited; - public $thread; - public $author; - - function get_from_database($id, $dbc) { - // TODO: Potential SQL injection risk? - $sql = "SELECT post_content, post_date_created, post_date_edited, post_thread, post_author FROM posts WHERE post_id = " . mysqli_real_escape_string($dbc, $id); - $result = mysqli_query($dbc, $sql); - - if (!$result) { - echo 'Failed to get post: ' . mysqli_error($dbc); - } - - if (mysqli_num_rows($result) == 0) { - return 0; - } else { - while ($row = mysqli_fetch_assoc($result)) { - $this->id = $id; - $this->content = $row['post_content']; - $this->date_created = $row['post_date_created']; - $this->date_edited = $row['post_date_edited']; - - $this->thread = new Thread(); - $this->thread->get_from_database($row['post_thread'], $dbc); - - $this->author = new User(); - $this->author->get_by_id($row['post_author'], $dbc); - } - } - - mysqli_free_result($result); - return 1; - } - - function display_content($dbc) { - echo '
' . $reply['post_content'] . '