diff -u -ru whois-1.1_vanilla/whois.module whois-refact/whois.module
--- whois-1.1_vanilla/whois.module	2008-08-12 13:15:57.000000000 +0200
+++ whois-refact/whois.module	2009-06-05 16:53:53.000000000 +0200
@@ -11,7 +11,7 @@
     case 'install' :
     case 'runtime' :
       $path = drupal_get_path('module', 'whois') . '/phpwhois/whois.main.php';
-	  if (!file_exists($path)) {
+      if (!file_exists($path)) {
         $requirements['whois'] = array(
           'title' => $t('Whois lookup'),
           'description' => $t("Whois module requires !phpwhois to do whois queries. !download and put it's contents in <em>modules/whois</em> directory (so that it looks something like this: <em>modules/whois/phpwhois/example.php</em>).", array('!phpwhois' => l('phpWhois library', 'http://phpwhois.sf.net/'), '!download' => l('Download phpWhois', 'http://sourceforge.net/project/showfiles.php?group_id=31207&package_id=23260'))),
@@ -102,7 +102,7 @@
     // Check for hourly threshold.
     if (flood_is_allowed('whois', variable_get('whois_hourly_threshold', 13))) {
       $output .= '<h3>' . t('Whois lookup for %address:', array('%address' => $address)) . '</h3>';
-      $output .= whois_get_whois($address);
+      $output .= whois_display_whois($address);
     }
     else {
       $output .= t("You cannot do more than %number whois lookups per hour. Please try again later.", array('%number' => variable_get('whois_hourly_threshold', 13)));
@@ -111,13 +111,6 @@
       // Avoid debug information(devel.module) from being added to the preview.
       $GLOBALS['devel_shutdown'] = FALSE;
 
-      if (variable_get('whois_log_watchdog', 1)) {
-        // Watchdog entry for lookup request.
-        watchdog('whois',
-          t('Whois lookup for: %address', array('%address' => $address)),
-          array($address), WATCHDOG_NOTICE, l('View', "whois/$address") . ' · ' . l('Address', "http://$address/"));
-      }
-
       // Stop further processing and return requested data.
       exit(drupal_json(array('html' => $output)));
     }
@@ -163,45 +156,29 @@
   global $user;
   $address = whois_parse_url($form_state['values']['whois_address']);
 
-  if (variable_get('whois_log_watchdog', 1)) {
-    // Watchdog entry for lookup request.
-    watchdog('whois',
-      t('Whois lookup for: %address', array('%address' => $address)),
-      array($address), WATCHDOG_NOTICE, l('View', "whois/$address") . ' · ' . l('Address', "http://$address/"));
-  }
-
   $form_state['redirect'] = 'whois/' . $address;
   return;
 }
 
-function whois_get_whois($address) {
+function whois_display_whois($address) {
   $data = '';
-  $path = drupal_get_path('module', 'whois') . '/phpwhois/whois.main.php';
-
-  if (!file_exists($path)) {
-    drupal_set_message(t('There are problems with <em>Whois lookup</em> setup. Report to the website administrators promptly!', array('@status' => url('admin/logs/status'))), 'error');
-  }
-  elseif ($address != '') {
-    include_once('phpwhois/whois.main.php');
-    include_once('phpwhois/whois.utils.php');
+  $result = whois_get_whois($address);
+  if ($result) {
     $option = variable_get('whois_output_method', 'html');
-    $whois = new Whois();
-    $result = $whois->Lookup($address);
-
-    switch($option) {
+    switch ($option) {
       case 'html':
         if (!empty($result['rawdata'])) {
           $utils = new utils;
           $data .= $utils->showHTML($result);
         }
         else {
-          $data .= implode($whois->Query['errstr'],"\n<br></br>");
+          $data .= implode($whois->Query['errstr'], "\n<br />");
         }  
       break;
 
       case 'object':
         if ($whois->Query['status'] < 0) {
-          $data .= implode($whois->Query['errstr'],"\n<br></br>");
+          $data .= implode($whois->Query['errstr'], "\n<br />");
         }
         else {
           $utils = new utils;
@@ -209,12 +186,13 @@
         }
       break;
 
+      case 'basic': // 'basic' is the default
       default:
-        if(!empty($result['rawdata'])) {
-          $data .= '<pre>' . implode($result['rawdata'],"\n") . '</pre>';
+        if (!empty($result['rawdata'])) {
+          $data .= '<pre>' . implode($result['rawdata'], "\n") . '</pre>';
         }
         else {
-          $data .= implode($whois->Query['errstr'],"\n<br></br>");
+          $data .= implode($whois->Query['errstr'], "\n<br ");
         } 
       break;
     }
@@ -223,6 +201,37 @@
   return $data;
 }
 
+/**
+ * Return the whois information for a given host.
+ *
+ * @param $address
+ *   The address of the host to look up.
+ *
+ * @return
+ *   An object describing the Whois result.
+ */
+function whois_get_whois($address) {
+  $data = '';
+  $path = drupal_get_path('module', 'whois') . '/phpwhois/whois.main.php';
+
+  if (!file_exists($path)) {
+    drupal_set_message(t('There are problems with <em>Whois lookup</em> setup. Report to the website administrators promptly!', array('@status' => url('admin/logs/status'))), 'error');
+  }
+  elseif ($address != '') {
+    include_once('phpwhois/whois.main.php');
+    include_once('phpwhois/whois.utils.php');
+    $whois = new Whois();
+    if (variable_get('whois_log_watchdog', 1)) {
+      // Watchdog entry for lookup request.
+      watchdog('whois',
+        t('Whois lookup for: %address', array('%address' => $address)),
+        array($address), WATCHDOG_NOTICE, l('View', "whois/$address") . ' · ' . l('Address', "http://$address/"));
+    }
+    return $whois->Lookup($address);
+  }
+  return FALSE;
+}
+
 function whois_parse_url($url) {
   $r  = "^(?:(?P<scheme>\w+)://)?";
   $r .= "(?:(?P<login>\w+):(?P<pass>\w+)@)?";
