From f373ead95fb5beb962c376b5b7b46dfde8ac4e57 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 23 Feb 2026 22:57:27 -0500 Subject: update website to work with crimson framework --- src/web/_model/_comments.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/web/_model/_comments.php') diff --git a/src/web/_model/_comments.php b/src/web/_model/_comments.php index 3518508..765fda8 100644 --- a/src/web/_model/_comments.php +++ b/src/web/_model/_comments.php @@ -36,10 +36,10 @@ class _comments_model extends Model { public function get_comments($page) { - $ip = CONTEXT['ip']; + $ip = $this->get_ip(); $query = $this->db() ->select('*') - ->from('admin.comment c') + ->from('website.comment c') ->where('c.page') ->eq($page) ->query('AND ( @@ -53,12 +53,30 @@ class _comments_model extends Model { public function post_comment($author, $content, $page, $vulgar) { - $ip = CONTEXT['ip']; + $ip = $this->get_ip(); return $this->db() - ->insert_into('admin.comment', + ->insert_into('website.comment', 'author', 'content', 'page', 'ip', 'vulgar') ->values($author, $content, $page, $ip, $vulgar) ->execute(); } + public function get_ip(): ?string + { + $headers = array ( + 'HTTP_CLIENT_IP', + 'HTTP_X_FORWARDED_FOR', + 'HTTP_X_FORWARDED', + 'HTTP_FORWARDED_FOR', + 'HTTP_FORWARDED', + 'HTTP_X_REAL_IP', + 'REMOTE_ADDR' + ); + foreach ($headers as $header) { + if (isset($_SERVER[$header])) + return $_SERVER[$header]; + } + return NULL; + } + } -- cgit v1.2.3-freya