From a8b833cd2eace1bd9c7fed4f729f62cdb6fa1c5c Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Sun, 27 Feb 2022 10:06:33 -0500 Subject: [PATCH] I like this so far --- homepage/index.php | 26 ++++++++++- homepage/style.css | 72 ++++++++++++++++++++++++------- homepage/views.php | 42 ++++++++++++++---- scripts/advanced.php | 5 +-- scripts/extract_new_birdsounds.sh | 2 +- scripts/history.php | 2 +- scripts/overview.php | 8 ++-- scripts/play.php | 4 +- scripts/spectrogram.php | 2 +- scripts/stats.php | 12 +++--- scripts/viewdb.php | 2 +- 11 files changed, 129 insertions(+), 48 deletions(-) diff --git a/homepage/index.php b/homepage/index.php index 2abdd61..ccfb05b 100644 --- a/homepage/index.php +++ b/homepage/index.php @@ -3,9 +3,31 @@ "; if(isset($_GET['stream'])){ - echo "

BirdNET-Pi


"; + 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'); +} +$caddypwd = $config['CADDY_PWD']; +if (!isset($_SERVER['PHP_AUTH_USER'])) { + header('WWW-Authenticate: Basic realm="My Realm"'); + header('HTTP/1.0 401 Unauthorized'); + echo 'You cannot listen to the live audio stream'; + exit; } else { - echo "

BirdNET-Pi


"; + $submittedpwd = $_SERVER['PHP_AUTH_PW']; + $submitteduser = $_SERVER['PHP_AUTH_USER']; + if($submittedpwd == $caddypwd && $submitteduser == 'birdnet'){ + echo "

BirdNET-Pi

"; + } else { + header('WWW-Authenticate: Basic realm="My Realm"'); + header('HTTP/1.0 401 Unauthorized'); + echo 'You cannot listen to the live audio stream'; + exit; + } +} +} else { + echo "

BirdNET-Pi

"; } echo ""; if(isset($_GET['log'])){ diff --git a/homepage/style.css b/homepage/style.css index a1dfc62..e910191 100644 --- a/homepage/style.css +++ b/homepage/style.css @@ -19,31 +19,31 @@ margin-right: auto; } -/* Add a black background color to the top navigation */ -.topnav { - overflow: hidden; - background-color: rgb(119, 196, 135); - width:100%; +.topbar { + display: block; + width: auto; + margin-left: 10%; + margin-right: 10%; +} + +.topnav { + background-color: rgb(119, 196, 135); display: block; - margin-left: auto; - margin-right: auto; } -/* Style the links inside the navigation bar */ .topnav button { - float: left; + background-color: transparent; display: block; text-align: center; padding: 14px 16px; + float:left; } -/* 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; @@ -54,8 +54,8 @@ display: none; } -.topnav form { - float:left; +h3 { + text-align: center; } iframe { @@ -91,10 +91,21 @@ th { text-align: center; } -audio { +audio, video{ width: 100%; } +.spectrogram { + width:33% +} + +.centered { + display: block; + width: auto; + margin-left: auto; + margin-right: auto; +} + button { font-size: large; background-color: transparent; @@ -103,17 +114,20 @@ button { cursor: pointer; } -.spectrogrambutton, .logbutton, .navbuttons { +.logbutton, .navbuttons { float: left; } +.spectrogrambutton { + float:top; +} + 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; @@ -131,3 +145,29 @@ body::-webkit-scrollbar { text-align: center; } } + +@media screen and (max-width: 600px) { + .top.nav button { + font-size: 16px; + } + .topnav button {display: 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: 600px) { + .topnav button { + font-size: 16px; + } + .topnav.responsive {position: relative;} + .topnav.responsive button { + float: left; + display: block; + text-align: center; + } +} diff --git a/homepage/views.php b/homepage/views.php index 1c564a8..7d17173 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -1,5 +1,6 @@ +
@@ -13,11 +14,12 @@
- +
- +
+ - - - - - "; + 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'); + } + $caddypwd = $config['CADDY_PWD']; + if (!isset($_SERVER['PHP_AUTH_USER'])) { + header('WWW-Authenticate: Basic realm="My Realm"'); + header('HTTP/1.0 401 Unauthorized'); + echo 'You cannot edit the settings for this installation'; + exit; + } else { + $submittedpwd = $_SERVER['PHP_AUTH_PW']; + $submitteduser = $_SERVER['PHP_AUTH_USER']; + if($submittedpwd == $caddypwd && $submitteduser == 'birdnet'){ + echo "
+ + + + +
"; + } else { + header('WWW-Authenticate: Basic realm="My Realm"'); + header('HTTP/1.0 401 Unauthorized'); + echo 'You cannot edit the settings for this installation'; + exit; + } + } } if($_POST['view'] == "Recordings"){include('play.php');} if($_POST['view'] == "Settings"){include('scripts/config.php');} @@ -106,4 +130,4 @@ function myFunction() { } } - + diff --git a/scripts/advanced.php b/scripts/advanced.php index 736d655..8de3286 100644 --- a/scripts/advanced.php +++ b/scripts/advanced.php @@ -199,12 +199,9 @@ foreach($formats as $format){ } ?> -

Passwords

+

BirdNET-Pi Password


-

This password protects the Live Audio Stream, the Processed extractions, phpSysInfo, your Tools, and WebTerminal. When you update this value, the web server will reload, so wait about 30 seconds and then reload the page.

- -

Custom URLs

When you update any of the URL settings below, the web server will reload, so be sure to wait at least 30 seconds and then reload the page.

diff --git a/scripts/extract_new_birdsounds.sh b/scripts/extract_new_birdsounds.sh index 651b723..ce9729e 100755 --- a/scripts/extract_new_birdsounds.sh +++ b/scripts/extract_new_birdsounds.sh @@ -64,7 +64,7 @@ for h in "${SCAN_DIRS[@]}";do | awk -F\; '{print $5}')"" #CONFIDENCE_SCORE="${CONFIDENCE:0:2}%" - CONFIDENCE_SCORE="$(printf %.0f $(echo "scale=2; ${CONFIDENCE} * 100" | bc))" + CONFIDENCE_SCORE="$(printf %.0f "$(echo "scale=2; ${CONFIDENCE} * 100" | bc)")" NEWFILE="${COMMON_NAME// /_}-${CONFIDENCE_SCORE}-${OLDFILE//.wav/.${AUDIOFMT}}" echo "NEWFILE=$NEWFILE" NEWSPECIES_BYDATE="${EXTRACTED}/By_Date/${DATE}/${COMMON_NAME// /_}" diff --git a/scripts/history.php b/scripts/history.php index 71f9b44..e184ba5 100644 --- a/scripts/history.php +++ b/scripts/history.php @@ -28,7 +28,7 @@ $totalcount = $result1->fetchArray(SQLITE3_ASSOC);
- +
diff --git a/scripts/overview.php b/scripts/overview.php index 8560472..1c72557 100644 --- a/scripts/overview.php +++ b/scripts/overview.php @@ -108,18 +108,18 @@ $speciestally = $result5->fetchArray(SQLITE3_ASSOC); - +
"; + echo ""; } else { echo "

No Detections For Today

"; } ?> -

Currently Analyzing

- +

Currently Analyzing

+ diff --git a/scripts/play.php b/scripts/play.php index e0ef825..022f0db 100644 --- a/scripts/play.php +++ b/scripts/play.php @@ -93,7 +93,7 @@ while($results=$result->fetchArray(SQLITE3_ASSOC)) Most confident recording: - + "; };};?> @@ -129,7 +129,7 @@ while($results=$result->fetchArray(SQLITE3_ASSOC)) $confidence = $results['Confidence']; echo " $date $time - + $sci_name
diff --git a/scripts/spectrogram.php b/scripts/spectrogram.php index 31b177e..e9d87bc 100644 --- a/scripts/spectrogram.php +++ b/scripts/spectrogram.php @@ -6,6 +6,6 @@ if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) { } $refresh = $config['RECORDING_LENGTH']; $time = time(); -echo ""; +echo ""; header("Refresh: $refresh;"); ?> diff --git a/scripts/stats.php b/scripts/stats.php index bb16c45..bf13117 100644 --- a/scripts/stats.php +++ b/scripts/stats.php @@ -41,7 +41,7 @@ if(isset($_POST['species'])){
Choose a species below to show statistics.

"; + echo "

Choose a species below to load images from Wikimedia Commons.

"; };?> @@ -65,7 +65,7 @@ $filename = "/By_Date/".$results['Date']."/".$comname."/".$results['File_Name']; - + fetchArray(SQLITE3_ASSOC)){ - +
$sciname $count $maxconf$date $time
$date $time
All About Birds
-

Loading Images from https://commons.wikimedia.org/w/index.php?search=$linkname&title=Special:MediaSearch&go=Go&type=image

", '6096'); +

Loading Images from Wikimedia Commons

", '6096'); ob_flush(); flush(); @@ -118,9 +118,7 @@ while($results=$result3->fetchArray(SQLITE3_ASSOC)){ foreach ($matches as $val) { $pos = strpos($val[2],"/"); $link = substr($val[2],1,-1); - if($pos == 1) - echo "http://domain.com" . $link; - elseif(strpos($link, "upload") == true) + if($pos !== 1 && strpos($link, "upload") == true && strpos($link, "CentralAutoLogin") == false) echo ""; } }} diff --git a/scripts/viewdb.php b/scripts/viewdb.php index 6dcfcb4..eedec69 100644 --- a/scripts/viewdb.php +++ b/scripts/viewdb.php @@ -109,7 +109,7 @@ $sciname = preg_replace('/ /', '_', $todaytable['Sci_Name']); ?> - +