add restore to views and system_controls
This commit is contained in:
+7
-2
@@ -13,6 +13,8 @@ $config = get_config();
|
|||||||
$color_scheme = get_color_scheme();
|
$color_scheme = get_color_scheme();
|
||||||
set_timezone();
|
set_timezone();
|
||||||
|
|
||||||
|
$restore = "cat $home/BirdSongs/restore.log";
|
||||||
|
|
||||||
if(is_authenticated() && (!isset($_SESSION['behind']) || !isset($_SESSION['behind_time']) || time() > $_SESSION['behind_time'] + 86400)) {
|
if(is_authenticated() && (!isset($_SESSION['behind']) || !isset($_SESSION['behind_time']) || time() > $_SESSION['behind_time'] + 86400)) {
|
||||||
shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi fetch > /dev/null 2>/dev/null &");
|
shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi fetch > /dev/null 2>/dev/null &");
|
||||||
$str = trim(shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi status"));
|
$str = trim(shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi status"));
|
||||||
@@ -71,7 +73,9 @@ elseif ($config["LONGITUDE"] == "0.000") {
|
|||||||
<button type="button" href="javascript:void(0);" class="icon" onclick="myFunction()"><img src="images/menu.png"></button>
|
<button type="button" href="javascript:void(0);" class="icon" onclick="myFunction()"><img src="images/menu.png"></button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<script type="text/javascript" src="static/plupload.full.min.js"></script>
|
||||||
|
<!--<script type="text/javascript" src="static/moxie.js"></script>
|
||||||
|
<script type="text/javascript" src="static/plupload.dev.js"></script>-->
|
||||||
<script>
|
<script>
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
var elements = document.querySelectorAll("button[name=view]");
|
var elements = document.querySelectorAll("button[name=view]");
|
||||||
@@ -283,7 +287,8 @@ if(isset($_GET['view'])){
|
|||||||
'sudo reboot',
|
'sudo reboot',
|
||||||
'update_birdnet.sh',
|
'update_birdnet.sh',
|
||||||
'sudo shutdown now',
|
'sudo shutdown now',
|
||||||
'sudo clear_all_data.sh');
|
'sudo clear_all_data.sh',
|
||||||
|
"$restore");
|
||||||
$command = $_GET['submit'];
|
$command = $_GET['submit'];
|
||||||
if(in_array($command,$allowedCommands)){
|
if(in_array($command,$allowedCommands)){
|
||||||
if(isset($command)){
|
if(isset($command)){
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
error_reporting(E_ERROR);
|
||||||
|
ini_set('display_errors',1);
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
require_once "scripts/common.php";
|
require_once "scripts/common.php";
|
||||||
$user = get_user();
|
$user = get_user();
|
||||||
@@ -19,6 +22,10 @@ if (stripos($str, "Your branch is up to date") !== false) {
|
|||||||
}
|
}
|
||||||
$_SESSION['behind'] = $num_commits_behind;
|
$_SESSION['behind'] = $num_commits_behind;
|
||||||
$_SESSION['behind_time'] = time();
|
$_SESSION['behind_time'] = time();
|
||||||
|
|
||||||
|
$restore = "cat $home/BirdSongs/restore.log";
|
||||||
|
$max_upload_size = floor(disk_free_space("$home/BirdNET-Pi/") / 1.001);
|
||||||
|
|
||||||
?><html>
|
?><html>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<br>
|
<br>
|
||||||
@@ -49,7 +56,10 @@ function update() {
|
|||||||
<button type="submit" name="submit" value="sudo clear_all_data.sh" onclick="return confirm('Clear ALL Data? Note that this cannot be undone and will take up to 90 seconds.')">Clear ALL data</button>
|
<button type="submit" name="submit" value="sudo clear_all_data.sh" onclick="return confirm('Clear ALL Data? Note that this cannot be undone and will take up to 90 seconds.')">Clear ALL data</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div><a href="scripts/backup.php" download ><button onclick="return confirm('Download backup? Note that this could take a long time.')">Download backup</button></a></div>
|
<div id="container">
|
||||||
|
<button id="pickfile" type="button" href="javascript:;">Restore data</button>
|
||||||
|
</div>
|
||||||
|
<div><a href="scripts/backup.php" download ><button onclick="return confirm('Download backup? Note that this could take a long time.')">Backup data</button></a></div>
|
||||||
<?php
|
<?php
|
||||||
$cmd="cd ".$home."/BirdNET-Pi && sudo -u ".$user." git rev-list --max-count=1 HEAD";
|
$cmd="cd ".$home."/BirdNET-Pi && sudo -u ".$user." git rev-list --max-count=1 HEAD";
|
||||||
$curr_hash = shell_exec($cmd);
|
$curr_hash = shell_exec($cmd);
|
||||||
@@ -58,4 +68,57 @@ function update() {
|
|||||||
<a href="https://github.com/Nachtzuster/BirdNET-Pi/commit/<?php echo $curr_hash; ?>" target="_blank">
|
<a href="https://github.com/Nachtzuster/BirdNET-Pi/commit/<?php echo $curr_hash; ?>" target="_blank">
|
||||||
<p style="font-size:11px;text-align:center;box-sizing: border-box"><?php echo $curr_hash; ?></p>
|
<p style="font-size:11px;text-align:center;box-sizing: border-box"><?php echo $curr_hash; ?></p>
|
||||||
</a>
|
</a>
|
||||||
|
<pre id="console" style="text-align:center"></pre>
|
||||||
</div>
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
// based on Custom example logic
|
||||||
|
|
||||||
|
var uploader = new plupload.Uploader({
|
||||||
|
runtimes : 'html5',
|
||||||
|
browse_button : 'pickfile', // you can pass an id...
|
||||||
|
container: document.getElementById('container'), // ... or DOM Element itself
|
||||||
|
url : 'scripts/restore.php',
|
||||||
|
chunk_size: '2mb',
|
||||||
|
multi_selection: false,
|
||||||
|
|
||||||
|
filters : {
|
||||||
|
max_file_size : '<?php echo "$max_upload_size"; ?>',
|
||||||
|
mime_types: [
|
||||||
|
{title : "Tar files", extensions : "tar"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
init: {
|
||||||
|
FilesAdded: function(up, files) {
|
||||||
|
uploader.start();
|
||||||
|
},
|
||||||
|
|
||||||
|
UploadProgress: function(up, file) {
|
||||||
|
if (file.percent !== 100) {
|
||||||
|
document.getElementById('pickfile').innerHTML = "<span>Uploading: <pre id='timer' class='bash'>" + String(file.percent).padStart(2, '0') + "%</pre></span>";
|
||||||
|
} else {
|
||||||
|
setInterval(function(){ seconds += 1; document.getElementById('pickfile').innerHTML = "Restoring: <pre id='timer' class='bash'>"+new Date(seconds * 1000).toISOString().substring(14, 19)+"</pre>"; }, 1000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
FileUploaded: function(up, file, info) {
|
||||||
|
// Called when file has finished uploading
|
||||||
|
console.log('[FileUploaded] File:', file, "Info:", info);
|
||||||
|
const xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onload = function() {
|
||||||
|
if(this.responseText.length > 0) {
|
||||||
|
document.body.innerHTML=this.responseText;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhttp.open("GET", "views.php?submit=<?php echo "$restore"; ?>");
|
||||||
|
xhttp.send();
|
||||||
|
},
|
||||||
|
|
||||||
|
Error: function(up, err) {
|
||||||
|
document.getElementById('console').appendChild(document.createTextNode("\nError #" + err.code + ": " + err.message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
uploader.init();
|
||||||
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user