reboot
This commit is contained in:
parent
f4ec9da481
commit
c8e6a6d439
|
|
@ -1,35 +1,22 @@
|
|||
<?php
|
||||
|
||||
include 'header.php';
|
||||
$url = "https://git.dbhatt.org/ShreeBhattJi/digital_encoder/raw/branch/main/version.json";
|
||||
|
||||
$json = file_get_contents($url);
|
||||
if ($json === false) {
|
||||
die("Failed to fetch JSON");
|
||||
}
|
||||
|
||||
// Decode
|
||||
$data = json_decode($json, true);
|
||||
if ($data === null) {
|
||||
die("Failed to decode JSON");
|
||||
}
|
||||
|
||||
// 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);
|
||||
switch ($_POST['action']) {
|
||||
case 'update':
|
||||
update_firmware();
|
||||
break;
|
||||
case '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
|
||||
</div>
|
||||
<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 class="card wide">
|
||||
<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>
|
||||
</div>
|
||||
<div class="card wide">
|
||||
<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>
|
||||
</div>
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -377,6 +377,17 @@
|
|||
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 {
|
||||
background-color: red;
|
||||
color: white;
|
||||
|
|
|
|||
Loading…
Reference in New Issue