]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiUser/POP3.php
seperate PassUser methods into seperate dir (memory usage)
[SourceForge/phpwiki.git] / lib / WikiUser / POP3.php
1 <?php //-*-php-*-
2 rcs_id('$Id: POP3.php,v 1.1 2004-11-01 10:43:58 rurban Exp $');
3 /* Copyright (C) 2004 $ThePhpWikiProgrammingTeam
4  */
5
6 class _POP3PassUser
7 extends _IMAPPassUser {
8 /**
9  * Define the var POP3_AUTH_HOST in config/config.ini
10  * Preferences are handled in _PassUser
11  */
12     function checkPass($submitted_password) {
13         if (!$this->isValidName()) {
14             return $this->_tryNextPass($submitted_password);
15         }
16         $userid = $this->_userid;
17         $pass = $submitted_password;
18         $host = defined('POP3_AUTH_HOST') ? POP3_AUTH_HOST : 'localhost:110';
19         if (defined('POP3_AUTH_PORT'))
20             $port = POP3_AUTH_PORT;
21         elseif (strstr($host,':')) {
22             list(,$port) = split(':',$host);
23         } else {
24             $port = 110;
25         }
26         $retval = false;
27         $fp = fsockopen($host, $port, $errno, $errstr, 10);
28         if ($fp) {
29             // Get welcome string
30             $line = fgets($fp, 1024);
31             if (! strncmp("+OK ", $line, 4)) {
32                 // Send user name
33                 fputs($fp, "user $userid\n");
34                 // Get response
35                 $line = fgets($fp, 1024);
36                 if (! strncmp("+OK ", $line, 4)) {
37                     // Send password
38                     fputs($fp, "pass $pass\n");
39                     // Get response
40                     $line = fgets($fp, 1024);
41                     if (! strncmp("+OK ", $line, 4)) {
42                         $retval = true;
43                     }
44                 }
45             }
46             // quit the connection
47             fputs($fp, "quit\n");
48             // Get the sayonara message
49             $line = fgets($fp, 1024);
50             fclose($fp);
51         } else {
52             trigger_error(_("Couldn't connect to %s","POP3_AUTH_HOST ".$host.':'.$port),
53                           E_USER_WARNING);
54         }
55         $this->_authmethod = 'POP3';
56         if ($retval) {
57             $this->_level = WIKIAUTH_USER;
58         } else {
59             $this->_level = WIKIAUTH_ANON;
60         }
61         return $this->_level;
62     }
63 }
64
65 // $Log: not supported by cvs2svn $
66
67 // Local Variables:
68 // mode: php
69 // tab-width: 8
70 // c-basic-offset: 4
71 // c-hanging-comment-ender-p: nil
72 // indent-tabs-mode: nil
73 // End:
74 ?>