$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 = CONTEXT['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 = CONTEXT['ip']; $this->db() ->insert_into('admin.banned', 'ip', 'reason') ->values($ip, 'vulgar language') ->execute(); } 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) ->execute(); } }