Add modified user's display name to aliases.conf.
This commit is contained in:
parent
bc2b20cf17
commit
5ec9cf5501
|
@ -1768,18 +1768,47 @@ function get_poster_name($name)
|
||||||
return ($thisposter);
|
return ($thisposter);
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_config_value($configfile, $name, $value)
|
/*
|
||||||
|
* This function returns false on success
|
||||||
|
* or return value contains error info
|
||||||
|
* 'added' etc.
|
||||||
|
*/
|
||||||
|
function save_config_value($configfile, $name, $value, $value_unique = false)
|
||||||
{
|
{
|
||||||
$list = file($configfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
global $spooldir;
|
||||||
$saveconfig = fopen($configfile, 'w+');
|
$return_val = false;
|
||||||
foreach ($list as $save) {
|
$tempfile = tempnam($spooldir, 'rslight-');
|
||||||
$name = explode(':', $save);
|
if(file_exists($tempfile)) {
|
||||||
if (strcmp($name[0], $group) == 0) {
|
unlink($tempfile);
|
||||||
fputs($saveconfig, $group . ":" . $article . "\n");
|
}
|
||||||
|
$lines = file($configfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
$found = false;
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
$current = explode(':', $line);
|
||||||
|
if ($value_unique && (strcmp($current[1], $value) == 0)) {
|
||||||
|
// Found value. Write once
|
||||||
|
if(!$found) {
|
||||||
|
file_put_contents($tempfile, $name . ":" . $value . "\n", FILE_APPEND);
|
||||||
|
}
|
||||||
|
$found = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strcmp($current[0], $name) == 0) {
|
||||||
|
// $name matches option. Overwrite
|
||||||
|
file_put_contents($tempfile, $name . ":" . $value . "\n", FILE_APPEND);
|
||||||
|
$found = true;
|
||||||
} else {
|
} else {
|
||||||
fputs($saveconfig, $save . "\n");
|
// $name does not match option. Keep current line
|
||||||
|
file_put_contents($tempfile, $line . "\n", FILE_APPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!$found) {
|
||||||
|
// $name not found in options. Add to file.
|
||||||
|
file_put_contents($tempfile, $name . ":" . $value . "\n", FILE_APPEND);
|
||||||
|
}
|
||||||
|
copy($tempfile, $configfile);
|
||||||
|
unlink($tempfile);
|
||||||
|
return $return_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_config_file_value($configfile, $request)
|
function get_config_file_value($configfile, $request)
|
||||||
|
|
|
@ -25,6 +25,12 @@ return [
|
||||||
// Disable Message-ID search in header
|
// Disable Message-ID search in header
|
||||||
'disable_msgid_search' => false,
|
'disable_msgid_search' => false,
|
||||||
|
|
||||||
|
// Reserved aliases
|
||||||
|
'reserved_names' => array("admin", "sysop", "rslight"),
|
||||||
|
|
||||||
|
// Users who may have duplicate aliases in aliases.conf
|
||||||
|
'duplicate_aliases' => array("admins user name here"),
|
||||||
|
|
||||||
// Just leave this here to avoid comma errors
|
// Just leave this here to avoid comma errors
|
||||||
'comma' => true
|
'comma' => true
|
||||||
];
|
];
|
||||||
|
|
|
@ -221,6 +221,27 @@ if (isset($_POST['command']) && $_POST['command'] == 'SaveConfig') {
|
||||||
$value = false;
|
$value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(isset($OVERRIDES['reserved_names'])) {
|
||||||
|
$reserved_names = $OVERRIDES['reserved_names'];
|
||||||
|
} else {
|
||||||
|
$reserved_names = array("admin", "sysop");
|
||||||
|
}
|
||||||
|
if(isset($OVERRIDES['duplicate_aliases'])) {
|
||||||
|
$dupe_ok = $OVERRIDES['duplicate_aliases'];
|
||||||
|
} else {
|
||||||
|
$dupe_ok = false;
|
||||||
|
}
|
||||||
|
foreach($reserved_names as $name) {
|
||||||
|
if(strtolower($_POST['display_name']) == strtolower($name)) {
|
||||||
|
// It's a reserved alias
|
||||||
|
echo '<b>' . $_POST['display_name'] . "</b> is unavailable.<br />Please try again";
|
||||||
|
echo '<form target="' . $frame['content'] . '" method="post" action="user.php">';
|
||||||
|
echo '<input name="command" type="hidden" id="command" value="Configuration" readonly="readonly">';
|
||||||
|
echo "<input type='hidden' name='username' value='" . $_POST['username'] . "' />";
|
||||||
|
echo '<button class="np_button_link" type="submit">Return to Configuration</button>';
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($value && (strtolower($_POST['display_name']) != $user)) {
|
if ($value && (strtolower($_POST['display_name']) != $user)) {
|
||||||
// It's someone else's username or alias
|
// It's someone else's username or alias
|
||||||
echo '<b>' . $_POST['display_name'] . "</b> is unavailable.<br />Please try again";
|
echo '<b>' . $_POST['display_name'] . "</b> is unavailable.<br />Please try again";
|
||||||
|
@ -253,8 +274,21 @@ if (isset($_POST['command']) && $_POST['command'] == 'SaveConfig') {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$user_config['display_name'] = $_POST['display_name'];
|
$user_config['display_name'] = trim($_POST['display_name']);
|
||||||
$user_config['display_email'] = $_POST['display_email'];
|
$user_config['display_email'] = trim($_POST['display_email']);
|
||||||
|
// Apply alias into $config_dir/aliases_conf
|
||||||
|
if(strtolower($user_config['display_name'] != strtolower($_POST['username']))) {
|
||||||
|
$value_unique = true;
|
||||||
|
if($dupe_ok) {
|
||||||
|
foreach($dupe_ok as $dupe) {
|
||||||
|
if($dupe == strtolower($_POST['username'])) {
|
||||||
|
$value_unique = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
save_config_value($config_dir . '/aliases.conf', strtolower($user_config['display_name']), strtolower($_POST['username']), $value_unique);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$user_config['signature'] = $_POST['signature'];
|
$user_config['signature'] = $_POST['signature'];
|
||||||
$user_config['xface'] = $_POST['xface'];
|
$user_config['xface'] = $_POST['xface'];
|
||||||
|
|
Loading…
Reference in New Issue