Forráskód Böngészése

upgraded to version 1.4 and debugged

centaurix 23 éve
szülő
commit
a535124000
2 módosított fájl, 36 hozzáadás és 51 törlés
  1. 22 29
      plugins/abook_take/setup.php
  2. 14 22
      plugins/abook_take/take.php

+ 22 - 29
plugins/abook_take/setup.php

@@ -1,5 +1,7 @@
 <?php
 
+   require_once('../functions/url_parser.php');
+
 
 /* Address Take -- steals addresses from incoming email messages.  Searches
    the To, Cc, From and Reply-To headers, also searches the body of the
@@ -18,45 +20,36 @@ function squirrelmail_plugin_init_abook_take()
 
 function valid_email ($email, $verify)
 {
-  global $abook_take_verify;
+  global $abook_take_verify, $Email_RegExp_Match;
   
-  if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](g|l|m|pa|t|u|v)?$", 
-    $email, $check)) 
-  {
-    if (! $verify)
-    {
-      return TRUE;
-    }
+  if (! eregi('^' . $Email_RegExp_Match . '$', $email))
+    return false;
     
-    if (checkdnsrr(substr(strstr($email, '@'), 1), 'ANY'))
-    {
-      return TRUE;
-    }
-  }
-  return FALSE;
+  if (! $verify)
+    return true;
+
+  if (! checkdnsrr(substr(strstr($email, '@'), 1), 'ANY'))
+    return false;
+
+  return true;
 }
 
 
 function abook_take_read_string($str)
 {
-  global $abook_found_email;
+  global $abook_found_email, $Email_RegExp_Match;
   
-  $str = eregi_replace('[^-0-9a-z_.@]', ' ', $str);
-  $str = eregi_replace('[[:space:]]+', ' ', $str);
-  $chances = split(' ', $str);
-  $i = 0;
-  while ($i < count($chances))
+
+  while (eregi('(' . $Email_RegExp_Match . ')', $str, $hits))
   {
-    if (valid_email($chances[$i], 0) && 
-        ! isset($abook_found_email[$chances[$i]]))
-    {
-      //echo '<option value="' . $chances[$i] . '">' . $chances[$i] . 
-      //  '</option>' . "\n";
-      echo "<input type=\"hidden\" name=\"email[]\" value=\"$chances[$i]\">\n";
-      $abook_found_email[$chances[$i]] = 1;
-    }
-    $i ++;
+      $str = substr(strstr($str, $hits[0]), strlen($hits[0]));
+      if (! isset($abook_found_email[$hits[0]]))
+      {
+          echo "<input type=\"hidden\" name=\"email[]\" value=\"$hits[0]\">\n";
+	  $abook_found_email[$hits[0]] = 1;
+      }
   }
+  return;
 }
 
 

+ 14 - 22
plugins/abook_take/take.php

@@ -1,4 +1,3 @@
-<?php /* Modified at 6 places by ri_once */ ?>
 <?php
   /**
    **  take.php
@@ -6,27 +5,15 @@
    **	Adds a "taken" address to the address book.  Takes addresses from
    **   incoming mail -- the body, To, From, Cc, or Reply-To.
    **/
-
-   session_start();
-
-   if(!isset($username)) {
-      echo "You need a valid user and password to access this page!";
-      exit;
-   }
-
-   chdir("..");
-   if (!isset($config_php))
-      /* '_once' Added by ri_once */ include_once("../config/config.php");
-   if (!isset($i18n_php))
-      /* '_once' Added by ri_once */ include_once("../functions/i18n.php");
-   if (!isset($page_header_php))
-      /* '_once' Added by ri_once */ include_once("../functions/page_header.php");
-   if (!isset($addressbook_php))
-      /* '_once' Added by ri_once */ include_once("../functions/addressbook.php");
-   if (!isset($strings_php))
-      /* '_once' Added by ri_once */ include_once("../functions/strings.php");
-
-   /* '_once' Added by ri_once */ include_once("../src/load_prefs.php");
+   
+   chdir('..');
+   require_once('../src/validate.php');
+   require_once("../functions/strings.php");
+   require_once("../config/config.php");
+   require_once("../functions/i18n.php");
+   require_once("../functions/page_header.php");
+   require_once("../functions/addressbook.php");
+   require_once("../src/load_prefs.php");
    
    displayPageHeader($color, "None");
    
@@ -65,6 +52,11 @@
           echo '<option value="' . htmlspecialchars($Val) .
               '">' . htmlspecialchars($Val) . "</option>\n";
       }
+      else
+      {
+          echo '<option value="' . htmlspecialchars($Val) .
+	      '">FAIL - ' . htmlspecialchars($Val) . "</option>\n";
+      }
   }
   echo "</select>\n";