X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fimap.php;h=954116997c5be47e6874551bde430a7299245f4b;hp=0362e32c97e5a61366bb964ae670d7d92985da80;hb=65d0d1624a60633c008fd0b5631ca37713a7ad7c;hpb=7ce342dcef2291f6e57eb53892e09a80d2f63dc9
diff --git a/functions/imap.php b/functions/imap.php
index 0362e32c..95411699 100644
--- a/functions/imap.php
+++ b/functions/imap.php
@@ -1,283 +1,27 @@
-
- /**
- ** imap.php
- **
- ** Functions for the IMAP connection
- **
- **/
-
- /** Read from the connection until we get either an OK or BAD message. **/
- function imapReadData($connection, $pre, $handle_errors, &$response, &$message) {
- require ("../config/config.php");
-
- $read = fgets($connection, 1024);
- $counter = 0;
- while ((substr($read, 0, strlen("$pre OK")) != "$pre OK") &&
- (substr($read, 0, strlen("$pre BAD")) != "$pre BAD") &&
- (substr($read, 0, strlen("$pre NO")) != "$pre NO")) {
- $data[$counter] = $read;
- $read = fgets($connection, 1024);
- $counter++;
- }
- if (substr($read, 0, strlen("$pre OK")) == "$pre OK") {
- $response = "OK";
- $message = trim(substr($read, strlen("$pre OK"), strlen($read)));
- } else if (substr($read, 0, strlen("$pre BAD")) == "$pre BAD") {
- $response = "BAD";
- $message = trim(substr($read, strlen("$pre BAD"), strlen($read)));
- } else {
- $response = "NO";
- $message = trim(substr($read, strlen("$pre NO"), strlen($read)));
- }
-
- if ($handle_errors == true) {
- if ($response == "NO") {
- echo "
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);
-
- $pos = strrpos($read, "\"");
- $read = substr($read, 0, $pos);
-
- $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($mailbox) {
- $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 (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 " |
";
- echo " Unknown user or password incorrect. Click here to try again. |