This repository has been archived by the owner on Nov 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathselecttimezone.php
55 lines (52 loc) · 1.79 KB
/
selecttimezone.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
include("auth/lock.php");
include_once("includes/common.php");
$tzlist = timezone_identifiers_list();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST['timezone']) && in_array($_POST['timezone'], $tzlist)) {
include_once('includes/queries.php');
set_user_timezone($_SESSION['login_id'], $_POST['timezone']);
flash(
sprintf(
'Your time zone has been set to %s successfully.',
$_POST['timezone']),
FLASH_SUCCESS);
$_SESSION['timezone'] = $_POST['timezone'];
redirect_to('index');
}
else {
errorpage('Bad Request', 'Input data is not as expected.', '400 Bad Request');
}
}
include("header.php");
?>
<div class="white-box fullWidth">
<p>You have not defined your timezone yet. Now is a good time to select it.</p>
<p>Detected timezone: <span id="timezoneinfo">Not detected yet</span></p>
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" class="inlineform">
<select name="timezone" id="tzselect" autofocus class="left">
<?php foreach($tzlist as $tz) { ?>
<option><?php echo $tz; ?></option>
<?php } ?>
</select>
<input type="submit" name="submit" value="Select timezone" class="left" />
</form>
</div>
<script type="text/javascript" src="lib/jquery.min.js"></script>
<script type="text/javascript" src="lib/jstz-1.0.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var tz = jstz.determine();
var tzname = tz.name();
$('#timezoneinfo').text(tzname);
var tzselect = $('#tzselect');
for (var i=0; i < tzselect[0].options.length; i++) {
if (tzselect[0].options[i].text === tzname) {
tzselect[0].selectedIndex = i;
}
}
});
</script>
<?php
include("footer.php");
?>