home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / IP.pm < prev    next >
Encoding:
Perl POD Document  |  2003-03-04  |  3.3 KB  |  141 lines

  1. package Geo::IP;
  2.  
  3. use strict;
  4. use vars qw(@ISA $VERSION @EXPORT);
  5.  
  6. require Geo::IP::Record;
  7. require DynaLoader;
  8. require Exporter;
  9. @ISA = qw(DynaLoader Exporter);
  10.  
  11. $VERSION = '1.15';
  12.  
  13. bootstrap Geo::IP $VERSION;
  14.  
  15. sub GEOIP_STANDARD(){0;}
  16. sub GEOIP_MEMORY_CACHE(){1;}
  17.  
  18. @EXPORT = qw( GEOIP_STANDARD GEOIP_MEMORY_CACHE );
  19.  
  20. 1;
  21. __END__
  22.  
  23. =head1 NAME
  24.  
  25. Geo::IP - Look up country by IP Address
  26.  
  27. =head1 SYNOPSIS
  28.  
  29.   use Geo::IP;
  30.  
  31.   my $gi = Geo::IP->new(GEOIP_STANDARD);
  32.  
  33.   # look up IP address '65.15.30.247'
  34.   # returns undef if country is unallocated, or not defined in our database
  35.   my $country = $gi->country_code_by_addr('65.15.30.247');
  36.   $country = $gi->country_code_by_name('yahoo.com');
  37.   # $country is equal to "US"
  38.  
  39. =head1 DESCRIPTION
  40.  
  41. This module uses a file based database.  This database simply contains
  42. IP blocks as keys, and countries as values. 
  43. This database should be more
  44. complete and accurate than reverse DNS lookups.
  45.  
  46. This module can be used to automatically select the geographically closest mirror,
  47. to analyze your web server logs
  48. to determine the countries of your visiters, for credit card fraud
  49. detection, and for software export controls.
  50.  
  51. =head1 IP ADDRESS TO COUNTRY DATABASES
  52.  
  53. Free monthly updates to the database are available from 
  54.  
  55.   http://www.maxmind.com/download/geoip/database/
  56.  
  57. This free database is similar to the database contained in IP::Country, as 
  58. well as many paid databases. It uses ARIN, RIPE, APNIC, and LACNIC whois to 
  59. obtain the IP->Country mappings.
  60.  
  61. If you require greater accuracy, MaxMind offers a Premium database on a paid 
  62. subscription basis. 
  63.  
  64. =head1 CLASS METHODS
  65.  
  66. =over 4
  67.  
  68. =item $gi = Geo::IP->new( $flags );
  69.  
  70. Constructs a new Geo::IP object with the default database located inside your system's
  71. I<datadir>, typically I</usr/local/share/GeoIP/GeoIP.dat>.
  72.  
  73. Flags can be set to either GEOIP_STANDARD, or for faster performance
  74. (at a cost of using more memory), GEOIP_MEMORY_CACHE.
  75.  
  76. =item $gi = Geo::IP->open( $database_filename, $flags );
  77.  
  78. Constructs a new Geo::IP object with the database located at C<$database_filename>.
  79.  
  80. =back
  81.  
  82. =head1 OBJECT METHODS
  83.  
  84. =over 4
  85.  
  86. =item $code = $gi->country_code_by_addr( $ipaddr );
  87.  
  88. Returns the ISO 3166 country code for an IP address.
  89.  
  90. =item $code = $gi->country_code_by_name( $ipname );
  91.  
  92. Returns the ISO 3166 country code for a hostname.
  93.  
  94. =item $code = $gi->country_code3_by_addr( $ipaddr );
  95.  
  96. Returns the 3 letter country code for an IP address.
  97.  
  98. =item $code = $gi->country_code3_by_name( $ipname );
  99.  
  100. Returns the 3 letter country code for a hostname.
  101.  
  102. =item $name = $gi->country_name_by_addr( $ipaddr );
  103.  
  104. Returns the full country name for an IP address.
  105.  
  106. =item $name = $gi->country_name_by_name( $ipname );
  107.  
  108. Returns the full country name for a hostname.
  109.  
  110. =item $name = $gi->record_by_addr( $ipaddr );
  111.  
  112. Returns a Geo::IP::Record object containing city location for an IP address.
  113.  
  114. =item $name = $gi->record_by_name( $ipname );
  115.  
  116. Returns a Geo::IP::Record object containing city location for a hostname.
  117.  
  118. =back
  119.  
  120. =head1 MAILING LISTS AND CVS
  121.  
  122. Are available from SourceForge, see
  123. http://sourceforge.net/projects/geoip/
  124.  
  125. =head1 VERSION
  126.  
  127. 1.15
  128.  
  129. =head1 SEE ALSO
  130.  
  131. Geo::IP::Record
  132.  
  133. =head1 AUTHOR
  134.  
  135. Copyright (c) 2002, MaxMind.com
  136.  
  137. All rights reserved.  This package is free software; you can redistribute it
  138. and/or modify it under the same terms as Perl itself.
  139.  
  140. =cut
  141.