Alexandros Vellis: Bugfix
[squirrelmail.git] / plugins / mail_fetch / options.php
index 4d1edb3534671f6ada4062a9f45ab80b6e9d141a..2d019413bd9a4316db519a0f290725a32b675899 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * mail_fetch/options.php
  *
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * Setup of the mailfetch plugin.
@@ -26,6 +26,9 @@ require_once(SM_PATH . 'include/load_prefs.php');
     if(isset($_POST['mf_cypher'])) {
         $mf_cypher = $_POST['mf_cypher'];
     }
+    else {
+        $mf_cyper = '';
+    }
     if(isset($_POST['mf_sn'])) {
         $mf_sn = $_POST['mf_sn'];
     }
@@ -75,7 +78,7 @@ require_once(SM_PATH . 'include/load_prefs.php');
         if ($mf_sn<1) $mf_sn=0;
         if (!isset($mf_server)) return;
         setPref($data_dir,$username,"mailfetch_server_$mf_sn", (isset($mf_server)?$mf_server:""));
-               setPref($data_dir,$username,"mailfetch_port_$mf_sn"), (isset($mf_port)?$mf_port:'110');
+        setPref($data_dir,$username,"mailfetch_port_$mf_sn", (isset($mf_port)?$mf_port:110));
         setPref($data_dir,$username,"mailfetch_alias_$mf_sn", (isset($mf_alias)?$mf_alias:""));
         setPref($data_dir,$username,"mailfetch_user_$mf_sn",(isset($mf_user)?$mf_user:""));
         setPref($data_dir,$username,"mailfetch_pass_$mf_sn",(isset($mf_pass)?encrypt( $mf_pass )    :""));
@@ -92,7 +95,7 @@ require_once(SM_PATH . 'include/load_prefs.php');
         //modify    a server
         if (!isset($mf_server)) return;
         setPref($data_dir,$username,"mailfetch_server_$mf_sn", (isset($mf_server)?$mf_server:""));
-               setPref($data_dir,$username,"mailfetch_port_$mf_sn"), (isset($mf_port)?$mf_port:'110');
+        setPref($data_dir,$username,"mailfetch_port_$mf_sn", (isset($mf_port)?$mf_port:110));
         setPref($data_dir,$username,"mailfetch_alias_$mf_sn", (isset($mf_alias)?$mf_alias:""));
         setPref($data_dir,$username,"mailfetch_user_$mf_sn",(isset($mf_user)?$mf_user:""));
         setPref($data_dir,$username,"mailfetch_pass_$mf_sn",(isset($mf_pass)?encrypt( $mf_pass )    :""));
@@ -117,7 +120,7 @@ require_once(SM_PATH . 'include/load_prefs.php');
             for ($i=$mf_sn;$i<$mailfetch_server_number;$i++) {
                 $tmp=$i+1;
                 setPref($data_dir,$username,"mailfetch_server_$i", getPref($data_dir, $username, "mailfetch_server_$tmp"));
-                setPref($data_dir,$username,"mailfetch_port_$i"), getPref($data_dir,$username, "mailfetch_port_$tmp"));
+                setPref($data_dir,$username,"mailfetch_port_$i", getPref($data_dir,$username, "mailfetch_port_$tmp"));
                 setPref($data_dir,$username,"mailfetch_alias_$i", getPref($data_dir, $username, "mailfetch_alias_$tmp"));
                 setPref($data_dir,$username,"mailfetch_user_$i", getPref($data_dir, $username, "mailfetch_user_$tmp"));
                 setPref($data_dir,$username,"mailfetch_pass_$i",(isset($mf_pass)?encrypt( $mf_pass ) :""));
@@ -197,9 +200,9 @@ require_once(SM_PATH . 'include/load_prefs.php');
                     html_tag( 'th', _("Server:"), 'right' ) .
                     html_tag( 'td', '<input type=text name=mf_server value="" size=40>', 'left' )
                 ) .
-                html_tar( 'tr',
+                html_tag( 'tr',
                     html_tag( 'th', _("Port:"), 'right') .
-                    html_tag( 'td', '<input type=text name=mf_port value="" size=20', 'left')
+                    html_tag( 'td', '<input type=text name=mf_port value="110" size=20', 'left')
                 ) .
                 html_tag( 'tr',
                     html_tag( 'th', _("Alias:"), 'right' ) .
@@ -257,7 +260,7 @@ require_once(SM_PATH . 'include/load_prefs.php');
             echo '<b>' . _("Server Name:") . '</b> <select name="mf_sn">';
             for ($i=0;$i<$mailfetch_server_number;$i++) {
                 echo "<option value=\"$i\">" .
-                    (($mailfetch_alias_[$i]=='')?$mailfetch_server_[$i]:$mailfetch_alias_[$i]) . "</option>>";
+                    htmlspecialchars( (($mailfetch_alias_[$i]=='')?$mailfetch_server_[$i]:$mailfetch_alias_[$i])) . "</option>>";
             }
             echo '</select>'.
                  '&nbsp;&nbsp;<INPUT TYPE=submit name=mf_action value="' . _("Modify") . '">'.
@@ -283,7 +286,7 @@ require_once(SM_PATH . 'include/load_prefs.php');
                     html_tag( 'td',
                         "<INPUT TYPE=\"hidden\" NAME=\"mf_sn\" VALUE=\"$mf_sn\">" .
                         '<INPUT TYPE="hidden" NAME="mf_action" VALUE="confirm_delete">' .
-                        '<br>' . _("Selected Server:") . " <b>$mailfetch_server_[$mf_sn]</b><br>" .
+                        '<br>' . _("Selected Server:") . " <b>" . htmlentities($mailfetch_server_[$mf_sn]) . "</b><br>" .
                         _("Confirm delete of selected server?") . '<br><br>' .
                         '<input type=submit name=submit_mailfetch value="' . _("Confirm Delete") . '">' .
                         '<br></form>' ,
@@ -310,7 +313,7 @@ require_once(SM_PATH . 'include/load_prefs.php');
             html_tag( 'table' ) .
                 html_tag( 'tr',
                     html_tag( 'th', _("Server:"), 'right' ) .
-                    html_tag( 'td', '<input type="text" name="mf_server" value="' . $mailfetch_server_[$mf_sn] . '" size="40">', 'left' )
+                    html_tag( 'td', '<input type="text" name="mf_server" value="' . htmlentities($mailfetch_server_[$mf_sn]) . '" size="40">', 'left' )
                 ) .
                 html_tag( 'tr',
                     html_tag( 'th', _("Port:"), 'right' ) .
@@ -318,7 +321,7 @@ require_once(SM_PATH . 'include/load_prefs.php');
                 ) .
                 html_tag( 'tr',
                     html_tag( 'th', _("Alias:"), 'right' ) .
-                    html_tag( 'td', '<input type="text" name="mf_alias" value="' . $mailfetch_alias_[$mf_sn] . '" size="40">', 'left' )
+                    html_tag( 'td', '<input type="text" name="mf_alias" value="' . htmlentities($mailfetch_alias_[$mf_sn]) . '" size="40">', 'left' )
                 ) .
                 html_tag( 'tr',
                     html_tag( 'th', _("Username:"), 'right' ) .
@@ -336,10 +339,11 @@ require_once(SM_PATH . 'include/load_prefs.php');
         $boxes = sqimap_mailbox_list($imapConnection);
         echo '<select name="mf_subfolder">';
         $selected = 0;
-        if ( isset($mf_subfolder) )
-          $selected = array(strtolower($mf_subfolder));
-        echo sqimap_mailbox_option_list($imapConnection, $selected);
-        echo '</select></td></tr>' .
+        if ( isset($mailfetch_subfolder_[$mf_sn]) ) {
+            $selected = array(strtolower($mailfetch_subfolder_[$mf_sn]));
+       } 
+        echo sqimap_mailbox_option_list($imapConnection, $selected) .
+             '</select></td></tr>' .
 
                 html_tag( 'tr',
                     html_tag( 'th', '&nbsp;', 'right' ) .