A live bird collage card for your Home Assistant dashboard.
tweaks to first_boot.html -- hoping to test soon
mcguirepr89a7aab7cb1d9d
diff --git a/scripts/config.php b/scripts/config.phpindex 1b2504b5..9268c05b 100644--- a/scripts/config.php+++ b/scripts/config.php@@ -1,3 +1,9 @@+<?php+session_start();+error_reporting(E_ALL);+ini_set('display_errors',1);++?><meta name="viewport" content="width=device-width, initial-scale=1"><style>/* Chrome, Safari, Edge, Opera */@@ -107,7 +113,7 @@ input {<body style="background-color: rgb(119, 196, 135);"><div class="row"><div class="column first">- <form action="write_config.php" method="POST">+ <form action="write_config.php" method="POST" name="normal"><?phpif (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {$config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');@@ -159,9 +165,7 @@ if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {<option value="labels_uk.txt">Ukrainian</option></select><br><br>- <button type="submit" class="block"><?php- @session_start();-+ <button type="submit" name="normal" class="block"><?phpif(isset($_SESSION['success'])){echo "Success!";unset($_SESSION['success']);@@ -179,5 +183,4 @@ if(isset($_SESSION['success'])){</div></div></body>-<input type="reset" form=">diff --git a/scripts/email_template b/scripts/email_templateindex 7b08789f..72a559e2 100644--- a/scripts/email_template+++ b/scripts/email_template@@ -8,6 +8,6 @@ Location= [ Create a location name ]%0A%0A%0AThank you so much!%0A[ Your Name Here ]--Disclaimer: By requesting this BirdWeather ID, I acknowledge that my location+%0A%0A+Disclaimer: By requesting this BirdWeather ID, I acknowledge that my location%0Aand recording data will be made public.diff --git a/scripts/email_template.html b/scripts/email_template.htmldeleted file mode 100644index 4dd2fcc1..00000000--- a/scripts/email_template.html+++ /dev/null@@ -1,10 +0,0 @@-Hi, Tim, and thank you so much for BirdWeather.com!-%0A%0A-Below is the information I would like to use to request a BirdWeather ID-%0A%0A-Latitude={{ LATITUDE }}%0A-Longitude={{ LONGITUDE }}%0A-Location= [ Create a location name ]%0A-%0A%0A-Thank you so much!%0A-[ Your Name Here ]diff --git a/scripts/first_boot.html b/scripts/first_boot.phpsimilarity index 72%rename from scripts/first_boot.htmlrename to scripts/first_boot.phpindex 18d9feab..dfbdf634 100644--- a/scripts/first_boot.html+++ b/scripts/first_boot.php@@ -1,5 +1,16 @@<meta name="viewport" content="width=device-width, initial-scale=1"><style>+/* Chrome, Safari, Edge, Opera */+input::-webkit-outer-spin-button,+input::-webkit-inner-spin-button {+ -webkit-appearance: none;+ margin: 0;+}++/* Firefox */+input[type=number] {+ -moz-appearance: textfield;+}* {font-family: 'Arial', 'Gill Sans', 'Gill Sans MT',' Calibri', 'Trebuchet MS', 'sans-serif';@@ -38,7 +49,7 @@ form {padding:10px;}-h1, h2 {+h1 {margin-bottom:0px;}@@ -74,22 +85,30 @@ input {}</style></head>-<h1 style="text-align:center;">Welcome!</h1>-<img class="center" alt="Can't Load Logo" src="../red-cardinal.png"/>+<?php+if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {+ $config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');+} elseif (file_exists('/home/pi/BirdNET-Pi/firstrun.ini')) {+ $config = parse_ini_file('/home/pi/BirdNET-Pi/firstrun.ini');+} ?>++<h1 style="float:top;text-align:center;">Welcome!</h1>+<img class="center" alt="Can't Load Logo" src="../images/red-cardinal.png"/><body style="background-color: rgb(119, 196, 135);">- <form action="write_config.php" method="POST">+ <form action="write_config.php" method="POST" name="firstboot"><p style="font-size:large">Thank you for installing BirdNET-Pi!to get started, fill out the Required sections below.</p><h2>Required</h2><label for="latitude">Latitude: </label>- <input name="latitude" type="text" value="" required/><br>+ <input name="latitude" type="number" min="-90" max="90" step="0.0001" value="<?php print($config['LATITUDE']);?>" required/><br><label for="longitude">Longitude: </label>- <input name="longitude" type="text" value="" required/><br>+ <input name="longitude" type="number" min="-180" max="180" step="0.0001" value="<?php print($config['LONGITUDE']);?>" required/><br><h2>Optional Services</h2><p>The services below are not required, but they are pretty cool.</p><label for="birdweather_id">BirdWeather ID: </label>- <input name="birdweather_id" type="text" value="" /><br>- <p>app.BirdWeather.com is a weather map for bird sounds. Stations around the world supply audio and video streams to BirdWeather where they are then analyzed by BirdNET and compared to eBird Grid data. BirdWeather catalogues the detections and visualizations so that you can listen to, view, and read about the birds in various regions across the globe! Pretty cool!</p>+ <input name="birdweather_id" type="text" value="<?php print($config['BIRDWEATHER_ID']);?>" /><br>+ <p>app.BirdWeather.com is a weather map for bird sounds. Stations around the world supply audio and video streams to BirdWeather where they are then analyzed by BirdNET and compared to eBird Grid data. BirdWeather catalogues the detections and visualizations so that you can listen to, view, and read about the birds in various regions across the globe! Pretty cool! <a href="mailto:[email protected]?subject=Request%20BirdWeather%20ID&body=<?php include('birdweather_request.php'); ?>" target="top">Email Tim</a> to request a BirdWeather ID</p>+<label for="pushed_app_key">Pushed App Key: </label><input name="pushed_app_key" type="text" value="" /><br><label for="pushed_app_secret">Pushed App Secret: </label>@@ -97,7 +116,7 @@ input {<p>Pushed.co is used to offer New Species notifications. Sorry Android users, but the Pushed.co Application is only for iOS.</p><label for="language">Database Language: </label><select name="language">- <option value="none">Select your language</option>+ <option value="none">English</option><option value="labels_af.txt">Afrikaans</option><option value="labels_ca.txt">Catalan</option><option value="labels_cs.txt">Czech</option>@@ -105,7 +124,6 @@ input {<option value="labels_hr.txt">Croatian</option><option value="labels_da.txt">Danish</option><option value="labels_nl.txt">Dutch</option>- <option value="labels_en.txt">English</option><option value="labels_et.txt">Estonian</option><option value="labels_fi.txt">Finnish</option><option value="labels_fr.txt">French</option>@@ -131,6 +149,6 @@ input {<br><br></body><footer>- <button type="submit" class="block">I Am Finished!</button>+ <button type="submit" name"firstboot" class="block">I Am Finished!</button></footer></form>diff --git a/scripts/write_config.php b/scripts/write_config.phpindex 6c993456..f423cd53 100644--- a/scripts/write_config.php+++ b/scripts/write_config.php@@ -1,4 +1,7 @@<?php+error_reporting(E_ALL);+ini_set('display_errors',1);+$latitude = $_POST["latitude"];$longitude = $_POST["longitude"];$birdweather_id = $_POST["birdweather_id"];@@ -23,24 +26,25 @@ $fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w");$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");fwrite($fh, $contents);fwrite($fh2, $contents2);-@session_start();--if(true){- $_SESSION['success'] = 1;- header("Location:config.php");+session_start();+$_SESSION['success'] = 1;+if(isset($_POST["normal"])){+ header('Location:config.php');+}else{+ header('Location:../../');}$language = $_POST["language"];if ($language != "none"){- $command = "sudo -upi set -x; sudo -upi mv /home/pi/BirdNET-Pi/model/labels.txt /home/pi/BirdNET-Pi/model/labels.txt.old && sudo -upi unzip /home/pi/BirdNET-Pi/model/labels_l18n.zip $language -d /home/pi/BirdNET-Pi/model && sudo -upi mv /home/pi/BirdNET-Pi/model/$language /home/pi/BirdNET-Pi/model/labels.txt";+ $command = "sudo -upi mv /home/pi/BirdNET-Pi/model/labels.txt /home/pi/BirdNET-Pi/model/labels.txt.old && sudo -upi unzip /home/pi/BirdNET-Pi/model/labels_l18n.zip $language -d /home/pi/BirdNET-Pi/model && sudo -upi mv /home/pi/BirdNET-Pi/model/$language /home/pi/BirdNET-Pi/model/labels.txt";$command_output = `$command`;- echo $command_output;- @session_start();-- if(true){- $_SESSION['success'] = 1;- header("Location:config.php");- }+session_start();+$_SESSION['success'] = 1;+if(isset($_POST["normal"])){+ header('Location:config.php');+}else{+ header('Location:../../');+}}?>