2 rcs_id('$Id: _AuthInfo.php,v 1.3 2004-02-02 05:36:29 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 * This may display passwords in cleartext.
26 * Used to debug auth problems and settings.
28 class WikiPlugin__AuthInfo
35 function getDescription () {
36 return _("Display general and user specific auth information.");
39 function getVersion() {
40 return preg_replace("/[Revision: $]/", '',
44 function getDefaultArguments() {
45 return array('userid' => '');
48 function run($dbi, $argstr, $request) {
49 $args = $this->getArgs($argstr, $request);
51 if (empty($userid) or $userid == $request->_user->UserName()) {
52 $user = & $request->_user;
53 $userid = $user->UserName();
55 $user = WikiUser($userid);
58 $html = HTML(HTML::h3(fmt("General Auth Settings")));
59 $table = HTML::table(array('border' => 1,
62 $table->pushContent($this->_showhash("AUTH DEFINES",
63 $this->_buildConstHash(
64 array("ENABLE_USER_NEW","ALLOW_ANON_USER",
65 "ALLOW_ANON_EDIT","ALLOW_BOGO_LOGIN",
66 "REQUIRE_SIGNIN_BEFORE_EDIT","ALLOW_USER_PASSWORDS",
67 "PASSWORD_LENGTH_MINIMUM","USE_DB_SESSION"))));
68 if ((defined('ALLOW_LDAP_LOGIN') && ALLOW_LDAP_LOGIN) or in_array("LDAP",$GLOBALS['USER_AUTH_ORDER']))
69 $table->pushContent($this->_showhash("LDAP DEFINES",
70 $this->_buildConstHash(array("LDAP_AUTH_HOST","LDAP_AUTH_SEARCH"))));
71 if ((defined('ALLOW_IMAP_LOGIN') && ALLOW_IMAP_LOGIN) or in_array("IMAP",$GLOBALS['USER_AUTH_ORDER']))
72 $table->pushContent($this->_showhash("IMAP DEFINES", array("IMAP_AUTH_HOST" => IMAP_AUTH_HOST)));
73 if (defined('AUTH_USER_FILE') or in_array("File",$GLOBALS['USER_AUTH_ORDER']))
74 $table->pushContent($this->_showhash("AUTH_USER_FILE",
75 $this->_buildConstHash(array("AUTH_USER_FILE",
76 "AUTH_USER_FILE_STORABLE"))));
77 if (defined('GROUP_METHOD'))
78 $table->pushContent($this->_showhash("GROUP_METHOD",
79 $this->_buildConstHash(array("GROUP_METHOD","AUTH_GROUP_FILE","GROUP_LDAP_QUERY"))));
80 $table->pushContent($this->_showhash("\$USER_AUTH_ORDER[]", $GLOBALS['USER_AUTH_ORDER']));
81 $table->pushContent($this->_showhash("USER_AUTH_POLICY", array("USER_AUTH_POLICY"=>USER_AUTH_POLICY)));
82 $table->pushContent($this->_showhash("\$DBParams[]", $GLOBALS['DBParams']));
83 unset($GLOBALS['DBAuthParams']['dummy']);
84 $table->pushContent($this->_showhash("\$DBAuthParams[]", $GLOBALS['DBAuthParams']));
85 $html->pushContent($table);
86 $html->pushContent(HTML(HTML::h3(fmt("Personal Auth Settings for '%s'",$userid))));
88 $html->pushContent(HTML::p(fmt("No userid")));
91 $table = HTML::table(array('border' => 1,
94 $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
95 $userdata = $this->_obj2hash($user);
96 $table->pushContent($this->_showhash("Object of ".get_class($user), $userdata));
97 $html->pushContent($table);
102 function _obj2hash ($obj, $exclude = false, $fields = false) {
104 if (! $fields ) $fields = get_object_vars($obj);
105 foreach ($fields as $key => $val) {
106 if (is_array($exclude)) {
107 if (in_array($key,$exclude)) continue;
114 function _showhash ($heading, $hash) {
115 static $seen = array();
118 $rows[] = HTML::tr(array('bgcolor' => '#ffcccc',
119 'style' => 'color:#000000'),
120 HTML::td(array('colspan' => 2,
121 'style' => 'color:#000000'),
125 foreach ($hash as $key => $val) {
126 if (is_object($val)) {
127 $heading = "Object of ".get_class($val);
128 if ($heading == "Object of wikidb_sql") $val = $heading;
129 elseif (substr($heading,0,13) == "Object of db_") $val = $heading;
130 elseif (!isset($seen[$heading])) {
131 if (empty($seen[$heading])) $seen[$heading] = 1;
132 $val = HTML::table(array('border' => 1,
135 $this->_showhash($heading, $this->_obj2hash($val)));
139 } elseif (is_array($val)) {
140 $heading = $key."[]";
141 if (!isset($seen[$heading])) {
142 if (empty($seen[$heading])) $seen[$heading] = 1;
143 $val = HTML::table(array('border' => 1,
146 $this->_showhash($heading, $val));
151 $rows[] = HTML::tr(HTML::td(array('align' => 'right',
152 'bgcolor' => '#cccccc',
153 'style' => 'color:#000000'),
154 HTML(HTML::raw(' '), $key,
155 HTML::raw(' '))),
156 HTML::td(array('bgcolor' => '#ffffff',
157 'style' => 'color:#000000'),
158 $val ? $val : HTML::raw(' '))
160 if (empty($seen[$key])) $seen[$key] = 1;
166 function _buildConstHash($constants) {
168 foreach ($constants as $c) {
169 $hash[$c] = defined($c) ? constant($c) : '<empty>';
170 if ($hash[$c] === false) $hash[$c] = 'false';
171 elseif ($hash[$c] === true) $hash[$c] = 'true';
177 // $Log: not supported by cvs2svn $
178 // Revision 1.2 2004/02/01 09:14:11 rurban
179 // Started with Group_Ldap (not yet ready)
180 // added new _AuthInfo plugin to help in auth problems (warning: may display passwords)
181 // fixed some configurator vars
182 // renamed LDAP_AUTH_SEARCH to LDAP_BASE_DN
183 // changed PHPWIKI_VERSION from 1.3.8a to 1.3.8pre
184 // USE_DB_SESSION defaults to true on SQL
185 // changed GROUP_METHOD definition to string, not constants
186 // changed sample user DBAuthParams from UPDATE to REPLACE to be able to
187 // create users. (Not to be used with external databases generally, but
188 // with the default internal user table)
190 // fixed the IndexAsConfigProblem logic. this was flawed:
191 // scripts which are the same virtual path defined their own lib/main call
192 // (hmm, have to test this better, phpwiki.sf.net/demo works again)
194 // Revision 1.1 2004/02/01 01:04:34 rurban
195 // Used to debug auth problems and settings.
196 // This may display passwords in cleartext.
197 // DB Objects are not displayed anymore.
199 // Revision 1.21 2003/02/21 04:22:28 dairiki
200 // Make this work for array-valued data. Make display of cached markup
201 // readable. Some code cleanups. (This still needs more work.)
203 // Revision 1.20 2003/01/18 21:19:24 carstenklapp
205 // Reformatting; added copyleft, getVersion, getDescription
208 // (c-file-style: "gnu")
213 // c-hanging-comment-ender-p: nil
214 // indent-tabs-mode: nil