Home
Home Page
XML on the screen of a browser
Interaction with life cycle of page
How to overtake competitors and at once to do{make} liderskie pages
Adjustment of parameters PHP in php.ini
KHehshirovanie passwords in PHP
Total Automation of Reception of payments on a site
Object-oriented programming, classes in PHP
Abstract classes and interfaces
The module of definition of a geographical position on IP - mod_GeoIP
Conclusion of messages to the user in webs - applications.
Manipulation date on PHP
The truth about Sessions
Realization of patterns on PHP.
Protection against a spam on a site
Imitation of files and directories
Door in protection: the post web - interface
Safety of search engines in the corporate environment
CHPU and PHP (revisited)
Links
 
 

The module of definition of a geographical position on IP - mod_GeoIP

The quite good module for apache1.3 - on IP the visitor is defined{determined} his  country, region and city. Can be useful to cut the left visitors - Chinese, for example, or amerikosov. All the same at me on a site it nothing them:) So, we put from ports:



/usr/home/lissyara/>

/usr/home/lissyara/> cd/usr/ports/

/usr/ports/> make search name ='mod_geoip '

Port: mod_geoip-1.2.7

Path:/usr/ports/www/mod_geoip

Info: An Apache module that provides the country code of the client's IP

Maint: seanc@FreeBSD.org

B-deps: GeoIP-1.3.14 apache-1.3.34_3 expat-1.95.8_3 perl-5.8.7_2

R-deps: GeoIP-1.3.14 apache-1.3.34_3 expat-1.95.8_3 perl-5.8.7_2

WWW: http://www.maxmind.com/app/mod_geoip


Port: mod_geoip2-1.1.7

Path:/usr/ports/www/mod_geoip2

Info: An Apache module that provides the country code of the client's IP

Maint: jau@iki.fi

B-deps: GeoIP-1.3.14 apache-2.0.55_2 expat-1.95.8_3 libiconv-1.9.2_1 perl-5.8.7_2

R-deps: GeoIP-1.3.14 apache-2.0.55_2 expat-1.95.8_3 libiconv-1.9.2_1 perl-5.8.7_2

WWW: http://www.maxmind.com/app/mod_geoip


/usr/ports/> cd/usr/ports/www/mod_geoip

/usr/ports/www/mod_geoip/> make ** make install ** make clean

......................................

......................................

************************************************************

Please edit your apache.conf or httpd.conf to enable and

setup this module.


You can always refer to the useful documents held in

$ {PREFIX}/share/doc/mod_geoip/, where $ {PREFIX} is

typically/usr/local.


When it's done, do the following to take effect:


  apachectl configtest (and correct any errors reported)

  apachectl restart


************************************************************

/usr/ports/www/mod_geoip/> pkg_info | grep " [Gg] eo "

GeoIP-1.3.14 Find the country that any IP address or hostname originates

mod_geoip-1.2.7 An Apache module that provides the country code of the clie

/usr/ports/www/mod_geoip/>


He behind itself(himself) drags actually GeoIP <http: // www.internet-technologies.ru/? url=http%3A%2F%2Fwww.maxmind.com%2Fgeoip%2F> - from him  to him it is necessary for a DB. After installation we edit a config of the apache - raskommentruem the module mod_geoip <http: // www.internet-technologies.ru/? url=http%3A%2F%2Fwww.maxmind.com%2Fapp%2Fmod_geoip>:

/usr/local/etc/apache/httpd.conf



LoadModule geoip_module libexec/apache/mod_geoip.so

AddModule mod_geoip.c


Also we add such lines:



<IfModule mod_geoip.c>

***** Module GeoIP began

*

* We include the module

GeoIPEnable On

* We specify a way to a DB (in docks to be spoken, that

* It is necessary a current if a site of a DB non-standard, but

* What is considered standard - anywhere has not found - therefore

* Just in case I specify) - a DB installitsja together with

* Port GeoIP.

GeoIPDBFile/usr/local/share/GeoIP/GeoIP.dat

* The following directive establishes where the module is applied

* GeoIP (at least I so have understood) - a current in notes apache (Notes),

* Only in variables of an environment (Env) or everywhere (All - on a default):

GeoIPOutput All

* Forces to check DB GeoIP.dat to define{determine}, whether the DB was updated

* It is necessary to not restart the apache at updating a DB

GeoIPFlags CheckCache


****** An example of blocking of the separate countries

* We block kosoglazen`kikh - all the same nichjo will not understand

SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry

* We block amerikosov - too nichjo will not understand, stupid{blunt} too.

SetEnvIf GEOIP_COUNTRY_CODE US BlockCountry

* That we, sobstveno, do{make} by above-stated rules,

* It should be in a directory which we block, i.e. inside

* <Directory "/usr/local/www/data">

*...............

*Deny from env=BlockCountry

* </Directory>

</IfModule>


Then we restart the apache, and it is tasted, that at us it has turned out, such skriptikom, on php:



<pre>

Whence it was secured:

<? php

$country_code = apache_note ("GEOIP_COUNTRY_CODE");

$region = apache_note ("GEOIP_REGION");

$country_name = apache_note ("GEOIP_COUNTRY_NAME");

$city = apache_note ("GEOIP_CITY");

echo " the Country code: ". $country_code. "\n";

echo " Region: ". $region. "\n";

echo " the Name of the country: ". $country_name. "\n";

echo " City: ". $city. "\n";

?>

</pre>


His  conclusion, for Moscow IP:



Whence it was secured:

Country code: RU

Region:

Name of the country: Russian Federation

City:


If to come with private{individual} IP (192.168.x.x) that will not show anything:) Why has not shown region and city - I so I think that count us the country wild where except for bears, in padded jackets and caps - caps with earlaps anything and is not present nuclear rockets, both people... By the way, in examples, on a site of the author of the module, the example was how to block access from region RU. I in the answer have given an example as zalochit` burzhuev:) Pshli nakh:)


P.S. It is added on results of the first comment. Where to take bases - here any program lays, did not penetrate. To her idud bases. It is necessary to put ` expert ` the version then bases will be established. Bases it is copied where it is necessary, correct it is sensitive a config:



<IfModule mod_geoip.c>

***** Module GeoIP began

*

* We include the module

GeoIPEnable On

* We specify a way to a DB (in docks to be spoken, that

* It is necessary a current if a site of a DB non-standard, but

* What is considered standard - anywhere has not found - therefore

* Just in case I specify) - a DB installitsja together with

* Port GeoIP.

GeoIPDBFile/usr/local/share/GeoIP/GeoIP.dat

GeoIPDBFile/usr/local/share/GeoIP/GeoIPCity.dat

GeoIPDBFile/usr/local/share/GeoIP/GeoIPOrg.dat

* The following directive establishes where the module is applied

* GeoIP (at least I so have understood) - a current in notes apache (Notes),

* Only in variables of an environment (Env) or everywhere (All - on a default):

GeoIPOutput All

* Forces to check DB GeoIP.dat to define{determine}, whether the DB was updated

* It is necessary to not restart the apache at updating a DB

GeoIPFlags CheckCache


****** An example of blocking of the separate countries

* We block kosoglazen`kikh - all the same nichjo will not understand

SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry

* We block amerikosov - too nichjo will not understand, stupid{blunt} too.

SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry

* That we, sobstveno, do{make} by above-stated rules,

* It should be in a directory which we block, i.e. inside

* <Directory "/usr/local/www/data">

*...............

*Deny from env=BlockCountry

* </Directory>

</IfModule>


Then it is accessible more than the data (apparently there is still a base of providers since ISP at me not vysvechivaetsja):



<?

<pre>

<b> Whence it was secured </b>

<? php

$country_code = apache_note ("GEOIP_COUNTRY_CODE");

$region = apache_note ("GEOIP_REGION");

$country_name = apache_note ("GEOIP_COUNTRY_NAME");

$city = apache_note ("GEOIP_CITY");

$connect_type = apache_note ("GEOIP_NETSPEED");

$dma_code = apache_note ("GEOIP_DMA_CODE");

$area_code = apache_note ("GEOIP_AREA_CODE");

$latitude = apache_note ("GEOIP_LATITUDE");

$longitude = apache_note ("GEOIP_LONGITUDE");

$postal_code = apache_note ("GEOIP_POSTAL_CODE");

$organization = apache_note ("GEOIP_ORGANIZATION");

$isp = apache_note ("GEOIP_ISP");


echo " the Country code: ". $country_code. "\n";

echo " Region: ". $region. "\n";

echo " the Name of the country: ". $country_name. "\n";

echo " City: ". $city. "\n";

echo " Speed: ". $connect_type. "\n";

echo " dma_code: ". $dma_code. "\n";

echo " area_code: ". $area_code. "\n";

echo " latitude: ". $latitude. "\n";

echo " longitude: ". $longitude. "\n";

echo " postal_code: ". $postal_code. "\n";

echo " the Organization: ". $organization. "\n";

echo " the Provider: ". $isp. "\n";


?>



Whence it was secured

Country code: RU

Region: 48

Name of the country: Russian Federation

City: Moscow

Speed:

dma_code: 0

area_code: 0

latitude: 55.752201

longitude: 37.615601

postal_code:

organization:Network of NICEVT

isp:


Half of items{points} is not quite clear... Well and it is not important.