Зависимости:
http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
//Get remote IP
$ip = Зависимости:
- http://www.maxmind.com/download/geoip/api/php/php-latest.tar.gz
-
http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
[110]
SERVER['REMOTE_ADDR'];
//Open GeoIP database and query our IP
$gi = geoip_open("GeoLiteCity.dat", GEOIP_STANDARD);
$record = geoip_record_by_addr($gi, $ip);
//If we for some reason didnt find data about the IP, default to a preset location.
if(!isset($record)) {
$record = new geoiprecord();
$record->latitude = 59.2;
$record->longitude = 17.8167;
$record->country_code = 'SE';
$record->region = 26;
}
//Calculate the timezone and local time
try {
//Create timezone
$user_timezone = new DateTimeZone(get_time_zone($record->country_code, ($record->region!='') ? $record->region : 0));
//Create local time
$user_localtime = new DateTime("now", $user_timezone);
$user_timezone_offset = $user_localtime->getOffset();
}
//Timezone and/or local time detection failed
catch(Exception $e) {
$user_timezone_offset = 7200;
$user_localtime = new DateTime("now");
}
echo 'User local time: ' . $user_localtime->format('H:i:s') . '
';
echo 'Timezone GMT offset: ' . $user_timezone_offset . '
';
Jacob is right - you might also want to look at this solution to fixup relative URLs.
Проблема в том, что HyperlinkButtons не может использовать относительные URL-адреса. Я столкнулся с этим буквально на днях. Это хакер, но я заставил его работать, добавив обработчик щелчка к HyperlinkButton и затем вызвав HtmlPage.Navigate, передав URI, помеченный как относительный