convert play.php
This commit is contained in:
+5
-68
@@ -7,26 +7,14 @@ $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
|
|||||||
error_reporting(E_ERROR);
|
error_reporting(E_ERROR);
|
||||||
ini_set('display_errors',1);
|
ini_set('display_errors',1);
|
||||||
require_once 'scripts/common.php';
|
require_once 'scripts/common.php';
|
||||||
|
$home = get_home();
|
||||||
|
$config = get_config();
|
||||||
|
|
||||||
$db = new SQLite3('./scripts/birds.db', SQLITE3_OPEN_READONLY);
|
$db = new SQLite3('./scripts/birds.db', SQLITE3_OPEN_READONLY);
|
||||||
$db->busyTimeout(1000);
|
$db->busyTimeout(1000);
|
||||||
|
|
||||||
if (file_exists('./scripts/thisrun.txt')) {
|
|
||||||
$config = parse_ini_file('./scripts/thisrun.txt');
|
|
||||||
} elseif (file_exists('firstrun.ini')) {
|
|
||||||
$config = parse_ini_file('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(isset($_GET['deletefile'])) {
|
if(isset($_GET['deletefile'])) {
|
||||||
if(isset($_SERVER['PHP_AUTH_USER'])) {
|
ensure_authenticated('You must be authenticated to delete files.');
|
||||||
$submittedpwd = $_SERVER['PHP_AUTH_PW'];
|
|
||||||
$submitteduser = $_SERVER['PHP_AUTH_USER'];
|
|
||||||
if($submittedpwd == $config['CADDY_PWD'] && $submitteduser == 'birdnet'){
|
|
||||||
$db_writable = new SQLite3('./scripts/birds.db', SQLITE3_OPEN_READWRITE);
|
$db_writable = new SQLite3('./scripts/birds.db', SQLITE3_OPEN_READWRITE);
|
||||||
$db->busyTimeout(1000);
|
$db->busyTimeout(1000);
|
||||||
$statement1 = $db_writable->prepare('DELETE FROM detections WHERE File_Name = :file_name LIMIT 1');
|
$statement1 = $db_writable->prepare('DELETE FROM detections WHERE File_Name = :file_name LIMIT 1');
|
||||||
@@ -41,25 +29,10 @@ if(isset($_GET['deletefile'])) {
|
|||||||
$result1 = $statement1->execute();
|
$result1 = $statement1->execute();
|
||||||
$db_writable->close();
|
$db_writable->close();
|
||||||
die();
|
die();
|
||||||
} else {
|
|
||||||
header('WWW-Authenticate: Basic realm="My Realm"');
|
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
|
||||||
echo 'You must be authenticated to change the protection of files.';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
header('WWW-Authenticate: Basic realm="My Realm"');
|
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
|
||||||
echo 'You must be authenticated to change the protection of files.';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_GET['excludefile'])) {
|
if(isset($_GET['excludefile'])) {
|
||||||
if(isset($_SERVER['PHP_AUTH_USER'])) {
|
ensure_authenticated('You must be authenticated to change the protection of files.');
|
||||||
$submittedpwd = $_SERVER['PHP_AUTH_PW'];
|
|
||||||
$submitteduser = $_SERVER['PHP_AUTH_USER'];
|
|
||||||
if($submittedpwd == $config['CADDY_PWD'] && $submitteduser == 'birdnet'){
|
|
||||||
if(!file_exists($home."/BirdNET-Pi/scripts/disk_check_exclude.txt")) {
|
if(!file_exists($home."/BirdNET-Pi/scripts/disk_check_exclude.txt")) {
|
||||||
file_put_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "##start\n##end\n");
|
file_put_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "##start\n##end\n");
|
||||||
}
|
}
|
||||||
@@ -85,48 +58,12 @@ if(isset($_GET['excludefile'])) {
|
|||||||
echo "OK";
|
echo "OK";
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
header('WWW-Authenticate: Basic realm="My Realm"');
|
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
|
||||||
echo 'You must be authenticated to change the protection of files.';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
header('WWW-Authenticate: Basic realm="My Realm"');
|
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
|
||||||
echo 'You must be authenticated to change the protection of files.';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifted_path = $home."/BirdSongs/Extracted/By_Date/shifted/";
|
$shifted_path = $home."/BirdSongs/Extracted/By_Date/shifted/";
|
||||||
|
|
||||||
if(isset($_GET['shiftfile'])) {
|
if(isset($_GET['shiftfile'])) {
|
||||||
|
ensure_authenticated('You cannot shift files for this installation');
|
||||||
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);
|
|
||||||
$caddypwd = $config['CADDY_PWD'];
|
|
||||||
if (!isset($_SERVER['PHP_AUTH_USER'])) {
|
|
||||||
header('WWW-Authenticate: Basic realm="My Realm"');
|
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
|
||||||
echo '<table><tr><td>You cannot shift files for this installation</td></tr></table>';
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
$submittedpwd = $_SERVER['PHP_AUTH_PW'];
|
|
||||||
$submitteduser = $_SERVER['PHP_AUTH_USER'];
|
|
||||||
if($submittedpwd !== $caddypwd || $submitteduser !== 'birdnet'){
|
|
||||||
header('WWW-Authenticate: Basic realm="My Realm"');
|
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
|
||||||
echo '<table><tr><td>You cannot shift files for this installation<</td></tr></table>';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$filename = $_GET['shiftfile'];
|
$filename = $_GET['shiftfile'];
|
||||||
$pp = pathinfo($filename);
|
$pp = pathinfo($filename);
|
||||||
|
|||||||
Reference in New Issue
Block a user