- Сообщений: 146
- Спасибо получено: 7
Это форк Vinaora Nivo Slider, пришлось переименовать, в силу требования JED. Даже старую версию качать можно было только с варезных сайтов, нашпигованную троянами. Зачем оно такое, согласитесь.
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
<br>Country Code:
<script language="JavaScript">document.write(geoip_country_code());</script>
<br>Country Name:
<script language="JavaScript">document.write(geoip_country_name());</script>
<br>City:
<script language="JavaScript">document.write(geoip_city());</script>
<br>Region:
<script language="JavaScript">document.write(geoip_region());</script>
<br>Region Name:
<script language="JavaScript">document.write(geoip_region_name());</script>
<br>Latitude:
<script language="JavaScript">document.write(geoip_latitude());</script>
<br>Longitude:
<script language="JavaScript">document.write(geoip_longitude());</script>
<br>Postal Code:
<script language="JavaScript">document.write(geoip_postal_code());</script>
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
<script language="JavaScript" src="http://j.maxmind.com/app/country.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">// <![CDATA[
if(geoip_country_code() == "CA"){
document.write("");
window.location = 'http://www.myCanadaianWebsite.com';
}
// ]]></script>
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
<!DOCTYPE>
<html>
<head>
<title>Geo data</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=true" type="text/javascript"></script>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
<script>
google.load("jquery", "1.4.4");
</script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
if(google.loader.ClientLocation) {
// Google has found you
visitor_lat = google.loader.ClientLocation.latitude;
visitor_lon = google.loader.ClientLocation.longitude;
visitor_city = google.loader.ClientLocation.address.city;
visitor_region = google.loader.ClientLocation.address.region;
visitor_country = google.loader.ClientLocation.address.country;
visitor_countrycode = google.loader.ClientLocation.address.country_code;
$("#user_method").html("Google Geo");
$("#user_latlong").html(visitor_lat + " / " + visitor_lon);
$("#user_town").html(visitor_city); $("#user_county").html(visitor_region);
$("#user_country").html(visitor_country + " (" + visitor_countrycode + ")");
}
else {
// Google couldnt find you, Maxmind could
visitor_lat = geoip_latitude();
visitor_lon = geoip_longitude();
visitor_city = geoip_city();
visitor_region_code = geoip_region();
visitor_region = geoip_region_name();
visitor_country = geoip_country_name();
visitor_countrycode = geoip_country_code();
visitor_postcode = geoip_postal_code();
$("#user_method").html("MaxMind");
$("#user_latlong").html(visitor_lat + " / " + visitor_lon);
$("#user_postcode").html(visitor_postcode);
$("#user_town").html(visitor_city); $("#user_county").html(visitor_region + " ("+visitor_region_code+")");
$("#user_country").html(visitor_country + " (" + visitor_countrycode + ")");
}
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
var latlng = new GLatLng(visitor_lat, visitor_lon);
map.setCenter(latlng, 13);
map.addOverlay(new GMarker(latlng));
var center = latlng;
var radius = 0.65;
//convert kilometers to miles-diameter
var radius = radius*1.609344;
var latOffset = 0.01;
var lonOffset = 0.01;
var latConv = center.distanceFrom(new GLatLng(center.lat()+0.1, center.lng()))/100;
var lngConv = center.distanceFrom(new GLatLng(center.lat(), center.lng()+0.1))/100;
// nodes = number of points to create circle polygon
var nodes = 40;
//Loop
var points = [];
var step = parseInt(360/nodes)||10;
for(var i=0; i<=360; i+=step) {
var pint = new GLatLng(center.lat() + (radius/latConv * Math.cos(i * Math.PI/180)), center.lng() + (radius/lngConv * Math.sin(i * Math.PI/ 180)));
// push pints into points array
points.push(pint);
}
var polygon = new GPolygon(points, "#f33f00", 1, 1, "#ff0000", 0.1);
map.addOverlay(polygon);
}
});
</script>
</body>
<div id="geoData">
<table style="width: 560px;" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>Geocode Method:</td>
<td><span id="user_method"> </span></td>
</tr>
<tr>
<td>Your Latitude/Longitude:</td>
<td><span id="user_latlong"> </span></td>
</tr>
<tr>
<td>Town / City:</td>
<td><span id="user_town"> </span></td>
</tr>
<tr>
<td>Post Code:</td>
<td><span id="user_postcode"> </span></td>
</tr>
<tr>
<td>Approximate County:</td>
<td><span id="user_county"> </span></td>
</tr>
<tr>
<td>Country and Code:</td>
<td><span id="user_country"> </span></td>
</tr>
<tr>
<td colspan="2">
<div id="map_canvas" style=" margin:10px; border:1px solid #007; width: 540px; height: 360px;">Enable Javascript to view this map</div></td>
</tr>
</tbody>
</table>
</div>
</html>
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
Aleksej пишет: Демку разместил в блоге.
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
Jannet пишет: демка перестала работать, и у меня на сайте тоже.
<?php
$ip = $_SERVER['REMOTE_ADDR'];
include("path_to_SxGeo.php");
$SxGeo = new SxGeo('path_to_SxGeoCity.dat');
$city = $SxGeo->get($ip);
$loc_array = array($city['city']['lat'],$city['city']['lon']);
$api_key="vash_lichnuy_key_wwo";
$num_of_days=1;
$loc_safe = array();
foreach($loc_array as $loc){
$loc_safe[] = urlencode($loc);
}
$loc_string=implode(',', $loc_safe);
//To add more conditions to the query, just lengthen the url string
$basicurl = sprintf('http://api.worldweatheronline.com/free/v1/weather.ashx?key=%s&q=%s&num_of_days=%s', $api_key, $loc_string, intval($num_of_days));
$xml_response = file_get_contents($basicurl);
$xml = simplexml_load_string($xml_response);
$ss = array();
foreach ($xml[0] as $name => $val) {
foreach ($val as $name1 => $val1)
{
$ss[$name1] = $val1;
}
}
?>
<script language="JavaScript">
var h=(new Date()).getHours();
if (h > 23 || h <7) document.write("<? echo 'Доброй ночи, ' . $city['city']['name_ru']; ?>");
if (h > 6 && h < 12) document.write("<? echo 'Доброе утро, ' . $city['city']['name_ru']; ?>");
if (h > 11 && h < 19) document.write("<? echo 'Добрый день, ' . $city['city']['name_ru']; ?>");
if (h > 18 && h < 24) document. write("<? echo 'Доброго вечера, ' . $city['city']['name_ru']; ?>");
</script>
<?
echo "<br>";
echo " У вас ";
echo "{$ss["temp_C"]} °С";
echo ', ';
echo "скорость ветра {$ss["windspeedKmph"]} м/сек.";
echo $ss["weatherDesc"];
echo '. ';
?>
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
serge пишет: Например могу предложить вот этот код...]
<?php
$ip = $_SERVER['REMOTE_ADDR'];
include("SxGeo.php");
$SxGeo = new SxGeo('SxGeoCity.dat');
$city = $SxGeo->get($ip);
$loc_array = array($city['city']['lat'],$city['city']['lon']);
$api_key="vash_api_key";
$num_of_days=1;
$loc_safe = array();
foreach($loc_array as $loc){
$loc_safe[] = urlencode($loc);
}
$loc_string=implode(',', $loc_safe);
//To add more conditions to the query, just lengthen the url string
$basicurl = sprintf('http://api.worldweatheronline.com/free/v1/weather.ashx?key=%s&q=%s&num_of_days=%s', $api_key, $loc_string, intval($num_of_days));
$xml_response = file_get_contents($basicurl);
$xml = simplexml_load_string($xml_response);
$ss = array();
foreach ($xml[0] as $name => $val) {
foreach ($val as $name1 => $val1)
{
$ss[$name1] = $val1;
}
}
?>
<style type="text/css">
.title_weather {
color: #006699;
}
</style>
<div class="title_weather">
<script language="JavaScript">
var h=(new Date()).getHours();
if (h > 23 || h <7) document.write("<? echo 'Доброй ночи, ' . $city['city']['name_ru']; ?>");
if (h > 6 && h < 12) document.write("<? echo 'Доброе утро, ' . $city['city']['name_ru']; ?>");
if (h > 11 && h < 19) document.write("<? echo 'Добрый день, ' . $city['city']['name_ru']; ?>");
if (h > 18 && h < 24) document. write("<? echo 'Добрый вечер, ' . $city['city']['name_ru']; ?>");
</script>
</div>
<?
echo "<br>";
echo '<img src="' . $xml->weather->weatherIconUrl . '"/>';
echo "<br>";
echo "<br>";
echo $ss["date"];
echo "<br>";
echo "Координаты {$ss["query"]}";
echo "<br>";
echo ($city['city']['name_en']);
echo "<br>";
echo ($city['country']['iso']);
echo "<br>";
echo "<br>";
echo "<div style='color:#006699;'> У вас сегодня:</div>";
echo "Температура {$ss["temp_C"]} С";
echo "<br>";
echo "Мин. температура сегодня {$ss["tempMinC"]} С*";
echo "<br>";
echo "Макс. температура сегодня {$ss["tempMaxC"]} С*";
echo "<br>";
echo "Скорость ветра {$ss["windspeedKmph"]} м/сек";
echo "<br>";
echo "Направление ветра {$ss["winddirection"]}";
echo "<br>";
echo "Пасмурно {$ss["cloudcover"]}%";
echo "<br>";
echo "Давление {$ss["pressure"]} mb";
echo "<br>";
echo "Влажность {$ss["humidity"]}%";
echo "<br>";
echo "Видимость {$ss["visibility"]} км";
echo "<br>";
echo $ss["weatherDesc"];
echo "<br>";
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.