? mw.patch
Index: sphinxsearch.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/sphinxsearch/sphinxsearch.info,v
retrieving revision 1.3.2.1
diff -u -F^f -p -r1.3.2.1 sphinxsearch.info
--- sphinxsearch.info	12 Sep 2008 03:36:10 -0000	1.3.2.1
+++ sphinxsearch.info	8 Nov 2008 14:15:54 -0000
@@ -1,5 +1,4 @@
 ; $Id: sphinxsearch.info,v 1.3.2.1 2008/09/12 03:36:10 markuspetrux Exp $
-name = "sphinxsearch"
+name = "Sphinx search"
 description = "Sphinx search integration for Drupal, based on XMLPipe source type and support for main+delta index scheme."
-package = "sphinxsearch"
 core = "6.x"
Index: sphinxsearch.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/sphinxsearch/sphinxsearch.module,v
retrieving revision 1.5.2.5
diff -u -F^f -p -r1.5.2.5 sphinxsearch.module
--- sphinxsearch.module	7 Nov 2008 18:56:27 -0000	1.5.2.5
+++ sphinxsearch.module	8 Nov 2008 14:15:55 -0000
@@ -82,6 +82,13 @@ function sphinxsearch_init() {
  */
 function sphinxsearch_menu() {
   $items = array();
+  $items['xmlpipe'] = array(
+    'title' => 'XML pipe',
+    'page callback' => 'sphinxsearch_xmlpipe',
+    'access callback' => 'sphinxsearch_menu_access_xmlpipe',
+    'file' => 'sphinxsearch.xmlpipe.inc',
+    'type' => MENU_CALLBACK,
+  );
   $items['admin/settings/sphinxsearch'] = array(
     'title' => 'Sphinx search',
     'page callback' => 'drupal_get_form',
@@ -123,6 +130,42 @@ function sphinxsearch_menu() {
   return $items;
 }
 
+// A menu access callback. Check access to XMLPipe process by IP.
+function sphinxsearch_menu_access_xmlpipe() {
+  $access_xmlpipe = FALSE;
+  $sphinxsearch_indexer_ips = array_map('trim', explode(',', variable_get('sphinxsearch_indexer_ips', '127.0.0.1')));
+  if (!empty($sphinxsearch_indexer_ips)) {
+    foreach ($sphinxsearch_indexer_ips as $cidr) {
+      if (sphinxsearch_ip_check_cidr(ip_address(), $cidr)) {
+        $access_xmlpipe = TRUE;
+        break;
+      }
+    }
+  }
+  return $access_xmlpipe;
+}
+
+/**
+ * Check if IP address belongs to specified CIDR range.
+ * Note: IPv6 addresses are not supported.
+ *
+ * @param string $ip
+ *   IPv4 address. ie. 192.168.0.1
+ * @param string $cidr
+ *   CIDR mask. ie. 192.168.0.0/24
+ * @return boolean
+ *   TRUE if $ip matches specified CIDR mask, FALSE otherwise.
+ */
+function sphinxsearch_ip_check_cidr($ip, $cidr) {
+  list($net, $mask) = explode('/', $cidr);
+  $ip_net = ip2long($net);
+  $ip_mask = ~((1 << (32 - $mask)) - 1);
+  $ip_ip = ip2long($ip);
+  $ip_ip_net = $ip_ip & $ip_mask;
+  return ($ip_ip_net == $ip_net);
+}
+
+
 /**
  * Implementation of hook_block().
  */
Index: sphinxsearch.xmlpipe.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/sphinxsearch/sphinxsearch.xmlpipe.inc,v
retrieving revision 1.4.2.3
diff -u -F^f -p -r1.4.2.3 sphinxsearch.xmlpipe.inc
--- sphinxsearch.xmlpipe.inc	31 Oct 2008 13:15:45 -0000	1.4.2.3
+++ sphinxsearch.xmlpipe.inc	8 Nov 2008 14:15:55 -0000
@@ -9,39 +9,12 @@
 /**
  * Entry point for XMLPipe generator.
  *
- * This function is invoked from sphinxsearch_scripts/sphinxsearch_xmlpipe.php
+ * This function is usually invoked from drupal.sh. See README-XMLPIPE.txt.
  *
  * Note this process may eat a lot of resources, and it will be executed by
- * anonymous user, so access control is based on IP.
+ * anonymous user, so access control is based on IP. See sphinxsearch_menu().
  */
 function sphinxsearch_xmlpipe($caller_version = 0) {
-  // Check caller version.
-  $sphinxsearch_xmlpipe_generator_version = 2;
-  if ((int)$caller_version != $sphinxsearch_xmlpipe_generator_version) {
-    $message = t('Oops! It looks like version of your sphinxsearch_xmlpipe.php script does not match the version expected by the sphinxsearch module. Maybe someone forgot to upgrade the contents of the sphinxsearch_scripts subdirectory when updating the module.');
-    watchdog('sphinxsearch', $message, NULL, WATCHDOG_ERROR);
-    print $message ."\n";
-    exit;
-  }
-
-  // Check access to XMLPipe process by IP.
-  $access_xmlpipe = FALSE;
-  $sphinxsearch_indexer_ips = array_map('trim', explode(',', variable_get('sphinxsearch_indexer_ips', '')));
-  if (!empty($sphinxsearch_indexer_ips)) {
-    foreach ($sphinxsearch_indexer_ips as $cidr) {
-      if (sphinxsearch_ip_check_cidr(ip_address(), $cidr)) {
-        $access_xmlpipe = TRUE;
-        break;
-      }
-    }
-  }
-  if (!$access_xmlpipe) {
-    $message = t('Not authorized.');
-    watchdog('sphinxsearch', $message, NULL, WATCHDOG_ERROR);
-    print $message ."\n";
-    exit;
-  }
-
   // Obtain current mode of operation.
   $mode = (isset($_GET['mode']) ? trim($_GET['mode']) : '');
 
@@ -659,24 +632,4 @@ function _sphinxsearch_wrapper_watchdog(
       module_invoke($module, 'watchdog', $log_message);
     }
   }
-}
-
-/**
- * Check if IP address belongs to specified CIDR range.
- * Note: IPv6 addresses are not supported.
- *
- * @param string $ip
- *   IPv4 address. ie. 192.168.0.1
- * @param string $cidr
- *   CIDR mask. ie. 192.168.0.0/24
- * @return boolean
- *   TRUE if $ip matches specified CIDR mask, FALSE otherwise.
- */
-function sphinxsearch_ip_check_cidr($ip, $cidr) {
-  list($net, $mask) = explode('/', $cidr);
-  $ip_net = ip2long($net);
-  $ip_mask = ~((1 << (32 - $mask)) - 1);
-  $ip_ip = ip2long($ip);
-  $ip_ip_net = $ip_ip & $ip_mask;
-  return ($ip_ip_net == $ip_net);
-}
+}
\ No newline at end of file
