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
19 * along with PhpWiki; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 require_once("lib/WikiUser/IMAP.php");
26 extends _IMAPPassUser {
28 * Define the var POP3_AUTH_HOST in config/config.ini
29 * Preferences are handled in _PassUser
31 function checkPass($submitted_password) {
32 if (!$this->isValidName()) {
33 trigger_error(_("Invalid username."), E_USER_WARNING);
34 if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => failed isValidName", E_USER_WARNING);
35 return $this->_tryNextPass($submitted_password);
37 if (!$this->_checkPassLength($submitted_password)) {
38 if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => failed checkPassLength", E_USER_WARNING);
39 return WIKIAUTH_FORBIDDEN;
41 $userid = $this->_userid;
42 $pass = $submitted_password;
43 $host = defined('POP3_AUTH_HOST') ? POP3_AUTH_HOST : 'localhost:110';
44 if (defined('POP3_AUTH_PORT'))
45 $port = POP3_AUTH_PORT;
46 elseif (strstr($host,':')) {
47 list(,$port) = explode(':', $host);
52 $fp = fsockopen($host, $port, $errno, $errstr, 10);
55 $line = fgets($fp, 1024);
56 if (! strncmp("+OK", $line, 3)) {
58 fputs($fp, "user $userid\n");
60 $line = fgets($fp, 1024);
61 if (! strncmp("+OK", $line, 3)) {
63 fputs($fp, "pass $pass\n");
65 $line = fgets($fp, 1024);
66 if (! strncmp("+OK", $line, 3)) {
71 // quit the connection
73 // Get the sayonara message
74 $line = fgets($fp, 1024);
77 trigger_error(_("Couldn't connect to %s","POP3_AUTH_HOST ".$host.':'.$port),
80 $this->_authmethod = 'POP3';
81 if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => $retval", E_USER_WARNING);
83 $this->_level = WIKIAUTH_USER;
85 $this->_level = WIKIAUTH_ANON;
90 function __userExists() {
91 if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::userExists => true (dummy)", E_USER_WARNING);
100 // c-hanging-comment-ender-p: nil
101 // indent-tabs-mode: nil