? php53.patch
Index: webpurify.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webpurify/webpurify.module,v
retrieving revision 1.4
diff -u -r1.4 webpurify.module
--- webpurify.module	25 Feb 2009 02:48:04 -0000	1.4
+++ webpurify.module	20 Dec 2009 13:24:59 -0000
@@ -39,7 +39,7 @@
 /**
  * Implementation of hook_menu()
  */
-function webpurify_menu() { 
+function webpurify_menu() {
   $items = array();
 
   $items['admin/settings/webpurify'] = array(
@@ -65,14 +65,14 @@
  */
 function webpurify_settings_form() {
   $form = array();
-  
+
   if (
     (variable_get('webpurify_node_body_mode', WEBPURIFY_MODE_OFF) == WEBPURIFY_MODE_REWRITE) ||
     (variable_get('webpurify_comment_body_mode', WEBPURIFY_MODE_OFF) == WEBPURIFY_MODE_REWRITE)
   ) {
     drupal_set_message(t('WARNING: You have configured rewrite mode on at least one context type. You MUST make sure to enable the WebPurify input filter for content to be filtered using WebPurify.'), 'warning', FALSE);
   };
-  
+
   $form['keys'] = array(
     '#type' => 'fieldset',
     '#title' => t('API Keys'),
@@ -103,7 +103,7 @@
     '#required'       => TRUE,
     '#default_value'  => variable_get('webpurify_filter_symbol', WEBPURIFY_DEFAULT_FILTER_SYMBOL),
   );
-  
+
   $form['nodes'] = array(
     '#type' => 'fieldset',
     '#title' => t('Nodes'),
@@ -175,7 +175,7 @@
     '#default_value' => variable_get('webpurify_node_view_fail_message', t(WEBPURIFY_NODE_VIEW_FAIL_MESSAGE)),
     '#description'   => t('This is the text that will be displayed if node viewing will be blocked during an API failure'),
   );
-  
+
   if (module_exists('comment')) {
     $form['comments'] = array(
       '#type' => 'fieldset',
@@ -251,7 +251,7 @@
     );
     */
   }
-  
+
   return system_settings_form($form);
 }
 
@@ -272,21 +272,21 @@
 
 function webpurify_test() {
   $output = '';
-  
+
   $output .= "check('fuck shit cock') = " . print_r(webpurify_api_check('fuck shit cock'), TRUE) . "<br>\n";
   $output .= "check('This is a test') = " . print_r(webpurify_api_check('This is a test'), TRUE) . "<br>\n";
-  
+
   $output .= "checkcount('fuck shit cock') = " . print_r(webpurify_api_checkcount('fuck shit cock'), TRUE) . "<br>\n";
   $output .= "checkcount('This is a test') = " . print_r(webpurify_api_checkcount('This is a test'), TRUE) . "<br>\n";
-  
+
   $output .= "replace('fuck shit cock') = " . print_r(webpurify_api_replace('fuck shit cock', WEBPURIFY_DEFAULT_FILTER_SYMBOL), TRUE) . "<br>\n";
   $output .= "replace('This is a test') = " . print_r(webpurify_api_replace('This is a test', WEBPURIFY_DEFAULT_FILTER_SYMBOL), TRUE) . "<br>\n";
-  
+
   $output .= "return('fuck shit cock') = " . print_r(webpurify_api_return('fuck shit cock', WEBPURIFY_DEFAULT_FILTER_SYMBOL), TRUE) . "<br>\n";
   $output .= "return('This is a test') = " . print_r(webpurify_api_return('This is a test', WEBPURIFY_DEFAULT_FILTER_SYMBOL), TRUE) . "<br>\n";
-  
+
   $output .= webpurify_get_error();
-  
+
   return $output;
 }
 
@@ -327,7 +327,7 @@
     if (empty($symbol)) {
       $symbol = variable_get('webpurify_filter_symbol', WEBPURIFY_DEFAULT_FILTER_SYMBOL);
     }
-  
+
     // try replacement
     $replaced_text = webpurify_api_replace($text, $symbol);
     if ($replaced_text === FALSE) {
@@ -341,7 +341,7 @@
       return $replaced_text;
     }
   }
-  
+
   return $text;
 }
 
@@ -365,13 +365,13 @@
  *
  * @param &$node
  *   editable node object
- * 
+ *
  * @param $op
  *   string of what process we're at
- * 
+ *
  * @param $teaser
  *   boolean if showing teaser
- * 
+ *
  * @param $page
  *   boolean if on full view page of a node
  *
@@ -386,7 +386,7 @@
       if (webpurify_get_node_body_mode() == WEBPURIFY_MODE_BLOCK) {
         _webpurify_nodeapi_validate_body_block($node, $op, $a3, $a4);
       }
-      
+
       // are we in rewrite mode
       if (webpurify_get_node_title_mode() == WEBPURIFY_MODE_REWRITE) {
         _webpurify_nodeapi_validate_title_rewrite($node, $op, $a3, $a4);
@@ -420,7 +420,7 @@
 function _webpurify_nodeapi_validate_title_block(&$node, $op, $a3 = NULL, $a4 = NULL) {
   // check for expletives
   $title_expletives = webpurify_api_return($a3['title']['#value']);
-  
+
   // handle a failure of the API properly
   if ($title_expletives === FALSE) {
     watchdog(WEBPURIFY_WATCHDOG_TYPE, __FUNCTION__ .': '. __LINE__ .' -- '. webpurify_get_error(), array(), WATCHDOG_ERROR);
@@ -428,10 +428,10 @@
       form_set_error('webpurify', variable_get('webpurify_node_title_fail_message', t(WEBPURIFY_NODE_TITLE_FAIL_MESSAGE)));
     }
   }
-  
+
   $type_info = node_get_types('type', $node);
   //drupal_set_message(__FUNCTION__ .': '. __LINE__ .' -- '. print_r($type_info, TRUE));
-  
+
   // check if we got expletives back
   if (is_array($title_expletives) && count($title_expletives)) {
     form_set_error('title', t('Your @field cannot be posted since it contains objectionable language (%expletives). Please reword your @field.', array('@field' => $type_info->title_label, '%expletives' => implode(', ', $title_expletives))));
@@ -441,7 +441,7 @@
 function _webpurify_nodeapi_validate_body_block(&$node, $op, $a3 = NULL, $a4 = NULL) {
   // check for expletives
   $body_expletives = webpurify_api_return($a3['body_field']['body']['#value']);
-  
+
   // handle a failure of the API properly
   if ($body_expletives === FALSE) {
     watchdog(WEBPURIFY_WATCHDOG_TYPE, __FUNCTION__ .': '. __LINE__ .' -- '. webpurify_get_error(), array(), WATCHDOG_ERROR);
@@ -449,7 +449,7 @@
       form_set_error('webpurify', variable_get('webpurify_node_create_fail_message', t(WEBPURIFY_NODE_CREATE_FAIL_MESSAGE)));
     }
   }
-  
+
   $type_info = node_get_types('type', $node);
 
   // check if we got expletives back
@@ -537,7 +537,7 @@
       if (webpurify_get_comment_subject_mode() == WEBPURIFY_MODE_BLOCK) {
         // get expletives
         $subject_expletives = webpurify_api_return($a1['subject']);
-        
+
         // handle a failure of the API properly
         if ($subject_expletives === FALSE) {
           watchdog(WEBPURIFY_WATCHDOG_TYPE, __FUNCTION__ .': '. __LINE__ .' -- '. webpurify_get_error(), array(), WATCHDOG_ERROR);
@@ -545,7 +545,7 @@
             form_set_error('webpurify', variable_get('webpurify_comment_fail_message', t(WEBPURIFY_COMMENT_CREATE_FAIL_MESSAGE)));
           }
         }
-        
+
         // check if we got expletives back
         if (is_array($subject_expletives) && count($subject_expletives)) {
           form_set_error('subject', t('Your subject cannot be posted since it contains objectionable language (%expletives). Please reword your subject.', array('%expletives' => implode(', ', $subject_expletives))));
@@ -554,7 +554,7 @@
       if (webpurify_get_comment_body_mode() == WEBPURIFY_MODE_BLOCK) {
         // get expletives
         $comment_expletives = webpurify_api_return($a1['comment']);
-        
+
         // handle a failure of the API properly
         if ($comment_expletives === FALSE) {
           watchdog(WEBPURIFY_WATCHDOG_TYPE, __FUNCTION__ .': '. __LINE__ .' -- '. webpurify_get_error(), array(), WATCHDOG_ERROR);
@@ -562,13 +562,13 @@
             form_set_error('webpurify', variable_get('webpurify_comment_fail_message', t(WEBPURIFY_COMMENT_CREATE_FAIL_MESSAGE)));
           }
         }
-        
+
         // check if we got expletives back
         if (is_array($comment_expletives) && count($comment_expletives)) {
           form_set_error('comment', t('Your comment cannot be posted since it contains objectionable language (%expletives). Please reword your comment.', array('%expletives' => implode(', ', $comment_expletives))));
         }
       }
-      
+
       // rewrite mode
       if (webpurify_get_comment_subject_mode() == WEBPURIFY_MODE_REWRITE) {
         $subject = webpurify_api_replace($a1['subject'], variable_get('webpurify_filter_symbol', WEBPURIFY_DEFAULT_FILTER_SYMBOL));
@@ -601,7 +601,7 @@
       //if (variable_get('webpurify_comment_mode', WEBPURIFY_COMMENT_MODE_OFF) == WEBPURIFY_COMMENT_MODE_REWRITE) {
       if (!empty($a1) && (webpurify_get_comment_subject_mode() == WEBPURIFY_MODE_REWRITE)) {
         $cid = $a1['cid'];
-        
+
         $subject = webpurify_api_replace($a1['subject'], variable_get('webpurify_filter_symbol', WEBPURIFY_DEFAULT_FILTER_SYMBOL));
         if ($subject === FALSE) {
           watchdog(WEBPURIFY_WATCHDOG_TYPE, __FUNCTION__ .': '. __LINE__ .' -- '. webpurify_get_error(), array(), WATCHDOG_ERROR);
@@ -620,12 +620,12 @@
  */
 function webpurify_api_check($text) {
   static $values = array();
-  
+
   $hash = md5($text);
   if (!empty($values[$hash])) {
     return $values[$hash];
   }
-  
+
   $result = _webpurify_api_call('webpurify.live.check', array('text'=>$text));
 
   if (isset($result['RSP']['#attributes']['STAT'])) {
@@ -644,7 +644,7 @@
       }
     }
   }
-  
+
   $GLOBALS['WEBPURIFY_ERROR'] = t("API error: unrecoginzable response");
   return FALSE;
 }
@@ -654,12 +654,12 @@
  */
 function webpurify_api_checkcount($text) {
   static $values = array();
-  
+
   $hash = md5($text);
   if (!empty($values[$hash])) {
     return $values[$hash];
   }
-  
+
   $result = _webpurify_api_call('webpurify.live.checkcount', array('text'=>$text));
 
   if (isset($result['RSP']['#attributes']['STAT'])) {
@@ -678,7 +678,7 @@
       }
     }
   }
-  
+
   $GLOBALS['WEBPURIFY_ERROR'] = t("API error: unrecoginzable response");
   return FALSE;
 }
@@ -688,7 +688,7 @@
  */
 function webpurify_api_replace($text, $replacesymbol) {
   static $values = array();
-  
+
   $hash = md5($text . $replacesymbol);
   if (!empty($values[$hash])) {
     return $values[$hash];
@@ -720,7 +720,7 @@
       }
     }
   }
-  
+
   $GLOBALS['WEBPURIFY_ERROR'] = t("API error: unrecoginzable response");
   return FALSE;
 }
@@ -730,7 +730,7 @@
  */
 function webpurify_api_return($text) {
   static $values = array();
-  
+
   $hash = md5($text);
   if (!empty($values[$hash])) {
     return $values[$hash];
@@ -738,7 +738,7 @@
 
   $result = _webpurify_api_call('webpurify.live.return', array('text'=>$text));
   $expletives = array();
-    
+
   if (isset($result['RSP']['#attributes']['STAT'])) {
     // was there an error?
     if ($result['RSP']['#attributes']['STAT'] == 'ok') {
@@ -773,7 +773,7 @@
       }
     }
   }
-  
+
   $GLOBALS['WEBPURIFY_ERROR'] = t("API error: unrecoginzable response");
   return FALSE;
 }
@@ -785,31 +785,31 @@
   $url = WEBPURIFY_REST_URL;
   $http_method = WEBPURIFY_REST_URL_METHOD;
   $headers = array();
-  
+
   if ($http_method == 'POST') {
     $headers['Content-Type'] = 'application/x-www-form-urlencoded';
   }
-  
+
   $raw_params = array(
         'api_key' => variable_get('webpurify_developerkey', ''),
         'method' => $method,
   );
   $raw_params = array_merge($raw_params, $params);
-  
+
   $encoded_params = array();
   foreach ($raw_params as $k => $v){
        $encoded_params[] = urlencode($k).'='.urlencode($v);
   }
-  
+
   if ($http_method == 'POST') {
     $result = drupal_http_request($url, $headers, $http_method, implode('&', $encoded_params));
   }
   else {
     $url = WEBPURIFY_REST_URL."?".implode('&', $encoded_params);
-    
+
     $result = drupal_http_request($url, $headers, $http_method);
   }
-  
+
   switch ($result->code) {
     case 200: // OK
     case 304: // Not modified
@@ -830,19 +830,19 @@
   $structure = array();
   $index = array();
   $result = FALSE;
-  
+
   // The WebPurify API doesn't wrap the text in cdata, so we will try to fix it
   if (!preg_match('@<text>\s*<!\[CDATA\[@im', $xml)) {
     $xml = preg_replace('@<text>@im', '<text><![CDATA[', $xml);
     $xml = preg_replace('@</text>@im', ']]></text>', $xml);
   }
-  
+
   // did we get any xml?
   if ($xml == "") {
     $GLOBALS['WEBPURIFY_ERROR'] = t("xml was empty");
     return FALSE;
   }
-  
+
   // create the parser object
   if (!($parser = xml_parser_create())) {
     $GLOBALS['WEBPURIFY_ERROR'] = t("xml_parser_create() failed to return parser");
@@ -850,7 +850,7 @@
   }
 
   // try to parse the xml
-  if (xml_parse_into_struct($parser, trim($xml), &$structure, &$index) === 0) {
+  if (xml_parse_into_struct($parser, trim($xml), $structure, &$index) === 0) {
     $err_code = xml_get_error_code($parser);
     $err_string = xml_error_string($err_code);
     $GLOBALS['WEBPURIFY_ERROR'] = t("xml_parse_into_struct failed: Code @code - @msg", array('@code'=>$err_code, '@msg'=>$err_string));
@@ -883,7 +883,7 @@
           if ($data['attributes']) {
             $element['#attributes'] = $data['attributes'];
           }
-          
+
           // see if we need to convert from single element to an array of elements
           if (isset($output[$data['tag']]['#tag'])) {
             $temp_element = $output[$data['tag']];
@@ -898,7 +898,7 @@
           // a single element
           else {
             $output[$data['tag']] = $element;
-          }  
+          }
           break;
 
         case 'open':
@@ -917,7 +917,7 @@
           if ($attributes) {
             $element['#attributes'] = $attributes;
           }
-          
+
           // see if we need to convert from single element to an array of elements
           if (isset($output[$data['tag']]['#tag'])) {
             $temp_element = $output[$data['tag']];
@@ -932,7 +932,7 @@
           // a single element
           else {
             $output[$data['tag']] = $element;
-          }  
+          }
           break;
       }
     }
