From 0804bcb14b28da1aad34b6e6d49d339351853f0c Mon Sep 17 00:00:00 2001
From: Baoshuo
Date: Wed, 21 Sep 2022 14:39:09 +0800
Subject: [PATCH] feat: display ip from http_x_forwarded_for
---
web/app/controllers/contest_members.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/web/app/controllers/contest_members.php b/web/app/controllers/contest_members.php
index 285e0d9..1508c0c 100644
--- a/web/app/controllers/contest_members.php
+++ b/web/app/controllers/contest_members.php
@@ -187,13 +187,15 @@
# | '.UOJLocale::get('username').' | remote_addr | 是否参赛 | ';
+ $header_row = '# | '.UOJLocale::get('username').' | remote_addr | http_x_forwarded_for | 是否参赛 |
';
$ip_owner = array();
+ $forwarded_ip_owner = array();
$has_participated = array();
foreach (DB::selectAll("select * from contests_registrants where contest_id = {$contest['id']} order by username desc") as $reg) {
$user = queryUser($reg['username']);
$ip_owner[$user['remote_addr']] = $reg['username'];
+ $forwarded_ip_owner[$user['http_x_forwarded_for']] = $reg['username'];
$has_participated[$reg['username']] = $reg['has_participated'];
}
} else {
@@ -211,7 +213,7 @@
if (!$show_ip) {
echo '';
} else {
- if ($ip_owner[$user['remote_addr']] != $user['username']) {
+ if ($ip_owner[$user['remote_addr']] != $user['username'] || $forwarded_ip_owner[$user['http_x_forwarded_for']] != $user['username']) {
echo '
';
} else {
echo '
';
@@ -221,6 +223,7 @@
echo ''.$user_link.' | ';
if ($show_ip) {
echo ''.$user['remote_addr'].' | ';
+ echo ''.$user['http_x_forwarded_for'].' | ';
echo ''.($has_participated[$user['username']] ? 'Yes' : 'No').' | ';
}
echo '
';