Strip unwanted parts of the spamcop auth code in case someone enters
[squirrelmail.git] / plugins / spamcop / options.php
index 2ff09a61790e55d35dd3e18f70212f24560ae916..5850261d826b44a5e3e1b4f8460c0e38393a5d2e 100755 (executable)
@@ -1,29 +1,60 @@
 <?php
-   chdir ('..');
-   define('SM_PATH','../');
-   require_once(SM_PATH . 'include/validate.php');
-
-   displayPageHeader($color, "None");   
-
-   if (! isset($action))
-      $action = '';
-   if ($action == 'enable')
-      setPref($data_dir, $username, 'spamcop_enabled', 1);
-   elseif ($action == 'disable')
-      setPref($data_dir, $username, 'spamcop_enabled', '');
-   elseif ($action == 'save')
-      setPref($data_dir, $username, 'spamcop_delete', '');
-   elseif ($action == 'delete')
-      setPref($data_dir, $username, 'spamcop_delete', 1);
-   elseif ($action == 'meth' && isset($meth))
-      setPref($data_dir, $username, 'spamcop_method', $meth);
-   elseif ($action == 'save_id' && isset($ID))
-      setPref($data_dir, $username, 'spamcop_id', $ID);
-
-   global $spamcop_enabled, $spamcop_delete;
-   spamcop_load();
-
-   ?>
+
+   /**
+    **  options.php -- SpamCop options page
+    **
+    **  Copyright (c) 1999-2002 The SquirrelMail development team
+    **  Licensed under the GNU GPL. For full terms see the file COPYING.
+    **
+    **  $Id$
+    **/
+
+define('SM_PATH','../../');
+require_once(SM_PATH . 'include/validate.php');
+
+displayPageHeader($color, 'None');
+   
+/* globals */
+sqextractGlobalVar('action');
+sqextractGlobalVar('meth');
+sqextractGlobalVar('ID');
+extract($_SESSION);
+/* end of globals */
+
+$action = (!isset($action) ? '' : $action);
+
+switch ($action) {
+    case 'enable':
+        setPref($data_dir, $username, 'spamcop_enabled', 1);
+        break;
+    case 'disable':
+        setPref($data_dir, $username, 'spamcop_enabled', '');
+        break;
+    case 'save':
+        setPref($data_dir, $username, 'spamcop_delete', '');
+        break;
+    case 'delete':
+        setPref($data_dir, $username, 'spamcop_delete', 1);
+        break;
+    case 'meth':
+        if (isset($meth)) {
+            setPref($data_dir, $username, 'spamcop_method', $meth);
+        }
+        break;
+    case 'save_id':
+        if (isset($ID)) {
+            $ID = trim($ID);
+            $ID = preg_replace('/@.*/','',$ID);
+            $ID = preg_replace('/.*\./','',$ID);
+            setPref($data_dir, $username, 'spamcop_id', $ID);
+        }
+        break;
+}
+
+global $spamcop_enabled, $spamcop_delete;
+spamcop_load();
+
+?>
       <br>
       <table width=95% align=center border=0 cellpadding=2 cellspacing=0><tr><td bgcolor="<?php echo $color[0] ?>">
          <center><b><?php echo _("Options") ?> - Message Filtering</b></center>