busyTimeout(1000); 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; $image_provider = 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']); $comnamegraph = str_replace("'", "\'", $mostrecent['Com_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["IMAGE_PROVIDER"])) { if ($image_provider === null) { if ($config["IMAGE_PROVIDER"] === 'FLICKR') { $image_provider = new Flickr(); } else { $image_provider = new Wikipedia(); } if ($image_provider->is_reset()) { $_SESSION['images'] = []; } } // if we already searched 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 { $cached_image = $image_provider->get_image($mostrecent['Sci_Name']); array_push($_SESSION["images"], array($comname, $cached_image["image_url"], $cached_image["title"], $cached_image["photos_url"], $cached_image["author_url"], $cached_image["license_url"])); $image = $_SESSION['images'][count($_SESSION['images']) - 1]; } } ?>

Most Recent Detection:

0) { ?>


Confidence:

">
prepare('SELECT COUNT(*) FROM detections WHERE Date == DATE(\'now\', \'localtime\')'); ensure_db_ok($statement2); $result2 = $statement2->execute(); $todaycount = $result2->fetchArray(SQLITE3_ASSOC); if($todaycount['COUNT(*)'] > 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") { $chart_data = get_summary(); $_SESSION['chart_data'] = $chart_data; ?>
Total
Today
Last Hour
Species Detected Today
Total Number of Species
Total Today Last Hour Species Total Species Today
Overview '; } ?>

prepare(" SELECT d_today.Com_Name, d_today.Sci_Name, d_today.Date, d_today.Time, d_today.Confidence, d_today.File_Name, MAX(d_today.Confidence) as MaxConfidence, (SELECT MAX(Date) FROM detections d_prev WHERE d_prev.Sci_Name = d_today.Sci_Name AND d_prev.Date < DATE('now', 'localtime')) as LastSeenDate, (SELECT COUNT(*) FROM detections d_occ WHERE d_occ.Sci_Name = d_today.Sci_Name AND d_occ.Date = DATE('now', 'localtime')) as OccurrenceCount FROM detections d_today WHERE d_today.Date = DATE('now', 'localtime') GROUP BY d_today.Sci_Name "); ensure_db_ok($statement); $result = $statement->execute(); $new_species = []; $rare_species = []; $rare_species_threshold = isset($config['RARE_SPECIES_THRESHOLD']) ? $config['RARE_SPECIES_THRESHOLD'] : 30; while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $last_seen_date = $row['LastSeenDate']; if ($last_seen_date === NULL) { $new_species[] = $row; } else { $date1 = new DateTime($last_seen_date); $date2 = new DateTime('now'); $interval = $date1->diff($date2); $days_ago = $interval->days; if ($days_ago > $rare_species_threshold) { $row['DaysAgo'] = $days_ago; $rare_species[] = $row; } } } if (!isset($_SESSION['images'])) { $_SESSION['images'] = []; } function display_species($species_list, $title, $show_last_seen=false) { global $config, $_SESSION, $image_provider; $species_count = count($species_list); if ($species_count > 0): ?>

detected today!

5): ?>
is_reset()) { $_SESSION['images'] = []; } } // Check if the image has been cached in the session $key = array_search($comname, array_column($_SESSION['images'], 0)); if ($key !== false) { $image = $_SESSION['images'][$key]; } else { // Retrieve the image from Flickr API and cache it $cached_image = $image_provider->get_image($todaytable['Sci_Name']); array_push($_SESSION["images"], array($comname, $cached_image["image_url"], $cached_image["title"], $cached_image["photos_url"], $cached_image["author_url"], $cached_image["license_url"])); $image = $_SESSION['images'][count($_SESSION['images']) - 1]; } $image_url = $image[1] ?? ""; // Get the image URL if available } $last_seen_text = ""; if ($show_last_seen && isset($todaytable['DaysAgo'])) { $days_ago = $todaytable['DaysAgo']; if ($days_ago > 30) { $months_ago = floor($days_ago / 30); $last_seen_text = "
Last seen: {$months_ago}mo ago"; } else { $last_seen_text = "
Last seen: {$days_ago}d ago"; } } $occurrence_text = ""; if (isset($todaytable['OccurrenceCount']) && $todaytable['OccurrenceCount'] > 1) { $occurrence_text = " ({$todaytable['OccurrenceCount']}x)"; } ?>


Max confidence: ' . round($todaytable['Confidence'] * 100 ) . '%' . $occurrence_text; echo "
First detection: {$todaytable['Time']}"; echo $last_seen_text; ?>
"; } ?>

5 Most Recent Detections

Loading...

Currently Analyzing

"; ?>