2 rcs_id('$Id: _AuthInfo.php,v 1.6 2004-02-15 15:21:24 rurban Exp $');
4 Copyright 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/Template.php');
25 * Used to debug auth problems and settings.
27 * Warning! This may display db and user passwords in cleartext.
28 * Fixme: How to avoid caching?
30 class WikiPlugin__AuthInfo
37 function getDescription () {
38 return _("Display general and user specific auth information.");
41 function getVersion() {
42 return preg_replace("/[Revision: $]/", '',
46 function getDefaultArguments() {
47 return array('userid' => '');
50 function run($dbi, $argstr, $request) {
51 $args = $this->getArgs($argstr, $request);
53 if (empty($userid) or $userid == $request->_user->UserName()) {
54 $user = & $request->_user;
55 $userid = $user->UserName();
57 $user = WikiUser($userid);
60 $html = HTML(HTML::h3(fmt("General Auth Settings")));
61 $table = HTML::table(array('border' => 1,
64 $table->pushContent($this->_showhash("AUTH DEFINES",
65 $this->_buildConstHash(
66 array("ENABLE_USER_NEW","ALLOW_ANON_USER",
67 "ALLOW_ANON_EDIT","ALLOW_BOGO_LOGIN",
68 "REQUIRE_SIGNIN_BEFORE_EDIT","ALLOW_USER_PASSWORDS",
69 "PASSWORD_LENGTH_MINIMUM","USE_DB_SESSION"))));
70 if ((defined('ALLOW_LDAP_LOGIN') && ALLOW_LDAP_LOGIN) or in_array("LDAP",$GLOBALS['USER_AUTH_ORDER']))
71 $table->pushContent($this->_showhash("LDAP DEFINES",
72 $this->_buildConstHash(array("LDAP_AUTH_HOST","LDAP_BASE_DN"))));
73 if ((defined('ALLOW_IMAP_LOGIN') && ALLOW_IMAP_LOGIN) or in_array("IMAP",$GLOBALS['USER_AUTH_ORDER']))
74 $table->pushContent($this->_showhash("IMAP DEFINES", array("IMAP_AUTH_HOST" => IMAP_AUTH_HOST)));
75 if (defined('AUTH_USER_FILE') or in_array("File",$GLOBALS['USER_AUTH_ORDER']))
76 $table->pushContent($this->_showhash("AUTH_USER_FILE",
77 $this->_buildConstHash(array("AUTH_USER_FILE",
78 "AUTH_USER_FILE_STORABLE"))));
79 if (defined('GROUP_METHOD'))
80 $table->pushContent($this->_showhash("GROUP_METHOD",
81 $this->_buildConstHash(array("GROUP_METHOD","AUTH_GROUP_FILE","GROUP_LDAP_QUERY"))));
82 $table->pushContent($this->_showhash("\$USER_AUTH_ORDER[]", $GLOBALS['USER_AUTH_ORDER']));
83 $table->pushContent($this->_showhash("USER_AUTH_POLICY", array("USER_AUTH_POLICY"=>USER_AUTH_POLICY)));
84 $DBParams = $GLOBALS['DBParams'];
85 $DBParams['dsn'] = class_exists('WikiDB_SQL') ? WikiDB_SQL::view_dsn($DBParams['dsn']) : '';
86 $table->pushContent($this->_showhash("\$DBParams[]", $DBParams));
87 $DBAuthParams = $GLOBALS['DBAuthParams'];
88 $DBAuthParams['auth_dsn'] = class_exists('WikiDB_SQL') ? WikiDB_SQL::view_dsn($DBAuthParams['auth_dsn']) : '';
89 unset($DBAuthParams['dummy']);
90 $table->pushContent($this->_showhash("\$DBAuthParams[]", $DBAuthParams));
91 $html->pushContent($table);
92 $html->pushContent(HTML(HTML::h3(fmt("Personal Auth Settings for '%s'",$userid))));
94 $html->pushContent(HTML::p(fmt("No userid")));
97 $table = HTML::table(array('border' => 1,
100 //$table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
101 $userdata = obj2hash($user);
102 $table->pushContent($this->_showhash("User: Object of ".get_class($user), $userdata));
103 $group = &WikiGroup::getGroup($request);
104 $table->pushContent($this->_showhash("Group: Object of ".get_class($group), $group));
105 $groups = $group->getAllGroupsIn();
106 $groupdata = array('getAllGroupsIn' => $groups);
107 foreach ($groups as $g) {
108 $groupdata["getMembersOf($g)"] = $group->getMembersOf($g);
109 $groupdata["isMember($g)"] = $group->isMember($g);
111 $table->pushContent($this->_showhash("Group Methods: ", $groupdata));
112 $html->pushContent($table);
117 function _showhash ($heading, $hash) {
118 static $seen = array();
121 $rows[] = HTML::tr(array('bgcolor' => '#ffcccc',
122 'style' => 'color:#000000'),
123 HTML::td(array('colspan' => 2,
124 'style' => 'color:#000000'),
126 if (is_object($hash))
127 $hash = obj2hash($hash);
130 foreach ($hash as $key => $val) {
131 if (is_object($val)) {
132 $heading = "Object of ".get_class($val);
133 if ($heading == "Object of wikidb_sql") $val = $heading;
134 elseif (substr($heading,0,13) == "Object of db_") $val = $heading;
135 elseif (!isset($seen[$heading])) {
136 if (empty($seen[$heading])) $seen[$heading] = 1;
137 $val = HTML::table(array('border' => 1,
140 $this->_showhash($heading, obj2hash($val)));
144 } elseif (is_array($val)) {
145 $heading = $key."[]";
146 if (!isset($seen[$heading])) {
147 if (empty($seen[$heading])) $seen[$heading] = 1;
148 $val = HTML::table(array('border' => 1,
151 $this->_showhash($heading, $val));
156 $rows[] = HTML::tr(HTML::td(array('align' => 'right',
157 'bgcolor' => '#cccccc',
158 'style' => 'color:#000000'),
159 HTML(HTML::raw(' '), $key,
160 HTML::raw(' '))),
161 HTML::td(array('bgcolor' => '#ffffff',
162 'style' => 'color:#000000'),
163 $val ? $val : HTML::raw(' '))
165 if (empty($seen[$key])) $seen[$key] = 1;
171 function _buildConstHash($constants) {
173 foreach ($constants as $c) {
174 $hash[$c] = defined($c) ? constant($c) : '<empty>';
175 if ($hash[$c] === false) $hash[$c] = 'false';
176 elseif ($hash[$c] === true) $hash[$c] = 'true';
182 // $Log: not supported by cvs2svn $
183 // Revision 1.5 2004/02/09 03:58:20 rurban
184 // for now default DB_SESSION to false
186 // * not existing perms will now query the parent, and not
187 // return the default perm
188 // * added pagePermissions func which returns the object per page
189 // * added getAccessDescription
191 // * added global ->prepare (not yet used) with smart user/pref/member table prefixing.
192 // * force init of authdbh in the 2 db classes
194 // * fixed session handling (not triple auth request anymore)
195 // * don't store cookie prefs with sessions
196 // stdlib: global obj2hash helper from _AuthInfo, also needed for PagePerm
198 // Revision 1.4 2004/02/07 10:41:25 rurban
199 // fixed auth from session (still double code but works)
201 // fixed DbPassUser upgrade and policy=old
204 // Revision 1.3 2004/02/02 05:36:29 rurban
205 // Simplification and more options, but no passwd or admin protection yet.
207 // Revision 1.2 2004/02/01 09:14:11 rurban
208 // Started with Group_Ldap (not yet ready)
209 // added new _AuthInfo plugin to help in auth problems (warning: may display passwords)
210 // fixed some configurator vars
211 // renamed LDAP_AUTH_SEARCH to LDAP_BASE_DN
212 // changed PHPWIKI_VERSION from 1.3.8a to 1.3.8pre
213 // USE_DB_SESSION defaults to true on SQL
214 // changed GROUP_METHOD definition to string, not constants
215 // changed sample user DBAuthParams from UPDATE to REPLACE to be able to
216 // create users. (Not to be used with external databases generally, but
217 // with the default internal user table)
219 // fixed the IndexAsConfigProblem logic. this was flawed:
220 // scripts which are the same virtual path defined their own lib/main call
221 // (hmm, have to test this better, phpwiki.sf.net/demo works again)
223 // Revision 1.1 2004/02/01 01:04:34 rurban
224 // Used to debug auth problems and settings.
225 // This may display passwords in cleartext.
226 // DB Objects are not displayed anymore.
228 // Revision 1.21 2003/02/21 04:22:28 dairiki
229 // Make this work for array-valued data. Make display of cached markup
230 // readable. Some code cleanups. (This still needs more work.)
232 // Revision 1.20 2003/01/18 21:19:24 carstenklapp
234 // Reformatting; added copyleft, getVersion, getDescription
237 // (c-file-style: "gnu")
242 // c-hanging-comment-ender-p: nil
243 // indent-tabs-mode: nil