X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fimap.php;h=9a3a41d22aa571d3da9ea38c61d5108383d6ea2e;hb=2ba138034e8cf69a80201035e0abdb51af93083d;hp=99b0192c143bb4064d6412922833178549290ab7;hpb=e80b444be0527cf72b12aad8c02fc9c4f7863a3a;p=squirrelmail.git
diff --git a/functions/imap.php b/functions/imap.php
index 99b0192c..9a3a41d2 100644
--- a/functions/imap.php
+++ b/functions/imap.php
@@ -1,346 +1,22 @@
-
+ERROR: Could not complete request.
Reason given: $message
";
- exit;
- } else if ($response == "BAD") {
- echo "
ERROR: Bad or malformed request.
Server responded: $message
";
- exit;
- }
- }
-
- return $data;
- }
-
- /** Parse the incoming mailbox name and return a string that is the FOLDER.MAILBOX **/
- function findMailboxName($mailbox) {
- $mailbox = trim($mailbox);
- if (substr($mailbox, strlen($mailbox)-1, strlen($mailbox)) == "\"") {
- $mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
- $pos = strrpos($mailbox, "\"") + 1;
- $box = substr($mailbox, $pos, strlen($mailbox));
- } else {
- $box = substr($mailbox, strrpos($mailbox, " ")+1, strlen($mailbox));
- }
- return $box;
- }
-
- /** Finds the delimeter between mailboxes **/
- function findMailboxDelimeter($imapConnection) {
- fputs($imapConnection, ". list \"\" \"\"\n");
- $read = fgets($imapConnection, 1024);
-
- if (strrpos($read, "\"") == strlen($read)) {
- $pos = strrpos($read, "\"");
- $read = substr($read, 0, $pos);
-
- $pos = strrpos($read, "\"");
- $read = substr($read, 0, $pos);
- } else {
- $pos = strrpos($read, " ");
- $read = substr($read, 0, $pos);
- }
-
- $pos = strrpos($read, "\"");
- $read = substr($read, 0, $pos);
-
- $pos = strrpos($read, "\"");
- $read = substr($read, $pos+1, strlen($read));
-
- $tmp = fgets($imapConnection, 1024);
- return $read;
- }
-
- function getMailboxFlags($imapConnection, $mailbox) {
- $name = findMailboxName($mailbox);
- fputs ($imapConnection, "1 LIST \"$name\" *\n");
- $data = imapReadData($imapConnection, "1", true, $response, $message);
- $mailbox = $data[0];
- $mailbox = trim($mailbox);
- $mailbox = substr($mailbox, strpos($mailbox, "(")+1, strlen($mailbox));
- $mailbox = substr($mailbox, 0, strpos($mailbox, ")"));
- $mailbox = str_replace("\\", "", $mailbox);
- $mailbox = strtolower($mailbox);
- $mailbox = explode(" ", $mailbox);
- return $mailbox;
- }
-
- // handles logging onto an imap server.
- function loginToImapServer($username, $key, $imapServerAddress, $hide) {
- require("../config/config.php");
-
- $imapConnection = fsockopen($imapServerAddress, 143, &$errorNumber, &$errorString);
- if (!$imapConnection) {
- echo "Error connecting to IMAP Server.
";
- echo "$errorNumber : $errorString
";
- exit;
- }
- $serverInfo = fgets($imapConnection, 256);
-
- // login
- fputs($imapConnection, "a001 LOGIN \"$username\" \"$key\"\n");
- $read = fgets($imapConnection, 1024);
- if ($debug_login == true) {
- echo "SERVER SAYS: $read
";
- }
-
- /** If the login attempt was UNsuccessful, lets see why **/
- if (substr($read, 0, 7) != "a001 OK") {
- if (!$hide) {
- if (substr($read, 0, 8) == "a001 BAD") {
- echo "Bad request: $read
";
- exit;
- }
- else if (substr($read, 0, 7) == "a001 NO") {
- echo "
";
- echo " |
";
- echo " Unknown user or password incorrect. Click here to try again. |