Separated code for IMAP into IMAP, POP3 and NNTP
authormoodler <moodler>
Sat, 16 Nov 2002 03:49:32 +0000 (03:49 +0000)
committermoodler <moodler>
Sat, 16 Nov 2002 03:49:32 +0000 (03:49 +0000)
auth/README
auth/imap/lib.php
auth/nntp/lib.php [new file with mode: 0644]
auth/pop3/lib.php [new file with mode: 0644]

index a1bdff4..6262f64 100644 (file)
@@ -52,6 +52,24 @@ imap  - Uses an external IMAP server
       a new account is created
 
 
+pop3  - Uses an external POP3 server
+
+    - user logs in using username and password
+    - these are checked against a POP3 server
+    - if correct, user is logged in
+    - if the username doesn't already exist then
+      a new account is created
+
+
+nntp  - Uses an external NNTP server
+
+    - user logs in using username and password
+    - these are checked against an NNTP server
+    - if correct, user is logged in
+    - if the username doesn't already exist then
+      a new account is created
+
+
 db  - Uses an external database to check username/password
     
     - user logs in using username and password
index 0f115e2..39b5b83 100644 (file)
@@ -1,12 +1,12 @@
 <?PHP  // $Id$
-       // Authentication by looking up an IMAP, POP or NNTP server
+       // Authentication by looking up an IMAP server
 
 // This code is completely untested so far  -  IT NEEDS TESTERS!
 // Looks like it should work though ...
 
 $CFG->auth_imaphost   = "127.0.0.1";  // Should be IP number
-$CFG->auth_imaptype   = "imap";       // imap, imapssl, imapcert, pop3, pop3cert, nntp
-$CFG->auth_imapport   = "143";        // 143, 993, 100, 119
+$CFG->auth_imaptype   = "imap";       // imap, imapssl, imapcert
+$CFG->auth_imapport   = "143";        // 143, 993
 
 
 function auth_user_login ($username, $password) {
@@ -25,15 +25,6 @@ function auth_user_login ($username, $password) {
         case "imapcert":
             $host = "{$CFG->auth_imaphost:$CFG->auth_imapport/imap/ssl/novalidate-cert}INBOX";
         break;
-        case "pop3":
-            $host = "{$CFG->auth_imaphost:$CFG->auth_imapport/pop3}INBOX";
-        break;
-        case "pop3cert":
-            $host = "{$CFG->auth_imaphost:$CFG->auth_imapport/pop3/ssl/novalidate-cert}INBOX";
-        break;
-        case "nntp":
-            $host = "{$CFG->auth_imaphost:$CFG->auth_imapport/nntp}";
-        break;
     }
 
     if ($connection = imap_open($host, $username, $password, OP_HALFOPEN)) {
diff --git a/auth/nntp/lib.php b/auth/nntp/lib.php
new file mode 100644 (file)
index 0000000..4223df2
--- /dev/null
@@ -0,0 +1,29 @@
+<?PHP  // $Id$
+       // Authentication by looking up an IMAP, POP or NNTP server
+
+// This code is completely untested so far  -  IT NEEDS TESTERS!
+// Looks like it should work though ...
+
+$CFG->auth_nntphost   = "127.0.0.1";  // Should be IP number
+$CFG->auth_nntpport   = "119";      
+
+
+function auth_user_login ($username, $password) {
+// Returns true if the username and password work
+// and false if they are wrong or don't exist.
+
+    global $CFG;
+
+    $host = "{$CFG->auth_nntphost:$CFG->auth_nntpport/nntp}";
+
+    if ($connection = imap_open($host, $username, $password, OP_HALFOPEN)) {
+        imap_close($connection);
+        return true;
+
+    } else {
+        return false;
+    }
+}
+
+
+?>
diff --git a/auth/pop3/lib.php b/auth/pop3/lib.php
new file mode 100644 (file)
index 0000000..179316e
--- /dev/null
@@ -0,0 +1,37 @@
+<?PHP  // $Id$
+       // Authentication by looking up a POP3 server
+
+// This code is completely untested so far  -  IT NEEDS TESTERS!
+// Looks like it should work though ...
+
+$CFG->auth_pop3host   = "127.0.0.1";  // Should be IP number
+$CFG->auth_pop3type   = "pop3";       // pop3, pop3cert
+$CFG->auth_pop3port   = "100";        // 143, 993, 100, 119
+
+
+function auth_user_login ($username, $password) {
+// Returns true if the username and password work
+// and false if they are wrong or don't exist.
+
+    global $CFG;
+
+    switch ($CFG->auth_pop3type) {
+        case "pop3":
+            $host = "{$CFG->auth_pop3host:$CFG->auth_pop3port/pop3}INBOX";
+        break;
+        case "pop3cert":
+            $host = "{$CFG->auth_pop3host:$CFG->auth_pop3port/pop3/ssl/novalidate-cert}INBOX";
+        break;
+    }
+
+    if ($connection = imap_open($host, $username, $password, OP_HALFOPEN)) {
+        imap_close($connection);
+        return true;
+
+    } else {
+        return false;
+    }
+}
+
+
+?>