|
1 <?php |
|
2 require('../timezone.php'); |
|
3 $set_zone = false; |
|
4 if ( isset($_POST['tz']) ) |
|
5 { |
|
6 if ( in_array($_POST['tz'], $zones) ) |
|
7 { |
|
8 setcookie(COOKIE_NAME, $_POST['tz'], time() + ( 365 * 24 * 60 * 60 )); |
|
9 $tz = $_POST['tz']; |
|
10 date_default_timezone_set($_POST['tz']); |
|
11 $set_zone = str_replace('_', ' ', str_replace('/', ': ', $tz)); |
|
12 } |
|
13 } |
|
14 ?><html> |
|
15 <head> |
|
16 <title>Change time zone</title> |
|
17 <style type="text/css"> |
|
18 select, option { |
|
19 background-color: white; |
|
20 } |
|
21 option.other { |
|
22 color: black; |
|
23 font-weight: normal; |
|
24 } |
|
25 option.region { |
|
26 color: black; |
|
27 font-weight: bold; |
|
28 } |
|
29 option.area { |
|
30 color: black; |
|
31 font-weight: normal; |
|
32 padding-left: 1em; |
|
33 } |
|
34 option.country { |
|
35 color: black; |
|
36 font-weight: bold; |
|
37 padding-left: 1em; |
|
38 } |
|
39 option.city { |
|
40 color: black; |
|
41 font-weight: normal; |
|
42 padding-left: 2em; |
|
43 } |
|
44 div.success { |
|
45 border: 1px solid #006300; |
|
46 background-color: #d3ffd3; |
|
47 padding: 10px; |
|
48 margin: 10px 0; |
|
49 } |
|
50 </style> |
|
51 </head> |
|
52 <body> |
|
53 <?php |
|
54 if ( $set_zone ) |
|
55 { |
|
56 $target = dirname($_SERVER['PHP_SELF']) . '/'; |
|
57 echo '<div class="success">' . "Successfully set time zone to <b>{$set_zone}</b>. <a href=\"$target\">Return to the stats page</a>." . '</div>'; |
|
58 } |
|
59 ?> |
|
60 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> |
|
61 Select time zone: |
|
62 <select name="tz"> |
|
63 <?php |
|
64 $zones = get_timezone_list(); |
|
65 foreach ( $zones as $region => $areas ) |
|
66 { |
|
67 if ( is_string($areas) ) |
|
68 { |
|
69 echo '<option value="' . $areas . '" class="other">' . $areas . '</option>' . "\n "; |
|
70 continue; |
|
71 } |
|
72 echo '<option disabled="disabled" class="region">' . $region . '</option>' . "\n "; |
|
73 foreach ( $areas as $aid => $area ) |
|
74 { |
|
75 if ( is_array($area) ) |
|
76 { |
|
77 echo ' <option disabled="disabled" class="country">' . str_replace('_', ' ', $aid) . '</option>' . "\n "; |
|
78 foreach ( $area as $city ) |
|
79 { |
|
80 $zoneid = "$region/$aid/$city"; |
|
81 $sel = ( $zoneid == $tz ) ? ' selected="selected"' : ''; |
|
82 echo ' <option value="' . $zoneid . '" class="city"' . $sel . '>' . str_replace('_', ' ', $city) . '</option>' . "\n "; |
|
83 } |
|
84 } |
|
85 else |
|
86 { |
|
87 $zoneid = "$region/$area"; |
|
88 $sel = ( $zoneid == $tz ) ? ' selected="selected"' : ''; |
|
89 echo ' <option value="' . $zoneid . '" class="area"' . $sel . '>' . str_replace('_', ' ', $area) . '</option>' . "\n "; |
|
90 } |
|
91 } |
|
92 } |
|
93 ?> |
|
94 </select> |
|
95 <input type="submit" value="Save" /><br /> |
|
96 <small>Make sure you have cookies enabled.</small> |
|
97 </form> |
|
98 </body> |
|
99 </html> |