summaryrefslogtreecommitdiff
path: root/src/web/_model/_comments.php
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-09-18 14:14:53 -0400
committerFreya Murphy <freya@freyacat.org>2024-09-18 14:48:54 -0400
commit1f9024763d9224c4cd9a181bac27e6b9f12ad672 (patch)
tree00f827470dad9aa2692483acbdef9502c1a464d3 /src/web/_model/_comments.php
parentfix rss (diff)
downloadwebsite-1f9024763d9224c4cd9a181bac27e6b9f12ad672.tar.gz
website-1f9024763d9224c4cd9a181bac27e6b9f12ad672.tar.bz2
website-1f9024763d9224c4cd9a181bac27e6b9f12ad672.zip
refactor
Diffstat (limited to 'src/web/_model/_comments.php')
-rw-r--r--src/web/_model/_comments.php33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/web/_model/_comments.php b/src/web/_model/_comments.php
index 73c1fc7..f36c642 100644
--- a/src/web/_model/_comments.php
+++ b/src/web/_model/_comments.php
@@ -1,12 +1,9 @@
<?php /* Copyright (c) 2024 Freya Murphy */
class _comments_model extends Model {
- function __construct($load) {
- parent::__construct($load);
- }
-
- private function load_profanity() {
- $path = $GLOBALS['assetroot'] . '/profanity.txt';
+ private function load_profanity()
+ {
+ $path = ASSET_ROOT . '/profanity.txt';
$str = file_get_contents($path);
$lines = explode("\n", $str);
@@ -25,14 +22,16 @@ class _comments_model extends Model {
return $regex;
}
- public function is_vulgar($text) {
+ 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
+ public function get_comments($page)
+ {
+ $ip = CONTEXT['ip'];
+ $query = $this->db()
->select('*')
->from('admin.comment c')
->where('c.page')
@@ -46,17 +45,19 @@ class _comments_model extends Model {
return $result;
}
- public function ban_user() {
- $ip = $this->main->info['ip'];
- $this->db
+ public function ban_user()
+ {
+ $ip = CONTEXT['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
+ public function post_comment($author, $content, $page, $vulgar)
+ {
+ $ip = CONTEXT['ip'];
+ return $this->db()
->insert_into('admin.comment',
'author', 'content', 'page', 'ip', 'vulgar')
->values($author, $content, $page, $ip, $vulgar)