Archived
1
0

changing settings is now possible

This commit is contained in:
nilsding
2014-08-18 17:49:20 +02:00
parent 1efa145cf2
commit 4364ad8706
5 changed files with 56 additions and 18 deletions

45
ucp.php
View File

@@ -71,7 +71,50 @@ switch ($_GET['page']) {
case "settings": {
check_privileges();
$tpl->draw("settings");
if (!isset($_POST['action'])) {
$tpl->draw("settings");
} else {
switch ($_POST['action']) {
case "generic": {
if (isset($_POST['sitename'])) {
$sql->query("UPDATE `config` SET `value`='" . $sql->real_escape_string(trim($_POST['sitename'])) . "' WHERE `key`='sitename'");
}
if (isset($_POST['recent_check'])) {
$sql->query("UPDATE `config` SET `value`='true' WHERE `key`='recent_public'");
} else {
$sql->query("UPDATE `config` SET `value`='false' WHERE `key`='recent_public'");
}
if (isset($_POST['recent_count'])) {
if (is_numeric($_POST['recent_count'])) {
$sql->query("UPDATE `config` SET `value`='" . (int) $_POST['recent_count'] . "' WHERE `key`='recent_count'");
}
}
$_SESSION['flash'] = "Successfully saved changes.";
header('Location: ucp.php?page=settings');
exit();
break;
}
case "password": {
if (isset($_POST['password_change']) && isset($_POST['password_verify'])) {
if ($_POST['password_change'] === $_POST['password_verify']) {
if (strlen($_POST['password_change']) > 3) {
$sql->query("UPDATE `config` SET `value`='" . $sql->real_escape_string(crypt_password($_POST['password_change'], gen_salt(22))) . "' WHERE `key`='password';");
$_SESSION['flash'] = "Successfully changed password.";
header('Location: ucp.php?page=settings');
exit();
}
}
}
$_SESSION['flash'] = "The passwords did not match or your password is shorter than 3 characters.";
header('Location: ucp.php?page=settings');
exit();
break;
}
default: {
$tpl->draw("settings");
}
}
}
break;
}
case "inbox":