I like this so far

This commit is contained in:
mcguirepr89
2022-02-26 14:49:57 -05:00
parent 05f580b79d
commit 579d3b1e26
12 changed files with 295 additions and 216 deletions
+19 -101
View File
@@ -1,106 +1,24 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<div class="banner">
<h1>BirdNET-Pi</h1>
<form action="" method="POST">
<?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');
echo "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";
if(isset($_GET['stream'])){
echo "<h1>BirdNET-Pi</h1><br><audio controls autoplay><source src=\"/stream\"></audio>";
} else {
echo "<h1>BirdNET-Pi</h1><br><form action=\"\" method=\"GET\"><button type=\"submit\" name=\"stream\" value=\"play\">Live Audio</button></form>";
}
$pages = array("Overview", "Database", "Species Stats", "History", "Tools", "Live Stream", "Extractions", "Spectrogram","Log");
foreach($pages as $page){
echo "<button type=\"submit\" name=\"view\" value=\"$page\">$page</button>";
}?>
</form>
</div>
<?php
function httpPost($url, $data){
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
echo $response;
}
if(isset($_POST['view'])){
if($_POST['view'] == "System"){header('location:phpsysinfo/index.php');}
if($_POST['view'] == "Spectrogram"){include('spectrogram.php');}
if($_POST['view'] == "Overview"){include('overview.php');}
if($_POST['view'] == "Database"){include('viewdb.php');}
if($_POST['view'] == "Species Stats"){include('stats.php');}
if($_POST['view'] == "History"){include('history.php');}
if($_POST['view'] == "Tools"){
echo "<form action=\"\" method=\"POST\">
<button type=\"submit\" name=\"view\" value=\"Settings\">Settings</button>
<button type=\"submit\" name=\"view\" value=\"System\">System Info</button>
<button type=\"submit\" name=\"view\" value=\"Included\">Custom Species List</button>
<button type=\"submit\" name=\"view\" value=\"Excluded\">Excluded Species List</button>
</form>";
}
if($_POST['view'] == "Live Stream"){
echo "<audio controls autoplay><source src=\"/stream\" type=\"audio/mpeg\"></audio>";
}
if($_POST['view'] == "Extractions"){include('play.php');}
if($_POST['view'] == "Settings"){include('scripts/config.php');}
if($_POST['view'] == "Advanced"){include('scripts/advanced.php');}
if($_POST['view'] == "Log"){
$url = 'http://birdnetpi.local:8080';
header("location: $url;");
}
if($_POST['view'] == "Included"){
if(isset($_POST['species']) && isset($_POST['add'])){
$file='/home/pi/BirdNET-Pi/include_species_list.txt';
$str=file_get_contents("$file");
$str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str);
file_put_contents("$file", "$str");
if(isset($_POST['species'])){
foreach ($_POST['species'] as $selectedOption)
file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", $selectedOption."\n", FILE_APPEND);
}
} elseif(isset($_POST['species']) && isset($_POST['del'])){
$file = '/home/pi/BirdNET-Pi/include_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents("$file", "$str");
foreach($_POST['species'] as $selectedOption) {
$content = file_get_contents("/home/pi/BirdNET-Pi/include_species_list.txt");
$newcontent = str_replace($selectedOption, "", "$content");
file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", "$newcontent");
}
$file = '/home/pi/BirdNET-Pi/include_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents("$file", "$str");
}
include('scripts/include_list.php');
}
if($_POST['view'] == "Excluded"){
if(isset($_POST['species']) && isset($_POST['add'])){
$file = '/home/pi/BirdNET-Pi/exclude_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str);
file_put_contents("$file", "$str");
foreach ($_POST['species'] as $selectedOption)
file_put_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt", $selectedOption."\n", FILE_APPEND);
} elseif (isset($_POST['species']) && isset($_POST['del'])){
$file = '/home/pi/BirdNET-Pi/exclude_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents("$file", "$str");
foreach($_POST['species'] as $selectedOption) {
$content = file_get_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt");
$newcontent = str_replace($selectedOption, "", "$content");
file_put_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt", "$newcontent");
}
$file = '/home/pi/BirdNET-Pi/exclude_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents("$file", "$str");
}
include('scripts/exclude_list.php');
echo "</div>";
if(isset($_GET['log'])){
if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
$config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');
$logs = $config['BIRDNETLOG_URL'];
} elseif (file_exists('/home/pi/BirdNET-Pi/firstrun.ini')) {
$config = parse_ini_file('/home/pi/BirdNET-Pi/firstrun.ini');
$logs = $config['BIRDNETLOG_URL'];
}
header("Location: $logs");
}elseif(isset($_GET['spectrogram'])){
header("Location: /spectrogram.php");
} else {
echo "<iframe src=\"/views.php\" width=\"100%\" height=\"85%\">";
}
?>
+96 -59
View File
@@ -1,96 +1,133 @@
/* style sheet */
* {
font-family: 'Arial', 'Gill Sans', 'Gill Sans MT',
' Calibri', 'Trebuchet MS', 'sans-serif';
box-sizing: border-box;
}
/* Create two equal columns that floats next to each other */
.column2 {
.banner {
height: auto;
text-align: center;
}
.banner h1 {
float: top;
}
.banner audio {
width: 120px;
margin-left: auto;
margin-right: auto;
width: 75%;
padding: 5px;
}
/* Create two equal columns that floats next to each other */
.column {
/* Add a black background color to the top navigation */
.topnav {
overflow: hidden;
background-color: rgb(119, 196, 135);
width:100%;
display: block;
margin-left: auto;
margin-right: auto;
}
/* Style the links inside the navigation bar */
.topnav button {
float: left;
width: 50%;
padding: 5px;
display: block;
text-align: center;
padding: 14px 16px;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
/* Change the color of links on hover */
.topnav button:hover {
background-color: #ddd;
color: black;
}
/* Add an active class to highlight the current page */
.topnav button.active {
background-color: #04AA6D;
color: white;
}
/* Hide the link that should open and close the topnav on small screens */
.topnav .icon {
display: none;
}
.topnav form {
float:left;
}
iframe {
border: none;
height: 85%;
width: 100%;
}
body {
background-color: rgb(119, 196, 135);
}
table {
background-color: rgb(219, 255, 235);
background-color: transparent;
margin: 0 auto;
font-size: large;
border-collapse: collapse;
border-spacing: 0;
width: 100%;
border: 1px solid black;
}
h1 {
text-align: center;
color: black;
font-size: xx-large;
}
h2 {
margin-left: -150px;
text-align: center;
color: black;
font-size: large;
}
h3 {
text-align: center;
color: black;
font-size: large;
/* border: 1px solid black;*/
}
td {
background-color: rgb(219, 255, 235);
font-weight: lighter;
border: 1px solid black;
padding: 10px;
border: 2px solid black;
text-align: center;
}
th {
background-color: rgb(219, 255, 235);
font-weight: bold;
border: 1px solid black;
padding: 10px;
height: auto;
text-align: center;
}
@media screen and (max-width: 600px) {
h2 {
margin-left: 0;
text-align: center;
color: black;
font-size: large;
}
.column {
width: 100%;
}
/* Create two equal columns that floats next to each other */
.column2 {
float: center;
width: 100%;
padding: 0px;
}
audio {
width: 100%;
}
button {
font-size: large;
background-color: transparent;
border: none;
color: black;
cursor: pointer;
}
.spectrogrambutton, .logbutton, .navbuttons {
float: left;
}
body::-webkit-scrollbar {
display:none
}
@media screen and (max-width: 1000px) {
.topnav button {display: none;}
.topnav form {float: none;}
/*.topnav button:not(:first-child) {display: none;}*/
.topnav button.icon {
display: block;
width: 100%;
margin-left: auto;
margin-right: auto;
}
}
@media screen and (max-width: 1000px) {
.topnav.responsive {position: relative;}
.topnav.responsive button {
float: left;
display: block;
text-align: center;
}
}
+109
View File
@@ -0,0 +1,109 @@
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<div class="topnav" id="myTopnav">
<form action="" method="POST" id="views">
<button type="submit" name="view" value="Overview" id="views">Overview</button>
<button type="submit" name="view" value="Today's Detections" id="views">Today's Detections</button>
<button type="submit" name="view" value="Species Stats" id="views">Species Stats</button>
<button type="submit" name="view" value="Daily Charts" id="views">Daily Charts</button>
<button type="submit" name="view" value="Tools" id="views">Tools</button>
<button type="submit" name="view" value="Recordings" id="views">Recordings</button>
</form>
<form action="index.php" method="GET" id="log">
<button type="submit" name="log" value="log" id="log">View Log</button>
</form>
<form action="index.php" method="GET" id="spectrogram">
<button type="submit" name="spectrogram" value="view" id="spectrogram">Spectrogram</button>
</form>
<button href="javascript:void(0);" class="icon" onclick="myFunction()"><img src="images/menu.png"></button>
</div>
<?php
if(isset($_POST['view'])){
if($_POST['view'] == "System"){header('location:phpsysinfo/index.php');}
if($_POST['view'] == "Spectrogram"){include('spectrogram.php');}
if($_POST['view'] == "Overview"){include('overview.php');}
if($_POST['view'] == "Today's Detections"){include('viewdb.php');}
if($_POST['view'] == "Species Stats"){include('stats.php');}
if($_POST['view'] == "Daily Charts"){include('history.php');}
if($_POST['view'] == "Tools"){
echo "<form action=\"\" method=\"POST\">
<button type=\"submit\" name=\"view\" value=\"Settings\">Settings</button>
<button type=\"submit\" name=\"view\" value=\"System\">System Info</button>
<button type=\"submit\" name=\"view\" value=\"Included\">Custom Species List</button>
<button type=\"submit\" name=\"view\" value=\"Excluded\">Excluded Species List</button>
</form>";
}
if($_POST['view'] == "Recordings"){include('play.php');}
if($_POST['view'] == "Settings"){include('scripts/config.php');}
if($_POST['view'] == "Advanced"){include('scripts/advanced.php');}
if($_POST['view'] == "Log"){
$url = 'http://birdnetpi.local:8080';
header("location: $url;");
}
if($_POST['view'] == "Included"){
if(isset($_POST['species']) && isset($_POST['add'])){
$file = '/home/pi/BirdNET-Pi/include_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str);
file_put_contents("$file", "$str");
if(isset($_POST['species'])){
foreach ($_POST['species'] as $selectedOption)
file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", $selectedOption."\n", FILE_APPEND);
}
} elseif(isset($_POST['species']) && isset($_POST['del'])){
$file = '/home/pi/BirdNET-Pi/include_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents("$file", "$str");
foreach($_POST['species'] as $selectedOption) {
$content = file_get_contents("/home/pi/BirdNET-Pi/include_species_list.txt");
$newcontent = str_replace($selectedOption, "", "$content");
file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", "$newcontent");
}
$file = '/home/pi/BirdNET-Pi/include_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents("$file", "$str");
}
include('scripts/include_list.php');
}
if($_POST['view'] == "Excluded"){
if(isset($_POST['species']) && isset($_POST['add'])){
$file = '/home/pi/BirdNET-Pi/exclude_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str);
file_put_contents("$file", "$str");
foreach ($_POST['species'] as $selectedOption)
file_put_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt", $selectedOption."\n", FILE_APPEND);
} elseif (isset($_POST['species']) && isset($_POST['del'])){
$file = '/home/pi/BirdNET-Pi/exclude_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents("$file", "$str");
foreach($_POST['species'] as $selectedOption) {
$content = file_get_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt");
$newcontent = str_replace($selectedOption, "", "$content");
file_put_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt", "$newcontent");
}
$file = '/home/pi/BirdNET-Pi/exclude_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents("$file", "$str");
}
include('scripts/exclude_list.php');
}
}else{
include('overview.php');}
?>
<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>