diff --git a/README.md b/README.md
index e9f75cd..4d71ce2 100644
--- a/README.md
+++ b/README.md
@@ -56,6 +56,21 @@ Posts also have sequencial IDs, generated by incrementing the following key:
INCR next_post_id => 134
Every post is stored into an hash named `post:134` with the following
+fields:
+
+ user_id
+ time
+ body
+ pre
+
+Comments
+---
+
+Comments also have sequencial IDs, generated by incrementing the following key:
+
+ INCR next_comment_id => 123
+
+Every comment is stored into an hash named `comment:123` with the following
fields:
user_id
diff --git a/comment.php b/comment.php
new file mode 100644
index 0000000..bb7587f
--- /dev/null
+++ b/comment.php
@@ -0,0 +1,28 @@
+
+include("retwis.php");
+
+if (!isLoggedIn()) {
+ header("Location:".index.php);
+ exit;
+}
+
+foreach ($_POST as $key => $value){
+ if (empty($value)) {
+ $refferer = $_SERVER['HTTP_REFERER'];
+ header("Location:".$refferer);
+ exit;
+ }
+ $cid = $key;
+ $comment = $value;
+}
+
+$r = redisLink();
+$commentid = $r->incr("next_comment_id");
+$comment = str_replace("\n"," ",$comment);
+$r->hmset("comment:$commentid","user_id",$User['id'],"time",time(),"body",$comment);
+$r->lpush("comments:$cid", $commentid);
+
+$refferer = $_SERVER['HTTP_REFERER'];
+header("Location:".$refferer);
+?>
+
diff --git a/followers.php b/followers.php
new file mode 100644
index 0000000..8e22413
--- /dev/null
+++ b/followers.php
@@ -0,0 +1,27 @@
+
+include("retwis.php");
+if (!isLoggedIn()) {
+ header("Location: index.php");
+ exit;
+}
+include("header.php");
+echo("
'.$userlink.' '.$status);
+ while($ref != -1) {
+ $refpost = $r->hgetall("post:$ref");
+ if (empty($refpost)) break;
+ $refuserid = $refpost['user_id'];
+ $refusername = $r->hget("user:$refuserid","username");
+ $refelapsed = strElapsed($refpost['time']);
+ $refuserlink = "
".utf8entities($refusername)."";
+ $refstatus = utf8entities($refpost['body']);
+ echo(' || '.$refuserlink.' '.$refstatus);
+ $ref = $refpost['ref'];
+ }
+ echo('
');
+ echo('
posted '.$elapsed.' ago via web');
+?>
+
+
+
+
+ showComment($id);
+ echo("
");
return true;
}
-function showUserPosts($userid,$start,$count) {
+function showUserPosts($userid,$start,$count,$means="ALL") {
$r = redisLink();
- $key = ($userid == -1) ? "timeline" : "posts:$userid";
- $posts = $r->lrange($key,$start,$start+$count);
- $c = 0;
+ if($means != "ALL")
+ $key = "selfPosts:$userid";
+ else
+ $key = ($userid == -1) ? "timeline" : "posts:$userid";
+ $posts = $r->lrange($key,$start,$start+$count-1);
foreach($posts as $p) {
- if (showPost($p)) $c++;
- if ($c == $count) break;
+ showPost($p);
}
- return count($posts) == $count+1;
+ return count($posts) == $count;
}
-function showUserPostsWithPagination($username,$userid,$start,$count) {
+function showUserPostsWithPagination($username,$userid,$start,$count,$means="ALL") {
global $_SERVER;
$thispage = $_SERVER['PHP_SELF'];
@@ -124,7 +167,7 @@ function showUserPostsWithPagination($username,$userid,$start,$count) {
if ($prev < 0) $prev = 0;
$u = $username ? "&u=".urlencode($username) : "";
- if (showUserPosts($userid,$start,$count))
+ if (showUserPosts($userid,$start,$count,$means))
$nextlink = "