";include('stats.php');} if($_POST['view'] == "Daily Charts"){include('history.php');} if($_POST['view'] == "Tools"){ 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'); } $caddypwd = $config['CADDY_PWD']; if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'You cannot edit the settings for this installation'; exit; } else { $submittedpwd = $_SERVER['PHP_AUTH_PW']; $submitteduser = $_SERVER['PHP_AUTH_USER']; if($submittedpwd == $caddypwd && $submitteduser == 'birdnet'){ $url = $_SERVER['SERVER_NAME']."/scripts/adminer.php"; echo "
"; } else { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'You cannot edit the settings for this installation'; exit; } } } if($_POST['view'] == "Recordings"){include('play.php');} if($_POST['view'] == "Settings"){include('scripts/config.php');} if($_POST['view'] == "Advanced"){include('scripts/advanced.php');} if($_POST['view'] == "Included"){ if(isset($_POST['species']) && isset($_POST['add'])){ $file = '/home/pi/BirdNET-Pi/include_species_list.txt'; $str = file_get_contents("$file"); $str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str); file_put_contents("$file", "$str"); if(isset($_POST['species'])){ foreach ($_POST['species'] as $selectedOption) file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", $selectedOption."\n", FILE_APPEND); } } elseif(isset($_POST['species']) && isset($_POST['del'])){ $file = '/home/pi/BirdNET-Pi/include_species_list.txt'; $str = file_get_contents("$file"); $str = preg_replace('/^\h*\v+/m', '', $str); file_put_contents("$file", "$str"); foreach($_POST['species'] as $selectedOption) { $content = file_get_contents("/home/pi/BirdNET-Pi/include_species_list.txt"); $newcontent = str_replace($selectedOption, "", "$content"); file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", "$newcontent"); } $file = '/home/pi/BirdNET-Pi/include_species_list.txt'; $str = file_get_contents("$file"); $str = preg_replace('/^\h*\v+/m', '', $str); file_put_contents("$file", "$str"); } include('scripts/include_list.php'); } if($_POST['view'] == "Excluded"){ if(isset($_POST['species']) && isset($_POST['add'])){ $file = '/home/pi/BirdNET-Pi/exclude_species_list.txt'; $str = file_get_contents("$file"); $str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str); file_put_contents("$file", "$str"); foreach ($_POST['species'] as $selectedOption) file_put_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt", $selectedOption."\n", FILE_APPEND); } elseif (isset($_POST['species']) && isset($_POST['del'])){ $file = '/home/pi/BirdNET-Pi/exclude_species_list.txt'; $str = file_get_contents("$file"); $str = preg_replace('/^\h*\v+/m', '', $str); file_put_contents("$file", "$str"); foreach($_POST['species'] as $selectedOption) { $content = file_get_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt"); $newcontent = str_replace($selectedOption, "", "$content"); file_put_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt", "$newcontent"); } $file = '/home/pi/BirdNET-Pi/exclude_species_list.txt'; $str = file_get_contents("$file"); $str = preg_replace('/^\h*\v+/m', '', $str); file_put_contents("$file", "$str"); } include('scripts/exclude_list.php'); } if($_POST['view'] == "File"){ header('Location: scripts/filemanager/filemanager.php'); } if($_POST['view'] == "Webterm"){ 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'); } $caddypwd = $config['CADDY_PWD']; if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'You cannot access the web terminal'; exit; } else { $submittedpwd = $_SERVER['PHP_AUTH_PW']; $submitteduser = $_SERVER['PHP_AUTH_USER']; if($submittedpwd == $caddypwd && $submitteduser == 'birdnet'){ #ACCESS THE WEB TERMINAL header("Location: /terminal"); } else { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'You cannot access the web terminal'; exit; } } } } elseif(isset($_POST['submit'])) { $command = $_POST['submit']; if(isset($command)){ $results = shell_exec("$command 2>&1"); echo "
$results
"; } ob_end_flush(); } else {include('overview.php');} ?>