*/
/** Includes.. */
-require_once(SM_PATH . 'functions/page_header.php');
-require_once(SM_PATH . 'functions/auth.php');
-include_once(SM_PATH . 'functions/rfc822address.php');
+
+require_once(SM_PATH . 'functions/rfc822address.php');
/**
} else {
global $squirrelmail_language, $color;
set_up_language($squirrelmail_language);
- require_once(SM_PATH . 'functions/display_messages.php');
$string = "<b><font color=\"$color[2]\">\n" .
_("ERROR: No available IMAP stream.") .
"</b></font>\n";
- error_box($string,$color);
+ error_box($string);
return false;
}
}
} else {
global $squirrelmail_language, $color;
set_up_language($squirrelmail_language);
- require_once(SM_PATH . 'functions/display_messages.php');
$string = "<b><font color=\"$color[2]\">\n" .
_("ERROR: No available IMAP stream.") .
"</b></font>\n";
- error_box($string,$color);
+ error_box($string);
return false;
}
}
*/
function sqimap_read_data_list($imap_stream, $tag, $handle_errors,
&$response, &$message, $query = '') {
- global $color, $squirrelmail_language;
+ global $color, $oTemplate, $squirrelmail_language;
set_up_language($squirrelmail_language);
- require_once(SM_PATH . 'functions/display_messages.php');
$string = "<b><font color=\"$color[2]\">\n" .
_("ERROR: Bad function call.") .
"</b><br />\n" .
'sqimap_run_command or sqimap_run_command_list instead<br /><br />'.
'The following query was issued:<br />'.
htmlspecialchars($query) . '<br />' . "</font><br />\n";
- error_box($string,$color);
- echo '</body></html>';
+ error_box($string);
+ $oTemplate->display('footer.tpl');
exit;
}
global $color, $squirrelmail_language;
set_up_language($squirrelmail_language);
- require_once(SM_PATH . 'functions/display_messages.php');
$string = "<font color=\"$color[2]\"><b>\n" . $title . "</b><br />\n";
$cmd = explode(' ',$query);
$cmd= strtolower($cmd[0]);
$string .= "</font><br />\n";
if ($link != '')
$string .= $link;
- error_box($string,$color);
+ error_box($string);
}
/**
$aResponse = '';
$resultlist = array();
$data = array();
+ $sCommand = '';
+ if (preg_match("/^(\w+)\s*/",$query,$aMatch)) {
+ $sCommand = strtoupper($aMatch[1]);
+ } else {
+ // error reporting (shouldn't happen)
+ }
$read = sqimap_fgets($imap_stream);
$i = 0;
while ($read) {
case '*':
{
- if (preg_match('/^\*\s\d+\sFETCH/',$read)) {
+ if (($sCommand == "FETCH" || $sCommand == "STORE") && preg_match('/^\*\s\d+\sFETCH/',$read)) {
/* check for literal */
$s = substr($read,-3);
$fetch_data = array();
* Implementing IMAP STARTTLS (rfc2595) in php 5.1.0+
* http://www.php.net/stream-socket-enable-crypto
*/
- if ($tls == 2) {
+ if ($tls === 2) {
if (function_exists('stream_socket_enable_crypto')) {
// check starttls capability, don't use cached capability version
if (! sqimap_capability($imap_stream, 'STARTTLS', false)) {
* Logs the user into the IMAP server. If $hide is set, no error messages
* will be displayed. This function returns the IMAP connection handle.
* @param string $username user name
- * @param string $password encrypted password
+ * @param string $password password encrypted with onetimepad. Since 1.5.2
+ * function can use internal password functions, if parameter is set to
+ * boolean false.
* @param string $imap_server_address address of imap server
* @param integer $imap_port port of imap server
* @param boolean $hide controls display connection errors
global $color, $squirrelmail_language, $onetimepad, $use_imap_tls,
$imap_auth_mech, $sqimap_capabilities;
- if (!isset($onetimepad) || empty($onetimepad)) {
- sqgetglobalvar('onetimepad' , $onetimepad , SQ_SESSION );
+ /* get imap login password */
+ if ($password===false) {
+ /* standard functions */
+ $password = sqauth_read_password();
+ } else {
+ /* old way. $key must be extracted from cookie */
+ if (!isset($onetimepad) || empty($onetimepad)) {
+ sqgetglobalvar('onetimepad' , $onetimepad , SQ_SESSION );
+ }
+ /* Decrypt the password */
+ $password = OneTimePadDecrypt($password, $onetimepad);
}
+
if (!isset($sqimap_capabilities)) {
- sqgetglobalvar('sqimap_capabilities' , $capability , SQ_SESSION );
+ sqgetglobalvar('sqimap_capabilities' , $sqimap_capabilities , SQ_SESSION );
}
$host = $imap_server_address;
$imap_stream = sqimap_create_stream($imap_server_address,$imap_port,$use_imap_tls);
- /* Decrypt the password */
- $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
$tag=sqimap_session_id(false);
*
**/
$tag=sqimap_session_id(false);
- $sasl = (isset($capability['SASL-IR']) && $capability['SASL-IR']) ? true : false;
+ $sasl = (isset($sqimap_capabilities['SASL-IR']) && $sqimap_capabilities['SASL-IR']) ? true : false;
$auth = base64_encode("$username\0$username\0$password");
if ($sasl) {
// IMAP Extension for SASL Initial Client Response
/* "BAD" and anything else gets reported here. */
$message = htmlspecialchars($message);
set_up_language($squirrelmail_language, true);
- require_once(SM_PATH . 'functions/display_messages.php');
if ($response == 'BAD') {
$string = sprintf (_("Bad request: %s")."<br />\r\n", $message);
} else {
$string .= htmlspecialchars($line) . "<br />\n";
}
}
- error_box($string,$color);
+ error_box($string);
exit;
} else {
/*
*/
set_up_language($squirrelmail_language, true);
- include_once(SM_PATH . 'functions/display_messages.php' );
sqsession_destroy();
+ sqsetcookieflush();
/* terminate the session nicely */
sqimap_logout($imap_stream);
logout_error( _("Unknown user or password incorrect.") );
if ( stristr($message, 'REFERRAL imap') === TRUE ) {
sqimap_logout($imap_stream);
set_up_language($squirrelmail_language, true);
- include_once(SM_PATH . 'functions/display_messages.php' );
sqsession_destroy();
logout_error( _("Your mailbox is not located at this server. Try a different server or consult your system administrator") );
exit;
if (!$bUseCache || ! sqgetGlobalVar('sqimap_capabilities', $sqimap_capabilities, SQ_SESSION)) {
$read = sqimap_run_command($imap_stream, 'CAPABILITY', true, $a, $b);
-
$c = explode(' ', $read[0]);
for ($i=2; $i < count($c); $i++) {
$cap_list = explode('=', $c[$i]);
if (isset($cap_list[1])) {
+ if(isset($sqimap_capabilities[trim($cap_list[0])]) &&
+ !is_array($sqimap_capabilities[trim($cap_list[0])])) {
+ // Remove array key that was added in 'else' block below
+ // This is to accomodate for capabilities like:
+ // SORT SORT=MODSEQ
+ unset($sqimap_capabilities[trim($cap_list[0])]);
+ }
$sqimap_capabilities[trim($cap_list[0])][] = $cap_list[1];
} else {
- $sqimap_capabilities[trim($cap_list[0])] = TRUE;
+ if(!isset($sqimap_capabilities[trim($cap_list[0])])) {
+ $sqimap_capabilities[trim($cap_list[0])] = TRUE;
+ }
}
}
}
* @since 1.5.1 and 1.4.5
*/
function sqimap_append_checkresponse($response, $sMailbox, $sid='', $query='') {
- global $color;
// static vars to keep them available when sqimap_append_done calls this function.
static $imapquery, $imapsid;
$yp = `ypmatch $username aliases`;
return chop(substr($yp, strlen($username)+1));
}
-
-?>
\ No newline at end of file