summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod.php71
1 files changed, 30 insertions, 41 deletions
diff --git a/mod.php b/mod.php
index ff7db7fb..e465adec 100644
--- a/mod.php
+++ b/mod.php
@@ -186,52 +186,41 @@
} elseif(preg_match('/^\/config$/', $query)) {
if($mod['type'] < $config['mod']['show_config']) error($config['error']['noaccess']);
- // Show instance-config.php
-
- //$data = highlight_file('inc/instance-config.php', true);
- //if(MOD_NEVER_REAL_PASSWORD) {
- // // Rough and dirty removal of password
- // $data = str_replace(MY_PASSWORD, '*******', $data);
- //}
-
- $constants = get_defined_constants(true);
- $constants = $constants['user'];
+ // Show instance-config.php
$data = '';
- foreach($constants as $name => $value) {
- if(MOD_NEVER_REAL_PASSWORD && $name == 'DB_PASSWORD')
- $value = '<em>hidden</em>';
- else {
- // For some reason PHP is only giving me the first defined value (the default), so use constant()
- $value = constant($name);
- if(gettype($value) == 'boolean') {
- $value = $value ? '<span style="color:green;">On</span>' : '<span style="color:red;">Off</span>';
- } elseif(gettype($value) == 'string') {
- if(empty($value))
- $value = '<em>empty</em>';
- else
- $value = '<span style="color:maroon;">' . utf8tohtml(substr($value, 0, 110) . (strlen($value) > 110 ? '…' : '')) . '</span>';
- } elseif(gettype($value) == 'integer') {
- // Show permissions in a cleaner way
- if(preg_match('/^MOD_/', $name) && $name != 'MOD_JANITOR' && $name != 'MOD_MOD' && $name != 'MOD_ADMIN') {
- if($value == MOD_JANITOR)
- $value = 'Janitor';
- elseif($value == MOD_MOD)
- $value = 'Mod';
- elseif($value == MOD_ADMIN)
- $value = 'Admin';
+
+ function do_array_part($array, $prefix = '') {
+ global $data, $config;
+
+ foreach($array as $name => $value) {
+ if(is_array($value)) {
+ do_array_part($value, $prefix . $name . ' → ');
+ } else {
+ if($config['mod']['never_reveal_password'] && $prefix == 'db → ' && $name == 'password') {
+ $value = '<em>hidden</em>';
+ } elseif(gettype($value) == 'boolean') {
+ $value = $value ? '<span style="color:green;">On</span>' : '<span style="color:red;">Off</span>';
+ } elseif(gettype($value) == 'string') {
+ if(empty($value))
+ $value = '<em>empty</em>';
+ else
+ $value = '<span style="color:maroon;">' . utf8tohtml(substr($value, 0, 110) . (strlen($value) > 110 ? '…' : '')) . '</span>';
+ } elseif(gettype($value) == 'integer') {
+ $value = '<span style="color:black;">' . $value . '</span>';
+ }
+
+ $data .=
+ '<tr><th style="text-align:left;">' .
+ $prefix . (gettype($name) == 'integer' ? '[]' : $name) .
+ '</th><td>' .
+ $value .
+ '</td></tr>';
}
- $value = '<span style="color:black;">' . $value . '</span>';
}
}
-
- $data .=
- '<tr><th style="text-align:left;">' .
- $name .
- '</th><td>' .
- $value .
- '</td></tr>';
- }
+
+ do_array_part($config);
$body = '<fieldset><legend>Configuration</legend><table>' . $data . '</table></fieldset>';