/**
* mail_fetch/fetch.php
*
- * Copyright (c) 1999-2003 The SquirrelMail Project Team
+ * Copyright (c) 1999-2004 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* Fetch code.
*
* $Id$
+ * @package plugins
+ * @subpackage mail_fetch
*/
+/** @ignore */
define('SM_PATH','../../');
require_once(SM_PATH . 'include/validate.php');
}
function Mail_Fetch_Servers() {
+ global $data_dir, $username;
+
$mailfetch['server_number'] = getPref($data_dir, $username, "mailfetch_server_number");
if (!isset($mailfetch['server_number']) || ($mailfetch['server_number'] < 1)) {
$mailfetch['server_number'] = 0;
}
function Mail_Fetch_Select_Server($mailfetch) {
+ global $PHP_SELF;
+
echo '<font size=-5><br></font>' .
"<form action=\"$PHP_SELF\" method=\"post\" target=\"_self\">" .
html_tag( 'table', '', 'center', '', 'width="70%" cols="2"' ) .
) ,
'center', '', 'width="95%" cols="1"' );
- if (!isset( $server_to_fetch ) ) {
+
+ /* there are no servers defined yet... */
+ if($mailfetch['server_number'] == 0) {
+ echo '<p>' . _("No POP3 servers configured yet.") . '</p>';
+ displayInternalLink('plugins/mail_fetch/options.php',
+ _("Click here to go to the options page.") );
+ echo '</body></html>';
+ exit();
+ }
+
+ // get $server_to_fetch from globals, if not set display a choice to the user
+ if (! sqgetGlobalVar('server_to_fetch', $server_to_fetch, SQ_POST) ) {
Mail_Fetch_Select_Server($mailfetch);
exit();
}
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;
}
continue;
} else {
$newmsgcount = $Count - $i + 1;
- Mail_Fetch_Status(_("Login OK: Inbox contains [") . $newmsgcount . _("] messages"));
+ Mail_Fetch_Status(sprintf(_("Login OK: Inbox contains %s messages"), $newmsgcount));
}
Mail_Fetch_Status(_("Fetching UIDL..."));
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);
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"));
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 {