1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

IMAP: Delete message

Also support mailboxes with spaces
This commit is contained in:
Jakub Vrana
2025-03-18 12:35:36 +01:00
parent 753642630b
commit 693dc5b8a7

View File

@@ -4,7 +4,8 @@
* - list messages in each mailbox - limit and offset works but there's no search and order
* - for each message, there's subject, from, to, date and some flags
* - editing the message shows some other information
* - inserting, deleting or updating the message does nothing
* - deleting marks the message for deletion but doesn't expunge the mailbox
* - inserting or updating the message does nothing
*/
namespace Adminer;
@@ -36,9 +37,10 @@ if (isset($_GET["imap"])) {
}
function query($query, $unbuffered = false) {
if (!preg_match('~^SELECT (.+)\sFROM (\w+)(?:\sWHERE uid = (\d+))?.*?(?:\sLIMIT (\d+)(?:\sOFFSET (\d+))?)?~s', $query, $match)) {
return false;
}
if (preg_match('~DELETE FROM "(.+?)"~', $query)) {
preg_match_all('~"uid" = (\d+)~', $query, $matches);
imap_delete($this->imap, implode(",", $matches[1]), FT_UID);
} elseif (preg_match('~^SELECT (.+)\sFROM "(.+?)"(?:\sWHERE "uid" = (\d+))?.*?(?:\sLIMIT (\d+)(?:\sOFFSET (\d+))?)?~s', $query, $match)) {
list(, $columns, $table, $uid, $limit, $offset) = $match;
if ($uid) {
$return = array((array) imap_fetchstructure($this->imap, $uid, FT_UID));
@@ -61,6 +63,8 @@ if (isset($_GET["imap"])) {
}
return new Result($return);
}
return false;
}
function quote($string) {
return $string;
@@ -181,7 +185,7 @@ if (isset($_GET["imap"])) {
}
function idf_escape($idf) {
return $idf; //! maybe {}
return '"' . str_replace('"', '""', $idf) . '"';
}
function table($idf) {