deletes file as well -- thanks @ehpersonal38
This commit is contained in:
+19
-13
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
error_reporting(E_ERROR);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
$db = new SQLite3('./scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
|
$db = new SQLite3('./scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
|
||||||
if($db == False){
|
if($db == False){
|
||||||
@@ -20,10 +20,16 @@ $home = trim($home);
|
|||||||
if(isset($_GET['deletefile'])) {
|
if(isset($_GET['deletefile'])) {
|
||||||
$statement1 = $db->prepare('DELETE FROM detections WHERE File_Name = "'.explode("/",$_GET['deletefile'])[2].'" LIMIT 1');
|
$statement1 = $db->prepare('DELETE FROM detections WHERE File_Name = "'.explode("/",$_GET['deletefile'])[2].'" LIMIT 1');
|
||||||
if($statement1 == False){
|
if($statement1 == False){
|
||||||
echo "Database is busy";
|
echo "Error";
|
||||||
header("refresh: 0;");
|
header("refresh: 0;");
|
||||||
} else {
|
} else {
|
||||||
|
$file_pointer = $home."/BirdSongs/Extracted/By_Date/".$_GET['deletefile'];
|
||||||
|
if (!exec("sudo rm $file_pointer && sudo rm $file_pointer.png")) {
|
||||||
echo "OK";
|
echo "OK";
|
||||||
|
} else {
|
||||||
|
echo "Error";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$result1 = $statement1->execute();
|
$result1 = $statement1->execute();
|
||||||
die();
|
die();
|
||||||
@@ -269,31 +275,31 @@ if(isset($_GET['species'])){ ?>
|
|||||||
<?php
|
<?php
|
||||||
// add disk_check_exclude.txt lines into an array for grepping
|
// add disk_check_exclude.txt lines into an array for grepping
|
||||||
$fp = @fopen($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", 'r');
|
$fp = @fopen($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", 'r');
|
||||||
if ($fp) {
|
if ($fp) {
|
||||||
$disk_check_exclude_arr = explode("\n", fread($fp, filesize($home."/BirdNET-Pi/scripts/disk_check_exclude.txt")));
|
$disk_check_exclude_arr = explode("\n", fread($fp, filesize($home."/BirdNET-Pi/scripts/disk_check_exclude.txt")));
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = $_GET['species'];
|
$name = $_GET['species'];
|
||||||
if(isset($_SESSION['date'])) {
|
if(isset($_SESSION['date'])) {
|
||||||
$date = $_SESSION['date'];
|
$date = $_SESSION['date'];
|
||||||
if(isset($_GET['sort']) && $_GET['sort'] == "confidence") {
|
if(isset($_GET['sort']) && $_GET['sort'] == "confidence") {
|
||||||
$statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" AND Date == \"$date\" ORDER BY Confidence DESC");
|
$statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" AND Date == \"$date\" ORDER BY Confidence DESC");
|
||||||
} else {
|
} else {
|
||||||
$statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" AND Date == \"$date\" ORDER BY Time DESC");
|
$statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" AND Date == \"$date\" ORDER BY Time DESC");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(isset($_GET['sort']) && $_GET['sort'] == "confidence") {
|
if(isset($_GET['sort']) && $_GET['sort'] == "confidence") {
|
||||||
$statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" ORDER BY Confidence DESC");
|
$statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" ORDER BY Confidence DESC");
|
||||||
} else {
|
} else {
|
||||||
$statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" ORDER BY Date DESC, Time DESC");
|
$statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" ORDER BY Date DESC, Time DESC");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($statement2 == False){
|
if($statement2 == False){
|
||||||
echo "Database is busy";
|
echo "Database is busy";
|
||||||
header("refresh: 0;");
|
header("refresh: 0;");
|
||||||
}
|
}
|
||||||
$result2 = $statement2->execute();
|
$result2 = $statement2->execute();
|
||||||
echo "<table>
|
echo "<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>$name</th>
|
<th>$name</th>
|
||||||
</tr>";
|
</tr>";
|
||||||
@@ -340,7 +346,7 @@ if(isset($_GET['species'])){ ?>
|
|||||||
|
|
||||||
}if($iter == 0){ echo "<tr><td><b>No recordings were found.</b><br><br><span style='font-size:medium'>They may have been deleted to make space for new recordings. You can prevent this from happening in the future by clicking the <img src='images/unlock.svg' style='width:20px'> icon in the top right of a recording.<br>You can also modify this behavior globally under \"Full Disk Behavior\" <a href='views.php?view=Advanced'>here.</a></span></td></tr>";}echo "</table>";}
|
}if($iter == 0){ echo "<tr><td><b>No recordings were found.</b><br><br><span style='font-size:medium'>They may have been deleted to make space for new recordings. You can prevent this from happening in the future by clicking the <img src='images/unlock.svg' style='width:20px'> icon in the top right of a recording.<br>You can also modify this behavior globally under \"Full Disk Behavior\" <a href='views.php?view=Advanced'>here.</a></span></td></tr>";}echo "</table>";}
|
||||||
|
|
||||||
if(isset($_GET['filename'])){
|
if(isset($_GET['filename'])){
|
||||||
$name = $_GET['filename'];
|
$name = $_GET['filename'];
|
||||||
$statement2 = $db->prepare("SELECT * FROM detections where File_name == \"$name\" ORDER BY Date DESC, Time DESC");
|
$statement2 = $db->prepare("SELECT * FROM detections where File_name == \"$name\" ORDER BY Date DESC, Time DESC");
|
||||||
if($statement2 == False){
|
if($statement2 == False){
|
||||||
|
|||||||
Reference in New Issue
Block a user