2020-05-16 15:18:27 +00:00
|
|
|
<?php
|
|
|
|
if (isset($_POST) && !empty($_POST)){
|
2020-10-17 16:03:55 +00:00
|
|
|
$userManager = new UserManager();
|
2021-03-01 16:38:44 +00:00
|
|
|
$roomManager = new RoomManager();
|
2020-05-16 15:18:27 +00:00
|
|
|
if (isset($_POST['submitPasswordChange']) && $_POST['submitPasswordChange'] != "") {
|
|
|
|
$oldPassword = $_POST['oldPassword'];
|
|
|
|
$newPassword = $_POST['newPassword1'];
|
|
|
|
$newPassword2 = $_POST['newPassword2'];
|
2020-10-17 16:03:55 +00:00
|
|
|
$userManager->changePassword($oldPassword, $newPassword, $newPassword2);
|
2020-05-16 15:18:27 +00:00
|
|
|
header('Location: ' . BASEURL . 'logout');
|
|
|
|
die();
|
|
|
|
} else if (isset($_POST['submitCreateUser']) && $_POST['submitCreateUser'] != "") {
|
|
|
|
$userName = $_POST['userName'];
|
|
|
|
$password = $_POST['userPassword'];
|
2020-10-17 16:03:55 +00:00
|
|
|
$email = $_POST['userEmail'];
|
|
|
|
$userManager->createUser($userName, $password, $email);
|
2020-05-16 15:18:27 +00:00
|
|
|
header('Location: ' . BASEURL . 'setting');
|
|
|
|
die();
|
|
|
|
} else if (isset($_POST['submitEnableOta']) && $_POST['submitEnableOta'] != "") {
|
2020-05-16 23:27:06 +00:00
|
|
|
$otaCode = $_POST['otaCode'];
|
|
|
|
$otaSecret = $_POST['otaSecret'];
|
2020-05-16 15:18:27 +00:00
|
|
|
|
|
|
|
$ga = new PHPGangsta_GoogleAuthenticator();
|
|
|
|
$checkResult = $ga->verifyCode($otaSecret, $otaCode, 2); // 2 = 2*30sec clock tolerance
|
2020-12-23 14:57:12 +00:00
|
|
|
if ($checkResult) {
|
|
|
|
$userManager->setOta($otaCode, $otaSecret);
|
|
|
|
}
|
2020-05-16 15:18:27 +00:00
|
|
|
header('Location: ' . BASEURL . 'setting');
|
|
|
|
die();
|
2020-10-17 16:03:55 +00:00
|
|
|
} else if (isset ($_POST['userPermission']) && !empty ($_POST['userID'])) {
|
|
|
|
$userManager->setUserDataAdmin("permission", $_POST['userPermission'], $_POST['userID']);
|
2020-12-23 14:57:12 +00:00
|
|
|
header('Location: ' . BASEURL . 'setting');
|
|
|
|
die();
|
2021-03-01 16:38:44 +00:00
|
|
|
} if (isset ($_POST['roomName']) && !empty ($_POST['roomId'])) {
|
|
|
|
$roomManager->edit($_POST['roomId'], array("name" => $_POST['roomName']));
|
|
|
|
header('Location: ' . BASEURL . 'setting');
|
|
|
|
die();
|
2020-12-23 14:57:12 +00:00
|
|
|
} else {
|
|
|
|
foreach ($_POST as $key => $value) {
|
|
|
|
if ($key == 'submit') continue;
|
|
|
|
$settingMng = new SettingsManager();
|
|
|
|
if ($settingMng->getByName($key)) {
|
|
|
|
$settingMng->update($key, $value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-17 16:03:55 +00:00
|
|
|
header('Location: ' . BASEURL . 'setting');
|
|
|
|
die();
|
2020-05-16 15:18:27 +00:00
|
|
|
}
|
|
|
|
}
|