3 /* Copyright (C) 2004 $ThePhpWikiProgrammingTeam
4 * This file is part of PhpWiki. Terms and Conditions see LICENSE. (GPL2)
7 require_once("lib/WikiUser/IMAP.php");
10 extends _IMAPPassUser {
12 * Define the var POP3_AUTH_HOST in config/config.ini
13 * Preferences are handled in _PassUser
15 function checkPass($submitted_password) {
16 if (!$this->isValidName()) {
17 trigger_error(_("Invalid username."), E_USER_WARNING);
18 if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => failed isValidName", E_USER_WARNING);
19 return $this->_tryNextPass($submitted_password);
21 if (!$this->_checkPassLength($submitted_password)) {
22 if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => failed checkPassLength", E_USER_WARNING);
23 return WIKIAUTH_FORBIDDEN;
25 $userid = $this->_userid;
26 $pass = $submitted_password;
27 $host = defined('POP3_AUTH_HOST') ? POP3_AUTH_HOST : 'localhost:110';
28 if (defined('POP3_AUTH_PORT'))
29 $port = POP3_AUTH_PORT;
30 elseif (strstr($host,':')) {
31 list(,$port) = split(':',$host);
36 $fp = fsockopen($host, $port, $errno, $errstr, 10);
39 $line = fgets($fp, 1024);
40 if (! strncmp("+OK", $line, 3)) {
42 fputs($fp, "user $userid\n");
44 $line = fgets($fp, 1024);
45 if (! strncmp("+OK", $line, 3)) {
47 fputs($fp, "pass $pass\n");
49 $line = fgets($fp, 1024);
50 if (! strncmp("+OK", $line, 3)) {
55 // quit the connection
57 // Get the sayonara message
58 $line = fgets($fp, 1024);
61 trigger_error(_("Couldn't connect to %s","POP3_AUTH_HOST ".$host.':'.$port),
64 $this->_authmethod = 'POP3';
65 if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => $retval", E_USER_WARNING);
67 $this->_level = WIKIAUTH_USER;
69 $this->_level = WIKIAUTH_ANON;
74 function __userExists() {
75 if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::userExists => true (dummy)", E_USER_WARNING);
80 // $Log: not supported by cvs2svn $
81 // Revision 1.6 2005/04/23 11:17:41 rurban
84 // Revision 1.5 2005/03/19 07:30:52 rurban
85 // fixed missing IMAP dependency. Thanks to sun-man
87 // Revision 1.4 2004/12/26 17:11:17 rurban
90 // Revision 1.3 2004/12/20 16:05:01 rurban
91 // gettext msg unification
93 // Revision 1.2 2004/12/19 00:58:02 rurban
94 // Enforce PASSWORD_LENGTH_MINIMUM in almost all PassUser checks,
95 // Provide an errormessage if so. Just PersonalPage and BogoLogin not.
96 // Simplify httpauth logout handling and set sessions for all methods.
97 // fix main.php unknown index "x" getLevelDescription() warning.
99 // Revision 1.1 2004/11/01 10:43:58 rurban
100 // seperate PassUser methods into seperate dir (memory usage)
101 // fix WikiUser (old) overlarge data session
102 // remove wikidb arg from various page class methods, use global ->_dbi instead
110 // c-hanging-comment-ender-p: nil
111 // indent-tabs-mode: nil