From: moodler Date: Sat, 16 Nov 2002 03:49:32 +0000 (+0000) Subject: Separated code for IMAP into IMAP, POP3 and NNTP X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=df3988ea8b783a0aa96af7f007dd023123349f8b;p=moodle.git Separated code for IMAP into IMAP, POP3 and NNTP --- diff --git a/auth/README b/auth/README index a1bdff4867..6262f643bd 100644 --- a/auth/README +++ b/auth/README @@ -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 diff --git a/auth/imap/lib.php b/auth/imap/lib.php index 0f115e2b76..39b5b83e79 100644 --- a/auth/imap/lib.php +++ b/auth/imap/lib.php @@ -1,12 +1,12 @@ 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 index 0000000000..4223df2917 --- /dev/null +++ b/auth/nntp/lib.php @@ -0,0 +1,29 @@ +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 index 0000000000..179316e1b7 --- /dev/null +++ b/auth/pop3/lib.php @@ -0,0 +1,37 @@ +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; + } +} + + +?>