Increment year in copyright notice.
[squirrelmail.git] / plugins / mail_fetch / fetch.php
index d2e6eaef5c81e2364689750efd7fb9fb75d5c2c2..898cecc0275c33c2f3c46c34e569af001278703d 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * mail_fetch/fetch.php
  *
- * Copyright (c) 1999-2003 The SquirrelMail Project Team
+ * Copyright (c) 1999-2005 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * Fetch code.
@@ -24,7 +24,7 @@ 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 */ 
+/* globals */
 sqgetGlobalVar('username',   $username,   SQ_SESSION);
 sqgetGlobalVar('key',        $key,        SQ_COOKIE);
 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
@@ -74,19 +74,19 @@ sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
     function Mail_Fetch_Select_Server($mailfetch) {
         global $PHP_SELF;
 
-        echo '<font size=-5><br></font>' .
-             "<form action=\"$PHP_SELF\" method=\"post\" target=\"_self\">" .
+        echo '<font size="-5"><br /></font>' .
+             '<form action="'.$PHP_SELF.'" method="post" target="_self">' .
              html_tag( 'table', '', 'center', '', 'width="70%" cols="2"' ) .
                  html_tag( 'tr' ) .
                      html_tag( 'td', _("Select Server:") . ' &nbsp; &nbsp;', 'right' ) .
                      html_tag( 'td', '', 'left' ) .
                          '<select name="server_to_fetch" size="1">' .
-                         '<option value="all" selected>..' . _("All") . "...\n";
+                         '<option value="all" selected="selected">..' . _("All") . "...\n";
         for ($i = 0;$i < $mailfetch['server_number'];$i++) {
              echo "<option value=\"$i\">" .
                  htmlspecialchars($mailfetch[$i]['alias']) .
                   '</option>' . "\n";
-        } 
+        }
         echo            '</select>' .
                     '</td>' .
                 '</tr>';
@@ -99,13 +99,13 @@ sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
                                   htmlspecialchars($mailfetch[$i]['alias']) .
                                   '</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' )
+                   html_tag( 'td', '<input type="submit" name="submit_mailfetch" value="' . _("Fetch Mail"). '" />', 'left' )
                ) .
              '</table></form>';
     }
@@ -113,7 +113,7 @@ sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
     $mailfetch = Mail_Fetch_Servers();
     displayPageHeader($color, 'None');
 
-    echo '<br><center>';
+    echo '<br /><center>';
 
     echo html_tag( 'table',
                html_tag( 'tr',
@@ -160,11 +160,11 @@ sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
 
         $pop3 = new POP3($mailfetch_server, 60);
 
-        echo '<br>' .
+        echo '<br />' .
         html_tag( 'table',
             html_tag( 'tr',
-                html_tag( 'td', '<b>' . _("Fetching from ") . 
-                    htmlspecialchars($mailfetch[$i_loop]['alias']) . 
+                html_tag( 'td', '<b>' . _("Fetching from ") .
+                    htmlspecialchars($mailfetch[$i_loop]['alias']) .
                     '</b>',
                 'center' ) ,
             '', $color[9] ) ,
@@ -183,7 +183,7 @@ sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
         Mail_Fetch_Status(_("Opening POP server"));
         $Count = $pop3->login($mailfetch_user, $mailfetch_pass);
         if (($Count == false || $Count == -1) && $pop3->ERROR != '') {
-            Mail_Fetch_Status(_("Login Failed:") . ' ' . $pop3->ERROR );
+            Mail_Fetch_Status(_("Login Failed:") . ' ' . htmlspecialchars($pop3->ERROR) );
             continue;
         }
 
@@ -210,7 +210,8 @@ sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
             continue;
         } else {
             $newmsgcount = $Count - $i + 1;
-            Mail_Fetch_Status(_("Login OK: Inbox contains [") . $newmsgcount . _("] messages"));
+            Mail_Fetch_Status(sprintf(ngettext("Login OK: Inbox contains %s message",
+                        "Login OK: Inbox contains %s messages",$newmsgcount), $newmsgcount));
         }
 
         Mail_Fetch_Status(_("Fetching UIDL..."));
@@ -228,7 +229,9 @@ sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
 
         for (; $i <= $Count; $i++) {
             Mail_Fetch_Status(_("Fetching message ") . "$i" );
-            set_time_limit(20); // 20 seconds per message max
+
+            if (!ini_get('safe_mode'))
+                set_time_limit(20); // 20 seconds per message max
             $Message = '';
             $MessArray = $pop3->get($i);
 
@@ -268,8 +271,10 @@ sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
                 fputs($imap_stream, $Message);
                 fputs($imap_stream, "\r\n");
                 sqimap_read_data($imap_stream, "A3$i", false, $response, $message);
+                $response=(implode('',$response));
+                $message=(implode('',$message));
                 if ($response != 'OK') {
-                    Mail_Fetch_Status(_("Error Appending Message!")." ".$message );
+                    Mail_Fetch_Status(_("Error Appending Message!")." ".htmlspecialchars($message) );
                     Mail_Fetch_Status(_("Closing POP"));
                     $pop3->quit();
                     Mail_Fetch_Status(_("Logging out from IMAP"));
@@ -286,7 +291,7 @@ sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
                    if( $pop3->delete($i) ) {
                         Mail_Fetch_Status(_("Message ") . $i . _(" deleted from Remote Server!"));
                    } else {
-                        Mail_Fetch_Status(_("Delete failed:") . $pop3->ERROR );
+                        Mail_Fetch_Status(_("Delete failed:") . htmlspecialchars($pop3->ERROR) );
                    }
                 }
             } else {
@@ -320,4 +325,4 @@ sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
 ?>
 </center>
 </body>
-</html>
+</html>
\ No newline at end of file