From f47b9e040efc2e26130fb35b5e6b834123784a69 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Sun, 28 May 2023 13:39:55 -0400 Subject: [PATCH] resolve #934 --- scripts/config.php | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/scripts/config.php b/scripts/config.php index 942f309..d16f6f4 100644 --- a/scripts/config.php +++ b/scripts/config.php @@ -2,14 +2,14 @@ error_reporting(E_ERROR); ini_set('display_errors',1); -if (file_exists('./scripts/thisrun.txt')) { - $config = parse_ini_file('./scripts/thisrun.txt'); -} elseif (file_exists('./scripts/firstrun.ini')) { - $config = parse_ini_file('./scripts/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 (file_exists($home.'/BirdNET-Pi/scripts/thisrun.txt')) { + $config = parse_ini_file($home.'/BirdNET-Pi/scripts/thisrun.txt'); +} elseif (file_exists($home.'/BirdNET-Pi/scripts/thisrun.ini')) { + $config = parse_ini_file($home.'/BirdNET-Pi/scripts/thisrun.ini'); +} if (file_exists($home."/BirdNET-Pi/apprise.txt")) { $apprise_config = file_get_contents($home."/BirdNET-Pi/apprise.txt"); } else { @@ -136,11 +136,10 @@ if(isset($_GET["latitude"])){ } } - // Update Language settings only if a change is requested - if (file_exists('./scripts/thisrun.txt')) { - $lang_config = parse_ini_file('./scripts/thisrun.txt'); - } elseif (file_exists('./scripts/firstrun.ini')) { - $lang_config = parse_ini_file('./scripts/firstrun.ini'); + if (file_exists($home.'/BirdNET-Pi/scripts/thisrun.txt')) { + $lang_config = parse_ini_file($home.'/BirdNET-Pi/scripts/thisrun.txt'); + } elseif (file_exists($home.'/BirdNET-Pi/scripts/thisrun.ini')) { + $lang_config = parse_ini_file($home.'/BirdNET-Pi/scripts/thisrun.ini'); } if ($model != $lang_config['MODEL'] || $language != $lang_config['DATABASE_LANG']){ @@ -183,7 +182,7 @@ if(isset($_GET["latitude"])){ $contents = preg_replace("/APPRISE_ONLY_NOTIFY_SPECIES_NAMES=.*/", "APPRISE_ONLY_NOTIFY_SPECIES_NAMES=\"$only_notify_species_names\"", $contents); $contents = preg_replace("/APPRISE_ONLY_NOTIFY_SPECIES_NAMES_2=.*/", "APPRISE_ONLY_NOTIFY_SPECIES_NAMES_2=\"$only_notify_species_names_2\"", $contents); - $contents2 = file_get_contents("./scripts/thisrun.txt"); + $contents2 = file_get_contents($home."/BirdNET-Pi/scripts/thisrun.txt"); $contents2 = preg_replace("/SITE_NAME=.*/", "SITE_NAME=\"$site_name\"", $contents2); $contents2 = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents2); $contents2 = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents2); @@ -213,7 +212,7 @@ if(isset($_GET["latitude"])){ } $fh = fopen("/etc/birdnet/birdnet.conf", "w"); - $fh2 = fopen("./scripts/thisrun.txt", "w"); + $fh2 = fopen($home."/BirdNET-Pi/scripts/thisrun.txt", "w"); fwrite($fh, $contents); fwrite($fh2, $contents2); @@ -231,18 +230,17 @@ if(isset($_GET["latitude"])){ } if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") { - $db = new SQLite3('./birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE); - $user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd"); $home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"); $home = trim($home); - - if (file_exists('./thisrun.txt')) { - $config = parse_ini_file('./thisrun.txt'); - } elseif (file_exists('./firstrun.ini')) { - $config = parse_ini_file('./firstrun.ini'); + if (file_exists($home.'/BirdNET-Pi/scripts/thisrun.txt')) { + $config = parse_ini_file($home.'/BirdNET-Pi/scripts/thisrun.txt'); + } elseif (file_exists($home.'/BirdNET-Pi/scripts/thisrun.ini')) { + $config = parse_ini_file($home.'/BirdNET-Pi/scripts/thisrun.ini'); } + $db = new SQLite3($home."/BirdNET-Pi/scripts/birds.db", SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE); + $cf = explode("\n",$_GET['apprise_config']); $cf = "'".implode("' '", $cf)."'"; @@ -497,7 +495,7 @@ function runProcess() {
BirdWeather.com is a weather map for bird sounds. Stations around the world supply audio and video streams to BirdWeather where they are then analyzed by BirdNET and compared to eBird Grid data. BirdWeather catalogues the bird audio and spectrogram visualizations so that you can listen to, view, and read about birds throughout the world. Email Tim to request a BirdWeather ID
+BirdWeather.com is a weather map for bird sounds. Stations around the world supply audio and video streams to BirdWeather where they are then analyzed by BirdNET and compared to eBird Grid data. BirdWeather catalogues the bird audio and spectrogram visualizations so that you can listen to, view, and read about birds throughout the world. Email Tim to request a BirdWeather ID
Notifications |