How to capture current temperature and current city?

All about creating websites!
Post Reply
User avatar
z3r0aCc3Ss
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 700
Joined: 23 Jun 2009, 16:00
14
Contact:

How to capture current temperature and current city?

Post by z3r0aCc3Ss »

I want to capture current user location city and temperature of that city via PHP and/or jQuery?

Is it possible? Please provide some reference.
Beta tester for major RATs, all kinds of stealers and keyloggers.
Learning NMAP

cwdykarn
suck-o-fied!
suck-o-fied!
Posts: 77
Joined: 19 Dec 2012, 10:15
11

Re: How to capture current temperature and current city?

Post by cwdykarn »

This should help you out, to get started :)

Code: Select all

http://www.mylesgray.com/software/use-geolocation-get-user-location-weather-ip-address/

http://stackoverflow.com/questions/12126295/show-weather-based-on-users-location

http://www.w3schools.com/html/html5_geolocation.asp
regards @cwDYKARN

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Re: How to capture current temperature and current city?

Post by bad_brain »

hm, not sure about the temperature, you might want to google for something like a live temperature database, I guess big weather channels provide something like that...with a little luck with a (free) API... :-k

fetching the location is no big deal though, you can use the GeoLite2 database for that:
http://dev.maxmind.com/geoip/geoip2/geolite2/" onclick="window.open(this.href);return false;
I am using it too for analytics of some websites, and it's quite accurate...how accurate of course depends a little on the location, at least the IP locations for North America and Europe are really precise.... :wink:
Image

User avatar
z3r0aCc3Ss
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 700
Joined: 23 Jun 2009, 16:00
14
Contact:

Re: How to capture current temperature and current city?

Post by z3r0aCc3Ss »

I liked MaxMind service, but not getting any idea on how to use it...
Can anyone give me short code snippet on it?
Beta tester for major RATs, all kinds of stealers and keyloggers.
Learning NMAP

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Re: How to capture current temperature and current city?

Post by bad_brain »

it's pretty well documented, have a look here:
http://dev.maxmind.com/geoip/legacy/downloadable/" onclick="window.open(this.href);return false;

you can find usage instructions (together with code examples) for a whole bunch of languages (PHP too of course).... :wink:
Image

User avatar
z3r0aCc3Ss
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 700
Joined: 23 Jun 2009, 16:00
14
Contact:

Re: How to capture current temperature and current city?

Post by z3r0aCc3Ss »

Thanks b_b.

I used ip2location for obtaining city and then used

Code: Select all

http://api.openweathermap.org/data/2.5/weather?q=london&mode=xml
for obtaining weather. ;) :D
Beta tester for major RATs, all kinds of stealers and keyloggers.
Learning NMAP

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Re: How to capture current temperature and current city?

Post by bad_brain »

would be cool if you can post the link, would like to see it in action so I can steal and re-use it... :lol:
Image

User avatar
z3r0aCc3Ss
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 700
Joined: 23 Jun 2009, 16:00
14
Contact:

Re: How to capture current temperature and current city?

Post by z3r0aCc3Ss »

Code: Select all

<?php
	include('php/ip2locationlite.class.php');
	 
	//Load the class
	$ipLite = new ip2location_lite;
	$ipLite->setKey('you api key here');
	 
	//Get errors and locations
	$locations = $ipLite->getCity($_SERVER['REMOTE_ADDR']);
	$errors = $ipLite->getError();
	
	//Getting the result
	/*echo "<p>\n";
	echo "<strong>First result</strong><br />\n";
	if (!empty($locations) && is_array($locations)) {
	  foreach ($locations as $field => $val) {
		echo $field . ' : ' . $val . "<br />\n";
	  }
	}
	
	echo "</p>\n";*/
	 
	/*//Show errors
	echo "<p>\n";
	echo "<strong>Dump of all errors</strong><br />\n";
	if (!empty($errors) && is_array($errors)) {
	  foreach ($errors as $error) {
		echo var_dump($error) . "<br /><br />\n";
	  }
	} else {
	  echo "No errors" . "<br />\n";
	}
	echo "</p>\n";*/
?>

<!DOCTYPE html>
<html>
	<head>
    	<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
    	<script type="text/javascript" src="js/custom_functions.js"></script>
        <script type="text/javascript" src="lib/jquery.xml2json.js"></script>
        <script type="text/javascript" src="lib/xmlwriter.js"></script>
    	<script type="text/javascript">
			$(document).ready(function(e) {
                
            
			var proxy = 'php/phpproxy.php?url=http%3A%2F%2F';
			var city = '<?php echo $locations[cityName]; ?>';
			var uri = proxy + encodeURIComponent("api.openweathermap.org/data/2.5/weather?q=" + city + "&mode=xml").replace(/'/g,"%27").replace(/"/g,"%22");
			
			connect(uri, getXML, "GET", true);
			
			function getXML()
			{
				//ready state 4 and is 200 success
				if (checkSuccess(this))
				{
					// converting string response object to json object
					var jsonObj = eval("(" + this.responseText + ")");
					// converting jason string value to using xml2jason utiliy
					jsonObj = $.xml2json(jsonObj.contents, false);
					// modifying date from YYYY-MM-DD HH MM SS to DD MM YYYY
					// var trans;
					document.write(jsonObj.current.city.country);
				}
			}
			});
		</script>
    </head>
    <body>
    </body>
</html>
Beta tester for major RATs, all kinds of stealers and keyloggers.
Learning NMAP

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Re: How to capture current temperature and current city?

Post by bad_brain »

sweet, thanks buddy! :D *thumb*
Image

Post Reply