]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiUser/POP3.php
gettext msg unification
[SourceForge/phpwiki.git] / lib / WikiUser / POP3.php
1 <?php //-*-php-*-
2 rcs_id('$Id: POP3.php,v 1.3 2004-12-20 16:05:01 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             trigger_error(_("Invalid username."),E_USER_WARNING);
15             return $this->_tryNextPass($submitted_password);
16         }
17         if (!$this->_checkPassLength($submitted_password)) {
18             return WIKIAUTH_FORBIDDEN;
19         }
20         $userid = $this->_userid;
21         $pass = $submitted_password;
22         $host = defined('POP3_AUTH_HOST') ? POP3_AUTH_HOST : 'localhost:110';
23         if (defined('POP3_AUTH_PORT'))
24             $port = POP3_AUTH_PORT;
25         elseif (strstr($host,':')) {
26             list(,$port) = split(':',$host);
27         } else {
28             $port = 110;
29         }
30         $retval = false;
31         $fp = fsockopen($host, $port, $errno, $errstr, 10);
32         if ($fp) {
33             // Get welcome string
34             $line = fgets($fp, 1024);
35             if (! strncmp("+OK ", $line, 4)) {
36                 // Send user name
37                 fputs($fp, "user $userid\n");
38                 // Get response
39                 $line = fgets($fp, 1024);
40                 if (! strncmp("+OK ", $line, 4)) {
41                     // Send password
42                     fputs($fp, "pass $pass\n");
43                     // Get response
44                     $line = fgets($fp, 1024);
45                     if (! strncmp("+OK ", $line, 4)) {
46                         $retval = true;
47                     }
48                 }
49             }
50             // quit the connection
51             fputs($fp, "quit\n");
52             // Get the sayonara message
53             $line = fgets($fp, 1024);
54             fclose($fp);
55         } else {
56             trigger_error(_("Couldn't connect to %s","POP3_AUTH_HOST ".$host.':'.$port),
57                           E_USER_WARNING);
58         }
59         $this->_authmethod = 'POP3';
60         if ($retval) {
61             $this->_level = WIKIAUTH_USER;
62         } else {
63             $this->_level = WIKIAUTH_ANON;
64         }
65         return $this->_level;
66     }
67 }
68
69 // $Log: not supported by cvs2svn $
70 // Revision 1.2  2004/12/19 00:58:02  rurban
71 // Enforce PASSWORD_LENGTH_MINIMUM in almost all PassUser checks,
72 // Provide an errormessage if so. Just PersonalPage and BogoLogin not.
73 // Simplify httpauth logout handling and set sessions for all methods.
74 // fix main.php unknown index "x" getLevelDescription() warning.
75 //
76 // Revision 1.1  2004/11/01 10:43:58  rurban
77 // seperate PassUser methods into seperate dir (memory usage)
78 // fix WikiUser (old) overlarge data session
79 // remove wikidb arg from various page class methods, use global ->_dbi instead
80 // ...
81 //
82
83 // Local Variables:
84 // mode: php
85 // tab-width: 8
86 // c-basic-offset: 4
87 // c-hanging-comment-ender-p: nil
88 // indent-tabs-mode: nil
89 // End:
90 ?>