From c5f39ea2cd7cf02246705ea8872d3b350526165c Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Fri, 24 May 2024 09:05:42 -0400 Subject: initial --- src/web/_model/_comments.php | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/web/_model/_comments.php (limited to 'src/web/_model/_comments.php') diff --git a/src/web/_model/_comments.php b/src/web/_model/_comments.php new file mode 100644 index 0000000..73c1fc7 --- /dev/null +++ b/src/web/_model/_comments.php @@ -0,0 +1,66 @@ + $line) { + if ($line == '') { + continue; + } + if ($idx != 0) { + $regex .= '|'; + } + $regex .= $line; + } + $regex .= ')/'; + + return $regex; + } + + public function is_vulgar($text) { + $profanity = $this->load_profanity(); + return preg_match($profanity, $text); + } + + public function get_comments($page) { + $ip = $this->main->info['ip']; + $query = $this->db + ->select('*') + ->from('admin.comment c') + ->where('c.page') + ->eq($page) + ->query('AND ( + (c.vulgar IS FALSE) OR + (c.vulgar IS TRUE and c.ip = ?) + )') + ->order_by('c.id', 'DESC'); + $result = $query->rows($ip); + return $result; + } + + public function ban_user() { + $ip = $this->main->info['ip']; + $this->db + ->insert_into('admin.banned', 'ip', 'reason') + ->values($ip, 'vulgar language') + ->execute(); + } + + public function post_comment($author, $content, $page, $vulgar) { + $ip = $this->main->info['ip']; + return $this->db + ->insert_into('admin.comment', + 'author', 'content', 'page', 'ip', 'vulgar') + ->values($author, $content, $page, $ip, $vulgar) + ->execute(); + } + +} -- cgit v1.2.3-freya