Add TS3 icon sync to the installer
This commit is contained in:
parent
d93bff9634
commit
c317ac3614
|
@ -36,9 +36,10 @@ $pageContent = ob_get_clean();
|
||||||
|
|
||||||
<title>Step <?= $stepNumber ?> | TS-website 2.0 Installer</title>
|
<title>Step <?= $stepNumber ?> | TS-website 2.0 Installer</title>
|
||||||
|
|
||||||
<!-- Bootswatch Lumen 4.1.3 -->
|
<!-- Bootswatch Lumen 4.5.2 -->
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/4.1.3/lumen/bootstrap.min.css"
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/4.5.2/lumen/bootstrap.min.css"
|
||||||
integrity="sha256-S3sZnj5Uxoan2Z6rfF8V+lCFpdDl06yG+3aem63aLmE=" crossorigin="anonymous">
|
integrity="sha512-dp4Bf44EU9Q91+7N3SgcqZXhScQ+4T1vHwE1Uz5nPsr7Kl63wDa84/mN3LjwKthmK8GAw6rcJjeLq1Sp8dM3cg=="
|
||||||
|
crossorigin="anonymous">
|
||||||
|
|
||||||
<!-- Bootstrap nav wizard -->
|
<!-- Bootstrap nav wizard -->
|
||||||
<link rel="stylesheet"
|
<link rel="stylesheet"
|
||||||
|
@ -57,13 +58,10 @@ $pageContent = ob_get_clean();
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"
|
||||||
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||||
|
|
||||||
<!-- Popper UMD 1.13.0 JS -->
|
<!-- Bootstrap 4.5.2 JS -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/umd/popper.min.js"
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/js/bootstrap.bundle.js"
|
||||||
integrity="sha256-pS96pU17yq+gVu4KBQJi38VpSuKN7otMrDQprzf/DWY=" crossorigin="anonymous"></script>
|
integrity="sha512-VgXiNYfIwR3cDfXZNpuFfYfFGQG5x2kbcxemIWrNcRo/Z4zv1H1O+vBWuaG2cGLH9L66SRz7a/aHnwlpIlvUuQ=="
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
<!-- Bootstrap 4.1.3 JS -->
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js"
|
|
||||||
integrity="sha256-VsEqElsCHSGmnmHXGQzvoWjWwoznFSZc6hs7ARLRacQ=" crossorigin="anonymous"></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
if(!defined("__TSWEBSITE_VERSION")) die("Direct access not allowed");
|
if(!defined("__TSWEBSITE_VERSION")) die("Direct access not allowed");
|
||||||
|
|
||||||
use Wruczek\TSWebsite\Config;
|
use Wruczek\TSWebsite\Config;
|
||||||
|
use Wruczek\TSWebsite\ServerIconCache;
|
||||||
|
use Wruczek\TSWebsite\Utils\ApiUtils;
|
||||||
|
|
||||||
if (!empty($_POST)) {
|
if (!empty($_POST)) {
|
||||||
$queryhostname = trim($_POST["queryhostname"]);
|
$queryhostname = trim($_POST["queryhostname"]);
|
||||||
|
@ -35,12 +37,14 @@ if (!empty($_POST)) {
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($configdata as $key => $value) {
|
foreach ($configdata as $key => $value) {
|
||||||
if(!$utils->setValue($key, $value)) {
|
try {
|
||||||
die("Error while inserting query data to database, at " . htmlspecialchars($key) . " => " . htmlspecialchars($value));
|
$utils->setValue($key, $value);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
die("Error while updating config in database, at " . htmlspecialchars($key) . " => " . htmlspecialchars($value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Location: ?step=" . ($stepNumber + 1));
|
$cacheIcons = true;
|
||||||
} else {
|
} else {
|
||||||
$errormessage .= '<br>Cannot retrieve server information';
|
$errormessage .= '<br>Cannot retrieve server information';
|
||||||
}
|
}
|
||||||
|
@ -58,6 +62,21 @@ if (!empty($_POST)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["syncicons"])) {
|
||||||
|
require_once __PRIVATE_DIR . "/vendor/autoload.php";
|
||||||
|
|
||||||
|
set_time_limit(0); // this might take a while
|
||||||
|
|
||||||
|
try {
|
||||||
|
ServerIconCache::syncIcons();
|
||||||
|
ApiUtils::jsonSuccess();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
ApiUtils::jsonError($e->getMessage(), $e->getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
exit;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- Modal -->
|
<!-- Modal -->
|
||||||
|
@ -95,6 +114,20 @@ if (!empty($_POST)) {
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php if(isset($cacheIcons)) { ?>
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<div class="alert alert-primary" style="display: inline-block">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<div class="spinner-border spinner-border-sm mr-2" role="status">
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
Caching icons from the TS3 server, please wait...
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php } else { ?>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
@ -183,8 +216,29 @@ if (!empty($_POST)) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$("#submitformalt").click(function () {
|
$("#submitformalt").click(function () {
|
||||||
$("#submitform").click();
|
$("#submitform").click();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<?php if(isset($cacheIcons)) { ?>
|
||||||
|
<script>
|
||||||
|
$.ajax({
|
||||||
|
data: { syncicons: 1 },
|
||||||
|
success: function (res) {
|
||||||
|
if (!res.success) {
|
||||||
|
alert("An error occurred while trying to sync TS3 icons: " + JSON.stringify(res))
|
||||||
|
}
|
||||||
|
|
||||||
|
location = "?step=5"
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
alert("An error occurred while trying to sync TS3 icons")
|
||||||
|
location = "?step=5"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<?php } ?>
|
||||||
|
|
Loading…
Reference in New Issue