deletes file as well -- thanks @ehpersonal38

This commit is contained in:
mcguirepr89
2022-07-14 10:13:49 -04:00
parent d2d914f8ee
commit c08e2e533f
+8 -2
View File
@@ -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();