From 8a6d79b642661d939efd648a14d387b357e0b991 Mon Sep 17 00:00:00 2001 From: Jake Herbst Date: Sun, 15 May 2022 13:36:00 -0400 Subject: [PATCH 1/4] Updating CADDY_PWD config updating to allow special characters --- scripts/advanced.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/advanced.php b/scripts/advanced.php index 9f67d46..31d90fa 100644 --- a/scripts/advanced.php +++ b/scripts/advanced.php @@ -33,12 +33,11 @@ if(isset($_GET['submit'])) { if(isset($_GET["caddy_pwd"])) { $caddy_pwd = $_GET["caddy_pwd"]; if(strcmp($caddy_pwd,$config['CADDY_PWD']) !== 0) { - $contents = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=$caddy_pwd", $contents); - $contents2 = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=$caddy_pwd", $contents2); + $contents = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=\"$caddy_pwd\"", $contents); $fh = fopen('/etc/birdnet/birdnet.conf', "w"); $fh2 = fopen("./scripts/thisrun.txt", "w"); fwrite($fh, $contents); - fwrite($fh2, $contents2); + fwrite($fh2, $contents); exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &'); } } From 697f19484e8d9ad364117a4890447535629b1e24 Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Sun, 15 May 2022 14:29:04 -0400 Subject: [PATCH 2/4] Re-adding contents2 for `thisrun.txt` use This is still needed for a silly reason which is that BirdNET-Pi does not have a good common configuration file that bash, PHP, and Python share -- instead, PHP and Python read from `thisrun.txt` which is pretty much .ini formatted, while bash uses `birdnet.conf`. Things that update one typically update the other in tandem. It's not best practice by any means. (Nor is storing the Caddy password in plaintext in a configuration file, so that sucks, too . . .) --- scripts/advanced.php | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/advanced.php b/scripts/advanced.php index 31d90fa..a4c1508 100644 --- a/scripts/advanced.php +++ b/scripts/advanced.php @@ -34,6 +34,7 @@ if(isset($_GET['submit'])) { $caddy_pwd = $_GET["caddy_pwd"]; if(strcmp($caddy_pwd,$config['CADDY_PWD']) !== 0) { $contents = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=\"$caddy_pwd\"", $contents); + $contents2 = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=\"$caddy_pwd\"", $contents); $fh = fopen('/etc/birdnet/birdnet.conf', "w"); $fh2 = fopen("./scripts/thisrun.txt", "w"); fwrite($fh, $contents); From a60a18188782d868d66729a68cd90bd6ee314379 Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Sun, 15 May 2022 14:29:40 -0400 Subject: [PATCH 3/4] Update advanced.php --- scripts/advanced.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/advanced.php b/scripts/advanced.php index a4c1508..1660e4b 100644 --- a/scripts/advanced.php +++ b/scripts/advanced.php @@ -38,7 +38,7 @@ if(isset($_GET['submit'])) { $fh = fopen('/etc/birdnet/birdnet.conf', "w"); $fh2 = fopen("./scripts/thisrun.txt", "w"); fwrite($fh, $contents); - fwrite($fh2, $contents); + fwrite($fh2, $contents2); exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &'); } } From ede6d358a42e22c5f351814f9e5fce17ae3c946d Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Sun, 15 May 2022 14:30:14 -0400 Subject: [PATCH 4/4] Update advanced.php --- scripts/advanced.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/advanced.php b/scripts/advanced.php index 1660e4b..5d37e0d 100644 --- a/scripts/advanced.php +++ b/scripts/advanced.php @@ -34,7 +34,7 @@ if(isset($_GET['submit'])) { $caddy_pwd = $_GET["caddy_pwd"]; if(strcmp($caddy_pwd,$config['CADDY_PWD']) !== 0) { $contents = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=\"$caddy_pwd\"", $contents); - $contents2 = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=\"$caddy_pwd\"", $contents); + $contents2 = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=\"$caddy_pwd\"", $contents2); $fh = fopen('/etc/birdnet/birdnet.conf', "w"); $fh2 = fopen("./scripts/thisrun.txt", "w"); fwrite($fh, $contents);