Difference between revisions of "GeoIP"

From TMM Wiki
Jump to navigationJump to search
 
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
}}
 
}}
  
[http://www.maxmind.com/app/mod_geoip Download] and install GeoIP from Maxmind. Please ensure that you install the '''Apache''' Module for GeoIP, as this will not work without the GeoIP Apache API installed.
+
'''Note: Unless you have purchased a license with access to the GeoIP Legacy databases, than you will need to set up GeoIP2 as detailed in our [https://tmmwiki.com/index.php/GeoIP2 GeoIP2] article  (link below)'''
 +
 
 +
 
 +
[http://www.maxmind.com/app/mod_geoip Download] and install GeoIP from Maxmind. Please ensure that you install the '''Apache''' Module for GeoIP or the PECL extension, as this will not work without the GeoIP Apache API or PECL extension installed.
  
 
Configure and test GeoIP, then find the ''nats/includes'' folder on your
 
Configure and test GeoIP, then find the ''nats/includes'' folder on your
server, open the ''config.php'' file, and enter the following:
+
server, open the ''config.php'' file, and enter the following for the Apache module:
  
 
<pre>
 
<pre>
 
$config['IP_FILTER'] = 'GEOIP';
 
$config['IP_FILTER'] = 'GEOIP';
 +
</pre>
 +
 +
Or the following for the PECL extension:
 +
<pre>
 +
$config['IP_FILTER'] = 'PECL_GEOIP';
 
</pre>
 
</pre>
  
Line 19: Line 27:
 
<pre>
 
<pre>
 
<?
 
<?
echo 'You are from '.apache_note("GEOIP_COUNTRY_NAME");
+
echo 'According to geoip apache module, you are from '.apache_note("GEOIP_COUNTRY_NAME");
echo '<br>You are from '.geoip_country_code_by_name($_SERVER['REMOTE_ADDR'])
+
echo '<br>According to geoip pecl php module, you are from '.geoip_country_code_by_name($_SERVER['REMOTE_ADDR']);
 
?>
 
?>
 
</pre>
 
</pre>

Latest revision as of 15:31, 16 May 2019

NATS 3
Configuration Admin
NATS3 Configuration Options
Extra Country Options
PayVia Minimum
Log Admin Activity
IP Address Filtering
MEMBER EXPIRE PAD
Second Sign-up Matching
Affiliate Signup Email
GeoIP
Fake Upgrade

Note: Unless you have purchased a license with access to the GeoIP Legacy databases, than you will need to set up GeoIP2 as detailed in our GeoIP2 article (link below)


Download and install GeoIP from Maxmind. Please ensure that you install the Apache Module for GeoIP or the PECL extension, as this will not work without the GeoIP Apache API or PECL extension installed.

Configure and test GeoIP, then find the nats/includes folder on your server, open the config.php file, and enter the following for the Apache module:

$config['IP_FILTER'] = 'GEOIP';

Or the following for the PECL extension:

$config['IP_FILTER'] = 'PECL_GEOIP';

You can put it anywhere in the file except for after the last line.

Test Code

The following PHP code will help you test GeoIP. Put it in a file, put the file on your webserver, and load its URL. It should print your country's name.

<?
echo 'According to geoip apache module, you are from '.apache_note("GEOIP_COUNTRY_NAME");
echo '<br>According to geoip pecl php module, you are from '.geoip_country_code_by_name($_SERVER['REMOTE_ADDR']);
?>

Note: Please be sure to perform this test after you install or update Maxmind's GeoIP.

See Also