Viewing file: tzset.phtml (3.07 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
require('ax5.inc');
function get_timezones() {
$timezones = array();
foreach(file('/usr/share/zoneinfo/zone.tab') as $line) {
$line=trim($line);
if (substr($line,0,1)=='#') continue;
$tomb=explode("\t",$line);
unset($x);
$x=explode("/",$tomb[2]);
$timezones[$x[0]][$x[1]]=$tomb[2];
}
foreach($timezones as $key=>$val) {
ksort($timezones[$key]);
}
ksort($timezones);
return $timezones;
}
function continent_form() {
global $back,$timezone;
echo "<div id=\"timeZoneSet\">";
echo "<p>Setting your timezone involves two simple steps:<br /></p>\n";
echo " <form action=\"tzset\" type=\"post\" >\n";
echo " First, select your continent:\n";
echo " <select name=\"continent\">\n";
foreach(get_timezones() as $continent=>$carray) {
echo " <option";
if (isset($_COOKIE['timezone']) and strstr($_COOKIE['timezone'],$continent))
echo " selected=\"selected\"";
echo ">".htmlspecialchars($continent)."</option>";
}
echo " </select>\n";
echo " <input type=\"hidden\" name=\"back\" value=\"$back\" />";
echo " <input type=\"submit\" name=\"action\" value=\"Select\" />\n";
echo " </form>\n";
echo "</div>\n";
}
function country_form($continent) {
global $back;
echo "<div id=\"timeZoneSet\">";
echo " <form action=\"tzset\" type=\"post\">\n";
echo " Second, select your city or region;<br> choose one where your local time is correctly displayed: <br /> \n";
echo " <select name=\"newtimezone\">\n";
$timezones=get_timezones();
$timezones=$timezones[$continent];
$zones=array();
foreach($timezones as $country=>$timezone) {
putenv("TZ=".$timezone);
$zones[$timezone]=date("H:i")." ".$country;
}
asort($zones);
foreach($zones as $timezone=>$text) {
echo ' <option value="'.htmlspecialchars($timezone).'"';
if (isset($_COOKIE['timezone']) and $_COOKIE['timezone']==$timezone)
echo " selected";
echo '>'.htmlspecialchars($text).'</option>';
}
echo " </select>\n";
echo " <input type=\"hidden\" name=\"back\" value=\"$back\" />";
echo " <input type=\"submit\" name=\"action\" value=\"select\" />\n";
echo " </form>";
echo "</div>";
}
disp_preamble("AX Main","Time Zone setting");
if(isset($newtimezone)) {
setcookie('timezone',$newtimezone,time()+10*365*86400,'/','axkickboxing.com');
putenv("TZ=".$newtimezone);
echo "<div id=\"timeZoneSet\">";
echo " <p>That was it!</p>";
echo " <p>Your timezone is now set.</p>";
echo " <p>Your local time is set to: ".date("Y-m-d H:i:s")."</p>";
echo " <p>Please don't forget to <b>Reload</b> the topic list so that you can see the change.</p>";
echo ' <p align=center>[ <a href="'.$back.'">Back to the Forum</a> ]</p>';
echo "</div>";
} else if (isset($continent)) {
country_form($continent);
} else {
$back=$_SERVER['HTTP_REFERER'];
continent_form();
}
disp_tail();
?>
|