Skip to content

Commit

Permalink
Merge pull request #361 from mcguirepr89/timezone-testy
Browse files Browse the repository at this point in the history
Timezone testy
  • Loading branch information
mcguirepr89 authored Jun 10, 2022
2 parents 056ce73 + 1407b71 commit 96efed4
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions scripts/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down

0 comments on commit 96efed4

Please sign in to comment.