This commit is contained in:
Gabriel Pedro 2016-05-11 18:32:51 -04:00
parent 42195da9dc
commit 4e18cb3c66
8 changed files with 22 additions and 12 deletions

View File

@ -348,7 +348,7 @@ class Player {
'vocation' => $_POST['selected_vocation'], 'vocation' => $_POST['selected_vocation'],
'town_id' => $_POST['selected_town'], 'town_id' => $_POST['selected_town'],
'sex' => $_POST['selected_gender'], 'sex' => $_POST['selected_gender'],
'lastip' => ip2long(getIP()), 'lastip' => getIPLong(),
'created' => time() 'created' => time()
); );

View File

@ -90,7 +90,7 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
'vocation' => $_POST['selected_vocation'], 'vocation' => $_POST['selected_vocation'],
'town_id' => $_POST['selected_town'], 'town_id' => $_POST['selected_town'],
'sex' => $_POST['selected_gender'], 'sex' => $_POST['selected_gender'],
'lastip' => ip2long(getIP()), 'lastip' => getIPLong(),
'created' => time() 'created' => time()
); );

View File

@ -124,7 +124,7 @@ function znote_visitors_get_data() {
// Set visitor basic data // Set visitor basic data
function znote_visitor_set_data($visitor_data) { function znote_visitor_set_data($visitor_data) {
$exist = false; $exist = false;
$ip = ip2long(getIP()); $ip = getIPLong();
foreach ((array)$visitor_data as $row) { foreach ((array)$visitor_data as $row) {
if ($ip == $row['ip']) { if ($ip == $row['ip']) {
@ -159,7 +159,7 @@ function znote_visitor_insert_detailed_data($type) {
type 4 = search character type 4 = search character
*/ */
$time = time(); $time = time();
$ip = ip2long(getIP()); $ip = getIPLong();
if (user_logged_in()) { if (user_logged_in()) {
$acc = (int)getSession('user_id'); $acc = (int)getSession('user_id');
mysql_insert("INSERT INTO `znote_visitors_details` (`ip`, `time`, `type`, `account_id`) VALUES ('$ip', '$time', '$type', '$acc')"); mysql_insert("INSERT INTO `znote_visitors_details` (`ip`, `time`, `type`, `account_id`) VALUES ('$ip', '$time', '$type', '$acc')");
@ -168,7 +168,7 @@ function znote_visitor_insert_detailed_data($type) {
function something () { function something () {
// Make acc data compatible: // Make acc data compatible:
$ip = ip2long(getIP()); $ip = getIPLong();
} }
// Secret token // Secret token
@ -233,9 +233,9 @@ function validate_name($string) {
// Checks if an IPv4(or localhost IPv6) address is valid // Checks if an IPv4(or localhost IPv6) address is valid
function validate_ip($ip) { function validate_ip($ip) {
$ipL = ip2long($ip); $ipL = safeIp2Long($ip);
$ipR = long2ip($ipL); $ipR = long2ip($ipL);
if ($ip === $ipR) { if ($ip === $ipR) {
return true; return true;
} elseif ($ip=='::1') { } elseif ($ip=='::1') {
@ -269,6 +269,7 @@ function online_list() {
else return mysql_select_multi("SELECT `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname` FROM `players` p LEFT JOIN `guild_ranks` gr ON `gr`.`id` = `p`.`rank_id` LEFT JOIN `guilds` g ON `gr`.`guild_id` = `g`.`id` WHERE `p`.`online` = '1' ORDER BY `p`.`name` DESC;"); else return mysql_select_multi("SELECT `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname` FROM `players` p LEFT JOIN `guild_ranks` gr ON `gr`.`id` = `p`.`rank_id` LEFT JOIN `guilds` g ON `gr`.`guild_id` = `g`.`id` WHERE `p`.`online` = '1' ORDER BY `p`.`name` DESC;");
} }
// Gets you the actual IP address even from users behind ISP proxies and so on. // Gets you the actual IP address even from users behind ISP proxies and so on.
function getIP() { function getIP() {
/* /*
@ -289,6 +290,15 @@ function getIP() {
return $_SERVER['REMOTE_ADDR']; return $_SERVER['REMOTE_ADDR'];
} }
function safeIp2Long($ip) {
return sprintf('%u', ip2long($ip));
}
// Gets you the actual IP address even from users in long type
function getIPLong() {
return safeIp2Long(getIP());
}
// Deprecated, just use count($array) instead. // Deprecated, just use count($array) instead.
function array_length($ar) { function array_length($ar) {
$r = 1; $r = 1;

View File

@ -79,7 +79,7 @@ if ($config['log_ip']) {
$v_form = 0; $v_form = 0;
foreach ((array)$visitor_detailed as $v_d) { foreach ((array)$visitor_detailed as $v_d) {
// Activity // Activity
if ($v_d['ip'] == ip2long(getIP())) { if ($v_d['ip'] == getIPLong()) {
// count each type of visit // count each type of visit
switch ($v_d['type']) { switch ($v_d['type']) {
case 0: // max activity case 0: // max activity

View File

@ -165,7 +165,7 @@ if ($view !== false) {
'username'=> getValue($_POST['username']), 'username'=> getValue($_POST['username']),
'subject' => getValue($_POST['subject']), 'subject' => getValue($_POST['subject']),
'message' => getValue($_POST['message']), 'message' => getValue($_POST['message']),
'ip' => ip2long(getIP()), 'ip' => getIPLong(),
'creation' => time(), 'creation' => time(),
'status' => 'Open' 'status' => 'Open'
); );

View File

@ -48,7 +48,7 @@ if (empty($_POST) === false) {
$znote_data = user_znote_account_data($login); $znote_data = user_znote_account_data($login);
if ($znote_data['ip'] == 0) { if ($znote_data['ip'] == 0) {
$update_data = array( $update_data = array(
'ip' => ip2long(getIP()), 'ip' => getIPLong(),
); );
user_update_znote_account($update_data); user_update_znote_account($update_data);
} }

View File

@ -348,7 +348,7 @@ if ($config['zeotss']['enabled'] && $config['zeotss']['visitors']) {
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 0);
$post_string = "longip=".ip2long($_SERVER['REMOTE_ADDR'])."&register=1"; $post_string = "longip=".getIPLong()."&register=1";
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
$result = curl_exec($curl_connection); $result = curl_exec($curl_connection);
if ($config['zeotss']['debug']) data_dump(false, array($result), "CURL DATA"); if ($config['zeotss']['debug']) data_dump(false, array($result), "CURL DATA");

View File

@ -112,7 +112,7 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
'password' => $_POST['password'], 'password' => $_POST['password'],
'email' => $_POST['email'], 'email' => $_POST['email'],
'created' => time(), 'created' => time(),
'ip' => ip2long(getIP()), 'ip' => getIPLong(),
'flag' => $_POST['flag'] 'flag' => $_POST['flag']
); );