From 3cbf0c2fcf6567ed8f53005d414cf49e7b666def Mon Sep 17 00:00:00 2001 From: Zankaria Date: Thu, 13 Jun 2024 19:53:37 +0200 Subject: [PATCH] post.php, pages.php: pack and unpack source ip addresses of ban appeals --- inc/mod/pages.php | 6 ++++++ post.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 7180d9d8..eec5d364 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1077,6 +1077,12 @@ function mod_ban_appeals() { WHERE `denied` != 1 ORDER BY `time`") or error(db_error()); $ban_appeals = $query->fetchAll(PDO::FETCH_ASSOC); foreach ($ban_appeals as &$ban) { + $unpacked_source_ip = inet_ntop($ban['source_ip']); + if ($unpacked_source_ip !== false) { + // IP inserted after the IPs were packeted. Display the converted version. + $ban['source_ip'] = $unpacked_source_ip; + } + if ($ban['post']) $ban['post'] = json_decode($ban['post'], true); $ban['mask'] = Bans::range_to_string(array($ban['ipstart'], $ban['ipend'])); diff --git a/post.php b/post.php index 346f68ef..2727738c 100644 --- a/post.php +++ b/post.php @@ -174,7 +174,7 @@ function db_insert_ban_appeal($ban_id, $source_ip, $appeal_message) { $query = prepare("INSERT INTO ``ban_appeals`` VALUES (NULL, :ban_id, :source_ip, :time, :message, 0)"); $query->bindValue(':ban_id', $ban_id, PDO::PARAM_INT); - $query->bindValue(':source_ip', $source_ip); + $query->bindValue(':source_ip', inet_pton($source_ip)); $query->bindValue(':time', time(), PDO::PARAM_INT); $query->bindValue(':message', $appeal_message); $query->execute() or error(db_error($query));