forked from mantisbt/mantisbt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adm_config_report.php
221 lines (205 loc) · 7.79 KB
/
adm_config_report.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
# MantisBT - A PHP based bugtracking system
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
/**
* @package MantisBT
* @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
* @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*
* @uses core.php
* @uses access_api.php
* @uses authentication_api.php
* @uses config_api.php
* @uses constant_inc.php
* @uses database_api.php
* @uses form_api.php
* @uses helper_api.php
* @uses html_api.php
* @uses lang_api.php
* @uses print_api.php
* @uses project_api.php
* @uses string_api.php
* @uses user_api.php
*/
/**
* MantisBT Core API's
*/
require_once( 'core.php' );
require_api( 'access_api.php' );
require_api( 'authentication_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
require_api( 'database_api.php' );
require_api( 'form_api.php' );
require_api( 'helper_api.php' );
require_api( 'html_api.php' );
require_api( 'lang_api.php' );
require_api( 'print_api.php' );
require_api( 'project_api.php' );
require_api( 'string_api.php' );
require_api( 'user_api.php' );
access_ensure_global_level( config_get( 'view_configuration_threshold' ) );
$t_read_write_access = access_has_global_level( config_get('set_configuration_threshold' ) );
html_page_top( lang_get( 'configuration_report' ) );
print_manage_menu( 'adm_config_report.php' );
print_manage_config_menu( 'adm_config_report.php' );
function get_config_type( $p_type ) {
switch( $p_type ) {
case CONFIG_TYPE_INT:
return "integer";
case CONFIG_TYPE_FLOAT:
return "float";
case CONFIG_TYPE_COMPLEX:
return "complex";
case CONFIG_TYPE_STRING:
default:
return "string";
}
}
function print_config_value_as_string( $p_type, $p_value ) {
$t_corrupted = false;
switch( $p_type ) {
case CONFIG_TYPE_FLOAT:
$t_value = (float)$p_value;
echo $t_value;
return;
case CONFIG_TYPE_INT:
$t_value = (integer)$p_value;
echo $t_value;
return;
case CONFIG_TYPE_STRING:
$t_value = config_eval( $p_value );
echo string_nl2br( string_html_specialchars( $t_value ) );
return;
case CONFIG_TYPE_COMPLEX:
$t_value = @unserialize( $p_value );
if ( $t_value === false ) {
$t_corrupted = true;
}
break;
default:
$t_value = config_eval( $p_value );
break;
}
echo '<pre>';
if ( $t_corrupted ) {
echo lang_get( 'configuration_corrupted' );
} else {
if ( function_exists( 'var_export' ) ) {
var_export( $t_value );
} else {
print_r( $t_value );
}
}
echo '</pre>';
}
$t_config_table = db_get_table( 'config' );
$query = "SELECT config_id, user_id, project_id, type, value, access_reqd FROM $t_config_table ORDER BY user_id, project_id, config_id";
$result = db_query_bound( $query );
?>
<div id="adm-config-div" class="table-container">
<h2><?php echo lang_get( 'database_configuration' ) ?></h2>
<table cellspacing="1" cellpadding="5" border="1">
<tr class="row-category">
<th class="center"><?php echo lang_get( 'username' ) ?></th>
<th class="center"><?php echo lang_get( 'project_name' ) ?></th>
<th><?php echo lang_get( 'configuration_option' ) ?></th>
<th class="center"><?php echo lang_get( 'configuration_option_type' ) ?></th>
<th class="center"><?php echo lang_get( 'configuration_option_value' ) ?></th>
<th class="center"><?php echo lang_get( 'access_level' ) ?></th>
<?php if ( $t_read_write_access ): ?>
<th class="center"><?php echo lang_get( 'actions' ) ?></th>
<?php endif; ?>
</tr><?php
while ( $row = db_fetch_array( $result ) ) {
extract( $row, EXTR_PREFIX_ALL, 'v' ); ?>
<tr <?php echo helper_alternate_class() ?>>
<td class="center">
<?php echo ($v_user_id == 0) ? lang_get( 'all_users' ) : string_display_line( user_get_name( $v_user_id ) ) ?>
</td>
<td class="center"><?php echo string_display_line( project_get_name( $v_project_id, false ) ) ?></td>
<td><?php echo string_display_line( $v_config_id ) ?></td>
<td class="center"><?php echo string_display_line( get_config_type( $v_type ) ) ?></td>
<td class="left"><?php print_config_value_as_string( $v_type, $v_value ) ?></td>
<td class="center"><?php echo get_enum_element( 'access_levels', $v_access_reqd ) ?></td>
<?php if ( $t_read_write_access ): ?>
<td class="center">
<?php
if ( config_can_delete( $v_config_id ) ) {
print_button( "adm_config_delete.php?user_id=$v_user_id&project_id=$v_project_id&config_option=$v_config_id", lang_get( 'delete_link' ) );
} else {
echo ' ';
}
?>
</td>
<?php endif; ?>
</tr><?php
} # end for loop ?>
</table>
</div><?php
if ( $t_read_write_access ) { ?>
<div class="form-container">
<form method="post" action="adm_config_set.php">
<fieldset>
<legend><span><?php echo lang_get( 'set_configuration_option' ) ?></span></legend>
<?php echo form_security_field( 'adm_config_set' ) ?>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="config-user-id"><span><?php echo lang_get( 'username' ) ?></span></label>
<span class="select">
<select id="config-user-id" name="user_id">
<option value="0" selected="selected"><?php echo lang_get( 'all_users' ); ?></option>
<?php print_user_option_list( 0 ) ?>
</select>
</span>
<span class="label-style"></span>
</div>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="config-project-id"><span><?php echo lang_get( 'project_name' ) ?></span></label>
<span class="select">
<select id="config-project-id" name="project_id">
<option value="0" selected="selected"><?php echo lang_get( 'all_projects' ); ?></option>
<?php print_project_option_list( ALL_PROJECTS, false ) ?>
</select>
</span>
<span class="label-style"></span>
</div>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="config-option"><span><?php echo lang_get( 'configuration_option' ) ?></span></label>
<span class="input"><input type="text" id="config-option" name="config_option" value="" size="64" maxlength="64" /></span>
<span class="label-style"></span>
</div>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="config-type"><span><?php echo lang_get( 'configuration_option_type' ) ?></span></label>
<span class="select">
<select id="config-type" name="type">
<option value="default" selected="selected">default</option>
<option value="string">string</option>
<option value="integer">integer</option>
<option value="complex">complex</option>
</select>
</span>
<span class="label-style"></span>
</div>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="config-value"><span><?php echo lang_get( 'configuration_option_value' ) ?></span></label>
<span class="textarea"><textarea id="config-value" name="value" cols="80" rows="10"></textarea></span>
<span class="label-style"></span>
</div>
<span class="submit-button"><input type="submit" name="config_set" class="button" value="<?php echo lang_get( 'set_configuration_option' ) ?>" /></span>
</fieldset>
</form>
</div><?php
} # end user can change config
html_page_bottom();