Browse Source

Fixed "Show configuration" page for an arrayed config

pull/40/head
Savetheinternet 13 years ago
parent
commit
2c3b5d1dc2
  1. 71
      mod.php

71
mod.php

@ -186,52 +186,41 @@
} elseif(preg_match('/^\/config$/', $query)) { } elseif(preg_match('/^\/config$/', $query)) {
if($mod['type'] < $config['mod']['show_config']) error($config['error']['noaccess']); if($mod['type'] < $config['mod']['show_config']) error($config['error']['noaccess']);
// Show instance-config.php // 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'];
$data = ''; $data = '';
foreach($constants as $name => $value) {
if(MOD_NEVER_REAL_PASSWORD && $name == 'DB_PASSWORD') function do_array_part($array, $prefix = '') {
$value = '<em>hidden</em>'; global $data, $config;
else {
// For some reason PHP is only giving me the first defined value (the default), so use constant() foreach($array as $name => $value) {
$value = constant($name); if(is_array($value)) {
if(gettype($value) == 'boolean') { do_array_part($value, $prefix . $name . ' → ');
$value = $value ? '<span style="color:green;">On</span>' : '<span style="color:red;">Off</span>'; } else {
} elseif(gettype($value) == 'string') { if($config['mod']['never_reveal_password'] && $prefix == 'db → ' && $name == 'password') {
if(empty($value)) $value = '<em>hidden</em>';
$value = '<em>empty</em>'; } elseif(gettype($value) == 'boolean') {
else $value = $value ? '<span style="color:green;">On</span>' : '<span style="color:red;">Off</span>';
$value = '<span style="color:maroon;">' . utf8tohtml(substr($value, 0, 110) . (strlen($value) > 110 ? '…' : '')) . '</span>'; } elseif(gettype($value) == 'string') {
} elseif(gettype($value) == 'integer') { if(empty($value))
// Show permissions in a cleaner way $value = '<em>empty</em>';
if(preg_match('/^MOD_/', $name) && $name != 'MOD_JANITOR' && $name != 'MOD_MOD' && $name != 'MOD_ADMIN') { else
if($value == MOD_JANITOR) $value = '<span style="color:maroon;">' . utf8tohtml(substr($value, 0, 110) . (strlen($value) > 110 ? '…' : '')) . '</span>';
$value = 'Janitor'; } elseif(gettype($value) == 'integer') {
elseif($value == MOD_MOD) $value = '<span style="color:black;">' . $value . '</span>';
$value = 'Mod'; }
elseif($value == MOD_ADMIN)
$value = 'Admin'; $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 .= do_array_part($config);
'<tr><th style="text-align:left;">' .
$name .
'</th><td>' .
$value .
'</td></tr>';
}
$body = '<fieldset><legend>Configuration</legend><table>' . $data . '</table></fieldset>'; $body = '<fieldset><legend>Configuration</legend><table>' . $data . '</table></fieldset>';

Loading…
Cancel
Save