diff --git a/htdocs/comments.php b/htdocs/comments.php
index 12853bd..e1ec76e 100644
--- a/htdocs/comments.php
+++ b/htdocs/comments.php
@@ -14,136 +14,22 @@ if (false === $r = $stats->getSignature($signature_id))
return;
}
-function renderComments($comments)
-{
- global $S;
- foreach($comments as $c):
- $from = $c->name . " <" . $c->email . ">" . " " . date("r", $c->commented);
- $comment = Markdown::defaultTransform($c->comment);
- $del = "";
- if ($S->user->is_admin || $S->user_id == $c->user_id)
- {
- $del = " ";
- }
- $gid = md5($c->email);
- $avatar = (USE_SSL ? "https://secure.gravatar.com" : "http://www.gravatar.com") . "/avatar/$gid?r=x&d=mm&s=48";
-
-?>
-
-
-

-
-
-
-addSignatureComment($signature_id, $_POST["comment"]);
+ Comments::addSignatureComment($signature_id, $_POST["comment"]);
}
- renderComments($stats->getSignatureComments($signature_id));
+ Comments::renderComments($signature_id);
return;
}
if ($_POST["action"] == "del_comment")
{
- $stats->delSignatureComment($signature_id, $_POST["delete_id"]);
- renderComments($stats->getSignatureComments($signature_id));
+ Comments::delSignatureComment($signature_id, $_POST["delete_id"]);
+ Comments::renderComments($signature_id);
return;
}
-
-
-
-$comments = $stats->getSignatureComments($signature_id);
if (!$ajax) Layout::header();
-?>
-
-
-
-
-
-
-
-
-query($q);
+ }
+
+ function addSignatureComment($id, $text)
+ {
+ global $S;
+ $q = kl_str_sql("insert into comment (signature_id, user_id, comment) values (!i, !i, !s)", $id, $S->user_id, $text);
+ DBH::$db->query($q);
+ self::updateCommentCount($id);
+ }
+
+ function getSignatureComments($id)
+ {
+ $ret = array();
+ $q = kl_str_sql("select c.*, u.name, u.email from comment c join users u on c.user_id = u.user_id where signature_id=!i order by id asc;", $id);
+ if (!$res = DBH::$db->query($q)) return;
+
+ while ($row = DBH::$db->fetchRow($res))
+ {
+ $c = new stdClass;
+ DBH::$db->loadFromDbRow($c, $res, $row);
+ $ret[] = $c;
+ }
+
+ return $ret;
+ }
+
+ function delSignatureComment($id, $del_id)
+ {
+ $q = kl_str_sql("delete from comment where id=!i", $del_id);
+ DBH::$db->query($q);
+ self::updateCommentCount($id);
+ }
+
+ function renderComments($id)
+ {
+ global $S;
+ $comments = self::getSignatureComments($id);
+
+ foreach($comments as $c):
+ $from = $c->name . " <" . $c->email . ">" . " " . date("r", $c->commented);
+ $comment = Markdown::defaultTransform($c->comment);
+ $del = "";
+ if ($S->user->is_admin || $S->user_id == $c->user_id)
+ {
+ $del = " ";
+ }
+ $gid = md5($c->email);
+ $avatar = (USE_SSL ? "https://secure.gravatar.com" : "http://www.gravatar.com") . "/avatar/$gid?r=x&d=mm&s=48";
+
+ ?>
+
+
+

+
+
+
+
+
+
+
+
+query($q);
- }
-
- function addSignatureComment($id, $text)
- {
- global $S;
- $q = kl_str_sql("insert into comment (signature_id, user_id, comment) values (!i, !i, !s)", $id, $S->user_id, $text);
- DBH::$db->query($q);
- self::updateCommentCount($id);
- }
-
- function getSignatureComments($id)
- {
- $ret = array();
- $q = kl_str_sql("select c.*, u.name, u.email from comment c join users u on c.user_id = u.user_id where signature_id=!i order by id asc;", $id);
- if (!$res = DBH::$db->query($q)) return;
-
- while ($row = DBH::$db->fetchRow($res))
- {
- $c = new stdClass;
- DBH::$db->loadFromDbRow($c, $res, $row);
- $ret[] = $c;
- }
-
- return $ret;
- }
-
- function delSignatureComment($id, $del_id)
- {
- $q = kl_str_sql("delete from comment where id=!i", $del_id);
- DBH::$db->query($q);
- self::updateCommentCount($id);
- }
}
\ No newline at end of file