|
@@ -11,46 +11,32 @@
|
|
* $Id$
|
|
* $Id$
|
|
*/
|
|
*/
|
|
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Copies specified messages to specified folder
|
|
|
|
- ****************************************************************************/
|
|
|
|
|
|
+/* Copies specified messages to specified folder */
|
|
function sqimap_messages_copy ($imap_stream, $start, $end, $mailbox) {
|
|
function sqimap_messages_copy ($imap_stream, $start, $end, $mailbox) {
|
|
$read = sqimap_run_command ($imap_stream, "COPY $start:$end \"$mailbox\"", true, $response, $message);
|
|
$read = sqimap_run_command ($imap_stream, "COPY $start:$end \"$mailbox\"", true, $response, $message);
|
|
}
|
|
}
|
|
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Deletes specified messages and moves them to trash if possible
|
|
|
|
- ****************************************************************************/
|
|
|
|
|
|
+/* Deletes specified messages and moves them to trash if possible */
|
|
function sqimap_messages_delete ($imap_stream, $start, $end, $mailbox) {
|
|
function sqimap_messages_delete ($imap_stream, $start, $end, $mailbox) {
|
|
global $move_to_trash, $trash_folder, $auto_expunge;
|
|
global $move_to_trash, $trash_folder, $auto_expunge;
|
|
|
|
|
|
if (($move_to_trash == true) && (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder))) {
|
|
if (($move_to_trash == true) && (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder))) {
|
|
sqimap_messages_copy ($imap_stream, $start, $end, $trash_folder);
|
|
sqimap_messages_copy ($imap_stream, $start, $end, $trash_folder);
|
|
- sqimap_messages_flag ($imap_stream, $start, $end, "Deleted");
|
|
|
|
- } else {
|
|
|
|
- sqimap_messages_flag ($imap_stream, $start, $end, "Deleted");
|
|
|
|
}
|
|
}
|
|
|
|
+ sqimap_messages_flag ($imap_stream, $start, $end, "Deleted");
|
|
}
|
|
}
|
|
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Sets the specified messages with specified flag
|
|
|
|
- ****************************************************************************/
|
|
|
|
|
|
+/* Sets the specified messages with specified flag */
|
|
function sqimap_messages_flag ($imap_stream, $start, $end, $flag) {
|
|
function sqimap_messages_flag ($imap_stream, $start, $end, $flag) {
|
|
$read = sqimap_run_command ($imap_stream, "STORE $start:$end +FLAGS (\\$flag)", true, $response, $message);
|
|
$read = sqimap_run_command ($imap_stream, "STORE $start:$end +FLAGS (\\$flag)", true, $response, $message);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Remove specified flag from specified messages
|
|
|
|
- ****************************************************************************/
|
|
|
|
|
|
+/* Remove specified flag from specified messages */
|
|
function sqimap_messages_remove_flag ($imap_stream, $start, $end, $flag) {
|
|
function sqimap_messages_remove_flag ($imap_stream, $start, $end, $flag) {
|
|
$read = sqimap_run_command ($imap_stream, "STORE $start:$end -FLAGS (\\$flag)", true, $response, $message);
|
|
$read = sqimap_run_command ($imap_stream, "STORE $start:$end -FLAGS (\\$flag)", true, $response, $message);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Returns some general header information -- FROM, DATE, and SUBJECT
|
|
|
|
- ****************************************************************************/
|
|
|
|
|
|
+/* Returns some general header information -- FROM, DATE, and SUBJECT */
|
|
class small_header {
|
|
class small_header {
|
|
var $from = '', $subject = '', $date = '', $to = '',
|
|
var $from = '', $subject = '', $date = '', $to = '',
|
|
$priority = 0, $message_id = 0, $cc = '';
|
|
$priority = 0, $message_id = 0, $cc = '';
|
|
@@ -60,8 +46,9 @@ function sqimap_get_small_header ($imap_stream, $id, $sent) {
|
|
$res = sqimap_get_small_header_list($imap_stream, array($id), $sent);
|
|
$res = sqimap_get_small_header_list($imap_stream, array($id), $sent);
|
|
return $res[0];
|
|
return $res[0];
|
|
}
|
|
}
|
|
-
|
|
|
|
-/* Sort the message list and crunch to be as small as possible
|
|
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Sort the message list and crunch to be as small as possible
|
|
* (overflow could happen, so make it small if possible)
|
|
* (overflow could happen, so make it small if possible)
|
|
*/
|
|
*/
|
|
function sqimap_message_list_squisher($messages_array) {
|
|
function sqimap_message_list_squisher($messages_array) {
|
|
@@ -84,9 +71,9 @@ function sqimap_message_list_squisher($messages_array) {
|
|
$msgs_str .= ':' . $end;
|
|
$msgs_str .= ':' . $end;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return $msgs_str;
|
|
return $msgs_str;
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
|
|
function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
|
|
function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
|
|
global $squirrelmail_language, $color, $data_dir, $username;
|
|
global $squirrelmail_language, $color, $data_dir, $username;
|
|
@@ -99,7 +86,7 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
|
|
$read_list = array();
|
|
$read_list = array();
|
|
$sizes_list = array();
|
|
$sizes_list = array();
|
|
|
|
|
|
- /**
|
|
|
|
|
|
+ /*
|
|
* We need to return the data in the same order as the caller supplied
|
|
* We need to return the data in the same order as the caller supplied
|
|
* in $msg_list, but IMAP servers are free to return responses in
|
|
* in $msg_list, but IMAP servers are free to return responses in
|
|
* whatever order they wish... So we need to re-sort manually
|
|
* whatever order they wish... So we need to re-sort manually
|
|
@@ -120,7 +107,6 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
|
|
'</b><br>' .
|
|
'</b><br>' .
|
|
_("Unknown response from IMAP server: ") . ' 1.' .
|
|
_("Unknown response from IMAP server: ") . ' 1.' .
|
|
$r[0] . "</font><br>\n";
|
|
$r[0] . "</font><br>\n";
|
|
- /* exit; */
|
|
|
|
} else if (! isset($id2index[$regs[1]]) || !count($id2index[$regs[1]])) {
|
|
} else if (! isset($id2index[$regs[1]]) || !count($id2index[$regs[1]])) {
|
|
set_up_language($squirrelmail_language);
|
|
set_up_language($squirrelmail_language);
|
|
echo '<br><b><font color=$color[2]>' .
|
|
echo '<br><b><font color=$color[2]>' .
|
|
@@ -128,17 +114,16 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
|
|
'</b><br>' .
|
|
'</b><br>' .
|
|
_("Unknown message number in reply from server: ") .
|
|
_("Unknown message number in reply from server: ") .
|
|
$regs[1] . "</font><br>\n";
|
|
$regs[1] . "</font><br>\n";
|
|
- /* exit */
|
|
|
|
} else {
|
|
} else {
|
|
$read_list[$id2index[$regs[1]]] = $r;
|
|
$read_list[$id2index[$regs[1]]] = $r;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
arsort($read_list);
|
|
arsort($read_list);
|
|
-
|
|
|
|
|
|
+
|
|
$query = "$sid FETCH $msgs_str RFC822.SIZE\r\n";
|
|
$query = "$sid FETCH $msgs_str RFC822.SIZE\r\n";
|
|
fputs ($imap_stream, $query);
|
|
fputs ($imap_stream, $query);
|
|
$sizesin_list = sqimap_read_data_list($imap_stream, $sid, true, $response, $message);
|
|
$sizesin_list = sqimap_read_data_list($imap_stream, $sid, true, $response, $message);
|
|
-
|
|
|
|
|
|
+
|
|
foreach ($sizesin_list as $r) {
|
|
foreach ($sizesin_list as $r) {
|
|
if (!eregi("^\\* ([0-9]+) FETCH", $r[0], $regs)) {
|
|
if (!eregi("^\\* ([0-9]+) FETCH", $r[0], $regs)) {
|
|
set_up_language($squirrelmail_language);
|
|
set_up_language($squirrelmail_language);
|
|
@@ -161,7 +146,7 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
|
|
$sizes_list[$id2index[$regs[1]]] = $r;
|
|
$sizes_list[$id2index[$regs[1]]] = $r;
|
|
}
|
|
}
|
|
arsort($sizes_list);
|
|
arsort($sizes_list);
|
|
-
|
|
|
|
|
|
+
|
|
for ($msgi = 0; $msgi < $maxmsg; $msgi++) {
|
|
for ($msgi = 0; $msgi < $maxmsg; $msgi++) {
|
|
$subject = _("(no subject)");
|
|
$subject = _("(no subject)");
|
|
$from = _("Unknown Sender");
|
|
$from = _("Unknown Sender");
|
|
@@ -174,52 +159,50 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
|
|
$type[1] = "";
|
|
$type[1] = "";
|
|
$read = $read_list[$msgi];
|
|
$read = $read_list[$msgi];
|
|
|
|
|
|
- for ($i = 0; $i < count($read); $i++) {
|
|
|
|
- if (eregi ("^to:(.*)$", $read[$i], $regs)) {
|
|
|
|
- /*$to = sqimap_find_displayable_name(substr($read[$i], 3));*/
|
|
|
|
|
|
+ foreach ($read as $read_part) {
|
|
|
|
+ if (eregi ("^to:(.*)$", $read_part, $regs)) {
|
|
$to = $regs[1];
|
|
$to = $regs[1];
|
|
- } else if (eregi ("^from:(.*)$", $read[$i], $regs)) {
|
|
|
|
- /*$from = sqimap_find_displayable_name(substr($read[$i], 5));*/
|
|
|
|
|
|
+ } else if (eregi ("^from:(.*)$", $read_part, $regs)) {
|
|
$from = $regs[1];
|
|
$from = $regs[1];
|
|
- } else if (eregi ("^x-priority:(.*)$", $read[$i], $regs)) {
|
|
|
|
|
|
+ } else if (eregi ("^x-priority:(.*)$", $read_part, $regs)) {
|
|
$priority = trim($regs[1]);
|
|
$priority = trim($regs[1]);
|
|
- } else if (eregi ("^message-id:(.*)$", $read[$i], $regs)) {
|
|
|
|
|
|
+ } else if (eregi ("^message-id:(.*)$", $read_part, $regs)) {
|
|
$messageid = trim($regs[1]);
|
|
$messageid = trim($regs[1]);
|
|
- } else if (eregi ("^cc:(.*)$", $read[$i], $regs)) {
|
|
|
|
|
|
+ } else if (eregi ("^cc:(.*)$", $read_part, $regs)) {
|
|
$cc = $regs[1];
|
|
$cc = $regs[1];
|
|
- } else if (eregi ("^date:(.*)$", $read[$i], $regs)) {
|
|
|
|
|
|
+ } else if (eregi ("^date:(.*)$", $read_part, $regs)) {
|
|
$date = $regs[1];
|
|
$date = $regs[1];
|
|
- } else if (eregi ("^subject:(.*)$", $read[$i], $regs)) {
|
|
|
|
|
|
+ } else if (eregi ("^subject:(.*)$", $read_part, $regs)) {
|
|
$subject = htmlspecialchars(trim($regs[1]));
|
|
$subject = htmlspecialchars(trim($regs[1]));
|
|
if ($subject == "") {
|
|
if ($subject == "") {
|
|
$subject = _("(no subject)");
|
|
$subject = _("(no subject)");
|
|
}
|
|
}
|
|
- } else if (eregi ("^content-type:(.*)$", $read[$i], $regs)) {
|
|
|
|
|
|
+ } else if (eregi ("^content-type:(.*)$", $read_part, $regs)) {
|
|
$type = strtolower(trim($regs[1]));
|
|
$type = strtolower(trim($regs[1]));
|
|
if ($pos = strpos($type, ";")) {
|
|
if ($pos = strpos($type, ";")) {
|
|
$type = substr($type, 0, $pos);
|
|
$type = substr($type, 0, $pos);
|
|
}
|
|
}
|
|
$type = explode("/", $type);
|
|
$type = explode("/", $type);
|
|
- if (! isset($type[1])) {
|
|
|
|
|
|
+ if (!isset($type[1])) {
|
|
$type[1] = '';
|
|
$type[1] = '';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $internaldate = getPref($data_dir, $username, 'internal_date_sort');
|
|
|
|
|
|
+ $internaldate = getPref($data_dir, $username, 'internal_date_sort');
|
|
if (trim($date) == "" || $internaldate) {
|
|
if (trim($date) == "" || $internaldate) {
|
|
fputs($imap_stream, "$sid FETCH $msg_list[$msgi] INTERNALDATE\r\n");
|
|
fputs($imap_stream, "$sid FETCH $msg_list[$msgi] INTERNALDATE\r\n");
|
|
$readdate = sqimap_read_data($imap_stream, $sid, true, $response, $message);
|
|
$readdate = sqimap_read_data($imap_stream, $sid, true, $response, $message);
|
|
if (eregi(".*INTERNALDATE \"(.*)\".*", $readdate[0], $regs)) {
|
|
if (eregi(".*INTERNALDATE \"(.*)\".*", $readdate[0], $regs)) {
|
|
- $date_list = explode(" ", trim($regs[1]));
|
|
|
|
- $date_list[0] = str_replace("-", " ", $date_list[0]);
|
|
|
|
- $date = implode(" ", $date_list);
|
|
|
|
|
|
+ $date_list = explode(' ', trim($regs[1]));
|
|
|
|
+ $date_list[0] = str_replace("-", ' ', $date_list[0]);
|
|
|
|
+ $date = implode(' ', $date_list);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
eregi("([0-9]+)[^0-9]*$", $sizes_list[$msgi][0], $regs);
|
|
eregi("([0-9]+)[^0-9]*$", $sizes_list[$msgi][0], $regs);
|
|
$size = $regs[1];
|
|
$size = $regs[1];
|
|
-
|
|
|
|
|
|
+
|
|
$header = new small_header;
|
|
$header = new small_header;
|
|
- if ($issent == true) {
|
|
|
|
|
|
+ if ($issent) {
|
|
$header->from = (trim($to) != '' ? $to : '(' ._("No To Address") . ')');
|
|
$header->from = (trim($to) != '' ? $to : '(' ._("No To Address") . ')');
|
|
} else {
|
|
} else {
|
|
$header->from = $from;
|
|
$header->from = $from;
|
|
@@ -240,15 +223,13 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
|
|
return $result;
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Returns the flags for the specified messages
|
|
|
|
- ****************************************************************************/
|
|
|
|
|
|
+/* Returns the flags for the specified messages */
|
|
function sqimap_get_flags ($imap_stream, $i) {
|
|
function sqimap_get_flags ($imap_stream, $i) {
|
|
$read = sqimap_run_command ($imap_stream, "FETCH $i:$i FLAGS", true, $response, $message);
|
|
$read = sqimap_run_command ($imap_stream, "FETCH $i:$i FLAGS", true, $response, $message);
|
|
- if (ereg("FLAGS(.*)", $read[0], $regs)) {
|
|
|
|
|
|
+ if (ereg('FLAGS(.*)', $read[0], $regs)) {
|
|
return explode(' ', trim(ereg_replace('[\\(\\)\\\\]', '', $regs[1])));
|
|
return explode(' ', trim(ereg_replace('[\\(\\)\\\\]', '', $regs[1])));
|
|
}
|
|
}
|
|
- return Array('None');
|
|
|
|
|
|
+ return array('None');
|
|
}
|
|
}
|
|
|
|
|
|
function sqimap_get_flags_list ($imap_stream, $msg_list) {
|
|
function sqimap_get_flags_list ($imap_stream, $msg_list) {
|
|
@@ -260,7 +241,7 @@ function sqimap_get_flags_list ($imap_stream, $msg_list) {
|
|
$result_flags = array();
|
|
$result_flags = array();
|
|
|
|
|
|
for ($i = 0; $i < sizeof($result_list); $i++) {
|
|
for ($i = 0; $i < sizeof($result_list); $i++) {
|
|
- if (eregi("^\\* ([0-9]+).*FETCH.*FLAGS(.*)", $result_list[$i][0], $regs)
|
|
|
|
|
|
+ if (eregi('^\* ([0-9]+).*FETCH.*FLAGS(.*)', $result_list[$i][0], $regs)
|
|
&& isset($id2index[$regs[1]]) && count($id2index[$regs[1]])) {
|
|
&& isset($id2index[$regs[1]]) && count($id2index[$regs[1]])) {
|
|
$result_flags[$id2index[$regs[1]]] = explode(" ", trim(ereg_replace('[\\(\\)\\\\]', '', $regs[2])));
|
|
$result_flags[$id2index[$regs[1]]] = explode(" ", trim(ereg_replace('[\\(\\)\\\\]', '', $regs[2])));
|
|
} else {
|
|
} else {
|
|
@@ -277,31 +258,25 @@ function sqimap_get_flags_list ($imap_stream, $msg_list) {
|
|
return $result_flags;
|
|
return $result_flags;
|
|
}
|
|
}
|
|
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Returns a message array with all the information about a message. See
|
|
|
|
- ** the documentation folder for more information about this array.
|
|
|
|
- ****************************************************************************/
|
|
|
|
|
|
+/*
|
|
|
|
+ * Returns a message array with all the information about a message.
|
|
|
|
+ * See the documentation folder for more information about this array.
|
|
|
|
+ */
|
|
function sqimap_get_message ($imap_stream, $id, $mailbox) {
|
|
function sqimap_get_message ($imap_stream, $id, $mailbox) {
|
|
$header = sqimap_get_message_header($imap_stream, $id, $mailbox);
|
|
$header = sqimap_get_message_header($imap_stream, $id, $mailbox);
|
|
return sqimap_get_message_body($imap_stream, $header);
|
|
return sqimap_get_message_body($imap_stream, $header);
|
|
}
|
|
}
|
|
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Wrapper function that reformats the header information.
|
|
|
|
- ****************************************************************************/
|
|
|
|
|
|
+/* Wrapper function that reformats the header information. */
|
|
function sqimap_get_message_header ($imap_stream, $id, $mailbox) {
|
|
function sqimap_get_message_header ($imap_stream, $id, $mailbox) {
|
|
$read = sqimap_run_command ($imap_stream, "FETCH $id:$id BODY[HEADER]", true, $response, $message);
|
|
$read = sqimap_run_command ($imap_stream, "FETCH $id:$id BODY[HEADER]", true, $response, $message);
|
|
-
|
|
|
|
$header = sqimap_get_header($imap_stream, $read);
|
|
$header = sqimap_get_header($imap_stream, $read);
|
|
$header->id = $id;
|
|
$header->id = $id;
|
|
$header->mailbox = $mailbox;
|
|
$header->mailbox = $mailbox;
|
|
-
|
|
|
|
return $header;
|
|
return $header;
|
|
}
|
|
}
|
|
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Wrapper function that reformats the entity header information.
|
|
|
|
- ****************************************************************************/
|
|
|
|
|
|
+/* Wrapper function that reformats the entity header information. */
|
|
function sqimap_get_ent_header ($imap_stream, $id, $mailbox, $ent) {
|
|
function sqimap_get_ent_header ($imap_stream, $id, $mailbox, $ent) {
|
|
$read = sqimap_run_command ($imap_stream, "FETCH $id:$id BODY[$ent.HEADER]", true, $response, $message);
|
|
$read = sqimap_run_command ($imap_stream, "FETCH $id:$id BODY[$ent.HEADER]", true, $response, $message);
|
|
$header = sqimap_get_header($imap_stream, $read);
|
|
$header = sqimap_get_header($imap_stream, $read);
|
|
@@ -311,9 +286,7 @@ function sqimap_get_ent_header ($imap_stream, $id, $mailbox, $ent) {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Wrapper function that returns entity headers for use by decodeMime
|
|
|
|
- ****************************************************************************/
|
|
|
|
|
|
+/* Wrapper function that returns entity headers for use by decodeMime */
|
|
/*
|
|
/*
|
|
function sqimap_get_entity_header ($imap_stream, &$read, &$type0, &$type1, &$bound, &$encoding, &$charset, &$filename) {
|
|
function sqimap_get_entity_header ($imap_stream, &$read, &$type0, &$type1, &$bound, &$encoding, &$charset, &$filename) {
|
|
$header = sqimap_get_header($imap_stream, $read);
|
|
$header = sqimap_get_header($imap_stream, $read);
|
|
@@ -325,15 +298,13 @@ function sqimap_get_entity_header ($imap_stream, &$read, &$type0, &$type1, &$bou
|
|
$filename = $header["FILENAME"];
|
|
$filename = $header["FILENAME"];
|
|
}
|
|
}
|
|
*/
|
|
*/
|
|
-
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Queries the IMAP server and gets all header information.
|
|
|
|
- ****************************************************************************/
|
|
|
|
|
|
+/* Queries the IMAP server and gets all header information. */
|
|
function sqimap_get_header ($imap_stream, $read) {
|
|
function sqimap_get_header ($imap_stream, $read) {
|
|
global $where, $what;
|
|
global $where, $what;
|
|
|
|
|
|
$hdr = new msg_header();
|
|
$hdr = new msg_header();
|
|
$i = 0;
|
|
$i = 0;
|
|
|
|
+
|
|
/* Set up some defaults */
|
|
/* Set up some defaults */
|
|
$hdr->type0 = "text";
|
|
$hdr->type0 = "text";
|
|
$hdr->type1 = "plain";
|
|
$hdr->type1 = "plain";
|
|
@@ -344,21 +315,18 @@ function sqimap_get_header ($imap_stream, $read) {
|
|
$hdr->mime = true;
|
|
$hdr->mime = true;
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /** ENCODING TYPE **/
|
|
|
|
|
|
+ /* ENCODING TYPE */
|
|
else if (substr(strtolower($read[$i]), 0, 26) == "content-transfer-encoding:") {
|
|
else if (substr(strtolower($read[$i]), 0, 26) == "content-transfer-encoding:") {
|
|
$hdr->encoding = strtolower(trim(substr($read[$i], 26)));
|
|
$hdr->encoding = strtolower(trim(substr($read[$i], 26)));
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /** CONTENT-TYPE **/
|
|
|
|
- else if (strtolower(substr($read[$i], 0, 13)) == "content-type:") {
|
|
|
|
|
|
+ /* CONTENT-TYPE */
|
|
|
|
+ else if (strtolower(substr($read[$i], 0, 13)) == "content-type:") {
|
|
$cont = strtolower(trim(substr($read[$i], 13)));
|
|
$cont = strtolower(trim(substr($read[$i], 13)));
|
|
if (strpos($cont, ";")) {
|
|
if (strpos($cont, ";")) {
|
|
$cont = substr($cont, 0, strpos($cont, ";"));
|
|
$cont = substr($cont, 0, strpos($cont, ";"));
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
if (strpos($cont, "/")) {
|
|
if (strpos($cont, "/")) {
|
|
$hdr->type0 = substr($cont, 0, strpos($cont, "/"));
|
|
$hdr->type0 = substr($cont, 0, strpos($cont, "/"));
|
|
$hdr->type1 = substr($cont, strpos($cont, "/")+1);
|
|
$hdr->type1 = substr($cont, strpos($cont, "/")+1);
|
|
@@ -366,7 +334,6 @@ function sqimap_get_header ($imap_stream, $read) {
|
|
$hdr->type0 = $cont;
|
|
$hdr->type0 = $cont;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
$line = $read[$i];
|
|
$line = $read[$i];
|
|
$i++;
|
|
$i++;
|
|
while ( (substr(substr($read[$i], 0, strpos($read[$i], " ")), -1) != ":") && (trim($read[$i]) != "") && (trim($read[$i]) != ")")) {
|
|
while ( (substr(substr($read[$i], 0, strpos($read[$i], " ")), -1) != ":") && (trim($read[$i]) != "") && (trim($read[$i]) != ")")) {
|
|
@@ -376,12 +343,12 @@ function sqimap_get_header ($imap_stream, $read) {
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
|
|
|
|
- /** Detect the boundary of a multipart message **/
|
|
|
|
|
|
+ /* Detect the boundary of a multipart message */
|
|
if (eregi('boundary="([^"]+)"', $line, $regs)) {
|
|
if (eregi('boundary="([^"]+)"', $line, $regs)) {
|
|
$hdr->boundary = $regs[1];
|
|
$hdr->boundary = $regs[1];
|
|
}
|
|
}
|
|
|
|
|
|
- /** Detect the charset **/
|
|
|
|
|
|
+ /* Detect the charset */
|
|
if (strpos(strtolower(trim($line)), "charset=")) {
|
|
if (strpos(strtolower(trim($line)), "charset=")) {
|
|
$pos = strpos($line, "charset=") + 8;
|
|
$pos = strpos($line, "charset=") + 8;
|
|
$charset = trim($line);
|
|
$charset = trim($line);
|
|
@@ -396,10 +363,8 @@ function sqimap_get_header ($imap_stream, $read) {
|
|
$hdr->charset = "us-ascii";
|
|
$hdr->charset = "us-ascii";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
else if (strtolower(substr($read[$i], 0, 20)) == "content-disposition:") {
|
|
else if (strtolower(substr($read[$i], 0, 20)) == "content-disposition:") {
|
|
- /** Add better dontent-disposition support **/
|
|
|
|
-
|
|
|
|
|
|
+ /* Add better content-disposition support */
|
|
$line = $read[$i];
|
|
$line = $read[$i];
|
|
$i++;
|
|
$i++;
|
|
while ( (substr(substr($read[$i], 0, strpos($read[$i], " ")), -1) != ":") && (trim($read[$i]) != "") && (trim($read[$i]) != ")")) {
|
|
while ( (substr(substr($read[$i], 0, strpos($read[$i], " ")), -1) != ":") && (trim($read[$i]) != "") && (trim($read[$i]) != ")")) {
|
|
@@ -409,27 +374,25 @@ function sqimap_get_header ($imap_stream, $read) {
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
|
|
|
|
- /** Detects filename if any **/
|
|
|
|
|
|
+ /* Detects filename if any */
|
|
if (strpos(strtolower(trim($line)), "filename=")) {
|
|
if (strpos(strtolower(trim($line)), "filename=")) {
|
|
$pos = strpos($line, "filename=") + 9;
|
|
$pos = strpos($line, "filename=") + 9;
|
|
$name = trim($line);
|
|
$name = trim($line);
|
|
if (strpos($line, " ", $pos) > 0) {
|
|
if (strpos($line, " ", $pos) > 0) {
|
|
- $name = substr($name, $pos, strpos($line, " ", $pos));
|
|
|
|
|
|
+ $name = substr($name, $pos, strpos($line, " ", $pos));
|
|
} else {
|
|
} else {
|
|
- $name = substr($name, $pos);
|
|
|
|
|
|
+ $name = substr($name, $pos);
|
|
}
|
|
}
|
|
$name = str_replace("\"", "", $name);
|
|
$name = str_replace("\"", "", $name);
|
|
$hdr->filename = $name;
|
|
$hdr->filename = $name;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- /** REPLY-TO **/
|
|
|
|
|
|
+ /* REPLY-TO */
|
|
else if (strtolower(substr($read[$i], 0, 9)) == "reply-to:") {
|
|
else if (strtolower(substr($read[$i], 0, 9)) == "reply-to:") {
|
|
$hdr->replyto = trim(substr($read[$i], 9, strlen($read[$i])));
|
|
$hdr->replyto = trim(substr($read[$i], 9, strlen($read[$i])));
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /** FROM **/
|
|
|
|
|
|
+ /* FROM */
|
|
else if (strtolower(substr($read[$i], 0, 5)) == "from:") {
|
|
else if (strtolower(substr($read[$i], 0, 5)) == "from:") {
|
|
$hdr->from = trim(substr($read[$i], 5, strlen($read[$i]) - 6));
|
|
$hdr->from = trim(substr($read[$i], 5, strlen($read[$i]) - 6));
|
|
if (! isset($hdr->replyto) || $hdr->replyto == "") {
|
|
if (! isset($hdr->replyto) || $hdr->replyto == "") {
|
|
@@ -437,7 +400,7 @@ function sqimap_get_header ($imap_stream, $read) {
|
|
}
|
|
}
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
- /** DATE **/
|
|
|
|
|
|
+ /* DATE */
|
|
else if (strtolower(substr($read[$i], 0, 5)) == "date:") {
|
|
else if (strtolower(substr($read[$i], 0, 5)) == "date:") {
|
|
$d = substr($read[$i], 5);
|
|
$d = substr($read[$i], 5);
|
|
$d = trim($d);
|
|
$d = trim($d);
|
|
@@ -446,23 +409,21 @@ function sqimap_get_header ($imap_stream, $read) {
|
|
$hdr->date = getTimeStamp($d);
|
|
$hdr->date = getTimeStamp($d);
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
- /** SUBJECT **/
|
|
|
|
|
|
+ /* SUBJECT */
|
|
else if (strtolower(substr($read[$i], 0, 8)) == "subject:") {
|
|
else if (strtolower(substr($read[$i], 0, 8)) == "subject:") {
|
|
$hdr->subject = trim(substr($read[$i], 8, strlen($read[$i]) - 9));
|
|
$hdr->subject = trim(substr($read[$i], 8, strlen($read[$i]) - 9));
|
|
if (strlen(Chop($hdr->subject)) == 0) {
|
|
if (strlen(Chop($hdr->subject)) == 0) {
|
|
$hdr->subject = _("(no subject)");
|
|
$hdr->subject = _("(no subject)");
|
|
}
|
|
}
|
|
-
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
if ($where == 'SUBJECT') {
|
|
if ($where == 'SUBJECT') {
|
|
$hdr->subject = $what;
|
|
$hdr->subject = $what;
|
|
// $hdr->subject = eregi_replace($what, "<b>\\0</b>", $hdr->subject);
|
|
// $hdr->subject = eregi_replace($what, "<b>\\0</b>", $hdr->subject);
|
|
}
|
|
}
|
|
*/
|
|
*/
|
|
-
|
|
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
- /** CC **/
|
|
|
|
|
|
+ /* CC */
|
|
else if (strtolower(substr($read[$i], 0, 3)) == "cc:") {
|
|
else if (strtolower(substr($read[$i], 0, 3)) == "cc:") {
|
|
$pos = 0;
|
|
$pos = 0;
|
|
$hdr->cc[$pos] = trim(substr($read[$i], 4));
|
|
$hdr->cc[$pos] = trim(substr($read[$i], 4));
|
|
@@ -473,7 +434,7 @@ function sqimap_get_header ($imap_stream, $read) {
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- /** BCC **/
|
|
|
|
|
|
+ /* BCC */
|
|
else if (strtolower(substr($read[$i], 0, 4)) == "bcc:") {
|
|
else if (strtolower(substr($read[$i], 0, 4)) == "bcc:") {
|
|
$pos = 0;
|
|
$pos = 0;
|
|
$hdr->bcc[$pos] = trim(substr($read[$i], 5));
|
|
$hdr->bcc[$pos] = trim(substr($read[$i], 5));
|
|
@@ -484,7 +445,7 @@ function sqimap_get_header ($imap_stream, $read) {
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- /** TO **/
|
|
|
|
|
|
+ /* TO */
|
|
else if (strtolower(substr($read[$i], 0, 3)) == "to:") {
|
|
else if (strtolower(substr($read[$i], 0, 3)) == "to:") {
|
|
$pos = 0;
|
|
$pos = 0;
|
|
$hdr->to[$pos] = trim(substr($read[$i], 4));
|
|
$hdr->to[$pos] = trim(substr($read[$i], 4));
|
|
@@ -495,14 +456,12 @@ function sqimap_get_header ($imap_stream, $read) {
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- /** MESSAGE ID **/
|
|
|
|
|
|
+ /* MESSAGE ID */
|
|
else if (strtolower(substr($read[$i], 0, 11)) == "message-id:") {
|
|
else if (strtolower(substr($read[$i], 0, 11)) == "message-id:") {
|
|
$hdr->message_id = trim(substr($read[$i], 11));
|
|
$hdr->message_id = trim(substr($read[$i], 11));
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
- /** ERROR CORRECTION **/
|
|
|
|
|
|
+ /* ERROR CORRECTION */
|
|
else if (substr($read[$i], 0, 1) == ")") {
|
|
else if (substr($read[$i], 0, 1) == ")") {
|
|
if (strlen(trim($hdr->subject)) == 0) {
|
|
if (strlen(trim($hdr->subject)) == 0) {
|
|
$hdr->subject = _("(no subject)");
|
|
$hdr->subject = _("(no subject)");
|
|
@@ -515,7 +474,7 @@ function sqimap_get_header ($imap_stream, $read) {
|
|
}
|
|
}
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
- /** X-PRIORITY **/
|
|
|
|
|
|
+ /* X-PRIORITY */
|
|
else if (strtolower(substr($read[$i], 0, 11)) == "x-priority:") {
|
|
else if (strtolower(substr($read[$i], 0, 11)) == "x-priority:") {
|
|
$hdr->priority = trim(substr($read[$i], 11));
|
|
$hdr->priority = trim(substr($read[$i], 11));
|
|
$i++;
|
|
$i++;
|
|
@@ -527,17 +486,10 @@ function sqimap_get_header ($imap_stream, $read) {
|
|
return $hdr;
|
|
return $hdr;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Returns the body of a message.
|
|
|
|
- ****************************************************************************/
|
|
|
|
|
|
+/* Returns the body of a message. */
|
|
function sqimap_get_message_body ($imap_stream, &$header) {
|
|
function sqimap_get_message_body ($imap_stream, &$header) {
|
|
$id = $header->id;
|
|
$id = $header->id;
|
|
return decodeMime($imap_stream, $header);
|
|
return decodeMime($imap_stream, $header);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-/****************************************************************************
|
|
|
|
- ** Returns an array with the body structure
|
|
|
|
- ****************************************************************************/
|
|
|
|
?>
|
|
?>
|