Typo making '">' and argument, and probably messing up the posting of
[squirrelmail.git] / plugins / mail_fetch / fetch.php
index e1f220c3f9647c4abe1dcb15b43a5cfd1f15397b..73755e9cb6fa6f60b8cd2da2c06181bd00496b9e 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * mail_fetch/fetch.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.
  *
  * Fetch code.
@@ -21,20 +21,20 @@ require_once(SM_PATH . 'plugins/mail_fetch/class.POP3.php');
 require_once(SM_PATH . 'plugins/mail_fetch/functions.php' );
 require_once(SM_PATH . 'functions/html.php' );
 
-    /* globals */ 
-    $username = $_SESSION['username'];
-    $key = $_COOKIE['key'];
-    $onetimepad = $_SESSION['onetimepad'];
-    $delimter = $_SESSION['delimiter'];
+/* globals */ 
+sqgetGlobalVar('username',   $username,   SQ_SESSION);
+sqgetGlobalVar('key',        $key,        SQ_COOKIE);
+sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
+sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
 
-    /* This form, like the advanced identities form
      uses dynamic post variable names so we need
      to extract the whole $_POST array to make 
      things work
   */
+/* FIXME: This form, like the advanced identities form
* uses dynamic post variable names so we need
* to extract the whole $_POST array to make 
* things work
+ */
 
-    extract($_POST);
-    /* end globals */
+extract($_POST);
+/* end globals */
 
     function Mail_Fetch_Status($msg) {
         echo html_tag( 'table',
@@ -53,6 +53,7 @@ require_once(SM_PATH . 'functions/html.php' );
     if ($mailfetch_server_number<1) $mailfetch_server_number=0;
     for ($i=0;$i<$mailfetch_server_number;$i++) {
         $mailfetch_server_[$i] = getPref($data_dir, $username, "mailfetch_server_$i");
+               $mailfetch_port_[$i] = getPref($data_dir, $username, "mailfetch_port_$i");
         $mailfetch_alias_[$i] = getPref($data_dir, $username, "mailfetch_alias_$i");
         $mailfetch_user_[$i] = getPref($data_dir, $username, "mailfetch_user_$i");
         $mailfetch_pass_[$i] = getPref($data_dir, $username, "mailfetch_pass_$i");
@@ -85,7 +86,7 @@ require_once(SM_PATH . 'functions/html.php' );
                          '<option value="all" selected>..' . _("All") . "...\n";
         for ($i=0;$i<$mailfetch_server_number;$i++) {
              echo "<option value=\"$i\">" .
-                  (($mailfetch_alias_[$i]=='')?$mailfetch_server_[$i]:$mailfetch_alias_[$i]) .
+                 htmlspecialchars((($mailfetch_alias_[$i]=='')?$mailfetch_server_[$i]:$mailfetch_alias_[$i])) .
                   '</option>' . "\n";
         } 
         echo            '</select>' .
@@ -97,18 +98,17 @@ require_once(SM_PATH . 'functions/html.php' );
              if ($mailfetch_pass_[$i]=='') {
                   echo html_tag( 'tr',
                               html_tag( 'td', _("Password for") . ' <b>' .
-                                  (($mailfetch_alias_[$i]=='')?$mailfetch_server_[$i]:$mailfetch_alias_[$i]) .
+                                  htmlspecialchars((($mailfetch_alias_[$i]=='')?$mailfetch_server_[$i]:$mailfetch_alias_[$i])) .
                                   '</b>: &nbsp; &nbsp; ',
                               'right' ) .
-                              html_tag( 'td', '<input type="password" name="pass_' . $i , '">', 'left' )
+                              html_tag( 'td', '<input type="password" name="pass_' . $i . '">', 'left' )
                           );
              }
         }
         echo html_tag( 'tr',
                    html_tag( 'td', '&nbsp;' ) .
                    html_tag( 'td', '<input type=submit name=submit_mailfetch value="' . _("Fetch Mail"). '">', 'left' )
-               );
-
+               ) .
              '</table></form>';
         exit();
     }
@@ -123,6 +123,7 @@ require_once(SM_PATH . 'functions/html.php' );
     
     for ($i_loop=$i_start;$i_loop<$i_stop;$i_loop++) {
         $mailfetch_server=$mailfetch_server_[$i_loop];
+               $mailfetch_port=$mailfetch_port_[$i_loop];
         $mailfetch_user=$mailfetch_user_[$i_loop];
         if ($mailfetch_pass_[$i_loop]=="") {
             $tmp="pass_$i_loop";
@@ -142,7 +143,7 @@ require_once(SM_PATH . 'functions/html.php' );
         html_tag( 'table',
             html_tag( 'tr',
                 html_tag( 'td', '<b>' . _("Fetching from ") . 
-                    (($mailfetch_alias_[$i_loop] == '')?$mailfetch_server:$mailfetch_alias_[$i_loop]) . 
+                    htmlspecialchars((($mailfetch_alias_[$i_loop] == '')?$mailfetch_server:$mailfetch_alias_[$i_loop])) . 
                     '</b>',
                 'center' ) ,
             '', $color[9] ) ,
@@ -150,7 +151,7 @@ require_once(SM_PATH . 'functions/html.php' );
           
         flush();
         
-        if (!$pop3->connect($mailfetch_server)) {
+        if (!$pop3->connect($mailfetch_server,$mailfetch_port)) {
             Mail_Fetch_Status(_("Oops, ") . $pop3->ERROR );
             continue;
         }