-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin.php
28 lines (26 loc) · 1.04 KB
/
admin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
$action = isset($_GET['action']) ? $_GET['action'] : exit;
// подключаем файл настроек калькулятора
$settingsFile = file_get_contents('../../assets/settings.json');
$settings = json_decode($settingsFile, true);
switch ($action) {
case "save":
$settings = isset($_POST['settings']) ? $_POST['settings'] : exit;
$settings = json_encode($settings, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK);
if (file_put_contents('../../assets/settings.json', $settings)!==false) {
echo true;
} else {
echo false;
}
break;
case "changePassword":
$password = isset($_POST['password']) ? $_POST['password'] : exit;
$settings["passwordHash"] = password_hash($password, PASSWORD_DEFAULT);
$settings = json_encode($settings, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK);
if (file_put_contents('../../assets/settings.json', $settings)!==false) {
echo true;
} else {
echo false;
}
break;
}