2 rcs_id('$Id: _AuthInfo.php,v 1.2 2004-02-01 09:14:11 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 $auth_defines = array();
63 foreach (array("ENABLE_USER_NEW","ALLOW_ANON_USER","ALLOW_ANON_EDIT","ALLOW_BOGO_LOGIN",
64 "REQUIRE_SIGNIN_BEFORE_EDIT","ALLOW_USER_PASSWORDS",
65 "PASSWORD_LENGTH_MINIMUM","USE_DB_SESSION") as $constant) {
66 $auth_defines[$constant] = constant($constant);
68 $table->pushContent($this->_showhash("AUTH DEFINES", $auth_defines));
69 if ((defined('ALLOW_LDAP_LOGIN') && ALLOW_LDAP_LOGIN) or in_array("LDAP",$GLOBALS['USER_AUTH_ORDER']))
70 $table->pushContent($this->_showhash("LDAP DEFINES", array("LDAP_AUTH_HOST" => LDAP_AUTH_HOST,
71 "LDAP_AUTH_SEARCH" => LDAP_AUTH_SEARCH)));
72 if ((defined('ALLOW_IMAP_LOGIN') && ALLOW_IMAP_LOGIN) or in_array("IMAP",$GLOBALS['USER_AUTH_ORDER']))
73 $table->pushContent($this->_showhash("IMAP DEFINES", array("IMAP_AUTH_HOST" => IMAP_AUTH_HOST)));
74 if (defined('AUTH_USER_FILE') or in_array("File",$GLOBALS['USER_AUTH_ORDER']))
75 $table->pushContent($this->_showhash("AUTH_USER_FILE", array("AUTH_USER_FILE" => AUTH_USER_FILE,
76 "AUTH_USER_FILE_STORABLE" => AUTH_USER_FILE_STORABLE,
77 "AUTH_GROUP_FILE" => AUTH_GROUP_FILE
79 if (defined('GROUP_METHOD'))
80 $table->pushContent($this->_showhash("GROUP_METHOD", array("GROUP_METHOD" => GROUP_METHOD)));
81 $table->pushContent($this->_showhash("\$USER_AUTH_ORDER[]", $GLOBALS['USER_AUTH_ORDER']));
82 $table->pushContent($this->_showhash("USER_AUTH_POLICY", array("USER_AUTH_POLICY"=>USER_AUTH_POLICY)));
83 $table->pushContent($this->_showhash("\$DBParams[]", $GLOBALS['DBParams']));
84 unset($GLOBALS['DBAuthParams']['dummy']);
85 $table->pushContent($this->_showhash("\$DBAuthParams[]", $GLOBALS['DBAuthParams']));
86 $html->pushContent($table);
87 $html->pushContent(HTML(HTML::h3(fmt("Personal Auth Settings for '%s'",$userid))));
89 $html->pushContent(HTML::p(fmt("No userid")));
92 $table = HTML::table(array('border' => 1,
95 $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
96 $userdata = $this->_obj2hash($user);
97 $table->pushContent($this->_showhash("Object of ".get_class($user), $userdata));
98 $html->pushContent($table);
103 function _obj2hash ($obj, $exclude = false, $fields = false) {
105 if (! $fields ) $fields = get_object_vars($obj);
106 foreach ($fields as $key => $val) {
107 if (is_array($exclude)) {
108 if (in_array($key,$exclude)) continue;
115 function _showhash ($heading, $hash) {
116 static $seen = array();
119 $rows[] = HTML::tr(array('bgcolor' => '#ffcccc',
120 'style' => 'color:#000000'),
121 HTML::td(array('colspan' => 2,
122 'style' => 'color:#000000'),
126 foreach ($hash as $key => $val) {
127 if (is_object($val)) {
128 $heading = "Object of ".get_class($val);
129 if ($heading == "Object of wikidb_sql") $val = $heading;
130 elseif (substr($heading,0,13) == "Object of db_") $val = $heading;
131 elseif (!isset($seen[$heading])) {
132 if (empty($seen[$heading])) $seen[$heading] = 1;
133 $val = HTML::table(array('border' => 1,
136 $this->_showhash($heading, $this->_obj2hash($val)));
140 } elseif (is_array($val)) {
141 $heading = $key."[]";
142 if (!isset($seen[$heading])) {
143 if (empty($seen[$heading])) $seen[$heading] = 1;
144 $val = HTML::table(array('border' => 1,
147 $this->_showhash($heading, $val));
152 $rows[] = HTML::tr(HTML::td(array('align' => 'right',
153 'bgcolor' => '#cccccc',
154 'style' => 'color:#000000'),
155 HTML(HTML::raw(' '), $key,
156 HTML::raw(' '))),
157 HTML::td(array('bgcolor' => '#ffffff',
158 'style' => 'color:#000000'),
159 $val ? $val : HTML::raw(' '))
161 if (empty($seen[$key])) $seen[$key] = 1;
168 // $Log: not supported by cvs2svn $
169 // Revision 1.1 2004/02/01 01:04:34 rurban
170 // Used to debug auth problems and settings.
171 // This may display passwords in cleartext.
172 // DB Objects are not displayed anymore.
174 // Revision 1.21 2003/02/21 04:22:28 dairiki
175 // Make this work for array-valued data. Make display of cached markup
176 // readable. Some code cleanups. (This still needs more work.)
178 // Revision 1.20 2003/01/18 21:19:24 carstenklapp
180 // Reformatting; added copyleft, getVersion, getDescription
183 // (c-file-style: "gnu")
188 // c-hanging-comment-ender-p: nil
189 // indent-tabs-mode: nil