? browscap.install.patch
? browscap.module_0.patch
Index: browscap.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/browscap/Attic/browscap.install,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 browscap.install
--- browscap.install	4 Jun 2008 17:41:19 -0000	1.1.2.3
+++ browscap.install	16 Sep 2009 23:01:20 -0000
@@ -39,7 +39,28 @@ function browscap_install() {
       
       break;
     case 'pgsql':
-      // This space available...
+      $queries = db_query("CREATE TABLE {browscap} (
+                  useragent varchar(255) NOT NULL default '' PRIMARY KEY,
+                  data text NOT NULL
+                  )");
+      $queries &= db_query("CREATE TABLE {browscap_statistics} (
+                  parent VARCHAR(255) NOT NULL PRIMARY KEY,
+                  counter INTEGER NOT NULL DEFAULT 0,
+                  is_crawler INTEGER NOT NULL DEFAULT 0
+                )");
+      $queries &= db_query("CREATE TABLE {cache_browscap} (
+                  cid varchar(255) NOT NULL default '' PRIMARY KEY,
+                  data text,
+                  expire integer NOT NULL default 0,
+                  created integer NOT NULL default 0,
+                  headers text
+                  )");
+      if ($queries) {
+        drupal_set_message(t('Browscap tables installed into the database'));
+      }
+      else {
+        drupal_set_message(t('There was a problem installing the Browscap tables.'), 'error');
+      }
       break;
   }
 }
Index: browscap.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/browscap/browscap.module,v
retrieving revision 1.6.2.6
diff -u -p -r1.6.2.6 browscap.module
--- browscap.module	8 Mar 2009 11:10:09 -0000	1.6.2.6
+++ browscap.module	16 Sep 2009 23:01:21 -0000
@@ -18,7 +18,7 @@
 function browscap_menu($may_cache) {
   $items = array();
   $access = user_access('access administration pages');
-  
+
   if ($may_cache) {
     // LOG PAGES
     $items[] = array('path' => 'admin/logs/browscap',
@@ -44,7 +44,7 @@ function browscap_menu($may_cache) {
       'callback arguments' => array('crawlers'),
       'title' => t('Crawlers'), 'access' => $access, 'weight' => 3,
       'type' => MENU_LOCAL_TASK);
-    
+
     // SETTINGS PAGE
     $items[] = array(
       'path' => 'admin/settings/browscap',
@@ -54,7 +54,7 @@ function browscap_menu($may_cache) {
       'callback arguments' => array('browscap_settings'),
       'access' => user_access('administer site configuration'),
     );
-    
+
     $items[] = array(
       'path' => 'admin/settings/browscap/refresh',
       'title' => t('Browscap Refresh'),
@@ -62,7 +62,7 @@ function browscap_menu($may_cache) {
       'access' => user_access('administer site configuration'),
       'type' => MENU_CALLBACK
     );
-    
+
   }
   else {
     if (arg(0) == 'admin' && arg(1) == 'logs' && arg(2) == 'browscap' && arg(3) == 'useragent' && arg(4)) {
@@ -71,7 +71,7 @@ function browscap_menu($may_cache) {
         'path' => 'admin/logs/browscap/useragent',
         'callback' => 'browscap_useragent_properties',
         'title' => arg(4),
-        'access' => $access, 
+        'access' => $access,
         'weight' => 5,
         'type' => MENU_LOCAL_TASK
       );
@@ -194,7 +194,7 @@ function browscap_top_useragents($view =
       array('data' => t('Percent'), 'field' => 'percent')
     );
   }
-  
+
   drupal_set_title($title);
 
   $query .= tablesort_sql($header);
@@ -202,7 +202,7 @@ function browscap_top_useragents($view =
   $result = pager_query($query, 50, 0, $query_cnt);
 
   while ($useragent = db_fetch_object($result)) {
-    if (db_result(db_query_range('SELECT useragent FROM {browscap} WHERE useragent = "%s"', $useragent->parent, 0, 1))) {
+    if (db_result(db_query_range("SELECT useragent FROM {browscap} WHERE useragent = '%s'", $useragent->parent, 0, 1))) {
       $parent = l($useragent->parent, 'admin/logs/browscap/useragent/'. urlencode($useragent->parent));
     }
     else {
@@ -314,7 +314,7 @@ function _browscap_import($cron = TRUE) 
   $browscapfp = fopen($browscapfile, "w");
   fwrite($browscapfp, $browscap->data);
   fclose($browscapfp);
-  
+
   $a = parse_ini_file($browscapfile, TRUE);
   if ($a) {
     // the first entry in the array is the version info
@@ -330,9 +330,10 @@ function _browscap_import($cron = TRUE) 
       }
       $useragent = strtr($key, '*?', '%_');
       $e = array_change_key_case($e);
-      db_query("REPLACE INTO {browscap} (useragent, data) VALUES('%s','%s')", $useragent, serialize($e));
+      db_query("DELETE FROM {browscap} WHERE useragent = '%s'", $useragent);
+      db_query("INSERT INTO {browscap} (useragent, data) VALUES('%s','%s')", $useragent, serialize($e));
     }
-    
+
     cache_clear_all('*', 'cache_browscap', TRUE);
     variable_set('browscap_version', $browscapversion);
     watchdog('browscap', t("New version of browscap imported: "). $browscapversion);
@@ -371,7 +372,7 @@ function browscap_useragent_properties($
     drupal_not_found();
     return;
   }
-  $row = db_fetch_object(db_query('SELECT * FROM {browscap} WHERE useragent = "%s"', $useragent));
+  $row = db_fetch_object(db_query("SELECT * FROM {browscap} WHERE useragent = '%s'", $useragent));
   if (!$row) {
     drupal_not_found();
     return;
