]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiUser/IMAP.php
Activated Id substitution for Subversion
[SourceForge/phpwiki.git] / lib / WikiUser / IMAP.php
1 <?php //-*-php-*-
2 rcs_id('$Id$');
3 /* Copyright (C) 2004 $ThePhpWikiProgrammingTeam
4  * This file is part of PhpWiki. Terms and Conditions see LICENSE. (GPL2)
5  */
6
7 class _IMAPPassUser
8 extends _PassUser
9 /**
10  * Define the var IMAP_AUTH_HOST in config/config.ini (with port probably)
11  *
12  * Preferences are handled in _PassUser
13  */
14 {
15     function checkPass($submitted_password) {
16         if (!$this->isValidName()) {
17             if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => failed isValidName", E_USER_WARNING);
18             trigger_error(_("Invalid username."),E_USER_WARNING);
19             return $this->_tryNextPass($submitted_password);
20         }
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;
24         }
25         $userid = $this->_userid;
26         $mbox = @imap_open( "{" . IMAP_AUTH_HOST . "}",
27                             $userid, $submitted_password, OP_HALFOPEN );
28         if ($mbox) {
29             imap_close($mbox);
30             $this->_authmethod = 'IMAP';
31             if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => ok", E_USER_WARNING);
32             $this->_level = WIKIAUTH_USER;
33             return $this->_level;
34         } else {
35             if ($submitted_password != "") { // if LENGTH 0 is allowed
36                 trigger_error(_("Unable to connect to IMAP server "). IMAP_AUTH_HOST, 
37                               E_USER_WARNING);
38             }
39         }
40         if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => wrong", E_USER_WARNING);
41
42         return $this->_tryNextPass($submitted_password);
43     }
44
45     //CHECKME: this will not be okay for the auth policy strict
46     function userExists() {
47         return true;
48
49         if ($this->checkPass($this->_prefs->get('passwd'))) {
50             if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::userExists => true (pass ok)", E_USER_WARNING);
51             return true;
52         }
53         if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::userExists => false (pass wrong)", E_USER_WARNING);
54         return $this->_tryNextUser();
55     }
56
57     function mayChangePass() {
58         if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::mayChangePass => false", E_USER_WARNING);
59         return false;
60     }
61 }
62
63 // $Log: not supported by cvs2svn $
64 // Revision 1.6  2006/08/25 22:35:50  rurban
65 // fix checkPass call in userExists
66 //
67 // Revision 1.5  2005/04/25 19:46:08  rurban
68 // trivial tuning by michael pruitt. Patch #1120185
69 //
70 // Revision 1.4  2004/12/26 17:11:17  rurban
71 // just copyright
72 //
73 // Revision 1.3  2004/12/20 16:05:01  rurban
74 // gettext msg unification
75 //
76 // Revision 1.2  2004/12/19 00:58:02  rurban
77 // Enforce PASSWORD_LENGTH_MINIMUM in almost all PassUser checks,
78 // Provide an errormessage if so. Just PersonalPage and BogoLogin not.
79 // Simplify httpauth logout handling and set sessions for all methods.
80 // fix main.php unknown index "x" getLevelDescription() warning.
81 //
82 // Revision 1.1  2004/11/01 10:43:58  rurban
83 // seperate PassUser methods into seperate dir (memory usage)
84 // fix WikiUser (old) overlarge data session
85 // remove wikidb arg from various page class methods, use global ->_dbi instead
86 // ...
87 //
88
89 // Local Variables:
90 // mode: php
91 // tab-width: 8
92 // c-basic-offset: 4
93 // c-hanging-comment-ender-p: nil
94 // indent-tabs-mode: nil
95 // End:
96 ?>