1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-30 18:24:29 +01:00

Fixed "Show configuration" page for an arrayed config

This commit is contained in:
Savetheinternet 2011-02-16 19:27:52 +11:00
parent 9008916c6c
commit 2c3b5d1dc2

41
mod.php
View File

@ -188,23 +188,18 @@
// 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 = '') {
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>'; $value = '<em>hidden</em>';
else { } elseif(gettype($value) == 'boolean') {
// 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>'; $value = $value ? '<span style="color:green;">On</span>' : '<span style="color:red;">Off</span>';
} elseif(gettype($value) == 'string') { } elseif(gettype($value) == 'string') {
if(empty($value)) if(empty($value))
@ -212,26 +207,20 @@
else else
$value = '<span style="color:maroon;">' . utf8tohtml(substr($value, 0, 110) . (strlen($value) > 110 ? '…' : '')) . '</span>'; $value = '<span style="color:maroon;">' . utf8tohtml(substr($value, 0, 110) . (strlen($value) > 110 ? '…' : '')) . '</span>';
} elseif(gettype($value) == 'integer') { } 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';
}
$value = '<span style="color:black;">' . $value . '</span>'; $value = '<span style="color:black;">' . $value . '</span>';
} }
}
$data .= $data .=
'<tr><th style="text-align:left;">' . '<tr><th style="text-align:left;">' .
$name . $prefix . (gettype($name) == 'integer' ? '[]' : $name) .
'</th><td>' . '</th><td>' .
$value . $value .
'</td></tr>'; '</td></tr>';
} }
}
}
do_array_part($config);
$body = '<fieldset><legend>Configuration</legend><table>' . $data . '</table></fieldset>'; $body = '<fieldset><legend>Configuration</legend><table>' . $data . '</table></fieldset>';