2020-07-09 23:18:23 +00:00
|
|
|
<?php
|
|
|
|
require 'Database.php';
|
2020-07-17 23:10:04 +00:00
|
|
|
require 'SSettings.php';
|
2020-07-09 23:18:23 +00:00
|
|
|
|
|
|
|
$conn = Database::getInstance()->getConnection();
|
2020-07-17 23:10:04 +00:00
|
|
|
$settings = new SSettings();
|
2020-07-09 23:18:23 +00:00
|
|
|
|
|
|
|
if (isset($_POST['action'])) {
|
|
|
|
$action = $_POST['action'];
|
|
|
|
switch ($action) {
|
|
|
|
case "loadGeneralSettings":
|
|
|
|
$query = "SELECT * from settings";
|
|
|
|
|
|
|
|
$result = $conn->query($query);
|
|
|
|
if ($result->num_rows > 1) {
|
|
|
|
// todo throw error
|
|
|
|
}
|
|
|
|
|
|
|
|
$r = mysqli_fetch_assoc($result);
|
2020-07-17 23:10:04 +00:00
|
|
|
// booleans need to be set manually
|
2020-08-04 16:53:11 +00:00
|
|
|
$r['passwordEnabled'] = $r['password'] != "-1";
|
2020-07-17 23:10:04 +00:00
|
|
|
$r['TMDB_grabbing'] = ($r['TMDB_grabbing'] != '0');
|
|
|
|
|
2020-07-09 23:18:23 +00:00
|
|
|
echo json_encode($r);
|
|
|
|
break;
|
2020-07-10 17:13:40 +00:00
|
|
|
case "saveGeneralSettings":
|
|
|
|
$mediacentername = $_POST['mediacentername'];
|
|
|
|
$password = $_POST['password'];
|
|
|
|
$videopath = $_POST['videopath'];
|
|
|
|
$tvshowpath = $_POST['tvshowpath'];
|
2020-07-17 23:10:04 +00:00
|
|
|
$tmdbsupport = $_POST['tmdbsupport'];
|
2020-07-29 21:00:37 +00:00
|
|
|
$darkmodeenabled = $_POST['darkmodeenabled'];
|
2020-07-10 17:13:40 +00:00
|
|
|
|
|
|
|
$query = "UPDATE settings SET
|
|
|
|
video_path='$videopath',
|
|
|
|
episode_path='$tvshowpath',
|
|
|
|
password='$password',
|
2020-07-17 23:10:04 +00:00
|
|
|
mediacenter_name='$mediacentername',
|
2020-07-29 21:00:37 +00:00
|
|
|
TMDB_grabbing=$tmdbsupport,
|
|
|
|
DarkMode=$darkmodeenabled
|
2020-07-10 17:13:40 +00:00
|
|
|
WHERE 1";
|
|
|
|
|
|
|
|
if ($conn->query($query) === true) {
|
|
|
|
echo '{"success": true}';
|
|
|
|
} else {
|
|
|
|
echo '{"success": true}';
|
|
|
|
}
|
|
|
|
break;
|
2020-07-13 20:56:43 +00:00
|
|
|
case "loadInitialData":
|
|
|
|
$query = "SELECT * from settings";
|
|
|
|
|
|
|
|
$result = $conn->query($query);
|
|
|
|
if ($result->num_rows > 1) {
|
|
|
|
// todo throw error
|
|
|
|
}
|
|
|
|
|
|
|
|
$r = mysqli_fetch_assoc($result);
|
2020-07-28 16:17:17 +00:00
|
|
|
|
2020-08-04 16:53:11 +00:00
|
|
|
$r['passwordEnabled'] = $r['password'] != "-1";
|
|
|
|
unset($r['password']);
|
|
|
|
$r['DarkMode'] = (bool)($r['DarkMode'] != '0');
|
2020-07-13 20:56:43 +00:00
|
|
|
echo json_encode($r);
|
|
|
|
break;
|
2020-07-09 23:18:23 +00:00
|
|
|
}
|
|
|
|
}
|