updated some folder stuff
[squirrelmail.git] / functions / imap.php
CommitLineData
3302d0d4 1<?
2 /**
a09387f4 3 ** imap.php
3302d0d4 4 **
5 ** Functions for the IMAP connection
6 **
7 **/
8
9 /** Read from the connection until we get either an OK or BAD message. **/
10 function imapReadData($connection) {
11 $read = fgets($connection, 1024);
12 $counter = 0;
13 while ((substr($read, strpos($read, " ") + 1, 2) != "OK") && (substr($read, strpos($read, " ") + 1, 3) != "BAD")) {
14 $data[$counter] = $read;
15 $read = fgets($connection, 1024);
16 $counter++;
17 }
18 return $data;
19 }
aa42fbfb 20
21 /** Parse the incoming mailbox name and return a string that is the FOLDER.MAILBOX **/
22 function findMailboxName($mailbox) {
23 // start at -2 so that we skip the initial quote at the end of the mailbox name
24 $i = -2;
25 $char = substr($mailbox, $i, 1);
26 while ($char != "\"") {
27 $i--;
28 $temp .= $char;
29 $char = substr($mailbox, $i, 1);
30 }
31 return strrev($temp);
32 }
8c7dfc99 33
34 /** must be sent in the form: user.<USER>.<FOLDER> **/
35 function createFolder($imapConnection, $folder) {
36 fputs($imapConnection, "1 create \"$folder\"\n");
37 }
38
39 /** must be sent in the form: user.<USER>.<FOLDER> **/
40 function deleteFolder($imapConnection, $folder) {
41 fputs($imapConnection, "1 delete \"$folder\"\n");
42 }
3302d0d4 43?>