PHP_SMART_HOME_V3/app/controls/setting.php

35 lines
1.3 KiB
PHP
Raw Normal View History

2019-10-30 14:18:29 +00:00
<?php
if (isset($_POST) && !empty($_POST)){
if (isset($_POST['submitPasswordChange']) && $_POST['submitPasswordChange'] != "") {
$oldPassword = $_POST['oldPassword'];
$newPassword = $_POST['newPassword1'];
$newPassword2 = $_POST['newPassword2'];
UserManager::changePassword($oldPassword, $newPassword, $newPassword2);
header('Location: ' . BASEDIR . 'logout');
die();
} else if (isset($_POST['submitCreateUser']) && $_POST['submitCreateUser'] != "") {
$userName = $_POST['userName'];
$password = $_POST['userPassword'];
UserManager::createUser($userName, $password);
header('Location: ' . BASEDIR . 'setting');
die();
2020-06-11 19:36:15 +00:00
} else if (isset($_POST['submitCreateRoom']) && $_POST['submitCreateRoom'] != "") {
$roomName = $_POST['roomName'];
RoomManager::create($roomName);
header('Location: ' . BASEDIR . 'setting');
die();
2019-10-30 14:18:29 +00:00
} else if (isset($_POST['submitEnableOta']) && $_POST['submitEnableOta'] != "") {
echo $otaCode = $_POST['otaCode'];
echo $otaSecret = $_POST['otaSecret'];
$ga = new PHPGangsta_GoogleAuthenticator();
$checkResult = $ga->verifyCode($otaSecret, $otaCode, 2); // 2 = 2*30sec clock tolerance
if ($checkResult) {
UserManager::setOta($otaCode, $otaSecret);
}
header('Location: ' . BASEDIR . 'setting');
die();
}
}