diff options
| author | Freya Murphy <freya@freyacat.org> | 2026-02-23 22:57:27 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2026-02-23 22:57:27 -0500 |
| commit | f373ead95fb5beb962c376b5b7b46dfde8ac4e57 (patch) | |
| tree | c99df23521ff2a5e5e2e4627c525a5e99dc2e3ae /src/web/_model/_comments.php | |
| parent | add 96x96 logo (diff) | |
| download | website-f373ead95fb5beb962c376b5b7b46dfde8ac4e57.tar.gz website-f373ead95fb5beb962c376b5b7b46dfde8ac4e57.tar.bz2 website-f373ead95fb5beb962c376b5b7b46dfde8ac4e57.zip | |
update website to work with crimson framework
Diffstat (limited to 'src/web/_model/_comments.php')
| -rw-r--r-- | src/web/_model/_comments.php | 26 |
1 files changed, 22 insertions, 4 deletions
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; + } + } |