/**
* imap_general.php
*
- * Copyright (c) 1999-2004 The SquirrelMail Project Team
+ * Copyright (c) 1999-2005 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* This implements all functions that do general imap functions.
$read = sqimap_read_data ($imap_stream, $tag, $handle_errors, $response,
$message, $query,$filter,$outputstream,$no_return);
- if (empty($read)) { //Imap server dropped its connection
+ if (empty($read)) { //Imap server dropped its connection
$response = '';
$message = '';
return false;
if ($iRemaining < $iBufferSize) {
$iBufferSize = $iRemaining;
}
- if (!$sRead) {
+ if ($sRead == '') {
$results = false;
break;
}
- if ($sReadRem) {
+ if ($sReadRem != '') {
$sRead = $sReadRem . $sRead;
$sReadRem = '';
}
- if ($filter && $sRead) {
+ if ($filter && $sRead != '') {
// in case the filter is base64 decoding we return a remainder
$sReadRem = $filter($sRead);
}
- if ($outputstream && $sRead) {
+ if ($outputstream && $sRead != '') {
if (is_resource($outputstream)) {
fwrite($outputstream,$sRead);
} else if ($outputstream == 'php://stdout') {
$resultlist = array();
$data = array();
$read = sqimap_fgets($imap_stream);
- $i = $k = 0;
+ $i = 0;
while ($read) {
$char = $read{0};
switch ($char)
}
$read = sqimap_fgets($imap_stream);
if ($read === false) { /* error */
- break 3; /* switch switch while */
+ break 2; /* switch while */
}
break;
} // end case $tag{0}
* @return imap-stream resource identifier
*/
function sqimap_create_stream($server,$port,$tls=false) {
- global $username, $use_imap_tls;
+ global $squirrelmail_language;
if ($tls == true) {
if ((check_php_version(4,3)) and (extension_loaded('openssl'))) {
$server = 'tls://' . $server;
} else {
require_once(SM_PATH . 'functions/display_messages.php');
- $string = "Unable to connect to IMAP server!<br />TLS is enabled, but this " .
- "version of PHP does not support TLS sockets, or is missing the openssl " .
- "extension.<br /><br />Please contact your system administrator.";
- logout_error($string,$color);
+ logout_error( sprintf(_("Error connecting to IMAP server: %s."), $server).
+ '<br />'.
+ _("TLS is enabled, but this version of PHP does not support TLS sockets, or is missing the openssl extension.").
+ '<br /><br />'.
+ _("Please contact your system administrator and report this error.") );
}
}
if (!$imap_stream) {
set_up_language($squirrelmail_language, true);
require_once(SM_PATH . 'functions/display_messages.php');
- $string = sprintf (_("Error connecting to IMAP server: %s.") .
- "<br />\r\n", $server) .
- "$error_number : $error_string<br />\r\n";
- logout_error($string,$color);
+ logout_error( sprintf(_("Error connecting to IMAP server: %s."), $server).
+ "<br />\r\n$error_number : $error_string<br />\r\n" );
exit;
}
$server_info = fgets ($imap_stream, 1024);
$password = OneTimePadDecrypt($password, $onetimepad);
if (($imap_auth_mech == 'cram-md5') OR ($imap_auth_mech == 'digest-md5')) {
- // We're using some sort of authentication OTHER than plain or login
+ // We're using some sort of authentication OTHER than plain or login
$tag=sqimap_session_id(false);
if ($imap_auth_mech == 'digest-md5') {
$query = $tag . " AUTHENTICATE DIGEST-MD5\r\n";
fputs($imap_stream,$reply);
$read=sqimap_fgets($imap_stream);
if ($imap_auth_mech == 'digest-md5') {
- // DIGEST-MD5 has an extra step..
+ // DIGEST-MD5 has an extra step..
if (substr($read,0,1) == '+') { // OK so far..
fputs($imap_stream,"\r\n");
$read=sqimap_fgets($imap_stream);
$response=$results[1];
$message=$results[2];
} else {
- // Fake the response, so the error trap at the bottom will work
+ // Fake the response, so the error trap at the bottom will work
$response="BAD";
$message='IMAP server does not appear to support the authentication method selected.';
$message .= ' Please contact your system administrator.';
set_up_language($squirrelmail_language, true);
include_once(SM_PATH . 'functions/display_messages.php' );
sqsession_destroy();
+ /* terminate the session nicely */
+ sqimap_logout($imap_stream);
logout_error( _("Unknown user or password incorrect.") );
exit;
}
} else {
fputs ($imap_stream, ". LIST \"INBOX\" \"\"\r\n");
$read = sqimap_read_data($imap_stream, '.', true, $a, $b);
- $read = $read['.'][0]; //sqimap_read_data() now returns a tag array of response array
+ $read = $read['.'][0]; //sqimap_read_data() now returns a tag array of response array
$quote_position = strpos ($read[0], '"');
$sqimap_delimiter = substr ($read[0], $quote_position+1, 1);
}
*/
function sqimap_encode_mailbox_name($what)
{
- if (ereg("[\"\\\r\n]", $what))
- return '{' . strlen($what) . "}\r\n" . $what; /* 4.3 literal form */
- return '"' . $what . '"'; /* 4.3 quoted string form */
+ if (ereg("[\"\\\r\n]", $what))
+ return '{' . strlen($what) . "}\r\n" . $what; /* 4.3 literal form */
+ return '"' . $what . '"'; /* 4.3 quoted string form */
}
/**