88412f6b98149955e8652064910b58626202dd87
[moodle.git] / auth / pop3 / lib.php
1 <?PHP  // $Id$
2        // Authentication by looking up a POP3 server
4 // This code is completely untested so far  -  IT NEEDS TESTERS!
5 // Looks like it should work though ...
7 function auth_user_login ($username, $password) {
8 // Returns true if the username and password work
9 // and false if they are wrong or don't exist.
11     global $CFG;
13     switch ($CFG->auth_pop3type) {
14         case "pop3":
15             $host = "{".$CFG->auth_pop3host.":$CFG->auth_pop3port/pop3}INBOX";
16         break;
17         case "pop3cert":
18             $host = "{".$CFG->auth_pop3host.":$CFG->auth_pop3port/pop3/ssl/novalidate-cert}INBOX";
19         break;
20     }
22     error_reporting(0);
23     $connection = imap_open($host, $username, $password, OP_HALFOPEN);
24     error_reporting(7);   
26     if ($connection) {
27         imap_close($connection);
28         return true;
30     } else {
31         return false;
32     }
33 }
36 ?>