forked from kahst/BirdNET-Lite
-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #361 from mcguirepr89/timezone-testy
Timezone testy
- Loading branch information
Showing
1 changed file
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,11 @@ function syslog_shell_exec($cmd, $sudo_user = null) { | |
} | ||
} | ||
|
||
if(isset($_GET['restart_php']) && $_GET['restart_php'] == "true") { | ||
shell_exec("sudo service php7.4-fpm restart"); | ||
die(); | ||
} | ||
|
||
# Basic Settings | ||
if(isset($_GET["latitude"])){ | ||
$latitude = $_GET["latitude"]; | ||
|
@@ -24,6 +29,7 @@ function syslog_shell_exec($cmd, $sudo_user = null) { | |
$flickr_api_key = $_GET['flickr_api_key']; | ||
$flickr_filter_email = $_GET["flickr_filter_email"]; | ||
$language = $_GET["language"]; | ||
$timezone = $_GET["timezone"]; | ||
|
||
if(isset($_GET['apprise_notify_each_detection'])) { | ||
$apprise_notify_each_detection = 1; | ||
|
@@ -36,6 +42,17 @@ function syslog_shell_exec($cmd, $sudo_user = null) { | |
$apprise_notify_new_species = 0; | ||
} | ||
|
||
if(isset($timezone)) { | ||
shell_exec("sudo timedatectl set-timezone ".$timezone); | ||
date_default_timezone_set($timezone); | ||
echo "<script>setTimeout( | ||
function() { | ||
const xhttp = new XMLHttpRequest(); | ||
xhttp.open(\"GET\", \"scripts/config.php?restart_php=true\", true); | ||
xhttp.send(); | ||
}, 1000);</script>"; | ||
} | ||
|
||
// 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 | ||
|
@@ -190,7 +207,7 @@ function syslog_shell_exec($cmd, $sudo_user = null) { | |
<h3>Bird Photos from Flickr</h3> | ||
<label for="flickr_api_key">Flickr API Key: </label> | ||
<input name="flickr_api_key" type="text" value="<?php print($config['FLICKR_API_KEY']);?>"/><br> | ||
<label for="flickr_filter_email">Only search photos from this Flickr user?: </label> | ||
<label for="flickr_filter_email">Only search photos from this Flickr user: </label> | ||
<input name="flickr_filter_email" type="email" placeholder="[email protected]" value="<?php print($config['FLICKR_FILTER_EMAIL']);?>"/><br> | ||
<p>Set your Flickr API key to enable the display of bird images next to detections. <a target="_blank" href="https://www.flickr.com/services/api/misc.api_keys.html">Get your free key here.</a></p> | ||
<h3>Localization</h3> | ||
|
@@ -272,7 +289,27 @@ function handleChange(checkbox) { | |
<span>If connected to the internet, retrieve time automatically?</span> | ||
<input type="checkbox" onchange='handleChange(this)' <?php echo $checkedvalue; ?> ><br> | ||
<input onclick="this.showPicker()" type="date" id="date" name="date" value="<?php echo date('Y-m-d') ?>" <?php echo $disabledvalue; ?>> | ||
<input onclick="this.showPicker()" type="time" id="time" name="time" value="<?php echo date('H:i') ?>" <?php echo $disabledvalue; ?>> | ||
<input onclick="this.showPicker()" type="time" id="time" name="time" value="<?php echo date('H:i') ?>" <?php echo $disabledvalue; ?>><br> | ||
<label for="timezone">Select a Timezone: </label> | ||
<select name="timezone"> | ||
<option disabled selected> | ||
Select a timezone | ||
</option> | ||
<?php | ||
$current_timezone = trim(shell_exec("cat /etc/timezone")); | ||
$timezone_identifiers = DateTimeZone::listIdentifiers(DateTimeZone::ALL); | ||
|
||
$n = 425; | ||
for($i = 0; $i < $n; $i++) { | ||
$isSelected = ""; | ||
if($timezone_identifiers[$i] == $current_timezone) { | ||
$isSelected = 'selected="selected"'; | ||
} | ||
echo "<option $isSelected value='".$timezone_identifiers[$i]."'>".$timezone_identifiers[$i]."</option>"; | ||
} | ||
?> | ||
</select> | ||
|
||
<br><br><br> | ||
|
||
<input type="hidden" name="status" value="success"> | ||
|