Skip to content

A live bird collage card for your Home Assistant dashboard.

added new php configuration pages!! This is a good one!

mcguirepr8908f1fa34f2e6
diff --git a/requirements.txt b/requirements.txt
index 8e747ea7..081c5c96 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,3 +5,4 @@ pytz
tzlocal
pandas
seaborn
+basel
diff --git a/scripts/advanced.php b/scripts/advanced.php
new file mode 100644
index 00000000..2c38405d
--- /dev/null
+++ b/scripts/advanced.php
@@ -0,0 +1,135 @@
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+* {
+ font-family: 'Arial', 'Gill Sans', 'Gill Sans MT',
+ ' Calibri', 'Trebuchet MS', 'sans-serif';
+ box-sizing: border-box;
+}
+/* Create two unequal columns that floats next to each other */
+.column {
+ float: left;
+ padding: 10px;
+}
+.first {
+ width: calc(50% - 70px);
+}
+.second {
+ width: calc(50% - 30px);
+}
+.
+/* Clear floats after the columns */
+.row:after {
+ content: "";
+ display: table;
+ clear: both;
+}
+body {
+ background-color: rgb(119, 196, 135);
+}
+a {
+ font-size:large;
+ text-decoration: none;
+}
+.block {
+ display: block;
+ font-weight: bold;
+ width:100%;
+ border: none;
+ background-color: #04AA6D;
+ padding: 20px 20px;
+ color: white;
+ font-size: medium;
+ cursor: pointer;
+ text-align: center;
+}
+ @media screen and (max-width: 800px) {
+ .column {
+ float: none;
+ width: 100%;
+ }
+ }
+form {
+ text-align:left;
+ margin-left:20px;
+}
+h1 {
+ text-align:center;
+}
+h2,h3 {
+ margin-left: -10px;
+ text-align:left;
+}
+label {
+ font-weight:bold;
+}
+input {
+ text-align:center;
+ font-size:large;
+}
+ </style>
+ </head>
+ <body style="background-color: rgb(119, 196, 135);">
+ <div class="row">
+ <div class="column first">
+ <form action="write_advanced.php" method="POST">
+ <h3>Advanced Settings</h3>
+<?php
+if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
+ $config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');
+} elseif (file_exists('/home/pi/BirdNET-Pi/firstrun.ini')) {
+ $config = parse_ini_file('/home/pi/BirdNET-Pi/firstrun.ini');
+} ?>
+ <label for="full_disk">Full Disk Behavior: </label>
+ <input name="full_disk" type="text" value="<?php print($config['FULL_DISK']);?>" /><br>
+ <label for="rec_card">Audio Card: </label>
+ <input name="rec_card" type="text" value="<?php print($config['REC_CARD']);?>" /><br>
+ <label for="channels">Audio Channels: </label>
+ <input name="channels" type="text" value="<?php print($config['CHANNELS']);?>" /><br>
+ <label for="recording_length">Recording Length: </label>
+ <input name="recording_length" type="text" value="<?php print($config['RECORDING_LENGTH']);?>" /><br>
+ <label for="extraction_length">Extraction Length: </label>
+ <input name="extraction_length" type="text" value="<?php print($config['EXTRACTION_LENGTH']);?>" /><br>
+ <h3>Passwords</h3>
+ <label for="caddy_pwd">Webpage: </label>
+ <input name="caddy_pwd" type="text" value="<?php print($config['CADDY_PWD']);?>" /><br>
+ <label for="db_pwd">Database: </label>
+ <input name="db_pwd" type="text" value="<?php print($config['DB_PWD']);?>" /><br>
+ <label for="ice_pwd">Live Audio Stream: </label>
+ <input name="ice_pwd" type="text" value="<?php print($config['ICE_PWD']);?>" /><br>
+ </div>
+ <div class="column first">
+ <h3>Custom URLs</h3>
+ <label for="birdnetpi_url">BirdNET-Pi URL: </label>
+ <input name="birdnetpi_url" type="text" value="<?php print($config['BIRDNETPI_URL']);?>" /><br>
+ <label for="extractionlog_url">Extraction Log URL: </label>
+ <input name="extractionlog_url" type="text" value="<?php print($config['EXTRACTIONLOG_URL']);?>" /><br>
+ <label for="birdnetlog_url">BirdNET-Lite Log URL: </label>
+ <input name="birdnetlog_url" type="text" value="<?php print($config['BIRDNETLOG_URL']);?>" /><br>
+ <h3>BirdNET-Lite Settings</h3>
+ <label for="overlap">Overlap: </label>
+ <input name="overlap" type="text" value="<?php print($config['OVERLAP']);?>" /><br>
+ <label for="confidence">Minimum Confidence: </label>
+ <input name="confidence" type="text" value="<?php print($config['CONFIDENCE']);?>" /><br>
+ <label for="sensitivity">Sigmoid Sensitivity: </label>
+ <input name="sensitivity" type="text" value="<?php print($config['SENSITIVITY']);?>" /><br>
+ <br>
+ <br>
+ <input type="submit" value="<?php
+ @session_start();
+
+if(isset($_SESSION['success'])){
+ echo "Success!";
+ unset($_SESSION['success']);
+} else {
+ echo "Update Settings";
+}
+?>">
+ <br>
+ <br>
+ <br>
+ <button type="text"><a href="config.php">Basic Settings</a></button>
+ </form>
+</div>
+</div>
+</body>
+
diff --git a/scripts/config.php b/scripts/config.php
new file mode 100644
index 00000000..4775895d
--- /dev/null
+++ b/scripts/config.php
@@ -0,0 +1,108 @@
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+* {
+ font-family: 'Arial', 'Gill Sans', 'Gill Sans MT',
+ ' Calibri', 'Trebuchet MS', 'sans-serif';
+ box-sizing: border-box;
+}
+/* Create two unequal columns that floats next to each other */
+.column {
+ float: left;
+ padding: 10px;
+}
+.first {
+ width: calc(50% - 70px);
+}
+.second {
+ width: calc(50% - 30px);
+}
+.
+/* Clear floats after the columns */
+.row:after {
+ content: "";
+ display: table;
+ clear: both;
+}
+body {
+ background-color: rgb(119, 196, 135);
+}
+a {
+ text-decoration: none;
+}
+.block {
+ display: block;
+ font-weight: bold;
+ width:100%;
+ border: none;
+ background-color: #04AA6D;
+ padding: 20px 20px;
+ color: white;
+ font-size: medium;
+ cursor: pointer;
+ text-align: center;
+}
+@media screen and (max-width: 800px) {
+ .column {
+ float: none;
+ width: 100%;
+ }
+}
+form {
+ text-align:left;
+}
+h1 {
+ text-align:center;
+}
+h3 {
+ margin-left: -10px;
+ text-align:left;
+}
+label {
+ font-weight:bold;
+}
+input {
+ text-align:center;
+ font-size:large;
+}
+ </style>
+ </head>
+ <h2>Basic Settings</h2>
+ <body style="background-color: rgb(119, 196, 135);">
+ <div class="row">
+ <div class="column first">
+ <form action="write_config.php" method="POST">
+<?php
+if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
+ $config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');
+} elseif (file_exists('/home/pi/BirdNET-Pi/firstrun.ini')) {
+ $config = parse_ini_file('/home/pi/BirdNET-Pi/firstrun.ini');
+} ?>
+ <label for="latitude">Latitude: </label>
+ <input name="latitude" type="text" value="<?php print($config['LATITUDE']);?>" /><br>
+ <label for="longitude">Longitude: </label>
+ <input name="longitude" type="text" value="<?php print($config['LONGITUDE']);?>" />
+ <h4>Optional Services</h4>
+ <label for="birdweather_id">BirdWeather ID: </label>
+ <input name="birdweather_id" type="text" value="<?php print($config['BIRDWEATHER_ID']);?>" /><br>
+ <label for="pushed_app_key">Pushed App Key: </label>
+ <input name="pushed_app_key" type="text" value="<?php print($config['PUSHED_APP_KEY']);?>" /><br>
+ <label for="pushed_app_secret">Pushed App Secret: </label>
+ <input name="pushed_app_secret" type="text" value="<?php print($config['PUSHED_APP_SECRET']);?>" /><br>
+ <br>
+ <input type="submit" value="<?php
+ @session_start();
+
+if(isset($_SESSION['success'])){
+ echo "Success!";
+ unset($_SESSION['success']);
+} else {
+ echo "Update Settings";
+}
+?>">
+ <br>
+ <br>
+ <button type="text"><a href="advanced.php">Advanced Settings</a></button>
+ </form>
+ </div>
+ </div>
+</body>
diff --git a/scripts/form.php b/scripts/form.php
deleted file mode 100644
index f279ed55..00000000
--- a/scripts/form.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<html>
- <head>
- <title>Configure `birdnet.conf`</title>
- <style>
-* {
- font-family: 'Arial', 'Gill Sans', 'Gill Sans MT',
- ' Calibri', 'Trebuchet MS', 'sans-serif';
-}
-
-h1,h2,h3 {
- text-align:center;
-}
- input {
- font-size:large;
- }
- </style>
- </head>
- <h1>Configure BirdNET-Pi</h1>
- <body style="background-color: rgb(119, 196, 135);">
- <form style="text-align:center;" action="write_config.php" method="POST">
-<?php
- if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
- $config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');
- } elseif (file_exists('/home/pi/BirdNET-Pi/firstrun.ini')) {
- $config = parse_ini_file('/home/pi/BirdNET-Pi/firstrun.ini');
- } ?>
- <h3>Required</h3>
- <input name="field1" type="text" value="LATITUDE"/>
- <input name="field2" type="text" value="<?php print($config['LATITUDE']);?>" /><br>
- <input name="field3" type="text" value="LONGITUDE" />
- <input name="field4" type="text" value="<?php print($config['LONGITUDE']);?>" /><br>
- <input name="field5" type="text" value="CADDY_PWD" />
- <input name="field6" type="text" value="<?php print($config['CADDY_PWD']);?>" /><br>
- <input name="field7" type="text" value="DB_PWD" />
- <input name="field8" type="text" value="<?php print($config['DB_PWD']);?>" /><br>
- <input name="field9" type="text" value="ICE_PWD" />
- <input name="field10" type="text" value="<?php print($config['ICE_PWD']);?>" /><br>
- </form>
- <form style="text-align:center;" action="write_config.php" method="POST">
- <h3>Optional Services</h3>
- <input name="field11" type="text" value="BIRDWEATHER_ID" />
- <input name="field12" type="text" value="<?php print($config['BIRDWEATHER_ID']);?>" /><br>
- <input name="field13" type="text" value="PUSHED_APP_KEY" />
- <input name="field14" type="text" value="<?php print($config['PUSHED_APP_KEY']);?>" /><br>
- <input name="field15" type="text" value="PUSHED_APP_SECRET" />
- <input name="field16" type="text" value="<?php print($config['PUSHED_APP_SECRET']);?>" /><br>
- </form>
- <form style="text-align:center;" action="write_config.php" method="POST">
- <h3>Custom URLs</h3>
- <input name="field17" type="text" value="BIRDNETPI_URL" />
- <input name="field18" type="text" value="<?php print($config['BIRDNETPI_URL']);?>" /><br>
- <input name="field19" type="text" value="EXTRACTIONLOG_URL" />
- <input name="field20" type="text" value="<?php print($config['EXTRACTIONLOG_URL']);?>" /><br>
- <input name="field21" type="text" value="BIRDNETLOG_URL" />
- <input name="field22" type="text" value="<?php print($config['BIRDNETLOG_URL']);?>" /><br>
- </form>
- <form style="text-align:center;" action="write_config.php" method="POST">
- <h3>Default Services</h3>
- <input name="field23" type="text" value="INSTALL_NOMACHINE" />
- <input name="field24" type="text" value="<?php print($config['INSTALL_NOMACHINE']);?>" /><br>
- <input name="field25" type="text" value="DO_EXTRACTIONS" />
- <input name="field26" type="text" value="<?php print($config['DO_EXTRACTIONS']);?>" /><br>
- <input name="field27" type="text" value="DO_RECORDING" />
- <input name="field28" type="text" value="<?php print($config['DO_RECORDING']);?>" /><br>
- </form>
- <form style="text-align:center;" action="write_config.php" method="POST">
- <h3>Advanced Configuration</h3>
- <input name="field29" type="text" value="REC_CARD" />
- <input name="field30" type="text" value="<?php print($config['REC_CARD']);?>" /><br>
- <input name="field31" type="text" value="OVERLAP" />
- <input name="field32" type="text" value="<?php print($config['OVERLAP']);?>" /><br>
- <input name="field33" type="text" value="CONFIDENCE" />
- <input name="field34" type="text" value="<?php print($config['CONFIDENCE']);?>" /><br>
- <input name="field35" type="text" value="SENSITIVITY" />
- <input name="field36" type="text" value="<?php print($config['SENSITIVITY']);?>" /><br>
- <input name="field37" type="text" value="CHANNELS" />
- <input name="field38" type="text" value="<?php print($config['CHANNELS']);?>" /><br>
- <input name="field39" type="text" value="RECORDING_LENGTH" />
- <input name="field40" type="text" value="<?php print($config['RECORDING_LENGTH']);?>" /><br>
- <input name="field41" type="text" value="EXTRACTION_LENGTH" />
- <input name="field42" type="text" value="<?php print($config['EXTRACTION_LENGTH']);?>" /><br>
- </form>
- <a style="font-weight:bold;color:black;" href='birdnet.conf'>View Current Config</a>
- </body>
diff --git a/scripts/index.html b/scripts/index.html
index 17e13d29..90a44fb0 100644
--- a/scripts/index.html
+++ b/scripts/index.html
@@ -45,12 +45,12 @@ a {
cursor: pointer;
text-align: center;
}
-@media screen and (max-width: 800px) {
- .column {
- float: none;
- width: 100%;
+ @media screen and (max-width: 800px) {
+ .column {
+ float: none;
+ width: 100%;
+ }
}
-}
</style>
<body style="background-color: rgb(119, 196, 135);">
<div class="row">
@@ -79,9 +79,9 @@ a {
<form >
<button type="submit" class="block"><a target="_content" href="/scripts/adminer.php">Database Maintenance</a></button>
</form>
-
- <form action="/scripts/backup_data.php" onclick="return confirm('Backup ALL Data? Warning: This could take a long time.')">
- <button type="submit" class="block">Backup ALL data</button>
+ <form >
+ <button type="submit" class="block"><a target="content" href="/scripts/config.php">Reconfigure System</a></button>
+ </form>
</form>
<form action="/scripts/reboot_system.php" onclick="return confirm('Are you sure you want to reboot?')">
<button type="submit" class="block">Reboot BirdNET-Pi</button>
diff --git a/scripts/install_services.sh b/scripts/install_services.sh
index e133a850..c3ea8743 100755
--- a/scripts/install_services.sh
+++ b/scripts/install_services.sh
@@ -231,6 +231,7 @@ install_Caddyfile() {
cp /etc/caddy/Caddyfile{,.original}
fi
php_version="$(awk -F'php' '{print $3}' <(ls -l $(which /etc/alternatives/php)))"
+ if ! [ -z ${CADDY_PWD} ];then
HASHWORD=$(caddy hash-password -plaintext ${CADDY_PWD})
cat << EOF > /etc/caddy/Caddyfile
http://localhost http://birdnetpi.local ${BIRDNETPI_URL} {
@@ -252,6 +253,17 @@ http://localhost http://birdnetpi.local ${BIRDNETPI_URL} {
php_fastcgi unix//run/php/php${php_version}-fpm.sock
}
EOF
+ else
+ cat << EOF > /etc/caddy/Caddyfile
+http://localhost http://birdnetpi.local ${BIRDNETPI_URL} {
+ root * ${EXTRACTED}
+ file_server browse
+ reverse_proxy /stream localhost:8000
+ php_fastcgi unix//run/php/php${php_version}-fpm.sock
+}
+EOF
+ fi
+
if [ ! -z ${EXTRACTIONLOG_URL} ];then
cat << EOF >> /etc/caddy/Caddyfile
diff --git a/scripts/update_services.sh b/scripts/update_services.sh
index dbb64df4..ebdfca3d 100755
--- a/scripts/update_services.sh
+++ b/scripts/update_services.sh
@@ -228,6 +228,7 @@ install_Caddyfile() {
cp /etc/caddy/Caddyfile{,.original}
fi
php_version="$(awk -F'php' '{print $3}' <(ls -l $(which /etc/alternatives/php)))"
+ if ! [ -z ${CADDY_PWD} ];then
HASHWORD=$(caddy hash-password -plaintext ${CADDY_PWD})
cat << EOF > /etc/caddy/Caddyfile
http://localhost http://birdnetpi.local ${BIRDNETPI_URL} {
@@ -249,6 +250,17 @@ http://localhost http://birdnetpi.local ${BIRDNETPI_URL} {
php_fastcgi unix//run/php/php${php_version}-fpm.sock
}
EOF
+ else
+ cat << EOF > /etc/caddy/Caddyfile
+http://localhost http://birdnetpi.local ${BIRDNETPI_URL} {
+ root * ${EXTRACTED}
+ file_server browse
+ reverse_proxy /stream localhost:8000
+ php_fastcgi unix//run/php/php${php_version}-fpm.sock
+}
+EOF
+ fi
+
if [ ! -z ${EXTRACTIONLOG_URL} ];then
cat << EOF >> /etc/caddy/Caddyfile
diff --git a/scripts/write_advanced.php b/scripts/write_advanced.php
new file mode 100644
index 00000000..3be99c43
--- /dev/null
+++ b/scripts/write_advanced.php
@@ -0,0 +1,60 @@
+<?php
+$caddy_pwd = $_POST["caddy_pwd"];
+$db_pwd = $_POST["db_pwd"];
+$ice_pwd = $_POST["ice_pwd"];
+$birdnetpi_url = $_POST["birdnetpi_url"];
+$extractionlog_url = $_POST["extractionlog_url"];
+$birdnetlog_url = $_POST["birdnetlog_url"];
+$overlap = $_POST["overlap"];
+$confidence = $_POST["confidence"];
+$sensitivity = $_POST["sensitivity"];
+$full_disk = $_POST["full_disk"];
+$rec_card = $_POST["rec_card"];
+$channels = $_POST["channels"];
+$recording_length = $_POST["recording_length"];
+$extraction_length = $_POST["extraction_length"];
+
+$contents = file_get_contents("/home/pi/BirdNET-Pi/birdnet.conf");
+$contents = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=$caddy_pwd", $contents);
+$contents = preg_replace("/DB_PWD=.*/", "DB_PWD=$db_pwd", $contents);
+$contents = preg_replace("/ICE_PWD=.*/", "ICE_PWD=$ice_pwd", $contents);
+$contents = preg_replace("/BIRDNETPI_URL=.*/", "BIRDNETPI_URL=$birdnetpi_url", $contents);
+$contents = preg_replace("/EXTRACTIONLOG_URL=.*/", "EXTRACTIONLOG_URL=$extractionlog_url", $contents);
+$contents = preg_replace("/BIRDNETLOG_URL=.*/", "BIRDNETLOG_URL=$birdnetlog_url", $contents);
+$contents = preg_replace("/OVERLAP=.*/", "OVERLAP=$overlap", $contents);
+$contents = preg_replace("/CONFIDENCE=.*/", "CONFIDENCE=$confidence", $contents);
+$contents = preg_replace("/SENSITIVITY=.*/", "SENSITIVITY=$sensitivity", $contents);
+$contents = preg_replace("/FULL_DISK=.*/", "FULL_DISK=$full_disk", $contents);
+$contents = preg_replace("/REC_CARD=.*/", "REC_CARD=$rec_card", $contents);
+$contents = preg_replace("/CHANNELS=.*/", "CHANNELS=$channels", $contents);
+$contents = preg_replace("/RECORDING_LENGTH=.*/", "RECORDING_LENGTH=$recording_length", $contents);
+$contents = preg_replace("/EXTRACTION_LENGTH=.*/", "EXTRACTION_LENGTH=$extraction_length", $contents);
+
+$contents2 = file_get_contents("/home/pi/BirdNET-Pi/thisrun.txt");
+$contents2 = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=$caddy_pwd", $contents2);
+$contents2 = preg_replace("/DB_PWD=.*/", "DB_PWD=$db_pwd", $contents2);
+$contents2 = preg_replace("/ICE_PWD=.*/", "ICE_PWD=$ice_pwd", $contents2);
+$contents2 = preg_replace("/BIRDNETPI_URL=.*/", "BIRDNETPI_URL=$birdnetpi_url", $contents2);
+$contents2 = preg_replace("/EXTRACTIONLOG_URL=.*/", "EXTRACTIONLOG_URL=$extractionlog_url", $contents2);
+$contents2 = preg_replace("/BIRDNETLOG_URL=.*/", "BIRDNETLOG_URL=$birdnetlog_url", $contents2);
+$contents2 = preg_replace("/OVERLAP=.*/", "OVERLAP=$overlap", $contents2);
+$contents2 = preg_replace("/CONFIDENCE=.*/", "CONFIDENCE=$confidence", $contents2);
+$contents2 = preg_replace("/SENSITIVITY=.*/", "SENSITIVITY=$sensitivity", $contents2);
+$contents2 = preg_replace("/FULL_DISK=.*/", "FULL_DISK=$full_disk", $contents2);
+$contents2 = preg_replace("/REC_CARD=.*/", "REC_CARD=$rec_card", $contents2);
+$contents2 = preg_replace("/CHANNELS=.*/", "CHANNELS=$channels", $contents2);
+$contents2 = preg_replace("/RECORDING_LENGTH=.*/", "RECORDING_LENGTH=$recording_length", $contents2);
+$contents2 = preg_replace("/EXTRACTION_LENGTH=.*/", "EXTRACTION_LENGTH=$extraction_length", $contents2);
+
+$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w");
+$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");
+fwrite($fh, $contents);
+fwrite($fh2, $contents2);
+@session_start();
+
+if(true){
+ $_SESSION['success'] = 1;
+ header("Location:advanced.php");
+}
+?>
+
diff --git a/scripts/write_config.php b/scripts/write_config.php
index beb7bd35..4da9a4bc 100644
--- a/scripts/write_config.php
+++ b/scripts/write_config.php
@@ -1,14 +1,33 @@
<?php
-if(isset($_POST['field1']) && isset($_POST['field2'])) {
- $data = $_POST['field1'] . '-' . $_POST['field2'] . "\r\n";
- $ret = file_put_contents('/tmp/mydata.txt', $data, FILE_APPEND | LOCK_EX);
- if($ret === false) {
- die('There was an error writing this file');
- }
- else {
- echo "$ret bytes written to file";
- }
-}
-else {
- die('no post data to process');
+$latitude = $_POST["latitude"];
+$longitude = $_POST["longitude"];
+$birdweather_id = $_POST["birdweather_id"];
+$pushed_app_key = $_POST["pushed_app_key"];
+$pushed_app_secret = $_POST["pushed_app_secret"];
+
+$contents = file_get_contents("/home/pi/BirdNET-Pi/birdnet.conf");
+$contents = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents);
+$contents = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents);
+$contents = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents);
+$contents = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents);
+$contents = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents);
+
+$contents2 = file_get_contents("/home/pi/BirdNET-Pi/thisrun.txt");
+$contents2 = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents2);
+$contents2 = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents2);
+$contents2 = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents2);
+$contents2 = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents2);
+$contents2 = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents2);
+
+$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w");
+$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");
+fwrite($fh, $contents);
+fwrite($fh2, $contents2);
+@session_start();
+
+if(true){
+ $_SESSION['success'] = 1;
+ header("Location:config.php");
}
+?>
+