Eliminated all eveil chdir statements.
[squirrelmail.git] / plugins / mail_fetch / fetch.php
index eb00fff5974f127b65f4219e7d3cf1a47ae48caa..8e23b67461d7c2efe7d9cc881a1ae5bfb7f924d3 100644 (file)
@@ -1,30 +1,33 @@
 <?php
 
-   /**
   **  mail_fetch/fetch.php
   **
   **  Copyright (c) 1999-2002 The SquirrelMail Project Team
   **  Licensed under the GNU GPL. For full terms see the file COPYING.
   **
   **  Fetch code.
   **
   **  $Id$
   **/
+/**
* mail_fetch/fetch.php
+ *
* Copyright (c) 1999-2002 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
* Fetch code.
+ *
* $Id$
+ */
 
-    chdir('..');
-    require_once('../src/validate.php');
-    require_once('../functions/page_header.php');
-    require_once('../functions/imap.php');
-    require_once('../src/load_prefs.php');
-    require_once('../plugins/mail_fetch/class.POP3.php');
-    require_once('../functions/i18n.php');
-    require_once( '../plugins/mail_fetch/functions.php' );
+define('SM_PATH','../../');
 
+require_once(SM_PATH . 'include/validate.php');
+require_once(SM_PATH . 'functions/page_header.php');
+require_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'include/load_prefs.php');
+require_once(SM_PATH . 'plugins/mail_fetch/class.POP3.php');
+require_once(SM_PATH . 'functions/i18n.php');
+require_once(SM_PATH . 'plugins/mail_fetch/functions.php' );
+require_once(SM_PATH . 'functions/html.php' );
 
     function Mail_Fetch_Status($msg) {
-        echo '<table width="90%"><tr><td>' .
-            htmlspecialchars( $msg ) .
-            '</td></tr></table>';
+        echo html_tag( 'table',
+                   html_tag( 'tr',
+                       html_tag( 'td', htmlspecialchars( $msg ) , 'left' )
+                   ),
+                 '', '', 'width="90%"' );
         flush();
     }
 
     
     echo '<br><center>';
     
-    echo '<TABLE WIDTH=95% COLS=1 ALIGN=CENTER>' .
-            "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><b>" . _("Remote POP server Fetching Mail") . '</b></TD></TR>' .
-         '</TABLE>';
+    echo html_tag( 'table',
+               html_tag( 'tr',
+                   html_tag( 'td', '<b>' . _("Remote POP server Fetching Mail") . '</b>', 'center', $color[0] )
+               ) ,
+           'center', '', 'width="95%" cols="1"' );
     
     if (!isset( $server_to_fetch ) ) {
         
-        echo '<font size=-5><BR></font>' .
-             "<form action=\"$PHP_SELF\" METHOD=POST TARGET=_self>" .
-             '<TABLE WIDTH=70% COLS=2 ALIGN=CENTER>' .
-                '<TR>' .
-                    '<TD ALIGN=RIGHT>' . _("Select Server:") . ' &nbsp; &nbsp; </TD>' .
-                    '<TD><SELECT NAME=server_to_fetch SIZE=1>' .
-                        '<OPTION VALUE="all" SELECTED>..' . _("All") . "...\n";
+        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";
         for ($i=0;$i<$mailfetch_server_number;$i++) {
-             echo "<OPTION VALUE=\"$i\">" .
-                  (($mailfetch_alias_[$i]=='')?$mailfetch_server_[$i]:$mailfetch_alias_[$i]);
+             echo "<option value=\"$i\">" .
+                  (($mailfetch_alias_[$i]=='')?$mailfetch_server_[$i]:$mailfetch_alias_[$i]) .
+                  '</option>' . "\n";
         } 
-        echo            '</SELECT>' .
-                    '</TD>' .
-                '</TR>';
+        echo            '</select>' .
+                    '</td>' .
+                '</tr>';
         
         //if password not set, ask for it
         for ($i=0;$i<$mailfetch_server_number;$i++) {
              if ($mailfetch_pass_[$i]=='') {
-                  echo '<tr>' .
-                       '<TD ALIGN=RIGHT>' . _("Password for") . ' <B>' . (($mailfetch_alias_[$i]=='')?$mailfetch_server_[$i]:$mailfetch_alias_[$i]) . '</B>: &nbsp; &nbsp; </TD>' .
-                       "<TD><INPUT TYPE=PASSWORD NAME=pass_$i></TD>" .
-                       '</TR>';
+                  echo html_tag( 'tr',
+                              html_tag( 'td', _("Password for") . ' <b>' .
+                                  (($mailfetch_alias_[$i]=='')?$mailfetch_server_[$i]:$mailfetch_alias_[$i]) .
+                                  '</b>: &nbsp; &nbsp; ',
+                              'right' ) .
+                              html_tag( 'td', '<input type="password" name="pass_' . $i , '">', 'left' )
+                          );
              }
         }
-        echo '<TR>' .
-                '<TD>&nbsp;</TD>' .
-                '<TD><input type=submit name=submit_mailfetch value="' . _("Fetch Mail"). '"></TD>'.
-                '</TR>' .
-             '</TABLE></form>';
+        echo html_tag( 'tr',
+                   html_tag( 'td', '&nbsp;' ) .
+                   html_tag( 'td', '<input type=submit name=submit_mailfetch value="' . _("Fetch Mail"). '">', 'left' )
+               );
+
+             '</table></form>';
         exit();
     }
 
         
         $pop3 = new POP3($mailfetch_server, 60);
         
-        echo "<br><table width=\"90%\"><tr bgcolor=\"$color[9]\"><td><b>" . 
-            _("Fetching from ") . 
-            (($mailfetch_alias_[$i_loop] == '')?$mailfetch_server:$mailfetch_alias_[$i_loop]) . 
-            "</b></td></tr></table>";
+        echo '<br>' .
+        html_tag( 'table',
+            html_tag( 'tr',
+                html_tag( 'td', '<b>' . _("Fetching from ") . 
+                    (($mailfetch_alias_[$i_loop] == '')?$mailfetch_server:$mailfetch_alias_[$i_loop]) . 
+                    '</b>',
+                'center' ) ,
+            '', $color[9] ) ,
+        '', '', 'width="90%"' );
           
         flush();
         
                  // re-connect pop3
                  Mail_Fetch_Status(_("Server error...Disconnect"));
                 $pop3->quit();
-                 Mail_Fetch_Status(_("Re-connect from dead connectoin"));
+                 Mail_Fetch_Status(_("Reconnect from dead connection"));
                  if (!$pop3->connect($mailfetch_server)) {
                      Mail_Fetch_Status(_("Oops, ") . $pop3->ERROR );
                      Mail_Fetch_Status(_("Saving UIDL"));
 
                      continue;
                  }
-                 Mail_Fetch_Status(_("Re-fetching message ") . "$i" );
+                 Mail_Fetch_Status(_("Refetching message ") . "$i" );
                 $MessArray = $pop3->get($i);
 
             } // end while