Fix abook_take
authorkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 17 Jan 2003 18:15:24 +0000 (18:15 +0000)
committerkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 17 Jan 2003 18:15:24 +0000 (18:15 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4430 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/abook_take/INSTALL [deleted file]
plugins/abook_take/setup.php
plugins/abook_take/take.php

diff --git a/plugins/abook_take/INSTALL b/plugins/abook_take/INSTALL
deleted file mode 100644 (file)
index af088c6..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-Installing Plugins
-==================
-Simply untar the file in the plugins directory, and make sure it is
-in its own directory, and that the name of the directory is the name
-of the plugin.  Example below uses "plug_demo" as the name of the 
-plugin:
-
-  $ cd plugins
-  $ tar -zxvf /usr/archives/plug_demo.tar.gz
-
-Then go to your config directory and run conf.pl.  Choose option
-8 and add the plugin (+).  Save and exit, then that should be all
-if the plugin was made correctly.  :)
-
-  $ cd ../config
-  $ ./conf.pl
index dd36b66235204b93eb65e157f2819c66c811b1e8..9bdb840950a6f86c9150e2f8ee9c2243f7c4829d 100755 (executable)
 <?php
 
-/* Path for SquirrelMail required files. */
+/**
+ * setup.php
+ *
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * Address Take -- steals addresses from incoming email messages. Searches
+ * the To, Cc, From and Reply-To headers, also searches the body of the
+ * message.
+ *
+ * $Id$
+ */
+
 if (!defined('SM_PATH'))  {
-       define('SM_PATH','../../');
+    define('SM_PATH','../../');
 }
 
 /* SquirrelMail required files. */
 require_once(SM_PATH . '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
-   message.  */
-
 function squirrelmail_plugin_init_abook_take()
 {
-  global $squirrelmail_plugin_hooks;
+    global $squirrelmail_plugin_hooks;
   
-  $squirrelmail_plugin_hooks['read_body_bottom']['abook_take'] = 'abook_take_read';
-  $squirrelmail_plugin_hooks['loading_prefs']['abook_take'] = 'abook_take_pref';
-  $squirrelmail_plugin_hooks['options_display_inside']['abook_take'] = 'abook_take_options';
-  $squirrelmail_plugin_hooks['options_display_save']['abook_take'] = 'abook_take_save';
+    $squirrelmail_plugin_hooks['read_body_bottom']['abook_take'] = 'abook_take_read';
+    $squirrelmail_plugin_hooks['loading_prefs']['abook_take'] = 'abook_take_pref';
+    $squirrelmail_plugin_hooks['options_display_inside']['abook_take'] = 'abook_take_options';
+    $squirrelmail_plugin_hooks['options_display_save']['abook_take'] = 'abook_take_save';
 }
 
-
 function valid_email ($email, $verify)
 {
-  global $abook_take_verify, $Email_RegExp_Match;
+    global $Email_RegExp_Match;
   
-  if (! eregi('^' . $Email_RegExp_Match . '$', $email))
-    return false;
+    if (! eregi('^' . $Email_RegExp_Match . '$', $email))
+        return false;
     
-  if (! $verify)
-    return true;
+    if (! $verify)
+        return true;
 
-  if (! checkdnsrr(substr(strstr($email, '@'), 1), 'ANY'))
-    return false;
-
-  return true;
+    return checkdnsrr(substr(strstr($email, '@'), 1), 'ANY') ;
 }
 
-
 function abook_take_read_string($str)
 {
-  global $abook_found_email, $Email_RegExp_Match;
-  
+    global $abook_found_email, $Email_RegExp_Match;
+
+    while (eregi('(' . $Email_RegExp_Match . ')', $str, $hits))
+    {
+        $str = substr(strstr($str, $hits[0]), strlen($hits[0]));
+        if (! isset($abook_found_email[$hits[0]]))
+        {
+            echo '<input type="hidden" name="email[]" value="' .
+                 htmlspecialchars($hits[0]) . "\" />\n";
+            $abook_found_email[$hits[0]] = 1;
+        }
+    }
 
-  while (eregi('(' . $Email_RegExp_Match . ')', $str, $hits))
-  {
-      $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;
+    return;
 }
 
-
 function abook_take_read_array($array)
 {
-  $i = 0;
-  while ($i < count($array))
-  {
-    abook_take_read_string($array[$i]->getAddress());
-    $i ++;
-  }
+    foreach ($array as $item)
+        abook_take_read_string($item->getAddress());
 }
 
-
 function abook_take_read()
 {
-  global $color, $abook_take_location;
-  global $body, $abook_take_hide, $message, $imapConnection;
+    global $message;
 
-  if ($abook_take_hide)
-    return;
-    
-  echo '<form action="../plugins/abook_take/take.php" method="post">' . "\n" .
-  html_tag( 'table', '', $abook_take_location, $color[10], 'cellpadding="3" cellspacing="0" border="0"' ) .
-      html_tag( 'tr' ) .
-          html_tag( 'td', '', 'left' ) .
-              html_tag( 'table', '', '', $color[5], 'cellpadding="2" cellspacing="1" border="0"' ) .
-                  html_tag( 'tr' ) .
-                      html_tag( 'td' );
-
-              if (isset($message->rfc822_header->from))
-                  abook_take_read_array($message->rfc822_header->from);
-              if (isset($message->rfc822_header->cc))
-                  abook_take_read_array($message->rfc822_header->cc);
-              if (isset($message->rfc822_header->reply_to))
-                  abook_take_read_array($message->rfc822_header->reply_to);
-              if (isset($message->rfc822_header->to))
-                  abook_take_read_array($message->rfc822_header->to);
-
-
-              $new_body = $body;
-              $pos = strpos($new_body, 
-                '">' . _("Download this as a file") . '</a></center><br></small>');
-              if (is_int($pos))
-              {
-                $new_body = substr($new_body, 0, $pos);
-              }
-                     
-              $trans = get_html_translation_table(HTML_ENTITIES);
-              $trans[' '] = '&nbsp;';
-              $trans = array_flip($trans);
-              $new_body = strtr($new_body, $trans);
-
-              $new_body = urldecode($new_body);
-              $new_body = strip_tags($new_body);
-              
-              $new_body = strtr($new_body, "\n", ' ');
-    
-              abook_take_read_string($body);
-            
-              echo '<input type="submit" value="' . _("Take Address") . '">';
-            ?>
-            </td>
-          </tr>
-        </table>
-      </td>
-    </tr>
-  </table>
-  </form>
-  <?PHP
+    echo '<br /><form action="../plugins/abook_take/take.php" method="post"><center>'."\n";
+
+    if (isset($message->rfc822_header->reply_to))
+        abook_take_read_array($message->rfc822_header->reply_to);
+    if (isset($message->rfc822_header->from))
+        abook_take_read_array($message->rfc822_header->from);
+    if (isset($message->rfc822_header->cc))
+        abook_take_read_array($message->rfc822_header->cc);
+    if (isset($message->rfc822_header->to))
+        abook_take_read_array($message->rfc822_header->to);
+
+    echo '<input type="submit" value="' . _("Take Address") . '" />' .
+         '</center></form>';
 }
 
 function abook_take_pref()
 { 
-  global $username, $data_dir;
-  global $abook_take_hide, $abook_take_location, $abook_take_verify;
+    global $username, $data_dir, $abook_take_verify;
 
-  $abook_take_location = getPref($data_dir, $username, 'abook_take_location');
-  if ($abook_take_location == '')
-    $abook_take_location = 'center';
-    
-  $abook_take_hide = getPref($data_dir, $username, 'abook_take_hide');
-  $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
+    $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
 }
 
-
 function abook_take_options()
 {
-  global $abook_take_location, $abook_take_hide, $abook_take_verify;
-  
-  echo html_tag( 'tr' ) .
-      html_tag( 'td', _("Address Book Take") . ':', 'right', '', 'nowrap valign="top"' ) .
-      html_tag( 'td', '', 'left' ) .
-          '<select name="abook_take_abook_take_location">' .
-          '<option value="left"';
-          if ($abook_take_location == 'left')
-            echo ' selected';
-          echo '>' . _("Left aligned") . '</option>' .
-          '<option value="center"';
-          if ($abook_take_location == 'center')
-            echo ' selected';
-          echo '>' . _("Centered") . '</option>' .
-          '<option value="right"';
-          if ($abook_take_location == 'right')
-            echo ' selected';
-          echo '>' . _("Right aligned") . '</option>' .
-          '</select> ' . _("on the Read screen") .'<br>' .
-          '<input type="checkbox" name="abook_take_abook_take_hide"';
-          if ($abook_take_hide)
-            echo ' checked';
-          echo '>&nbsp;' . _("Hide the box") . '<br>' .
-          '<input type=checkbox name="abook_take_abook_take_verify"';
-          if ($abook_take_verify)
-            echo ' checked';
-          echo '>&nbsp;' . _("Try to verify addresses") . '</td></tr>';
+    global $abook_take_verify;
+
+    echo '<tr><td align="right" nowrap>' . _("Address Book Take:") . "</td>\n" .
+         '<td><input name="abook_take_abook_take_verify" type="checkbox"';
+    if (isset($abook_take_verify) && $abook_take_verify)
+        echo ' checked';
+    echo ' /> ' . _("Try to verify addresses") . "</td></tr>\n";
 }
 
 
 function abook_take_save()
 {
-  global $username, $data_dir;
-  global $abook_take_abook_take_location;
-  global $abook_take_abook_take_hide;
-  global $abook_take_abook_take_verify;
-  
+    global $username, $data_dir;
   
-  if (isset($abook_take_abook_take_location)) 
-  {
-    setPref($data_dir, $username, 'abook_take_location', $abook_take_abook_take_location);
-  } 
-  else 
-  {
-    setPref($data_dir, $username, 'abook_take_location', 'center');
-  }
-
-  if (isset($abook_take_abook_take_hide)) 
-  {
-    setPref($data_dir, $username, 'abook_take_hide', '1');
-  } 
-  else 
-  {
-    setPref($data_dir, $username, 'abook_take_hide', '');
-  }
-
-  if (isset($abook_take_abook_take_verify)) 
-  {
-    setPref($data_dir, $username, 'abook_take_verify', '1');
-  } 
-  else 
-  {
-    setPref($data_dir, $username, 'abook_take_verify', '');
-  }
+    if (sqgetGlobalVar('abook_take_abook_take_verify', $abook_take_abook_take_verify, SQ_POST)) 
+        setPref($data_dir, $username, 'abook_take_verify', '1');
+    else 
+        setPref($data_dir, $username, 'abook_take_verify', '');
 }
 
 ?>
index b062552e16defc9c66fd3aa83152f2b37bd2816e..81c96ae4cfd8ca763e921974c58acca39df5c1bd 100644 (file)
@@ -1,11 +1,16 @@
 <?php
 
-  /**
-   * take.php
-   *
-   * Adds a "taken" address to the address book.  Takes addresses from
-   * incoming mail -- the body, To, From, Cc, or Reply-To.
-   */
+/**
+ * take.php
+ *
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * Address Take -- steals addresses from incoming email messages. Searches
+ * the To, Cc, From and Reply-To headers.
+ *
+ * $Id$
+ */
    
 /* Path for SquirrelMail required files. */
 define('SM_PATH','../../');
@@ -21,11 +26,15 @@ require_once(SM_PATH . 'include/load_prefs.php');
 require_once(SM_PATH . 'functions/html.php');
    
 displayPageHeader($color, 'None');
-  
+
+/* input form data */
+sqgetGlobalVar('email', $email, SQ_POST);
+
 $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
 
 $abook = addressbook_init(false, true);
 $name = 'addaddr';
+
 echo '<form action="../../src/addressbook.php" name="f_add" method="post">' ."\n" .
     html_tag( 'table',
         html_tag( 'tr',
@@ -44,39 +53,38 @@ echo '<form action="../../src/addressbook.php" name="f_add" method="post">' ."\n
             html_tag( 'td', _("E-mail address") . ':', 'right', $color[4], 'width="50"' ) . "\n" .
             html_tag( 'td', '', 'left', $color[4] ) .
                 '<select name="' . $name . "[email]\">\n";
-  foreach ($email as $Val)
-  {
-      if (valid_email($Val, $abook_take_verify))
-      {
-          echo '<option value="' . htmlspecialchars($Val) .
-              '">' . htmlspecialchars($Val) . "</option>\n";
-      }
-      else
-      {
-          echo '<option value="' . htmlspecialchars($Val) .
+
+    foreach ($email as $Val)
+    {
+        if (valid_email($Val, $abook_take_verify))
+        {
+            echo '<option value="' . htmlspecialchars($Val) .
+                '">' . htmlspecialchars($Val) . "</option>\n";
+        } else {
+            echo '<option value="' . htmlspecialchars($Val) .
              '">FAIL - ' . htmlspecialchars($Val) . "</option>\n";
-      }
-  }
-  echo '</select></td></tr>' . "\n" . 
+        }
+    }
+    echo '</select></td></tr>' . "\n" . 
 
-  html_tag( 'tr', "\n" .
-      html_tag( 'td', _("First name") . ':', 'right', $color[4], 'width="50"' ) .
-      html_tag( 'td', '<input name="' . $name . '[firstname]" size="45" value="">', 'left', $color[4] )
-  ) . "\n" .
-  html_tag( 'tr', "\n" .
-      html_tag( 'td', _("Last name") . ':', 'right', $color[4], 'width="50"' ) .
-      html_tag( 'td', '<input name="' . $name . '[lastname]" size="45" value="">', 'left', $color[4] )
-  ) . "\n" .
-  html_tag( 'tr', "\n" .
-      html_tag( 'td', _("Additional info") . ':', 'right', $color[4], 'width="50"' ) .
-      html_tag( 'td', '<input name="' . $name . '[label]" size="45" value="">', 'left', $color[4] )
-  ) . "\n" .
-  html_tag( 'tr', "\n" .
-      html_tag( 'td',
-          '<input type="submit" name="' . $name . '[SUBMIT]" size="45" value="'. _("Add address") .'">' ,
-      'center', $color[4], 'colspan="2"' )
-  ) . "\n" .
-  '</table>';
+    html_tag( 'tr', "\n" .
+        html_tag( 'td', _("First name") . ':', 'right', $color[4], 'width="50"' ) .
+        html_tag( 'td', '<input name="' . $name . '[firstname]" size="45" value="">', 'left', $color[4] )
+    ) . "\n" .
+    html_tag( 'tr', "\n" .
+        html_tag( 'td', _("Last name") . ':', 'right', $color[4], 'width="50"' ) .
+        html_tag( 'td', '<input name="' . $name . '[lastname]" size="45" value="">', 'left', $color[4] )
+    ) . "\n" .
+    html_tag( 'tr', "\n" .
+        html_tag( 'td', _("Additional info") . ':', 'right', $color[4], 'width="50"' ) .
+        html_tag( 'td', '<input name="' . $name . '[label]" size="45" value="">', 'left', $color[4] )
+    ) . "\n" .
+    html_tag( 'tr', "\n" .
+        html_tag( 'td',
+            '<input type="submit" name="' . $name . '[SUBMIT]" size="45" value="'. _("Add address") .'">' ,
+        'center', $color[4], 'colspan="2"' )
+    ) . "\n" .
+    '</table>';
 ?>
 </form></body>
 </html>