Prefer get_browser_real_ip() over REMOTE_ADDR

This commit is contained in:
slawkens 2024-11-12 20:59:51 +01:00
parent a4a2480995
commit 941846605c
5 changed files with 8 additions and 8 deletions

View File

@ -183,14 +183,14 @@ clearstatcache();
if(is_writable(CACHE) && (MYAAC_OS != 'WINDOWS' || win_is_writable(CACHE))) {
if(!file_exists(BASE . 'install/ip.txt')) {
$content = warning('AAC installation is disabled. To enable it make file <b>ip.txt</b> in install/ directory and put there your IP.<br/>
Your IP is:<br /><b>' . $_SERVER['REMOTE_ADDR'] . '</b>', true);
Your IP is:<br /><b>' . get_browser_real_ip() . '</b>', true);
}
else {
$file_content = trim(file_get_contents(BASE . 'install/ip.txt'));
$allow = false;
$listIP = preg_split('/\s+/', $file_content);
foreach($listIP as $ip) {
if($_SERVER['REMOTE_ADDR'] == $ip) {
if(get_browser_real_ip() == $ip) {
$allow = true;
}
}
@ -199,7 +199,7 @@ if(is_writable(CACHE) && (MYAAC_OS != 'WINDOWS' || win_is_writable(CACHE))) {
{
$content = warning('In file <b>install/ip.txt</b> must be your IP!<br/>
In file is:<br /><b>' . nl2br($file_content) . '</b><br/>
Your IP is:<br /><b>' . $_SERVER['REMOTE_ADDR'] . '</b>', true);
Your IP is:<br /><b>' . get_browser_real_ip() . '</b>', true);
}
else {
ob_start();

View File

@ -331,7 +331,7 @@ if(setting('core.account_country_recognize')) {
$country_recognized = $country_session;
}
else {
$info = json_decode(@file_get_contents('http://ipinfo.io/' . $_SERVER['REMOTE_ADDR'] . '/geo'), true);
$info = json_decode(@file_get_contents('http://ipinfo.io/' . get_browser_real_ip() . '/geo'), true);
if(isset($info['country'])) {
$country_recognized = strtolower($info['country']);
setSession('country', $country_recognized);

View File

@ -95,7 +95,7 @@ if(Forum::canPost($account_logged)) {
if (count($errors) == 0) {
$saved = true;
$db->query("INSERT INTO `" . FORUM_TABLE_PREFIX . "forum` (`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile`, `post_html` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('0', '" . time() . "', '" . (int)$section_id . "', '0', '0', '" . $account_logged->getId() . "', '" . $char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . $smile . "', '" . $html . "', '" . time() . "', '0', '0', '" . $_SERVER['REMOTE_ADDR'] . "')");
$db->query("INSERT INTO `" . FORUM_TABLE_PREFIX . "forum` (`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile`, `post_html` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('0', '" . time() . "', '" . (int)$section_id . "', '0', '0', '" . $account_logged->getId() . "', '" . $char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . $smile . "', '" . $html . "', '" . time() . "', '0', '0', '" . get_browser_real_ip() . "')");
$thread_id = $db->lastInsertId();

View File

@ -72,7 +72,7 @@ class Forum
'post_smile' => 0, 'post_html' => 1,
'post_date' => time(),
'last_edit_aid' => 0, 'edit_date' => 0,
'post_ip' => $_SERVER['REMOTE_ADDR']
'post_ip' => get_browser_real_ip()
))) {
$thread_id = $db->lastInsertId();
$db->query("UPDATE `" . FORUM_TABLE_PREFIX . "forum` SET `first_post`=".(int) $thread_id." WHERE `id` = ".(int) $thread_id);
@ -94,7 +94,7 @@ class Forum
'post_smile' => $smile,
'post_html' => $html,
'post_date' => time(),
'post_ip' => $_SERVER['REMOTE_ADDR']
'post_ip' => get_browser_real_ip()
));
}
public static function add_board($name, $description, $access, $guild, &$errors)

View File

@ -37,7 +37,7 @@ class Visitors
$this->sessionTime = $sessionTime;
$this->cleanVisitors();
$ip = $_SERVER['REMOTE_ADDR'];
$ip = get_browser_real_ip();
$userAgentShortened = substr($_SERVER['HTTP_USER_AGENT'] ?? 'unknown', 0, 255);
if($this->visitorExists($ip))