Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
6af1e18298 | |||
2b0415fcb1 | |||
4fb0051f95 | |||
b40558e056 |
28
common.js
28
common.js
@@ -155,27 +155,35 @@ function get_updates() {
|
||||
});
|
||||
}
|
||||
|
||||
function check_upgrade() {
|
||||
var url = 'scan.php?op=check_upgrade';
|
||||
function check_upgrade(service) {
|
||||
var url = 'scan.php?op=check_upgrade&service='+service;
|
||||
jQuery.get(url, function(data) {
|
||||
console.log('check_upgrade: '+data);
|
||||
if (data=="WAIT" || data=="") {
|
||||
setTimeout(check_upgrade, 1000);
|
||||
console.log('check_upgrade '+service+': '+data);
|
||||
if (data!="") {
|
||||
jQuery("#status_"+service).html(data);
|
||||
}
|
||||
if (data!="OK") {
|
||||
setTimeout(check_upgrade, 1000, service);
|
||||
}
|
||||
else {
|
||||
// TODO
|
||||
console.log('upgrade end: '+service);
|
||||
jQuery("#status_"+service).html('Upgrade has finished');
|
||||
//get_updates();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function upgrade(service) {
|
||||
var url = 'scan.php?op=upgrade&service='+service;
|
||||
jQuery("#status_"+service).html('Upgrade has started');
|
||||
console.log('upgrade start: '+service);
|
||||
jQuery.get(url, function(data) {
|
||||
console.log('upgrade end: '+service);
|
||||
console.log('check_upgrade '+service+': '+data);
|
||||
if (data=="OK") {
|
||||
setTimeout(check_upgrade, 1000);
|
||||
setTimeout(check_upgrade, 1000, service);
|
||||
}
|
||||
else jQuery("#status_"+service).html(data);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -259,7 +267,7 @@ function confirm_uninstall(additional) {
|
||||
}
|
||||
|
||||
function request_letsencrypt(domain) {
|
||||
var url = 'scan.php?op=letsencrypt&domain='+domain;
|
||||
var url = 'scan.php?op=request_letsencrypt&domain='+domain;
|
||||
jQuery.get(url, function(data) {
|
||||
console.log('letsencrypt '+domain);
|
||||
if (data!="") {
|
||||
@@ -375,7 +383,6 @@ jQuery(document).ready(function(){
|
||||
|
||||
get_repositories();
|
||||
get_system();
|
||||
get_services();
|
||||
check_vpn();
|
||||
|
||||
jQuery('#deployments_btn').click(function() {
|
||||
@@ -384,6 +391,7 @@ jQuery(document).ready(function(){
|
||||
});
|
||||
|
||||
jQuery('#services_btn').click(function() {
|
||||
get_services();
|
||||
jQuery('#deployments').hide();
|
||||
jQuery('#services').toggle();
|
||||
});
|
||||
|
@@ -148,7 +148,7 @@ function show_service_update($name, $update, $uptodate, $error) {
|
||||
if (!empty($update)) {
|
||||
$arr = explode(" ",$update);
|
||||
foreach ($arr as $container) {
|
||||
$str .= "<tr><td> </td><td>".$container."</td><td>UPDATE AVAILABLE</td><td><a href=\"#\" onclick=\"upgrade('{$name}')\">UPDATE</a></td></tr>";
|
||||
$str .= "<tr><td> </td><td>".$container."</td><td><div id=\"status_".$name."\">UPDATE AVAILABLE</div></td><td><a href=\"javascript:void(0)\" onclick=\"upgrade('{$name}')\">UPDATE</a></td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ function show_service_update($name, $update, $uptodate, $error) {
|
||||
if (!empty($uptodate)) {
|
||||
$arr = explode(" ",$uptodate);
|
||||
foreach ($arr as $container) {
|
||||
$str .= "<tr><td> </td><td>".$container."</td><td>Already up to date</td><td><a href=\"#\" onclick=\"upgrade('{$name}')\">FORCE UPDATE</a></td></tr>";
|
||||
$str .= "<tr><td> </td><td>".$container."</td><td><div id=\"status_".$name."\">Already up to date</div></td><td><a href=\"javacript:void(0)\" onclick=\"upgrade('{$name}')\">FORCE UPDATE</a></td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ function show_service_update($name, $update, $uptodate, $error) {
|
||||
$arr = explode(" ",$error);
|
||||
foreach ($arr as $container) {
|
||||
//$str .= "<tr><td> </td><td>".$container."</td><td>N/A</td><td></td></tr>";
|
||||
$str .= "<tr><td> </td><td>".$container."</td><td>N/A</td><td><a href=\"#\" onclick=\"upgrade('{$name}')\">TRY UPDATE</a></td></tr>";
|
||||
$str .= "<tr><td> </td><td>".$container."</td><td><div id=\"status_".$name."\">N/A</div></td><td><a href=\"javascript:void(0)\" onclick=\"upgrade('{$name}')\">TRY UPDATE</a></td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,8 @@
|
||||
</div>
|
||||
<div style="text-align:center;float:left;width:34%">
|
||||
<a href="manage.html" id="refresh_btn">REFRESH</a>
|
||||
/
|
||||
<a href="manage2.html" id="new_btn">NEW DESIGN</a>
|
||||
</div>
|
||||
<div style="text-align:right;float:right">
|
||||
<a href="javascript:void()" id="settings_btn">SETTINGS</a>
|
||||
@@ -150,6 +152,6 @@
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.6/dist/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.2.1/dist/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
|
||||
<script src="common.js"></script>
|
||||
<script src="common.js?t=3"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
221
manage2.html
221
manage2.html
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Control Panel</title>
|
||||
<title>Safebox</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg-color: #ffffff;
|
||||
@@ -32,6 +32,13 @@
|
||||
justify-content: space-between;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
table {border: 1px solid orange; width:100%;}
|
||||
table th {padding-left: 20px; text-align: left; color: orange; width: 25%;}
|
||||
table td {padding-left: 20px; text-align:left; width: 25%;}
|
||||
|
||||
label {text-align: left !important;}
|
||||
a, a:hover, a:visited {color: orange}
|
||||
|
||||
.profile {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -46,6 +53,13 @@
|
||||
object-fit: cover;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.settings {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
font-weight: bold;
|
||||
gap: 5px;
|
||||
}
|
||||
.logo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -63,6 +77,7 @@
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 24px;
|
||||
color: var(--text-color);
|
||||
}
|
||||
.toggle {
|
||||
cursor: pointer;
|
||||
@@ -101,6 +116,22 @@
|
||||
cursor: pointer;
|
||||
color: var(--text-color);
|
||||
}
|
||||
.buttons button.active, .buttons button:hover {
|
||||
color: orange;
|
||||
border: 1px solid orange;
|
||||
}
|
||||
.container {
|
||||
clear:both;
|
||||
float:none;
|
||||
}
|
||||
.leftside {
|
||||
float:left;
|
||||
width:20%;
|
||||
}
|
||||
.rightside {
|
||||
float:right;
|
||||
width:80%;
|
||||
}
|
||||
.my-apps {
|
||||
flex: 1;
|
||||
background-color: var(--app-bg);
|
||||
@@ -197,7 +228,7 @@
|
||||
padding: 30px;
|
||||
border-radius: 15px;
|
||||
width: 80%;
|
||||
text-align: center;
|
||||
text-align: left;
|
||||
position: relative;
|
||||
animation: fadeIn 0.3s ease;
|
||||
}
|
||||
@@ -234,7 +265,9 @@
|
||||
}
|
||||
|
||||
.input-group input {
|
||||
padding: 10px;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
padding: 5px;
|
||||
border: 1px solid var(--button-border);
|
||||
border-radius: 10px;
|
||||
background: none;
|
||||
@@ -386,39 +419,65 @@
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.2.1/dist/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
|
||||
<!-- Custom styles for this template -->
|
||||
<link href="installer.css?t=5" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<div class="profile" id="profileSection">
|
||||
<img src="image.png" alt="Profilkép">
|
||||
<div>Pro</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="leftside">
|
||||
<div class="logo">
|
||||
<img src="image.png" alt="Logo">
|
||||
<div><h1>Control Panel</h1></div>
|
||||
<div>
|
||||
<h1>Safebox</h1>
|
||||
</div>
|
||||
<div class="toggle" id="themeToggle"></div>
|
||||
</header>
|
||||
</div>
|
||||
<div class="profile" id="profileSection">
|
||||
<!--<img src="image.png" alt="Profilkép">-->
|
||||
<div id="vpnBtn">Pro</div>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button id="servicesBtn">Services</button>
|
||||
</div>
|
||||
<div class="settings">Settings</div>
|
||||
<div class="buttons">
|
||||
<button id="updatesBtn">Updates</button>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button id="repositoriesBtn">Repositories</button>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button id="systemservicesBtn">System services</button>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
<div style="text-align:center;">
|
||||
<a href="manage2.html" id="refresh_btn">REFRESH</a>
|
||||
<br>
|
||||
<br>
|
||||
<a href="manage.html" id="old_btn">OLD DESIGN</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="buttons">
|
||||
<div class="rightside">
|
||||
<div class="buttons">
|
||||
<button id="myAppsBtn">My Apps</button>
|
||||
<button id="installAppsBtn">Install Apps</button>
|
||||
<button id="backupBtn">Backup</button>
|
||||
<button id="diskBtn">Disk Management</button>
|
||||
<button id="monitorBtn">Monitor</button>
|
||||
<div class="toggle" id="themeToggle"></div>
|
||||
</div>
|
||||
|
||||
<div class="my-apps" id="myAppsContainer"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="my-apps" id="myAppsContainer"></div>
|
||||
<div id="popup" class="popup hidden">
|
||||
<div class="popup-content">
|
||||
<span class="close">×</span>
|
||||
<div class="input-group">
|
||||
<div id="popupText" class="deployment">Load app template here</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
<div class="footer-links">
|
||||
@@ -433,7 +492,7 @@
|
||||
</div>
|
||||
|
||||
<div class="footer-social">
|
||||
<a href="#">GitHub</a>
|
||||
<a href="#">Discord</a>
|
||||
<a href="#">X</a>
|
||||
</div>
|
||||
</footer>
|
||||
@@ -449,6 +508,8 @@
|
||||
}
|
||||
toggle.classList.toggle('active');
|
||||
});
|
||||
// default dark
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
</script>
|
||||
|
||||
<script>
|
||||
@@ -463,6 +524,12 @@
|
||||
const diskBtn = document.getElementById('diskBtn');
|
||||
const monitorBtn = document.getElementById('monitorBtn');
|
||||
|
||||
const vpnBtn = document.getElementById('vpnBtn');
|
||||
const servicesBtn = document.getElementById('servicesBtn');
|
||||
const updatesBtn = document.getElementById('updatesBtn');
|
||||
const repositoriesBtn = document.getElementById('repositoriesBtn');
|
||||
const systemservicesBtn = document.getElementById('systemservicesBtn');
|
||||
|
||||
const myAppsContainer = document.getElementById('myAppsContainer');
|
||||
const popup = document.getElementById('popup');
|
||||
const popupText = document.getElementById('popupText');
|
||||
@@ -530,12 +597,126 @@
|
||||
}
|
||||
}
|
||||
|
||||
myAppsBtn.addEventListener('click', () => renderApps(false));
|
||||
installAppsBtn.addEventListener('click', () => renderApps(true));
|
||||
function renderVPN() {
|
||||
myAppsContainer.innerHTML = `
|
||||
<fieldset>
|
||||
<legend>Enable proxy</legend>
|
||||
<form class="form-install" action="#" method="post" id="save_vpn">
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="vpn_domain">Please add domain url to download the VPN hash from (default: https://portal.safebox.network):</label>
|
||||
<input type="text" class="form-control" name="VPN_DOMAIN" id="vpn_domain" value="https://portal.safebox.network">
|
||||
<div class="invalid-feedback">
|
||||
Please enter a valid domain.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="vpn_pass">Please type in the generated VPN passkey (8 digits):</label>
|
||||
<input type="text" class="form-control" name="VPN_PASS" id="vpn_pass" value="" maxlength="8" size="10">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="letsencrypt_mail">Please add the letsencrypt mail address:</label>
|
||||
<input type="email" class="form-control" name="LETSENCRYPT_MAIL" id="letsencrypt_mail" value="">
|
||||
<div class="invalid-feedback">
|
||||
Please enter a valid email.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="letsencrypt_servername">Please add letsencrypt server name (default is letsencrypt but you can add zerossl too):</label>
|
||||
<input type="text" class="form-control" name="LETSENCRYPT_SERVERNAME" id="letsencrypt_servername" value="letsencrypt">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit" id="vpn_save_btn"> Save </button>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="button" id="vpn_cancel_btn"> Cancel </button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderServices() {
|
||||
myAppsContainer.innerHTML = `
|
||||
<div id="services">
|
||||
Loading...
|
||||
</div>
|
||||
`;
|
||||
get_services();
|
||||
}
|
||||
|
||||
function renderUpdates() {
|
||||
myAppsContainer.innerHTML = `
|
||||
<div id="updates">
|
||||
Looking for updates... Please wait...
|
||||
</div>
|
||||
`;
|
||||
get_updates();
|
||||
}
|
||||
|
||||
function renderRepositories() {
|
||||
myAppsContainer.innerHTML = `
|
||||
<div class="input-group">
|
||||
<fieldset>
|
||||
<legend>Repositories</legend>
|
||||
<div id="repositories" style="text-align:left">Loading...</div>
|
||||
|
||||
<hr>
|
||||
<form class="form-install" action="#" method="post" id="add_repo">
|
||||
<div class="row">
|
||||
<div class="mb-3" style="text-align:left">
|
||||
<label for="registry">Please add a new GIT repository URL: </label>
|
||||
<input type="registry" class="form-control" name="repository" id="repository" size="100" value="" required>
|
||||
<div class="invalid-feedback">
|
||||
Please enter a valid repository url.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit" id="repo_add_btn"> Add </button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderSystemServices() {
|
||||
myAppsContainer.innerHTML = `
|
||||
<div id="system">
|
||||
Loading...
|
||||
</div>
|
||||
`;
|
||||
get_system();
|
||||
}
|
||||
|
||||
function activate(btn) {
|
||||
myAppsBtn.classList.remove('active');
|
||||
installAppsBtn.classList.remove('active');
|
||||
btn.classList.add('active');
|
||||
}
|
||||
|
||||
myAppsBtn.addEventListener('click', () => {renderApps(false); activate(myAppsBtn);});
|
||||
installAppsBtn.addEventListener('click', () => {renderApps(true); activate(installAppsBtn);});
|
||||
backupBtn.addEventListener('click', () => renderText('Backup'));
|
||||
diskBtn.addEventListener('click', () => renderText('Disk Management'));
|
||||
monitorBtn.addEventListener('click', () => renderText('Monitor'));
|
||||
|
||||
vpnBtn.addEventListener('click', () => renderVPN());
|
||||
servicesBtn.addEventListener('click', () => renderServices());
|
||||
updatesBtn.addEventListener('click', () => renderUpdates());
|
||||
repositoriesBtn.addEventListener('click', () => renderRepositories());
|
||||
systemservicesBtn.addEventListener('click', () => renderSystemServices());
|
||||
|
||||
closeBtn.addEventListener('click', () => {
|
||||
popup.classList.add('hidden');
|
||||
});
|
||||
|
52
scan.php
52
scan.php
@@ -207,7 +207,7 @@ switch ($_GET["op"]) {
|
||||
|
||||
|
||||
echo "
|
||||
<div class=\"row\">
|
||||
<div class=\"row buttons\">
|
||||
<div class=\"mb-3\">
|
||||
<button class=\"btn btn-lg btn-primary btn-block\" type=\"submit\" id=\"deploy_{$template->name}_btn\">".($reinstall ? "Reinstall" : "Install")."</button>
|
||||
</div>";
|
||||
@@ -263,12 +263,12 @@ switch ($_GET["op"]) {
|
||||
else echo ""; // no deployment, finished
|
||||
}
|
||||
break;
|
||||
case "letsencrypt":
|
||||
case "request_letsencrypt":
|
||||
$domain = $_GET["domain"];
|
||||
$arr = array($domain => array("status" => "requested"));
|
||||
$arr = array($domain => array("date" => date("Y-m-d H:i:s"), "status" => "requested"));
|
||||
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
|
||||
|
||||
if (set_output("letsencrypt2",$json)) echo "LETSENCRYPT in progress for {$domain}.<br><br>";
|
||||
if (set_output("request_letsencrypt",$json)) echo "LETSENCRYPT in progress for {$domain}.<br><br>";
|
||||
else echo "ERROR";
|
||||
break;
|
||||
case "check_letsencrypt":
|
||||
@@ -380,23 +380,51 @@ switch ($_GET["op"]) {
|
||||
echo $text;
|
||||
break;
|
||||
case "check_upgrade":
|
||||
$arr = check_response("upgrade");
|
||||
if (!empty($arr)) {
|
||||
$arr = check_deploy($_GET["service"]);
|
||||
if (!empty($arr)) { // deployment in progress
|
||||
foreach ($arr as $key=>$data) {
|
||||
if ($key=="upgrade") {
|
||||
var_dump($arr);
|
||||
//remove_response("$key");
|
||||
if ($key=="deploy-".$_GET["service"]) {
|
||||
if ($data["STATUS"]=="1") {
|
||||
echo "Install in progress... You can't uninstall while in progress...";
|
||||
}
|
||||
elseif ($data["STATUS"]=="2") {
|
||||
echo "Install has finished... You can upgrade now.";
|
||||
//echo "<script>get_deployments();</script>";
|
||||
remove_response("$key");
|
||||
}
|
||||
}
|
||||
}
|
||||
else echo "WAIT";
|
||||
}
|
||||
else { // no upgrade in progress -> upgrade
|
||||
$key = "upgrade-".$_GET["service"];
|
||||
$arr = check_response($key);
|
||||
if (!empty($arr)) {
|
||||
$data = $arr[$key];
|
||||
if ($data["STATUS"]=="1") {
|
||||
echo "Upgrade in progress... Please wait... ".date("Y-m-d H:i:s");
|
||||
}
|
||||
elseif ($data["STATUS"]=="2") {
|
||||
echo "OK";
|
||||
remove_response("$key");
|
||||
}
|
||||
}
|
||||
else echo "Upgrade in progress... Please wait...";
|
||||
}
|
||||
break;
|
||||
case "upgrade":
|
||||
if ($key=check_deploy($_GET["service"])) {
|
||||
$text="Deploy/uninstall of {$_GET["service"]} has started. Please wait...";
|
||||
}
|
||||
else {
|
||||
//$text="Deploy/uninstall of {$_GET["service"]} in progress... Please wait...";
|
||||
|
||||
$arr = array("NAME" => $_GET["service"], "ACTION" => "upgrade");
|
||||
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
|
||||
|
||||
if (set_output("upgrade",$json)) echo "OK";
|
||||
else echo "ERROR";
|
||||
if (set_output("upgrade",$json)) $text = "OK";
|
||||
else $text = "ERROR";
|
||||
}
|
||||
echo $text;
|
||||
break;
|
||||
case "repositories":
|
||||
$arr = array("STATUS" => 0);
|
||||
|
Reference in New Issue
Block a user