summaryrefslogtreecommitdiff
path: root/htdocs/src/Post.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'htdocs/src/Post.inc.php')
-rw-r--r--htdocs/src/Post.inc.php32
1 files changed, 30 insertions, 2 deletions
diff --git a/htdocs/src/Post.inc.php b/htdocs/src/Post.inc.php
index a4d34f7..22d2fce 100644
--- a/htdocs/src/Post.inc.php
+++ b/htdocs/src/Post.inc.php
@@ -31,7 +31,7 @@ class Post {
}
private static function getPost($where) {
- $query = "SELECT * FROM post WHERE $where";
+ $query = "SELECT *, UNIX_TIMESTAMP(created) AS createdts FROM post WHERE $where";
$db = getDatabase();
@@ -59,7 +59,11 @@ class Post {
}
public function getName() {
- return $this->info['name'];
+ return htmlspecialchars($this->info['name']);
+ }
+
+ public function getDescription() {
+ return htmlspecialchars($this->info['description']);
}
public function getStage() {
@@ -77,6 +81,30 @@ class Post {
public function getCreated() {
return $this->info['created'];
}
+
+ public function getAge() {
+ $diff = time() - $this->info['createdts'];
+
+ if ($diff < 60) {
+ return floor($diff) ." seconds ago";
+
+ } else if ($diff < 3600) {
+ return floor($diff / 60) ." minutes ago";
+
+ } else if ($diff < 86400) {
+ return floor($diff / 3600) ." hours ago";
+
+ } else if ($diff < 604800) {
+ return floor($diff / 86400) ." days ago";
+
+ } else {
+ return floor($diff / 604800) . " weeks ago";
+ }
+ }
+
+ public function getLocation() {
+ return $this->info['location'];
+ }
}
?>