* automatically detect player country based on user location (IP) on create account

This commit is contained in:
slawkens 2017-08-24 16:33:55 +02:00
parent 45aa2c2f23
commit 603c2175e3
2 changed files with 10 additions and 1 deletions

View File

@ -85,6 +85,7 @@ $config = array(
'account_welcome_mail' => true, // send welcome email when user registers 'account_welcome_mail' => true, // send welcome email when user registers
'account_mail_change' => 2, // how many days user need to change email to account - block hackers 'account_mail_change' => 2, // how many days user need to change email to account - block hackers
'account_country' => true, // user will be able to set country of origin when registering account, this information will be viewable in others places aswell 'account_country' => true, // user will be able to set country of origin when registering account, this information will be viewable in others places aswell
'account_country_recognize' => true, // should country of user be automatically recognized by his IP? This makes an external API call to http://ipinfo.io
'account_change_character_name' => false, // can user change their character name for premium points? 'account_change_character_name' => false, // can user change their character name for premium points?
'account_change_character_name_points' => 30, // cost of name change 'account_change_character_name_points' => 30, // cost of name change
'account_change_character_sex' => false, // can user change their character sex for premium points? 'account_change_character_sex' => false, // can user change their character sex for premium points?

View File

@ -384,6 +384,14 @@ function validate_form(thisform)
} }
</script> </script>
<?php <?php
$country_recognized = null;
if($config['account_country_recognize']) {
$info = json_decode(@file_get_contents('http://ispinfo.io/' . $_SERVER['REMOTE_ADDR'] . '/geo'), true);
if(isset($info['country'])) {
$country_recognized = strtolower($info['country']);
}
}
if(!empty($errors)) if(!empty($errors))
output_errors($errors); output_errors($errors);
?> ?>
@ -446,7 +454,7 @@ Also you have to agree to the terms presented below. If you have done so, your a
echo '<option value="">----------</option>'; echo '<option value="">----------</option>';
foreach($config['countries'] as $code => $c) foreach($config['countries'] as $code => $c)
echo '<option value="' . $code . '"' . ((isset($country) && $country == $code) ? ' selected' : '') . '>' . $c . '</option>'; echo '<option value="' . $code . '"' . (((isset($country) && $country == $code) || (!isset($country) && $country_recognized == $code)) ? ' selected' : '') . '>' . $c . '</option>';
?> ?>
</select> </select>
<img src="" id="account_country_img"/> <img src="" id="account_country_img"/>