diff --git a/homepage/images/lock.svg b/homepage/images/lock.svg new file mode 100644 index 0000000..a3bd577 --- /dev/null +++ b/homepage/images/lock.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/homepage/images/unlock.svg b/homepage/images/unlock.svg new file mode 100644 index 0000000..e8ddb69 --- /dev/null +++ b/homepage/images/unlock.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/advanced.php b/scripts/advanced.php index 9f67d46..657cb99 100644 --- a/scripts/advanced.php +++ b/scripts/advanced.php @@ -204,7 +204,7 @@ if (file_exists('./scripts/thisrun.txt')) { >Purge -

When the disk becomes full, you can choose to 'purge' old files to make room for new ones or 'keep' your data and stop all services instead.

+

When the disk becomes full, you can choose to 'purge' old files to make room for new ones or 'keep' your data and stop all services instead.
Note: you can exclude specific files from 'purge' on the Recordings page.


Set Audio Card to 'default' to use PulseAudio (always recommended), or an ALSA recognized sound card device from the output of `aplay -L`.

diff --git a/scripts/play.php b/scripts/play.php index 87912a8..2115253 100644 --- a/scripts/play.php +++ b/scripts/play.php @@ -9,6 +9,43 @@ if($db == False){ header("refresh: 0;"); } +if (file_exists('./scripts/thisrun.txt')) { + $config = parse_ini_file('./scripts/thisrun.txt'); +} elseif (file_exists('firstrun.ini')) { + $config = parse_ini_file('firstrun.ini'); +} + +$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd"); +$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"); +$home = trim($home); + +if(isset($_GET['excludefile'])) { + if(!file_exists($home."/BirdNET-Pi/scripts/disk_check_exclude.txt")) { + file_put_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "##start\n##end"); + } + if(isset($_GET['exclude_add'])) { + $myfile = fopen($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "a") or die("Unable to open file!"); + $txt = $_GET['excludefile']; + fwrite($myfile, $txt."\n"); + fwrite($myfile, $txt.".png\n"); + fclose($myfile); + echo "OK"; + die(); + } else { + $lines = file($home."/BirdNET-Pi/scripts/disk_check_exclude.txt"); + $search = $_GET['excludefile']; + + $result = ''; + foreach($lines as $line) { + if(stripos($line, $search) === false && stripos($line, $search.".png") === false) { + $result .= $line; + } + } + file_put_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", $result); + echo "OK"; + die(); + } +} if(isset($_GET['bydate'])){ $statement = $db->prepare('SELECT DISTINCT(Date) FROM detections GROUP BY Date ORDER BY Date DESC'); @@ -70,9 +107,6 @@ if(isset($_GET['bydate'])){ session_unset(); $view = "choose"; } -$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd"); -$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"); -$home = trim($home); ?> @@ -83,6 +117,29 @@ $home = trim($home); + + - @@ -199,6 +255,7 @@ if(isset($_GET['species'])){ ?> $sci_name = $results['Sci_Name']; $time = $results['Time']; $confidence = $results['Confidence']; + $filename_formatted = $date."/".$comname."/".$results['File_Name']; // file was deleted by disk check, no need to show the detection in recordings if(!file_exists($home."/BirdSongs/Extracted/".$filename)) { @@ -206,13 +263,31 @@ if(isset($_GET['species'])){ ?> } $iter++; - echo " - - "; + if($config["FULL_DISK"] == "purge") { + if(trim(shell_exec("cat ".$home."/BirdNET-Pi/scripts/disk_check_exclude.txt | grep \"".$filename_formatted."\" | wc -l")) == "0") { + $imageicon = "images/unlock.svg"; + $title = "This file is not delete protected."; + $type = "add"; + } else { + $imageicon = "images/lock.svg"; + $title = "This file is delete protected."; + $type = "del"; + } - }if($iter == 0){ echo "";}echo "
$date $time
$confidence
- -
No recordings were found on this date.

They may have been deleted to make space for new recordings. You can modify this setting for the future in Tools -> Settings -> Advanced Settings -> Full Disk Behavior.
";} + echo " + $date $time
$confidence
+ + + "; + } else { + echo " + $date $time
$confidence
+ + + "; + } + + }if($iter == 0){ echo "No recordings were found.

They may have been deleted to make space for new recordings. You can modify this setting for the future in Tools -> Settings -> Advanced Settings -> Full Disk Behavior.";}echo "";} if(isset($_GET['filename'])){ $name = $_GET['filename']; @@ -236,11 +311,29 @@ if(isset($_GET['filename'])){ $sci_name = $results['Sci_Name']; $time = $results['Time']; $confidence = $results['Confidence']; - echo " - $date $time
$confidence
- - - "; + $filename_formatted = $date."/".$comname."/".$results['File_Name']; + + if($config["FULL_DISK"] == "purge") { + if(trim(shell_exec("cat ".$home."/BirdNET-Pi/scripts/disk_check_exclude.txt | grep \"".$filename_formatted."\" | wc -l")) == "0") { + $imageicon = "images/unlock.svg"; + $title = "This file is not delete protected."; + $type = "add"; + } else { + $imageicon = "images/lock.svg"; + $title = "This file is delete protected."; + $type = "del"; + } + + echo " + $date $time
$confidence
+ + "; + } else { + echo " + $date $time
$confidence
+ + "; + } }echo "";}?> diff --git a/scripts/stats.php b/scripts/stats.php index a136946..3f41a22 100644 --- a/scripts/stats.php +++ b/scripts/stats.php @@ -56,7 +56,18 @@ if(isset($_GET['species'])){ $user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd"); $home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"); $home = trim($home); -file_put_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", ""); +if(!file_exists($home."/BirdNET-Pi/scripts/disk_check_exclude.txt")) { + file_put_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "##start\n##end"); +} +function editfile( $sourcefile, $start='##start', $end='##end', $data=array() ){ + $lines=array_filter( file( $sourcefile , FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES ) ); + $output=array_merge( + array_splice( $lines, 0, array_search( strtolower( $start ), array_map('strtolower', $lines ) ) + 1 ), + $data, + array_splice( $lines, array_search( strtolower( $end ), array_map('strtolower', $lines ) ) ) + ); + file_put_contents( $sourcefile, implode( PHP_EOL, $output ) ); +} ?> @@ -151,21 +162,22 @@ while($results=$result3->fetchArray(SQLITE3_ASSOC)){ if($pos !== 1 && strpos($link, "upload") == true && strpos($link, "CentralAutoLogin") == false) echo ""; } -}} +} +} ?>


fetchArray(SQLITE3_ASSOC)) { $comname = preg_replace('/ /', '_', $results['Com_Name']); $comname = preg_replace('/\'/', '', $comname); $filename = "/By_Date/".$results['Date']."/".$comname."/".$results['File_Name']; -$excludefile = fopen($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "a") or die("Unable to open file!"); -$txt = $results['Date']."/".$comname."/".$results['File_Name']."\n".$results['Date']."/".$comname."/".$results['File_Name'].".png\n"; -fwrite($excludefile, $txt); +array_push($excludelines, $results['Date']."/".$comname."/".$results['File_Name']); +array_push($excludelines, $results['Date']."/".$comname."/".$results['File_Name'].".png"); ?> @@ -176,6 +188,7 @@ fwrite($excludefile, $txt); Best Recording: