busyTimeout(1000);
$statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Date == DATE(\'now\', \'localtime\')');
ensure_db_ok($statement2);
$result2 = $statement2->execute();
$todaycount = $result2->fetchArray(SQLITE3_ASSOC);
if(isset($_GET['custom_image'])){
if(isset($config["CUSTOM_IMAGE"])) {
?>
";
echo $img_tag;
}
die();
}
if(isset($_GET['blacklistimage'])) {
ensure_authenticated('You must be authenticated.');
$imageid = $_GET['blacklistimage'];
$file_handle = fopen($home."/BirdNET-Pi/scripts/blacklisted_images.txt", 'a+');
fwrite($file_handle, $imageid . "\n");
fclose($file_handle);
unset($_SESSION['images']);
die("OK");
}
if(isset($_GET['fetch_chart_string']) && $_GET['fetch_chart_string'] == "true") {
$myDate = date('Y-m-d');
$chart = "Combo-$myDate.png";
echo $chart;
die();
}
if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isset($_GET['previous_detection_identifier'])) {
$statement4 = $db->prepare('SELECT Com_Name, Sci_Name, Date, Time, Confidence, File_Name FROM detections ORDER BY Date DESC, Time DESC LIMIT 15');
ensure_db_ok($statement4);
$result4 = $statement4->execute();
if(!isset($_SESSION['images'])) {
$_SESSION['images'] = [];
}
$iterations = 0;
$flickr = null;
// hopefully one of the 5 most recent detections has an image that is valid, we'll use that one as the most recent detection until the newer ones get their images created
while($mostrecent = $result4->fetchArray(SQLITE3_ASSOC)) {
$comname = preg_replace('/ /', '_', $mostrecent['Com_Name']);
$sciname = preg_replace('/ /', '_', $mostrecent['Sci_Name']);
$comname = preg_replace('/\'/', '', $comname);
$filename = "/By_Date/".$mostrecent['Date']."/".$comname."/".$mostrecent['File_Name'];
// check to make sure the image actually exists, sometimes it takes a minute to be created\
if(file_exists($home."/BirdSongs/Extracted".$filename.".png")){
if($_GET['previous_detection_identifier'] == $filename) { die(); }
if($_GET['only_name'] == "true") { echo $comname.",".$filename;die(); }
$iterations++;
if (!empty($config["FLICKR_API_KEY"])) {
if ($flickr === null) {
$flickr = new Flickr();
}
if ($_SESSION["FLICKR_FILTER_EMAIL"] !== $flickr->get_uid_from_db()['uid']) {
if (isset($_SESSION["FLICKR_FILTER_EMAIL"])) {
$_SESSION['images'] = [];
}
$_SESSION["FLICKR_FILTER_EMAIL"] = $flickr->get_uid_from_db()['uid'];
}
// if we already searched flickr for this species before, use the previous image rather than doing an unneccesary api call
$key = array_search($comname, array_column($_SESSION['images'], 0));
if ($key !== false) {
$image = $_SESSION['images'][$key];
} else {
$flickr_cache = $flickr->get_image($mostrecent['Sci_Name']);
array_push($_SESSION["images"], array($comname, $flickr_cache["image_url"], $flickr_cache["title"], $flickr_cache["photos_url"], $flickr_cache["author_url"], $flickr_cache["license_url"]));
$image = $_SESSION['images'][count($_SESSION['images']) - 1];
}
}
?>
Most Recent Detection:
0) { ?>
0) {
echo "
Your system is currently processing a backlog of audio. This can take several hours before normal functionality of your BirdNET-Pi resumes.
";
} else {
echo "
No Detections For Today.
";
}
}
die();
}
if(isset($_GET['ajax_left_chart']) && $_GET['ajax_left_chart'] == "true") {
$statement = $db->prepare('SELECT COUNT(*) FROM detections');
ensure_db_ok($statement);
$result = $statement->execute();
$totalcount = $result->fetchArray(SQLITE3_ASSOC);
$statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Date == Date(\'now\', \'localtime\') AND TIME >= TIME(\'now\', \'localtime\', \'-1 hour\')');
ensure_db_ok($statement3);
$result3 = $statement3->execute();
$hourcount = $result3->fetchArray(SQLITE3_ASSOC);
$statement5 = $db->prepare('SELECT COUNT(DISTINCT(Com_Name)) FROM detections WHERE Date == Date(\'now\',\'localtime\')');
ensure_db_ok($statement5);
$result5 = $statement5->execute();
$speciestally = $result5->fetchArray(SQLITE3_ASSOC);
$statement6 = $db->prepare('SELECT COUNT(DISTINCT(Com_Name)) FROM detections');
ensure_db_ok($statement6);
$result6 = $statement6->execute();
$totalspeciestally = $result6->fetchArray(SQLITE3_ASSOC);
?>