4 * Copyright (C) 2004 $ThePhpWikiProgrammingTeam
6 * This file is part of PhpWiki.
8 * PhpWiki is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * PhpWiki is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 require_once 'lib/WikiUser/IMAP.php';
29 * Define the var POP3_AUTH_HOST in config/config.ini
30 * Preferences are handled in _PassUser
32 function checkPass($submitted_password)
34 if (!$this->isValidName()) {
35 trigger_error(_("Invalid username."), E_USER_WARNING);
36 if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this) . "::checkPass => failed isValidName", E_USER_WARNING);
37 return $this->_tryNextPass($submitted_password);
39 if (!$this->_checkPassLength($submitted_password)) {
40 if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this) . "::checkPass => failed checkPassLength", E_USER_WARNING);
41 return WIKIAUTH_FORBIDDEN;
43 $userid = $this->_userid;
44 $pass = $submitted_password;
45 $host = defined('POP3_AUTH_HOST') ? POP3_AUTH_HOST : 'localhost:110';
46 if (defined('POP3_AUTH_PORT'))
47 $port = POP3_AUTH_PORT;
48 elseif (strstr($host, ':')) {
49 list(, $port) = explode(':', $host);
54 $fp = fsockopen($host, $port, $errno, $errstr, 10);
57 $line = fgets($fp, 1024);
58 if (!strncmp("+OK", $line, 3)) {
60 fputs($fp, "user $userid\n");
62 $line = fgets($fp, 1024);
63 if (!strncmp("+OK", $line, 3)) {
65 fputs($fp, "pass $pass\n");
67 $line = fgets($fp, 1024);
68 if (!strncmp("+OK", $line, 3)) {
73 // quit the connection
75 // Get the sayonara message
79 trigger_error(_("Couldn't connect to %s", "POP3_AUTH_HOST " . $host . ':' . $port),
82 $this->_authmethod = 'POP3';
83 if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this) . "::checkPass => $retval", E_USER_WARNING);
85 $this->_level = WIKIAUTH_USER;
87 $this->_level = WIKIAUTH_ANON;
92 function __userExists()
94 if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this) . "::userExists => true (dummy)", E_USER_WARNING);
103 // c-hanging-comment-ender-p: nil
104 // indent-tabs-mode: nil