advanced settings now update the settings in the system
not just the files
This commit is contained in:
+183
-26
@@ -1,3 +1,162 @@
|
||||
<?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');
|
||||
}
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if(isset($_POST['submit'])) {
|
||||
$contents = file_get_contents("/home/pi/BirdNET-Pi/birdnet.conf");
|
||||
$contents2 = file_get_contents("/home/pi/BirdNET-Pi/thisrun.txt");
|
||||
|
||||
if(isset($_POST["caddy_pwd"])) {
|
||||
$caddy_pwd = $_POST["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);
|
||||
$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w");
|
||||
$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");
|
||||
fwrite($fh, $contents);
|
||||
fwrite($fh2, $contents2);
|
||||
exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &');
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["db_pwd"])) {
|
||||
$db_pwd = $_POST["db_pwd"];
|
||||
if(strcmp($db_pwd,$config['DB_PWD']) !== 0) {
|
||||
shell_exec('sudo /usr/local/bin/update_db_pwd_bullseye.sh');
|
||||
$contents = preg_replace("/DB_PWD=.*/", "DB_PWD=$db_pwd", $contents);
|
||||
$contents2 = preg_replace("/DB_PWD=.*/", "DB_PWD=$db_pwd", $contents2);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["ice_pwd"])) {
|
||||
$ice_pwd = $_POST["ice_pwd"];
|
||||
if(strcmp($ice_pwd,$config['ICE_PWD']) !== 0) {
|
||||
$contents = preg_replace("/ICE_PWD=.*/", "ICE_PWD=$ice_pwd", $contents);
|
||||
$contents2 = preg_replace("/ICE_PWD=.*/", "ICE_PWD=$ice_pwd", $contents2);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["birdnetpi_url"])) {
|
||||
$birdnetpi_url = $_POST["birdnetpi_url"];
|
||||
if(strcmp($birdnetpi_url,$config['BIRDNETPI_URL']) !== 0) {
|
||||
$contents = preg_replace("/BIRDNETPI_URL=.*/", "BIRDNETPI_URL=$birdnetpi_url", $contents);
|
||||
$contents2 = preg_replace("/BIRDNETPI_URL=.*/", "BIRDNETPI_URL=$birdnetpi_url", $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);
|
||||
exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &');
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["webterminal_url"])) {
|
||||
$webterminal_url = $_POST["webterminal_url"];
|
||||
if(strcmp($webterminal_url,$config['WEBTERMINAL_URL']) !== 0) {
|
||||
$contents = preg_replace("/WEBTERMINAL_URL=.*/", "WEBTERMINAL_URL=$webterminal_url", $contents);
|
||||
$contents2 = preg_replace("/WEBTERMINAL_URL=.*/", "WEBTERMINAL_URL=$webterminal_url", $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);
|
||||
exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &');
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["birdnetlog_url"])) {
|
||||
$birdnetlog_url = $_POST["birdnetlog_url"];
|
||||
if(strcmp($birdnetlog_url,$config['BIRDNETLOG_URL']) !== 0) {
|
||||
$contents = preg_replace("/BIRDNETLOG_URL=.*/", "BIRDNETLOG_URL=$birdnetlog_url", $contents);
|
||||
$contents2 = preg_replace("/BIRDNETLOG_URL=.*/", "BIRDNETLOG_URL=$birdnetlog_url", $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);
|
||||
exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &');
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["overlap"])) {
|
||||
$overlap = $_POST["overlap"];
|
||||
if(strcmp($overlap,$config['OVERLAP']) !== 0) {
|
||||
$contents = preg_replace("/OVERLAP=.*/", "OVERLAP=$overlap", $contents);
|
||||
$contents2 = preg_replace("/OVERLAP=.*/", "OVERLAP=$overlap", $contents2);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["confidence"])) {
|
||||
$confidence = $_POST["confidence"];
|
||||
if(strcmp($confidence,$config['CONFIDENCE']) !== 0) {
|
||||
$contents = preg_replace("/CONFIDENCE=.*/", "CONFIDENCE=$confidence", $contents);
|
||||
$contents2 = preg_replace("/CONFIDENCE=.*/", "CONFIDENCE=$confidence", $contents2);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["sensitivity"])) {
|
||||
$sensitivity = $_POST["sensitivity"];
|
||||
if(strcmp($sensitivity,$config['SENSITIVITY']) !== 0) {
|
||||
$contents = preg_replace("/SENSITIVITY=.*/", "SENSITIVITY=$sensitivity", $contents);
|
||||
$contents2 = preg_replace("/SENSITIVITY=.*/", "SENSITIVITY=$sensitivity", $contents2);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["full_disk"])) {
|
||||
$full_disk = $_POST["full_disk"];
|
||||
if(strcmp($full_disk,$config['FULL_DISK']) !== 0) {
|
||||
$contents = preg_replace("/FULL_DISK=.*/", "FULL_DISK=$full_disk", $contents);
|
||||
$contents2 = preg_replace("/FULL_DISK=.*/", "FULL_DISK=$full_disk", $contents2);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["rec_card"])) {
|
||||
$rec_card = $_POST["rec_card"];
|
||||
if(strcmp($rec_card,$config['REC_CARD']) !== 0) {
|
||||
$contents = preg_replace("/REC_CARD=.*/", "REC_CARD=$rec_card", $contents);
|
||||
$contents2 = preg_replace("/REC_CARD=.*/", "REC_CARD=$rec_card", $contents2);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["channels"])) {
|
||||
$channels = $_POST["channels"];
|
||||
if(strcmp($channels,$config['CHANNELS']) !== 0) {
|
||||
$contents = preg_replace("/CHANNELS=.*/", "CHANNELS=$channels", $contents);
|
||||
$contents2 = preg_replace("/CHANNELS=.*/", "CHANNELS=$channels", $contents2);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["recording_length"])) {
|
||||
$recording_length = $_POST["recording_length"];
|
||||
if(strcmp($recording_length,$config['RECORDING_LENGTH']) !== 0) {
|
||||
$contents = preg_replace("/RECORDING_LENGTH=.*/", "RECORDING_LENGTH=$recording_length", $contents);
|
||||
$contents2 = preg_replace("/RECORDING_LENGTH=.*/", "RECORDING_LENGTH=$recording_length", $contents2);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST["extraction_length"])) {
|
||||
$extraction_length = $_POST["extraction_length"];
|
||||
if(strcmp($extraction_length,$config['EXTRACTION_LENGTH']) !== 0) {
|
||||
$contents = preg_replace("/EXTRACTION_LENGTH=.*/", "EXTRACTION_LENGTH=$extraction_length", $contents);
|
||||
$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:/scripts/update_settings_inprogress.php');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
/* Chrome, Safari, Edge, Opera */
|
||||
@@ -89,66 +248,65 @@ input {
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<?php
|
||||
if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
|
||||
$newconfig = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');
|
||||
} elseif (file_exists('/home/pi/BirdNET-Pi/firstrun.ini')) {
|
||||
$newconfig = parse_ini_file('/home/pi/BirdNET-Pi/firstrun.ini');
|
||||
}
|
||||
?>
|
||||
<h2>Advanced Settings</h2>
|
||||
<body style="background-color: rgb(119, 196, 135);">
|
||||
<div class="row">
|
||||
<div class="column first">
|
||||
<form action="write_advanced.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');
|
||||
} ?>
|
||||
<form action="advanced.php" method="POST">
|
||||
<h3>Defaults</h3>
|
||||
<label>Full Disk Behavior: </label>
|
||||
<label style="width:30%;" for="purge">
|
||||
<input style="width:15%;" name="full_disk" type="radio" id="purge" value="purge"
|
||||
<?php
|
||||
if (strcmp($config['FULL_DISK'], "purge") == 0) {
|
||||
if (strcmp($newconfig['FULL_DISK'], "purge") == 0) {
|
||||
echo "checked";
|
||||
}?>>Purge</label>
|
||||
<label style="width:30%;" for="keep">
|
||||
<input style="width:15%" name="full_disk" type="radio" id="keep" value="keep"
|
||||
<?php
|
||||
if (strcmp($config['FULL_DISK'], "keep") == 0) {
|
||||
if (strcmp($newconfig['FULL_DISK'], "keep") == 0) {
|
||||
echo "checked";
|
||||
}?>>Keep</label>
|
||||
<label for="rec_card">Audio Card: </label>
|
||||
<input name="rec_card" type="text" value="<?php print($config['REC_CARD']);?>" required/><br>
|
||||
<input name="rec_card" type="text" value="<?php print($newconfig['REC_CARD']);?>" required/><br>
|
||||
<label for="channels">Audio Channels: </label>
|
||||
<input name="channels" type="number" min="1" max="32" step="1" value="<?php print($config['CHANNELS']);?>" required/><br>
|
||||
<input name="channels" type="number" min="1" max="32" step="1" value="<?php print($newconfig['CHANNELS']);?>" required/><br>
|
||||
<label for="recording_length">Recording Length: </label>
|
||||
<input name="recording_length" type="number" min="3" max="60" step="1" value="<?php print($config['RECORDING_LENGTH']);?>" required/><br>
|
||||
<input name="recording_length" type="number" min="3" max="60" step="1" value="<?php print($newconfig['RECORDING_LENGTH']);?>" required/><br>
|
||||
<label for="extraction_length">Extraction Length: </label>
|
||||
<input name="extraction_length" type="number" min="3" max="<?php print($config['RECORDING_LENGTH']);?>" value="<?php print($config['EXTRACTION_LENGTH']);?>" /><br>
|
||||
<input name="extraction_length" type="number" min="3" max="<?php print($newconfig['RECORDING_LENGTH']);?>" value="<?php print($newconfig['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>
|
||||
<input name="caddy_pwd" type="text" value="<?php print($newconfig['CADDY_PWD']);?>" /><br>
|
||||
<label for="db_pwd">Database: </label>
|
||||
<input name="db_pwd" type="text" value="<?php print($config['DB_PWD']);?>" required/><br>
|
||||
<input name="db_pwd" type="text" value="<?php print($newconfig['DB_PWD']);?>" required/><br>
|
||||
<label for="ice_pwd">Live Audio Stream: </label>
|
||||
<input name="ice_pwd" type="text" value="<?php print($config['ICE_PWD']);?>" required/><br>
|
||||
<input name="ice_pwd" type="text" value="<?php print($newconfig['ICE_PWD']);?>" required/><br>
|
||||
</div>
|
||||
<div class="column second">
|
||||
<h3>Custom URLs</h3>
|
||||
<label for="birdnetpi_url">BirdNET-Pi URL: </label>
|
||||
<input name="birdnetpi_url" type="url" value="<?php print($config['BIRDNETPI_URL']);?>" /><br>
|
||||
<input name="birdnetpi_url" type="url" value="<?php print($newconfig['BIRDNETPI_URL']);?>" /><br>
|
||||
<label for="birdnetlog_url">BirdNET-Lite Log URL: </label>
|
||||
<input name="birdnetlog_url" type="url" value="<?php print($config['BIRDNETLOG_URL']);?>" /><br>
|
||||
<input name="birdnetlog_url" type="url" value="<?php print($newconfig['BIRDNETLOG_URL']);?>" /><br>
|
||||
<label for="webterminal_url">Web Terminal URL: </label>
|
||||
<input name="webterminal_url" type="url" value="<?php print($config['WEBTERMINAL_URL']);?>" /><br>
|
||||
<input name="webterminal_url" type="url" value="<?php print($newconfig['WEBTERMINAL_URL']);?>" /><br>
|
||||
<h3>BirdNET-Lite Settings</h3>
|
||||
<label for="overlap">Overlap: </label>
|
||||
<input name="overlap" type="number" min="0.0" max="2.9" step="0.1" value="<?php print($config['OVERLAP']);?>" required/><br>
|
||||
<input name="overlap" type="number" min="0.0" max="2.9" step="0.1" value="<?php print($newconfig['OVERLAP']);?>" required/><br>
|
||||
<label for="confidence">Minimum Confidence: </label>
|
||||
<input name="confidence" type="number" min="0.01" max="0.99" step="0.01" value="<?php print($config['CONFIDENCE']);?>" required/><br>
|
||||
<input name="confidence" type="number" min="0.01" max="0.99" step="0.01" value="<?php print($newconfig['CONFIDENCE']);?>" required/><br>
|
||||
<label for="sensitivity">Sigmoid Sensitivity: </label>
|
||||
<input name="sensitivity" type="number" min="0.5" max="1.5" step="0.01" value="<?php print($config['SENSITIVITY']);?>" required/><br>
|
||||
<input name="sensitivity" type="number" min="0.5" max="1.5" step="0.01" value="<?php print($newconfig['SENSITIVITY']);?>" required/><br>
|
||||
<br><br>
|
||||
<button type="submit" class="block"><?php
|
||||
@session_start();
|
||||
<button type="submit" name="submit" class="block"><?php
|
||||
|
||||
if(isset($_SESSION['success'])){
|
||||
echo "Success!";
|
||||
@@ -169,4 +327,3 @@ if(isset($_SESSION['success'])){
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user