This commit has been accessed 564 times via Git panel.
commit 9152992e8ba5f9213e2a9c46b93db7cff3be730b
tree 48f913441e6c067b297b6c20434dad5fb4585e48
parent e2d6e639925ad21ec537953b38d9061abdb7958a
author Engels Antonio <engels@majcms.org> 1333302838 +0800
committer Engels Antonio <engels@majcms.org> 1333302838 +0800
Migrate from message sequence number to UID
diff --git a/core.php b/core.php
index 25ae794..1c570f8 100644
--- a/core.php
+++ b/core.php
@@ -89,7 +89,7 @@ function get_mime_type(&$struct) {
function get_part($stream, $msg_number, $mime_type, $structure = false, $part_number = false) {
if (!$structure) {
- $structure = imap_fetchstructure($stream, $msg_number);
+ $structure = imap_fetchstructure($stream, $msg_number, FT_UID);
}
if ($structure) {
@@ -100,7 +100,7 @@ function get_part($stream, $msg_number, $mime_type, $structure = false, $part_nu
$part_number = "1";
}
- $text = imap_fetchbody($stream, $msg_number, $part_number);
+ $text = imap_fetchbody($stream, $msg_number, $part_number, FT_UID);
if ($structure->encoding == 3) {
return imap_base64($text);
diff --git a/inbox.php b/inbox.php
index 945489a..049ce6b 100644
--- a/inbox.php
+++ b/inbox.php
@@ -12,12 +12,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
if ($_POST['del'] == "1") {
imap_createmailbox($mbox,"{$host}Trash");
- imap_mail_move($mbox,$msgno,"Trash");
+ imap_mail_move($mbox,$msgno,"Trash",CP_UID);
imap_expunge($mbox);
}
if ($_POST['del'] == "0") {
- imap_mail_move($mbox,$msgno,"Inbox");
+ imap_mail_move($mbox,$msgno,"Inbox",CP_UID);
imap_expunge($mbox);
}
}
@@ -36,14 +36,12 @@ else {
$show_max = $_POST['show_max'];
}
-imap_headers($mbox);
-
if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
$imap_search_query = $_POST['imap_search_query'];
$imap_search_where = $_POST['imap_search_where'];
$imap_search_criteria = $imap_search_where . ' "'. $imap_search_query . '"';
- $mbox_sort = imap_search($mbox,$imap_search_criteria);
+ $mbox_sort = imap_search($mbox,$imap_search_criteria,SE_UID);
rsort($mbox_sort);
@@ -55,7 +53,7 @@ if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) a
}
}
else {
- $mbox_sort = imap_sort($mbox,SORTARRIVAL,1);
+ $mbox_sort = imap_sort($mbox,SORTARRIVAL,1,SE_UID|SE_NOPREFETCH);
}
/*
@@ -106,8 +104,8 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
continue;
}
- $val = imap_fetch_overview($mbox,$mbox_row);
- $msgno = $val[0]->msgno;
+ $val = imap_fetch_overview($mbox,$mbox_row,FT_UID);
+ $msgno = $val[0]->uid;
$seen = $val[0]->seen;
$recent = $val[0]->recent;
$answered = $val[0]->answered;
diff --git a/index.php b/index.php
index 7acd969..0e5b2ab 100644
--- a/index.php
+++ b/index.php
@@ -913,9 +913,9 @@ if (isset($_SESSION['logged_uid'])) {
$reply_headers = $reply_headers . "Resent-Bcc: $reply_bcc\r\n";
}
- $reply_headers = $reply_headers . imap_fetchheader($mbox,$_POST['msg']);
+ $reply_headers = $reply_headers . imap_fetchheader($mbox,$_POST['msg'],FT_UID|FT_PREFETCHTEXT);
- $reply_body = imap_body($mbox,$_POST['msg']);
+ $reply_body = imap_body($mbox,$_POST['msg'],FT_UID);
}
imap_createmailbox($mbox,"{$host}Sent");
@@ -933,14 +933,13 @@ if (isset($_SESSION['logged_uid'])) {
if ($_POST['ack'] == 1) {
- //imap_reopen($mbox, "{$host}$folder");
- imap_setflag_full($mbox, $_POST['msg'], '\\Answered');
+ imap_setflag_full($mbox, $_POST['msg'], '\\Answered',ST_UID);
}
}
if (isset($_POST['not']) and !empty($_POST['not']) and is_numeric($_POST['not'])) {
- imap_clearflag_full($mbox, $_POST['msg'], '\\Seen');
+ imap_clearflag_full($mbox, $_POST['msg'], '\\Seen',ST_UID);
imap_expunge($mbox);
}
diff --git a/read.php b/read.php
index 9fb9e33..6b71992 100644
--- a/read.php
+++ b/read.php
@@ -10,7 +10,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$msgno = trim(strip_tags($_POST['msg']));
- $header = imap_headerinfo($mbox, $msgno);
+ $header = imap_rfc822_parse_headers(imap_fetchbody($mbox,$msgno,0,FT_UID));
$header_subject = header_mime2text($header->subject);
@@ -27,7 +27,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$header_ccaddress = header_mime2text($header->ccaddress);
$header_ccaddress = htmlentities($header_ccaddress,ENT_QUOTES);
- $header_fetch = imap_fetchheader($mbox,$msgno);
+ $header_fetch = imap_fetchheader($mbox,$msgno,FT_UID);
$header_raw_lines = explode("\r\n",$header_fetch);
@@ -49,7 +49,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$imap_search_query = $_POST['imap_search_query'];
$imap_search_where = $_POST['imap_search_where'];
$imap_search_criteria = $imap_search_where . ' "'. $imap_search_query . '"';
- $mbox_sort = imap_search($mbox,$imap_search_criteria);
+ $mbox_sort = imap_search($mbox,$imap_search_criteria,SE_UID);
rsort($mbox_sort);
@@ -61,7 +61,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
}
else {
- $mbox_sort = imap_sort($mbox,SORTARRIVAL,1);
+ $mbox_sort = imap_sort($mbox,SORTARRIVAL,1,SE_UID|SE_NOPREFETCH);
}
$mbox_row = array_search($msgno, $mbox_sort);
@@ -292,13 +292,13 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$filePath = "attach/o/$fileUsr/$fileDir";
- $struct = imap_fetchstructure($mbox, $msgno);
+ $struct = imap_fetchstructure($mbox, $msgno, FT_UID);
$contentParts = count($struct->parts);
for ($n = 0; $n <= $contentParts; $n++) {
- $contentPart = imap_bodystruct($mbox,$msgno,$n);
+ $contentPart = imap_bodystruct($mbox,imap_msgno($mbox,$msgno),$n);
if (($contentPart->disposition == "attachment") or ($contentPart->disposition == "inline")) {
@@ -311,7 +311,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$fileName = $contentDP[0]->value;
$fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$fileName);
- $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n));
+ $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n,FT_UID));
if (!file_exists($filePath)) {
mkdir($filePath,0700,1);
@@ -335,7 +335,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$fileName = $contentDP[0]->value;
$fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$fileName);
- $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n));
+ $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n,FT_UID));
if (!file_exists($filePath)) {
mkdir($filePath,0700,1);
@@ -384,14 +384,14 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$msgBody = mb_convert_encoding($msgBody,"UTF-8","auto");
$msgBody = mb_convert_encoding($msgBody,"UTF-8","UTF-8");
-//echo nl2br(htmlentities(imap_fetchheader($mbox,$msgno)));
-//echo nl2br(htmlentities(imap_body($mbox,$msgno)));
+//echo nl2br(htmlentities(imap_fetchheader($mbox,$msgno,FT_UID)));
+//echo nl2br(htmlentities(imap_body($mbox,$msgno,FT_UID)));
$get_fromaddress = extract_emails_from($header->fromaddress);
$get_fromaddress = explode("@",$get_fromaddress[0]);
if ($get_fromaddress[0] == "MAILER-DAEMON") {
- echo nl2br(htmlentities(imap_body($mbox,$msgno)));
+ echo nl2br(htmlentities(imap_body($mbox,$msgno,FT_UID)));
}
else {
echo $msgBody;
@@ -399,9 +399,6 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "</div>";
- //$do_fromaddress = extract_emails_from($header->fromaddress);
- //$do_toaddress = extract_emails_from($header->toaddress);
-
if (file_exists("$filePath")) {
$fileAttachments = glob("$filePath/*");
diff --git a/send.php b/send.php
index aa53b23..b3edb0d 100644
--- a/send.php
+++ b/send.php
@@ -10,7 +10,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$msgno = trim(strip_tags($_POST['msg']));
- $header = imap_headerinfo($mbox, $msgno);
+ $header = imap_rfc822_parse_headers(imap_fetchbody($mbox,$msgno,0,FT_UID));
$header_subject = $header->subject;
$header_fromaddress = $header->senderaddress;
@@ -81,7 +81,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$reply_subject = htmlentities($reply_subject,ENT_QUOTES);
$reply_cc = htmlentities($reply_cc,ENT_QUOTES);
- $header_fetch = imap_fetchheader($mbox,$msgno);
+ $header_fetch = imap_fetchheader($mbox,$msgno,FT_UID);
$header_raw_lines = explode("\r\n",$header_fetch);
tree 48f913441e6c067b297b6c20434dad5fb4585e48
parent e2d6e639925ad21ec537953b38d9061abdb7958a
author Engels Antonio <engels@majcms.org> 1333302838 +0800
committer Engels Antonio <engels@majcms.org> 1333302838 +0800
Migrate from message sequence number to UID
diff --git a/core.php b/core.php
index 25ae794..1c570f8 100644
--- a/core.php
+++ b/core.php
@@ -89,7 +89,7 @@ function get_mime_type(&$struct) {
function get_part($stream, $msg_number, $mime_type, $structure = false, $part_number = false) {
if (!$structure) {
- $structure = imap_fetchstructure($stream, $msg_number);
+ $structure = imap_fetchstructure($stream, $msg_number, FT_UID);
}
if ($structure) {
@@ -100,7 +100,7 @@ function get_part($stream, $msg_number, $mime_type, $structure = false, $part_nu
$part_number = "1";
}
- $text = imap_fetchbody($stream, $msg_number, $part_number);
+ $text = imap_fetchbody($stream, $msg_number, $part_number, FT_UID);
if ($structure->encoding == 3) {
return imap_base64($text);
diff --git a/inbox.php b/inbox.php
index 945489a..049ce6b 100644
--- a/inbox.php
+++ b/inbox.php
@@ -12,12 +12,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
if ($_POST['del'] == "1") {
imap_createmailbox($mbox,"{$host}Trash");
- imap_mail_move($mbox,$msgno,"Trash");
+ imap_mail_move($mbox,$msgno,"Trash",CP_UID);
imap_expunge($mbox);
}
if ($_POST['del'] == "0") {
- imap_mail_move($mbox,$msgno,"Inbox");
+ imap_mail_move($mbox,$msgno,"Inbox",CP_UID);
imap_expunge($mbox);
}
}
@@ -36,14 +36,12 @@ else {
$show_max = $_POST['show_max'];
}
-imap_headers($mbox);
-
if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
$imap_search_query = $_POST['imap_search_query'];
$imap_search_where = $_POST['imap_search_where'];
$imap_search_criteria = $imap_search_where . ' "'. $imap_search_query . '"';
- $mbox_sort = imap_search($mbox,$imap_search_criteria);
+ $mbox_sort = imap_search($mbox,$imap_search_criteria,SE_UID);
rsort($mbox_sort);
@@ -55,7 +53,7 @@ if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) a
}
}
else {
- $mbox_sort = imap_sort($mbox,SORTARRIVAL,1);
+ $mbox_sort = imap_sort($mbox,SORTARRIVAL,1,SE_UID|SE_NOPREFETCH);
}
/*
@@ -106,8 +104,8 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
continue;
}
- $val = imap_fetch_overview($mbox,$mbox_row);
- $msgno = $val[0]->msgno;
+ $val = imap_fetch_overview($mbox,$mbox_row,FT_UID);
+ $msgno = $val[0]->uid;
$seen = $val[0]->seen;
$recent = $val[0]->recent;
$answered = $val[0]->answered;
diff --git a/index.php b/index.php
index 7acd969..0e5b2ab 100644
--- a/index.php
+++ b/index.php
@@ -913,9 +913,9 @@ if (isset($_SESSION['logged_uid'])) {
$reply_headers = $reply_headers . "Resent-Bcc: $reply_bcc\r\n";
}
- $reply_headers = $reply_headers . imap_fetchheader($mbox,$_POST['msg']);
+ $reply_headers = $reply_headers . imap_fetchheader($mbox,$_POST['msg'],FT_UID|FT_PREFETCHTEXT);
- $reply_body = imap_body($mbox,$_POST['msg']);
+ $reply_body = imap_body($mbox,$_POST['msg'],FT_UID);
}
imap_createmailbox($mbox,"{$host}Sent");
@@ -933,14 +933,13 @@ if (isset($_SESSION['logged_uid'])) {
if ($_POST['ack'] == 1) {
- //imap_reopen($mbox, "{$host}$folder");
- imap_setflag_full($mbox, $_POST['msg'], '\\Answered');
+ imap_setflag_full($mbox, $_POST['msg'], '\\Answered',ST_UID);
}
}
if (isset($_POST['not']) and !empty($_POST['not']) and is_numeric($_POST['not'])) {
- imap_clearflag_full($mbox, $_POST['msg'], '\\Seen');
+ imap_clearflag_full($mbox, $_POST['msg'], '\\Seen',ST_UID);
imap_expunge($mbox);
}
diff --git a/read.php b/read.php
index 9fb9e33..6b71992 100644
--- a/read.php
+++ b/read.php
@@ -10,7 +10,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$msgno = trim(strip_tags($_POST['msg']));
- $header = imap_headerinfo($mbox, $msgno);
+ $header = imap_rfc822_parse_headers(imap_fetchbody($mbox,$msgno,0,FT_UID));
$header_subject = header_mime2text($header->subject);
@@ -27,7 +27,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$header_ccaddress = header_mime2text($header->ccaddress);
$header_ccaddress = htmlentities($header_ccaddress,ENT_QUOTES);
- $header_fetch = imap_fetchheader($mbox,$msgno);
+ $header_fetch = imap_fetchheader($mbox,$msgno,FT_UID);
$header_raw_lines = explode("\r\n",$header_fetch);
@@ -49,7 +49,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$imap_search_query = $_POST['imap_search_query'];
$imap_search_where = $_POST['imap_search_where'];
$imap_search_criteria = $imap_search_where . ' "'. $imap_search_query . '"';
- $mbox_sort = imap_search($mbox,$imap_search_criteria);
+ $mbox_sort = imap_search($mbox,$imap_search_criteria,SE_UID);
rsort($mbox_sort);
@@ -61,7 +61,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
}
else {
- $mbox_sort = imap_sort($mbox,SORTARRIVAL,1);
+ $mbox_sort = imap_sort($mbox,SORTARRIVAL,1,SE_UID|SE_NOPREFETCH);
}
$mbox_row = array_search($msgno, $mbox_sort);
@@ -292,13 +292,13 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$filePath = "attach/o/$fileUsr/$fileDir";
- $struct = imap_fetchstructure($mbox, $msgno);
+ $struct = imap_fetchstructure($mbox, $msgno, FT_UID);
$contentParts = count($struct->parts);
for ($n = 0; $n <= $contentParts; $n++) {
- $contentPart = imap_bodystruct($mbox,$msgno,$n);
+ $contentPart = imap_bodystruct($mbox,imap_msgno($mbox,$msgno),$n);
if (($contentPart->disposition == "attachment") or ($contentPart->disposition == "inline")) {
@@ -311,7 +311,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$fileName = $contentDP[0]->value;
$fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$fileName);
- $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n));
+ $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n,FT_UID));
if (!file_exists($filePath)) {
mkdir($filePath,0700,1);
@@ -335,7 +335,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$fileName = $contentDP[0]->value;
$fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$fileName);
- $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n));
+ $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n,FT_UID));
if (!file_exists($filePath)) {
mkdir($filePath,0700,1);
@@ -384,14 +384,14 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$msgBody = mb_convert_encoding($msgBody,"UTF-8","auto");
$msgBody = mb_convert_encoding($msgBody,"UTF-8","UTF-8");
-//echo nl2br(htmlentities(imap_fetchheader($mbox,$msgno)));
-//echo nl2br(htmlentities(imap_body($mbox,$msgno)));
+//echo nl2br(htmlentities(imap_fetchheader($mbox,$msgno,FT_UID)));
+//echo nl2br(htmlentities(imap_body($mbox,$msgno,FT_UID)));
$get_fromaddress = extract_emails_from($header->fromaddress);
$get_fromaddress = explode("@",$get_fromaddress[0]);
if ($get_fromaddress[0] == "MAILER-DAEMON") {
- echo nl2br(htmlentities(imap_body($mbox,$msgno)));
+ echo nl2br(htmlentities(imap_body($mbox,$msgno,FT_UID)));
}
else {
echo $msgBody;
@@ -399,9 +399,6 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "</div>";
- //$do_fromaddress = extract_emails_from($header->fromaddress);
- //$do_toaddress = extract_emails_from($header->toaddress);
-
if (file_exists("$filePath")) {
$fileAttachments = glob("$filePath/*");
diff --git a/send.php b/send.php
index aa53b23..b3edb0d 100644
--- a/send.php
+++ b/send.php
@@ -10,7 +10,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$msgno = trim(strip_tags($_POST['msg']));
- $header = imap_headerinfo($mbox, $msgno);
+ $header = imap_rfc822_parse_headers(imap_fetchbody($mbox,$msgno,0,FT_UID));
$header_subject = $header->subject;
$header_fromaddress = $header->senderaddress;
@@ -81,7 +81,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$reply_subject = htmlentities($reply_subject,ENT_QUOTES);
$reply_cc = htmlentities($reply_cc,ENT_QUOTES);
- $header_fetch = imap_fetchheader($mbox,$msgno);
+ $header_fetch = imap_fetchheader($mbox,$msgno,FT_UID);
$header_raw_lines = explode("\r\n",$header_fetch);