? ad_geoip-for-wusses-382864-1.patch
? geoip.dat
? geoip.inc
Index: INSTALL.txt
===================================================================
RCS file: /cvs/drupal/contributions/modules/ad_geoip/INSTALL.txt,v
retrieving revision 1.1
diff -u -p -r1.1 INSTALL.txt
--- INSTALL.txt	10 Jun 2008 20:40:36 -0000	1.1
+++ INSTALL.txt	25 Feb 2009 02:07:13 -0000
@@ -10,22 +10,61 @@ Requirements:
  - Ad module 1.5 or later.
      http://drupal.org/project/ad
 
+ - One or more of the GeoIP databases:
+     http://www.maxmind.com/app/geoip_features
+   A couple of which are freely available:
+     http://www.maxmind.com/app/geoip_country
+     http://www.maxmind.com/app/geolitecity
+
+ - Version 1.7 or later of the geoip PHP API:
+   http://geolite.maxmind.com/download/geoip/api/php/
+
+ Or, if you have access to your own server, you may opt instead to install the
+ following for improved performance over the pure PHP API:
  - Version 1.0.1 or later of the geoip PHP PECL package:
      http://pecl.php.net/package/geoip
 
  - Version 1.4.0 or later of the GeoIP C library:
      http://www.maxmind.com/app/c
 
- - One or more of the GeoIP databases:
-     http://www.maxmind.com/app/geoip_features
-   A couple of which are freely available:
-     http://www.maxmind.com/app/geoip_country
-     http://www.maxmind.com/app/geolitecity
+
+---------------------
+Installation (Typical):
+---------------------
+1) Download the "geoip.inc" file from:
+   http://geolite.maxmind.com/download/geoip/api/php/geoip.inc
+
+
+2) Place it in your ad_geoip module directory; for example:
+
+   sites/all/modules/ad_geoip/geoip.inc
+
+
+3) Download and extract one or more of the MaxMind GeoIP binary databases. You
+   can install one of the free databases, or one of the commercial databases.
+   (URLs can be found above in the requirements sections.)
+
+
+4) Place the database(s) in your ad_geoip module directory; for example:
+
+   sites/all/modules/ad_geoip/geoip.dat
+
+
+5) Enable the ad_geoip module.
+
+   Visit "Administer >> Site building >> Modules" and enable the "Ad GeoIP"
+   module, found in the "Ad" section toward the top of that patch.  You can
+   then visit "Administer >> Logs >> Status report" to confirm that the GeoIP
+   requirements are properly installed.
+
+
+------------------------
+Installation (Advanced):
+------------------------
+If you have access to your hosting environment, for improved performance you
+may also install the GeoIP libraries this way:
 
 
--------------
-Installation:
--------------
 1) Download, compile and install the latest MaxMind GeoIP C library.  (The URL
    can be found above in the requirements section.)
 
Index: ad_geoip.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/ad_geoip/ad_geoip.module,v
retrieving revision 1.1.2.9
diff -u -p -r1.1.2.9 ad_geoip.module
--- ad_geoip.module	29 Nov 2008 01:48:20 -0000	1.1.2.9
+++ ad_geoip.module	25 Feb 2009 02:07:31 -0000
@@ -16,6 +16,10 @@ define('AD_GEOIP_ALL', 0);
 define('AD_GEOIP_SELECTED', 1);
 define('AD_GEOIP_NOT_SELECTED', 2);
 
+if (!function_exists('geoip_db_get_all_info')) {
+  include_once drupal_get_path('module', 'ad_geoip') .'/geoip.inc';
+}
+
 /**
  * Implementation of hook_menu.
  */
@@ -561,3 +565,18 @@ function _ad_geoip_supported() {
   );
 }
 
+if (!function_exists('geoip_db_avail')) {
+  function geoip_db_avail($db) {
+    static $dat_files = array();
+
+    if (!$dat_files) {
+      $dat_files = file_scan_directory(drupal_get_path('module', 'ad_geoip'), '\.dat$');
+    }
+
+    foreach ($dat_files as $dat) {
+      if (isset($dat->$db)) {
+        return TRUE;
+      }
+    }
+  }
+}
