Skip to content

Commit b5bbae6

Browse files
committed
Prefer get_browser_real_ip() over REMOTE_ADDR
1 parent 71ef30d commit b5bbae6

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

install/index.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@
189189
if(is_writable(CACHE) && (MYAAC_OS != 'WINDOWS' || win_is_writable(CACHE))) {
190190
if(!file_exists(BASE . 'install/ip.txt')) {
191191
$content = warning('AAC installation is disabled. To enable it make file <b>ip.txt</b> in install/ directory and put there your IP.<br/>
192-
Your IP is:<br /><b>' . $_SERVER['REMOTE_ADDR'] . '</b>', true);
192+
Your IP is:<br /><b>' . get_browser_real_ip() . '</b>', true);
193193
}
194194
else {
195195
$file_content = trim(file_get_contents(BASE . 'install/ip.txt'));
196196
$allow = false;
197197
$listIP = preg_split('/\s+/', $file_content);
198198
foreach($listIP as $ip) {
199-
if($_SERVER['REMOTE_ADDR'] == $ip) {
199+
if(get_browser_real_ip() == $ip) {
200200
$allow = true;
201201
}
202202
}

system/libs/forum.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function add_thread($title, $body, $section_id, $player_id, $accou
7171
'post_smile' => 0, 'post_html' => 1,
7272
'post_date' => time(),
7373
'last_edit_aid' => 0, 'edit_date' => 0,
74-
'post_ip' => $_SERVER['REMOTE_ADDR']
74+
'post_ip' => get_browser_real_ip()
7575
))) {
7676
$thread_id = $db->lastInsertId();
7777
$db->query("UPDATE `" . FORUM_TABLE_PREFIX . "forum` SET `first_post`=".(int) $thread_id." WHERE `id` = ".(int) $thread_id);
@@ -93,7 +93,7 @@ public static function add_post($thread_id, $section, $author_aid, $author_guid,
9393
'post_smile' => $smile,
9494
'post_html' => $html,
9595
'post_date' => time(),
96-
'post_ip' => $_SERVER['REMOTE_ADDR']
96+
'post_ip' => get_browser_real_ip()
9797
));
9898
}
9999
public static function add_board($name, $description, $access, $guild, &$errors)

system/libs/visitors.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct($sessionTime = 10)
3333
$this->sessionTime = $sessionTime;
3434
$this->cleanVisitors();
3535

36-
$ip = $_SERVER['REMOTE_ADDR'];
36+
$ip = get_browser_real_ip();
3737
if($this->visitorExists($ip))
3838
$this->updateVisitor($ip, $_SERVER['REQUEST_URI']);
3939
else

system/login.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
else
7575
$tmp = array();
7676

77-
$ip = $_SERVER['REMOTE_ADDR'];
77+
$ip = get_browser_real_ip();
7878
$t = isset($tmp[$ip]) ? $tmp[$ip] : NULL;
7979
}
8080

system/pages/createaccount.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
$country_recognized = $country_session;
295295
}
296296
else {
297-
$info = json_decode(@file_get_contents('http://ipinfo.io/' . $_SERVER['REMOTE_ADDR'] . '/geo'), true);
297+
$info = json_decode(@file_get_contents('http://ipinfo.io/' . get_browser_real_ip() . '/geo'), true);
298298
if(isset($info['country'])) {
299299
$country_recognized = strtolower($info['country']);
300300
setSession('country', $country_recognized);

system/pages/forum/new_thread.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
}
6666
if (count($errors) == 0) {
6767
$saved = true;
68-
$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() . "', '" . (int)$char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . (int)$smile . "', '" . (int)$html . "', '" . time() . "', '0', '0', '" . $_SERVER['REMOTE_ADDR'] . "')");
68+
$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() . "', '" . (int)$char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . (int)$smile . "', '" . (int)$html . "', '" . time() . "', '0', '0', '" . get_browser_real_ip() . "')");
6969
$thread_id = $db->lastInsertId();
7070
$db->query("UPDATE `" . FORUM_TABLE_PREFIX . "forum` SET `first_post`=" . (int)$thread_id . " WHERE `id` = " . (int)$thread_id);
7171
header('Location: ' . getForumThreadLink($thread_id));

0 commit comments

Comments
 (0)