2 set_include_path(get_include_path() . PATH_SEPARATOR
. '../lib');
5 * Generate an associative of the PHP timezones and display text.
7 * @return array PHP Timezone => Displayed Description
9 function generate_timezone_list() {
10 $php_timezones = DateTimeZone
::listIdentifiers(DateTimeZone
::ALL
);
13 foreach ($php_timezones as $timezone) {
14 $tz = new DateTimeZone($timezone);
15 $offset = $tz->getOffset(new DateTime());
16 $offsets[$timezone] = "(UTC" . ($offset < 0 ?
"-" : "+") . gmdate("H:i", abs($offset)) .
25 * Set the timezone for the user.
30 $timezones = generate_timezone_list();
31 $update_cookie = false;
33 if (isset($_COOKIE["AURTZ"])) {
34 $timezone = $_COOKIE["AURTZ"];
35 } elseif (isset($_COOKIE["AURSID"])) {
37 $q = "SELECT Timezone FROM Users, Sessions ";
38 $q .= "WHERE Users.ID = Sessions.UsersID ";
39 $q .= "AND Sessions.SessionID = ";
40 $q .= $dbh->quote($_COOKIE["AURSID"]);
41 $result = $dbh->query($q);
44 $timezone = $result->fetchColumn(0);
47 $update_cookie = true;
50 if (!isset($timezone) ||
!array_key_exists($timezone, $timezones)) {
51 $timezone = config_get("options", "default_timezone");
53 date_default_timezone_set($timezone);
56 $timeout = intval(config_get("options", "persistent_cookie_timeout"));
57 $cookie_time = time() +
$timeout;
58 setcookie("AURTZ", $timezone, $cookie_time, "/");