]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiUser/BogoLogin.php
Reformat code
[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     var $_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                     if (!check_php_version(5))
52                         eval("\$this = \$user;");
53                     // /*PHP5 patch*/$this = $user;
54                     $user = UpgradeUser($this, $user);
55                     $this->_level = WIKIAUTH_USER;
56                     return $this->_level;
57                 } else {
58                     $this->_level = WIKIAUTH_ANON;
59                     return $this->_level;
60                 }
61             } else {
62                 $stored_password = $this->_prefs->get('passwd');
63                 if ($this->_checkPass($submitted_password, $stored_password)) {
64                     $this->_level = WIKIAUTH_USER;
65                     return $this->_level;
66                 } elseif (USER_AUTH_POLICY === 'strict') {
67                     $this->_level = WIKIAUTH_FORBIDDEN;
68                     return $this->_level;
69                 } else {
70                     return $this->_tryNextPass($submitted_password);
71                 }
72             }
73         }
74         if (isWikiWord($this->_userid)) {
75             $this->_level = WIKIAUTH_BOGO;
76         } else {
77             $this->_level = WIKIAUTH_ANON;
78         }
79         return $this->_level;
80     }
81 }
82
83 // Local Variables:
84 // mode: php
85 // tab-width: 8
86 // c-basic-offset: 4
87 // c-hanging-comment-ender-p: nil
88 // indent-tabs-mode: nil
89 // End: