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);
84 // c-hanging-comment-ender-p: nil
85 // indent-tabs-mode: nil