]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiUser/BogoLogin.php
var --> public
[SourceForge/phpwiki.git] / lib / WikiUser / BogoLogin.php
1 <?php
2
3 /*
4  * Copyright (C) 2004 ReiniUrban
5  *
6  * This file is part of PhpWiki.
7  *
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.
12  *
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.
17  *
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.
21  */
22
23 /** Without stored password. A _BogoLoginPassUser with password
24  *  is automatically upgraded to a PersonalPagePassUser.
25  */
26 class _BogoLoginPassUser extends _PassUser
27 {
28
29     public $_authmethod = 'BogoLogin';
30
31     function userExists()
32     {
33         if (isWikiWord($this->_userid)) {
34             $this->_level = WIKIAUTH_BOGO;
35             return true;
36         } else {
37             $this->_level = WIKIAUTH_ANON;
38             return false;
39         }
40     }
41
42     /** A BogoLoginUser requires no password at all
43      *  But if there's one stored, we override it with the PersonalPagePassUser instead
44      */
45     function checkPass($submitted_password)
46     {
47         if ($this->_prefs->get('passwd')) {
48             if (isset($this->_prefs->_method) and $this->_prefs->_method == 'HomePage') {
49                 $user = new _PersonalPagePassUser($this->_userid, $this->_prefs);
50                 if ($user->checkPass($submitted_password)) {
51                     UpgradeUser($this, $user);
52                     $this->_level = WIKIAUTH_USER;
53                     return $this->_level;
54                 } else {
55                     $this->_level = WIKIAUTH_ANON;
56                     return $this->_level;
57                 }
58             } else {
59                 $stored_password = $this->_prefs->get('passwd');
60                 if ($this->_checkPass($submitted_password, $stored_password)) {
61                     $this->_level = WIKIAUTH_USER;
62                     return $this->_level;
63                 } elseif (USER_AUTH_POLICY === 'strict') {
64                     $this->_level = WIKIAUTH_FORBIDDEN;
65                     return $this->_level;
66                 } else {
67                     return $this->_tryNextPass($submitted_password);
68                 }
69             }
70         }
71         if (isWikiWord($this->_userid)) {
72             $this->_level = WIKIAUTH_BOGO;
73         } else {
74             $this->_level = WIKIAUTH_ANON;
75         }
76         return $this->_level;
77     }
78 }
79
80 // Local Variables:
81 // mode: php
82 // tab-width: 8
83 // c-basic-offset: 4
84 // c-hanging-comment-ender-p: nil
85 // indent-tabs-mode: nil
86 // End: