-
Notifications
You must be signed in to change notification settings - Fork 0
/
get.php
74 lines (56 loc) · 2.15 KB
/
get.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<html>
<head>
<title>Weather Report of <?php echo $_GET['q']; ?> </title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/3/w3.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<style>
html, body, h1, h2, h3, h4, h5, h6 {
font-family: "Comic Sans MS", cursive, sans-serif;
background:url('pexels-photo-242236.jpeg');
}
h2 {
text-align: center;
}
</style>
<body>
<?php
error_reporting(0);
$get = json_decode(file_get_contents('http://ip-api.com/json/'),true);
date_default_timezone_set($get['timezone']);
$city = $_GET['q'];
$string = "http://api.openweathermap.org/data/2.5/weather?q=".$city."&units=metric&appid=c2c3c845e6f270f0f917824e733b7624";
// ebcf5230b3446f334fe3fa2fd2d4ce24
$data = json_decode(file_get_contents($string),true);
$temp = $data['main']['temp'];
$icon = $data['weather'][0]['icon'];
$visibility = $data['visibility'];
$visibilitykm = $visibility / 1000;
$country = "<h1 class='w3-xxxlarge w3-animate-zoom'><b>".$data['name'].",".$data['sys']['country']."</h1></b>";
$image_top = "<center><img src='http://openweathermap.org/img/w/".$icon.".png'></center>";
$desc = "<b><p>".$data['weather'][0]['description']."</p></b>";
$temperature = "<b>Temp:".$temp."°C</b><br>";
$clouds = "<b>Clouds:".$data['clouds']['all']."%</b><br>";
$humidity = "<b>Humidity:".$data['main']['humidity']."%</b><br>";
$windspeed = "<b>Wind Speed:".$data['wind']['speed']."m/s</b><br>";
$pressure = "<b>Pressure:".$data['main']['pressure']."hpa</b><br>";
$visibility = "<b>Visibility:".$visibilitykm."Km</b><br>";
$sunrise = "<b>Sunrise:".date('h:i A', $data['sys']['sunrise'])."</b><br>";
$sunset = "<b>Sunset:".date('h:i A', $data['sys']['sunset'])."</b>";
?>
<div class="container">
<h2 class="w3-xlarge">
<?php echo $image_top; ?>
<?php echo $temperature; ?>
<?php echo $clouds; ?>
<?php echo $humidity; ?>
<?php echo $$windspeed; ?>
<?php echo $pressure; ?>
<?php echo $$visibility; ?>
<?php echo $sunrise; ?>
<?php echo $sunset; ?>
</h2>
</div>
</body>
</html>