1) { die('Invalid threshold value'); } echo executeSysCommand('test_threshold', $threshold); die(); } if(isset($_GET['restart_php']) && $_GET['restart_php'] == "true") { executeSysCommand('restart_php'); die(); } # Basic Settings if(isset($_GET["latitude"])){ $latitude = $_GET["latitude"]; $longitude = $_GET["longitude"]; $site_name = $_GET["site_name"]; $site_name = str_replace('"', "", $site_name); $site_name = str_replace('\'', "", $site_name); $birdweather_id = $_GET["birdweather_id"]; $apprise_input = $_GET['apprise_input']; $apprise_notification_title = $_GET['apprise_notification_title']; $apprise_notification_body = $_GET['apprise_notification_body']; $minimum_time_limit = $_GET['minimum_time_limit']; $flickr_api_key = $_GET['flickr_api_key']; $flickr_filter_email = $_GET["flickr_filter_email"]; $language = $_GET["language"]; $timezone = $_GET["timezone"]; $model = $_GET["model"]; $sf_thresh = $_GET["sf_thresh"]; $only_notify_species_names = $_GET['only_notify_species_names']; $only_notify_species_names_2 = $_GET['only_notify_species_names_2']; if(isset($_GET['apprise_notify_each_detection'])) { $apprise_notify_each_detection = 1; } else { $apprise_notify_each_detection = 0; } if(isset($_GET['apprise_notify_new_species'])) { $apprise_notify_new_species = 1; } else { $apprise_notify_new_species = 0; } if(isset($_GET['apprise_notify_new_species_each_day'])) { $apprise_notify_new_species_each_day = 1; } else { $apprise_notify_new_species_each_day = 0; } if(isset($_GET['apprise_weekly_report'])) { $apprise_weekly_report = 1; } else { $apprise_weekly_report = 0; } if(isset($timezone) && in_array($timezone, DateTimeZone::listIdentifiers())) { executeSysCommand('set_timezone',$timezone); date_default_timezone_set($timezone); echo ""; } // logic for setting the date and time based on user inputs from the form below if(isset($_GET['date']) && isset($_GET['time'])) { // can't set the date manually if it's getting it from the internet, disable ntp executeSysCommand('disable_ntp'); // check if valid date and time $datetime = DateTime::createFromFormat('Y-m-d H:i', $_GET['date'] . ' ' . $_GET['time']); if ($datetime && $datetime->format('Y-m-d H:i') === $_GET['date'] . ' ' . $_GET['time']) { executeSysCommand('set_date', ['date' => $_GET['date'], 'time' => $_GET['time']]); } } else { // user checked 'use time from internet if available,' so make sure that's on if(strlen(trim(executeSysCommand('is_ntp_active'))) == 0){ executeSysCommand('enable_ntp'); sleep(3); } } // Update Language settings only if a change is requested changeLanguage($model, $language); saveSetting('SITE_NAME', "\"$site_name\""); saveSetting('LATITUDE', $latitude); saveSetting('LONGITUDE', $longitude); saveSetting('BIRDWEATHER_ID', $birdweather_id); saveSetting('APPRISE_NOTIFICATION_TITLE', "\"$apprise_notification_title\""); saveSetting('APPRISE_NOTIFICATION_BODY', "'$apprise_notification_body'"); saveSetting('APPRISE_NOTIFY_EACH_DETECTION', $apprise_notify_each_detection); saveSetting('APPRISE_NOTIFY_NEW_SPECIES', $apprise_notify_new_species); saveSetting('APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY', $apprise_notify_new_species_each_day); saveSetting('APPRISE_WEEKLY_REPORT', $apprise_weekly_report); saveSetting('FLICKR_API_KEY', $flickr_api_key); saveSetting('DATABASE_LANG', $language); saveSetting('FLICKR_FILTER_EMAIL', $flickr_filter_email); saveSetting('APPRISE_MINIMUM_SECONDS_BETWEEN_NOTIFICATIONS_PER_SPECIES', $minimum_time_limit); saveSetting('MODEL', $model); saveSetting('SF_THRESH', $sf_thresh); saveSetting('APPRISE_ONLY_NOTIFY_SPECIES_NAMES', "\"$only_notify_species_names\""); saveSetting('APPRISE_ONLY_NOTIFY_SPECIES_NAMES_2', "\"$only_notify_species_names_2\""); if($site_name != $config["SITE_NAME"]) { echo ""; } updateAppriseConfig($apprise_input); serviceMaintenance('restart core.services'); } if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") { $cf = explode("\n",$_GET['apprise_config']); $cf = "'".implode("' '", $cf)."'"; $result0 = getMostRecentDetectionToday(); foreach ($result0['data'] as $todaytable) { $sciname = $todaytable['Sci_Name']; $comname = $todaytable['Com_Name']; $confidence = $todaytable['Confidence']; $filename = $todaytable['File_Name']; $date = $todaytable['Date']; $time = $todaytable['Time']; $week = $todaytable['Week']; $latitude = $todaytable['Lat']; $longitude = $todaytable['Lon']; $cutoff = $todaytable['Cutoff']; $sens = $todaytable['Sens']; $overlap = $todaytable['Overlap']; } $title = $_GET['apprise_notification_title']; $body = $_GET['apprise_notification_body']; if($config["BIRDNETPI_URL"] != "") { $filename = $config["BIRDNETPI_URL"]."?filename=".$filename; } else{ $filename = "http://birdnetpi.local/"."?filename=".$filename; } $attach=""; $exampleimage = "https://live.staticflickr.com/7430/27545810581_8bfa8289a3_c.jpg"; if (strpos($body, '$flickrimage') !== false) { $attach = "--attach ".$exampleimage; } if (strpos($body, '{') === false) { $exampleimage = ""; } $title = str_replace("\$sciname", $sciname, $title); $title = str_replace("\$comname", $comname, $title); $title = str_replace("\$confidence", $confidence, $title); $title = str_replace("\$listenurl", $filename, $title); $title = str_replace("\$date", $date, $title); $title = str_replace("\$time", $time, $title); $title = str_replace("\$week", $week, $title); $title = str_replace("\$latitude", $latitude, $title); $title = str_replace("\$longitude", $longitude, $title); $title = str_replace("\$cutoff", $cutoff, $title); $title = str_replace("\$sens", $sens, $title); $title = str_replace("\$overlap", $overlap, $title); $title = str_replace("\$flickrimage", $exampleimage, $title); $body = str_replace("\$sciname", $sciname, $body); $body = str_replace("\$comname", $comname, $body); $body = str_replace("\$confidence", $confidence, $body); $body = str_replace("\$listenurl", $filename, $body); $body = str_replace("\$date", $date, $body); $body = str_replace("\$time", $time, $body); $body = str_replace("\$week", $week, $body); $body = str_replace("\$latitude", $latitude, $body); $body = str_replace("\$longitude", $longitude, $body); $body = str_replace("\$cutoff", $cutoff, $body); $body = str_replace("\$sens", $sens, $body); $body = str_replace("\$overlap", $overlap, $body); $body = str_replace("\$flickrimage", $exampleimage, $body); echo "
" . executeSysCommand('appraise_notification', ['title' => $title, 'body' => $body, 'attach' => $attach, 'cf' => $cf]) . "";
die();
}
?>