A live bird collage card for your Home Assistant dashboard.
delete improvements
ehpersonal38eeee9e77feae
diff --git a/homepage/images/delete.svg b/homepage/images/delete.svgindex 107369b6..287e2ba2 100644--- a/homepage/images/delete.svg+++ b/homepage/images/delete.svg@@ -1,14 +1,18 @@<?xml version="1.0" encoding="iso-8859-1"?><!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"- viewBox="0 0 459 459" style="enable-background:new 0 0 459 459;" xml:space="preserve">+ viewBox="0 0 457.503 457.503" style="enable-background:new 0 0 457.503 457.503;" xml:space="preserve"><g><g>- <path d="M229.5,0C102.751,0,0,102.751,0,229.5S102.751,459,229.5,459S459,356.249,459,229.5S356.249,0,229.5,0z M307.105,271.629- c9.797,9.797,9.797,25.68,0,35.477c-4.898,4.898-11.318,7.347-17.738,7.347c-6.42,0-12.84-2.449-17.738-7.347L229.5,264.977- l-42.128,42.129c-4.898,4.898-11.318,7.347-17.738,7.347c-6.42,0-12.84-2.449-17.738-7.347c-9.797-9.796-9.797-25.68,0-35.477- l42.129-42.129l-42.129-42.129c-9.797-9.797-9.797-25.68,0-35.477s25.68-9.797,35.477,0l42.128,42.129l42.128-42.129- c9.797-9.797,25.68-9.797,35.477,0c9.797,9.796,9.797,25.68,0,35.477l-42.13,42.129L307.105,271.629z"/>+ <path d="M381.575,57.067h-90.231C288.404,25.111,261.461,0,228.752,0C196.043,0,169.1,25.111,166.16,57.067H75.929+ c-26.667,0-48.362,21.695-48.362,48.362c0,26.018,20.655,47.292,46.427,48.313v246.694c0,31.467,25.6,57.067,57.067,57.067+ h195.381c31.467,0,57.067-25.6,57.067-57.067V153.741c25.772-1.02,46.427-22.294,46.427-48.313+ C429.936,78.761,408.242,57.067,381.575,57.067z M165.841,376.817c0,8.013-6.496,14.509-14.508,14.509+ c-8.013,0-14.508-6.496-14.508-14.509V186.113c0-8.013,6.496-14.508,14.508-14.508c8.013,0,14.508,6.496,14.508,14.508V376.817z+ M243.26,376.817c0,8.013-6.496,14.509-14.508,14.509c-8.013,0-14.508-6.496-14.508-14.509V186.113+ c0-8.013,6.496-14.508,14.508-14.508c8.013,0,14.508,6.496,14.508,14.508V376.817z M320.679,376.817+ c0,8.013-6.496,14.509-14.508,14.509c-8.013,0-14.509-6.496-14.509-14.509V186.113c0-8.013,6.496-14.508,14.509-14.508+ s14.508,6.496,14.508,14.508V376.817z"/></g></g><g>diff --git a/scripts/play.php b/scripts/play.phpindex 72b5542a..9d7f923c 100644--- a/scripts/play.php+++ b/scripts/play.php@@ -18,22 +18,39 @@ $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['deletefile'])) {- $statement1 = $db->prepare('DELETE FROM detections WHERE File_Name = "'.explode("/",$_GET['deletefile'])[2].'" LIMIT 1');- if($statement1 == False){- echo "Error";- header("refresh: 0;");- } else {- $file_pointer = $home."/BirdSongs/Extracted/By_Date/".$_GET['deletefile'];- if (!exec("sudo rm $file_pointer && sudo rm $file_pointer.png")) {- echo "OK";+ if(isset($_SERVER['PHP_AUTH_USER'])) {+ $submittedpwd = $_SERVER['PHP_AUTH_PW'];+ $submitteduser = $_SERVER['PHP_AUTH_USER'];+ if($submittedpwd == $config['CADDY_PWD'] && $submitteduser == 'birdnet'){+ $statement1 = $db->prepare('DELETE FROM detections WHERE File_Name = "'.explode("/",$_GET['deletefile'])[2].'" LIMIT 1');+ if($statement1 == False){+ echo "Error";+ header("refresh: 0;");+ } else {+ $file_pointer = $home."/BirdSongs/Extracted/By_Date/".$_GET['deletefile'];+ if (!exec("sudo rm $file_pointer && sudo rm $file_pointer.png")) {+ echo "OK";+ } else {+ echo "Error";+ }++ }+ $result1 = $statement1->execute();+ die();} else {- echo "Error";+ header('WWW-Authenticate: Basic realm="My Realm"');+ header('HTTP/1.0 401 Unauthorized');+ echo 'You must be authenticated to change the protection of files.';+ exit;}-+ } else {+ header('WWW-Authenticate: Basic realm="My Realm"');+ header('HTTP/1.0 401 Unauthorized');+ echo 'You must be authenticated to change the protection of files.';+ exit;}- $result1 = $statement1->execute();- die();}if(isset($_GET['excludefile'])) {