Skip to content

A live bird collage card for your Home Assistant dashboard.

new feature to edit all scripts and web pages

mcguirepr8977c61f9a507a
diff --git a/scripts/advanced.php b/scripts/advanced.php
index dd7ffef8..3277090f 100644
--- a/scripts/advanced.php
+++ b/scripts/advanced.php
@@ -141,6 +141,7 @@ if(isset($_SESSION['success'])){
<br>
<button type="text"><a href="config.php">Basic Settings</a></button>
<button type="text"><a href="edit_crontab.php">Edit the Crontab</a></button>
+ <button type="text"><a href="list_scripts.php">Edit Scripts</a></button>
</form>
</div>
</div>
diff --git a/scripts/edit_scripts.php b/scripts/edit_scripts.php
new file mode 100644
index 00000000..9ce3c0a5
--- /dev/null
+++ b/scripts/edit_scripts.php
@@ -0,0 +1,46 @@
+<?php
+
+// configuration
+$url = 'list_scripts.php';
+$file = $_POST["script"];
+
+// check if form has been submitted
+if (isset($_POST['text']))
+{
+ // save the text contents
+ file_put_contents($file, $_POST['text']);
+
+ // redirect to form again
+ header(sprintf('Location: %s', $url));
+ printf('<a href="%s">Moved</a>.', htmlspecialchars($url));
+ exit();
+}
+
+// read the textfile
+$text = file_get_contents($file);
+
+?>
+<!-- HTML form -->
+<head>
+<style>
+* {
+ font-family: 'monospace';
+}
+
+a {
+ text-decoration: none;
+ color: black;
+}
+
+form {
+ text-align: center;
+}
+</style>
+<body style="background-color:rgb(119, 196, 135);">
+<form style="height:95%" action="" method="post">
+<input style="margin-left:-150px;" type="submit" value="Update" />
+<input type="reset" value="Discard Changes" />
+<button type="text"><a href="advanced.php">Back</a></button><br>
+<textarea name="text" style="font-size:large;width:100%;height:95%;"><?php echo htmlspecialchars($text) ?></textarea>
+</form>
+</body>
diff --git a/scripts/list_pages.php b/scripts/list_pages.php
new file mode 100644
index 00000000..92058689
--- /dev/null
+++ b/scripts/list_pages.php
@@ -0,0 +1,115 @@
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+* {
+ font-family: 'Arial', 'Gill Sans', 'Gill Sans MT',
+ ' Calibri', 'Trebuchet MS', 'sans-serif';
+ box-sizing: border-box;
+}
+/* Create two unequal columns that floats next to each other */
+.column {
+float: left;
+padding: 10px;
+}
+.first {
+width: calc(50% - 70px);
+}
+.second {
+width: calc(50% - 30px);
+}
+.
+/* Clear floats after the columns */
+.row:after {
+content: "";
+display: table;
+clear: both;
+}
+body {
+ background-color: rgb(119, 196, 135);
+}
+a {
+ font-size:large;
+ text-decoration: none;
+}
+.block {
+display: block;
+ font-weight: bold;
+width:100%;
+border: none;
+ background-color: #04AA6D;
+padding: 20px 20px;
+color: white;
+ font-size: medium;
+cursor: pointer;
+ text-align: center;
+}
+
+form {
+ text-align:left;
+ margin-left:20px;
+}
+h2 {
+ margin-bottom:0px;
+}
+h3 {
+ margin-left: -10px;
+ text-align:left;
+}
+label {
+float:left;
+width: 40%;
+ font-weight:bold;
+}
+input {
+width: 60%;
+ text-align:center;
+ font-size:large;
+}
+@media screen and (max-width: 800px) {
+ h2 {
+ margin-bottom:0px;
+ text-align:center;
+ } form {
+ text-align:left;
+ margin-left:0px;
+ }
+ .column {
+float: none;
+width: 100%;
+ }
+}
+</style>
+<div class="row">
+<div class="column first">
+<form action="edit_scripts.php" method="POST">
+<?php
+function printFoldersRecursive($dir) {
+ $allfiles = array();
+
+ // Open a directory, and read its contents
+ if (is_dir($dir)){
+ if ($dh = opendir($dir)){
+ while (($file = readdir($dh)) !== false){
+ if($file != '.' && $file != '..' && $file != 'By_Date' && $file != 'By_Common_Name' && $file != 'By_Scientific_Name' && $file != 'Charts' && $file != 'Processed' && $file != '.git' && $file != '.github' && $file != 'phpsysinfo' && $file != '.DS_Store'){
+ $allfiles[] = $file;
+ }
+ }
+ closedir($dh);
+ }
+ }
+
+ sort($allfiles);
+
+ foreach($allfiles as $file) {
+ echo "<input name=\"script\" type=\"submit\" value=\"$file\">";
+ if(is_dir($dir.'/'.$file)){
+ printFoldersRecursive($dir.'/'.$file);
+ }
+ }
+}
+
+printFoldersRecursive('../../BirdSongs/Extracted');
+?>
+</form>
+</div>
+</div>
+</body>
diff --git a/scripts/list_scripts.php b/scripts/list_scripts.php
new file mode 100644
index 00000000..4f5128eb
--- /dev/null
+++ b/scripts/list_scripts.php
@@ -0,0 +1,115 @@
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+* {
+ font-family: 'Arial', 'Gill Sans', 'Gill Sans MT',
+ ' Calibri', 'Trebuchet MS', 'sans-serif';
+ box-sizing: border-box;
+}
+/* Create two unequal columns that floats next to each other */
+.column {
+float: left;
+padding: 10px;
+}
+.first {
+width: calc(50% - 70px);
+}
+.second {
+width: calc(50% - 30px);
+}
+.
+/* Clear floats after the columns */
+.row:after {
+content: "";
+display: table;
+clear: both;
+}
+body {
+ background-color: rgb(119, 196, 135);
+}
+a {
+ font-size:large;
+ text-decoration: none;
+}
+.block {
+display: block;
+ font-weight: bold;
+width:100%;
+border: none;
+ background-color: #04AA6D;
+padding: 20px 20px;
+color: white;
+ font-size: medium;
+cursor: pointer;
+ text-align: center;
+}
+
+form {
+ text-align:left;
+ margin-left:20px;
+}
+h2 {
+ margin-bottom:0px;
+}
+h3 {
+ margin-left: -10px;
+ text-align:left;
+}
+label {
+float:left;
+width: 40%;
+ font-weight:bold;
+}
+input {
+width: 60%;
+ text-align:center;
+ font-size:large;
+}
+@media screen and (max-width: 800px) {
+ h2 {
+ margin-bottom:0px;
+ text-align:center;
+ } form {
+ text-align:left;
+ margin-left:0px;
+ }
+ .column {
+float: none;
+width: 100%;
+ }
+}
+</style>
+<div class="row">
+<div class="column first">
+<form action="edit_scripts.php" method="POST">
+<?php
+function printFoldersRecursive($dir) {
+ $allfiles = array();
+
+ // Open a directory, and read its contents
+ if (is_dir($dir)){
+ if ($dh = opendir($dir)){
+ while (($file = readdir($dh)) !== false){
+ if($file != '.' && $file != '..') {
+ $allfiles[] = $file;
+ }
+ }
+ closedir($dh);
+ }
+ }
+
+ sort($allfiles);
+
+ foreach($allfiles as $file) {
+ echo "<input name=\"script\" type=\"submit\" value=\"$file\">";
+ if(is_dir($dir.'/'.$file)){
+ printFoldersRecursive($dir.'/'.$file);
+ }
+ }
+}
+
+printFoldersRecursive('.');
+?>
+</form>
+</div>
+</div>
+</body>