reboot
This commit is contained in:
parent
f4ec9da481
commit
c8e6a6d439
|
|
@ -1,35 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include 'header.php';
|
include 'header.php';
|
||||||
$url = "https://git.dbhatt.org/ShreeBhattJi/digital_encoder/raw/branch/main/version.json";
|
|
||||||
|
|
||||||
$json = file_get_contents($url);
|
switch ($_POST['action']) {
|
||||||
if ($json === false) {
|
case 'update':
|
||||||
die("Failed to fetch JSON");
|
update_firmware();
|
||||||
}
|
break;
|
||||||
|
case 'reset':
|
||||||
// Decode
|
$files = glob('/var/www/html/*.json');
|
||||||
$data = json_decode($json, true);
|
foreach ($files as $file) {
|
||||||
if ($data === null) {
|
if (is_file($file) && basename($file) !== 'critical.json') {
|
||||||
die("Failed to decode JSON");
|
unlink($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access "version"
|
|
||||||
if (isset($data['version'])) {
|
|
||||||
$version = $data['version'];
|
|
||||||
} else {
|
|
||||||
$version = "Key 'version' not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_POST['action'] === 'update') {
|
|
||||||
update_firmware();
|
|
||||||
} elseif ($_POST['action'] === 'reset') {
|
|
||||||
$files = glob('/var/www/html/*.json');
|
|
||||||
foreach ($files as $file) {
|
|
||||||
if (is_file($file) && basename($file) !== 'critical.json') {
|
|
||||||
unlink($file);
|
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
case 'reboot':
|
||||||
|
exec('sudo reboot');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
@ -39,16 +26,18 @@ if ($_POST['action'] === 'update') {
|
||||||
Currunt Firmware Version :- 1.0
|
Currunt Firmware Version :- 1.0
|
||||||
</div>
|
</div>
|
||||||
<div class="card wide">
|
<div class="card wide">
|
||||||
Latest Firmware Version :- <?php echo $version ?>
|
<form method="post" class="form-center">
|
||||||
|
<button type="submit" name="action" value="reboot" class="blueviolet-btn">Reboot</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="card wide">
|
<div class="card wide">
|
||||||
<form method="post" class="form-center">
|
<form method="post" class="form-center">
|
||||||
<button type="submit" name="action" value="update" class="red-btn">Update</button>
|
<button type="submit" name="action" value="update" class="red-btn">Update or Reset Firmware</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="card wide">
|
<div class="card wide">
|
||||||
<form method="post" class="form-center" onsubmit="return confirm('Are you sure you want to reset all settings?');">
|
<form method="post" class="form-center" onsubmit="return confirm('Are you sure you want to reset all settings?');">
|
||||||
<button type="submit" name="action" value="reset" class="red-btn">Reset</button>
|
<button type="submit" name="action" value="reset" class="red-btn">Reset Settings</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
|
|
||||||
|
|
@ -377,6 +377,17 @@
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.blueviolet-btn {
|
||||||
|
background-color: blueviolet;
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border: none;
|
||||||
|
width: 33%;
|
||||||
|
border-radius: 7px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.red-btn {
|
.red-btn {
|
||||||
background-color: red;
|
background-color: red;
|
||||||
color: white;
|
color: white;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue