summaryrefslogtreecommitdiff
path: root/model/Post.php
diff options
context:
space:
mode:
Diffstat (limited to 'model/Post.php')
-rw-r--r--model/Post.php15
1 files changed, 11 insertions, 4 deletions
diff --git a/model/Post.php b/model/Post.php
index 5d85f20..d7aba72 100644
--- a/model/Post.php
+++ b/model/Post.php
@@ -25,13 +25,14 @@ function add_quote($dbc, $thread_id, $matches) {
class Post {
public $id;
public $content;
- public $date;
+ 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, post_thread, post_author FROM posts WHERE post_id = " . mysqli_real_escape_string($dbc, $id);
+ $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) {
@@ -39,11 +40,13 @@ class Post {
}
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 = $row['post_date'];
+ $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);
@@ -54,12 +57,16 @@ class Post {
}
mysqli_free_result($result);
+ return 1;
}
function display_content($dbc) {
echo '<div class="header" id="p' . $this->id . '"><b>#' . $this->id . '</b>';
echo ' Posted by <a href="viewuser.php?id='. $this->author->id . '">' . $this->author->name . '</a>';
- echo ' on ' . date('m/d/Y g:ia', strtotime($this->date));
+ echo ' on ' . date('m/d/Y g:ia', strtotime($this->date_created));
+ if (!is_null($this->date_edited)) {
+ echo ' <small>edited ' . date('m/d/Y g:ia', strtotime($this->date_edited)) . '</small>';
+ }
if (isset($_SESSION['signed_in']) && $_SESSION['user_id'] == $this->author->id) {
echo '<span style="float:right;">';
echo '[<a href="includes/manage_post.php?action=edit&id=' . $this->id . '">Edit</a>] ';