X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=functions%2Fimap_general.php;h=a0db4b45dc9dec0cac23b23657df39cf3747fb8a;hb=1cbd87548bd63a925cb3d4ce025ae40b616b7c64;hp=56e551fe073d108f1788348f6dbe298c1f5f3bd0;hpb=b35a58627a97bab88b8d519aa2cb0fc5f44aa25f;p=squirrelmail.git
diff --git a/functions/imap_general.php b/functions/imap_general.php
index 56e551fe..a0db4b45 100755
--- a/functions/imap_general.php
+++ b/functions/imap_general.php
@@ -3,25 +3,24 @@
/**
* imap_general.php
*
- * 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.
+ * This implements all functions that do general IMAP functions.
*
+ * @copyright © 1999-2007 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
* @subpackage imap
*/
/** Includes.. */
-require_once(SM_PATH . 'functions/page_header.php');
-require_once(SM_PATH . 'functions/auth.php');
+
+require_once(SM_PATH . 'functions/rfc822address.php');
/**
* Generates a new session ID by incrementing the last one used;
* this ensures that each command has a unique ID.
- * @param bool $unique_id (since 1.3.0) controls use of unique
+ * @param bool $unique_id (since 1.3.0) controls use of unique
* identifiers/message sequence numbers in IMAP commands. See IMAP
* rfc 'UID command' chapter.
* @return string IMAP session id of the form 'A000'.
@@ -40,15 +39,13 @@ function sqimap_session_id($unique_id = FALSE) {
/**
* Both send a command and accept the result from the command.
* This is to allow proper session number handling.
- * @param resource $imap_stream imap connection resource
+ * @param stream $imap_stream imap connection resource
* @param string $query imap command
* @param boolean $handle_errors see sqimap_retrieve_imap_response()
- * @param mixed $response
- * @param mixed $message
- * @param boolean $unique_id (since 1.3.0) controls use of unique
- * identifiers/message sequence numbers in IMAP commands. See IMAP
- * rfc 'UID command' chapter.
- * @return mixed returns false on imap error. displays error message
+ * @param array $response
+ * @param array $message
+ * @param boolean $unique_id (since 1.3.0) see sqimap_session_id().
+ * @return mixed returns false on imap error. displays error message
* if imap stream is not available.
* @since 1.2.3
*/
@@ -66,28 +63,25 @@ function sqimap_run_command_list ($imap_stream, $query, $handle_errors, &$respon
} else {
global $squirrelmail_language, $color;
set_up_language($squirrelmail_language);
- require_once(SM_PATH . 'functions/display_messages.php');
$string = "\n" .
- _("ERROR : No available imapstream.") .
+ _("ERROR: No available IMAP stream.") .
"\n";
- error_box($string,$color);
+ error_box($string);
return false;
}
}
/**
- * @param resource $imap_stream imap connection resource
+ * @param stream $imap_stream imap connection resource
* @param string $query imap command
* @param boolean $handle_errors see sqimap_retrieve_imap_response()
- * @param mixed $response
- * @param mixed $message
- * @param boolean $unique_id (since 1.3.0) controls use of unique
- * identifiers/message sequence numbers in IMAP commands. See IMAP
- * rfc 'UID command' chapter.
- * @param mixed $filter (since 1.4.1 and 1.5.0)
- * @param mixed $outputstream (since 1.4.1 and 1.5.0)
- * @param mixed $no_return (since 1.4.1 and 1.5.0)
- * @return mixed returns false on imap error. displays error message
+ * @param array $response empty string, if return = false
+ * @param array $message empty string, if return = false
+ * @param boolean $unique_id (since 1.3.0) see sqimap_session_id()
+ * @param boolean $filter (since 1.4.1 and 1.5.0) see sqimap_fread()
+ * @param mixed $outputstream (since 1.4.1 and 1.5.0) see sqimap_fread()
+ * @param boolean $no_return (since 1.4.1 and 1.5.0) see sqimap_fread()
+ * @return mixed returns false on imap error. displays error message
* if imap stream is not available.
* @since 1.2.3
*/
@@ -102,7 +96,7 @@ function sqimap_run_command ($imap_stream, $query, $handle_errors, &$response,
$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;
@@ -119,15 +113,21 @@ function sqimap_run_command ($imap_stream, $query, $handle_errors, &$response,
} else {
global $squirrelmail_language, $color;
set_up_language($squirrelmail_language);
- require_once(SM_PATH . 'functions/display_messages.php');
$string = "\n" .
- _("ERROR : No available imapstream.") .
+ _("ERROR: No available IMAP stream.") .
"\n";
- error_box($string,$color);
+ error_box($string);
return false;
}
}
+/**
+ * @param mixed $new_query
+ * @param string $tag
+ * @param array $aQuery
+ * @param boolean $unique_id see sqimap_session_id()
+ * @since 1.5.0
+ */
function sqimap_prepare_pipelined_query($new_query,&$tag,&$aQuery,$unique_id) {
$sid = sqimap_session_id($unique_id);
$tag_uid_a = explode(' ',trim($sid));
@@ -136,15 +136,27 @@ function sqimap_prepare_pipelined_query($new_query,&$tag,&$aQuery,$unique_id) {
$aQuery[$tag] = $query;
}
+/**
+ * @param stream $imap_stream imap stream
+ * @param array $aQueryList
+ * @param boolean $handle_errors
+ * @param array $aServerResponse
+ * @param array $aServerMessage
+ * @param boolean $unique_id see sqimap_session_id()
+ * @param boolean $filter see sqimap_fread()
+ * @param mixed $outputstream see sqimap_fread()
+ * @param boolean $no_return see sqimap_fread()
+ * @since 1.5.0
+ */
function sqimap_run_pipelined_command ($imap_stream, $aQueryList, $handle_errors,
&$aServerResponse, &$aServerMessage, $unique_id = false,
$filter=false,$outputstream=false,$no_return=false) {
$aResponse = false;
/*
- Do not fire all calls at once to the imap-server but split the calls up
+ Do not fire all calls at once to the IMAP server but split the calls up
in portions of $iChunkSize. If we do not do that I think we misbehave as
- IMAP client or should handle BYE calls if the IMAP-server drops the
+ IMAP client or should handle BYE calls if the IMAP server drops the
connection because the number of queries is to large. This isn't tested
but a wild guess how it could work in the field.
@@ -200,10 +212,11 @@ function sqimap_run_pipelined_command ($imap_stream, $aQueryList, $handle_errors
}
/**
- * Custom fgets function: gets a line from the IMAP-server,
+ * Custom fgets function: gets a line from the IMAP server,
* no matter how big it may be.
- * @param stream imap_stream the stream to read from
+ * @param stream $imap_stream the stream to read from
* @return string a line
+ * @since 1.2.8
*/
function sqimap_fgets($imap_stream) {
$read = '';
@@ -225,6 +238,15 @@ function sqimap_fgets($imap_stream) {
return $results;
}
+/**
+ * @param stream $imap_stream
+ * @param integer $iSize
+ * @param boolean $filter
+ * @param mixed $outputstream stream or 'php://stdout' string
+ * @param boolean $no_return controls data returned by function
+ * @return string
+ * @since 1.4.1
+ */
function sqimap_fread($imap_stream,$iSize,$filter=false,
$outputstream=false, $no_return=false) {
if (!$filter || !$outputstream) {
@@ -281,16 +303,21 @@ function sqimap_fread($imap_stream,$iSize,$filter=false,
/**
* Obsolete function, inform plugins that use it
+ * @param stream $imap_stream
+ * @param string $tag
+ * @param boolean $handle_errors
+ * @param array $response
+ * @param array $message
+ * @param string $query
* @since 1.1.3
* @deprecated (since 1.5.0) use sqimap_run_command or sqimap_run_command_list instead
*/
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 = "\n" .
- _("ERROR : Bad function call.") .
+ _("ERROR: Bad function call.") .
"
\n" .
_("Reason:") . ' '.
'There is a plugin installed which make use of the
' .
@@ -299,26 +326,26 @@ function sqimap_read_data_list($imap_stream, $tag, $handle_errors,
'sqimap_run_command or sqimap_run_command_list instead
'.
'The following query was issued:
'.
htmlspecialchars($query) . '
' . "
\n";
- error_box($string,$color);
- echo '