-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_prediction.php
207 lines (163 loc) · 7.01 KB
/
get_prediction.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<?php
session_start();
include_once 'dbconnect.php';
if(isset($_SESSION['weather'])){
$usrid=$_SESSION['weather'];
}
else{
header("Location: index.php");
exit;
}
$res1=mysqli_query($conn,"SELECT accpic FROM profile WHERE usrid='$usrid'");
$row1=mysqli_fetch_array($res1);
$filenamee=$row1['accpic'];
?>
<html>
<head><title><?php echo $_GET['q']; ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="imgs/favicon.ico" type="image/x-icon">
<link type="text/css" rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<style>
body, html {
height: 100%;
margin: 0;
overflow-x: hidden;
scroll-behavior: smooth;
}
.bg {
background: linear-gradient(to right, #00F260, #0575E6);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.nv :hover, .nv :focus{
color: #ff6600;
}
.nav-link{
color: #888;
}
.ddp :focus, .ddp:active{
background: #ff6600 !important;
}
</style>
</head>
<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/forecast?q=".$city."&units=metric&appid=9d7b748ab7d47e8f73a824885e4e69d2";
$data = json_decode(file_get_contents($string),true);
$country = "<h1 class='text-white'>".$data['city']['name'].", ".$data['city']['country']."</h1>";
?>
<nav style="background: #455668;">
<div class="nav justify-content-end mb-2 mr-2 mr-sm-3">
<!--<img src="">-->
<span class="text-white-50 text-right align-bottom"><img src="submissions/<?php echo $usrid."/".$filenamee ?>" height="20px" width="20px" style="border-radius: 50%;"> </span>
<!--dropdown menu-->
<div class="dropdown">
<a class="dropdown-toggle text-white-50 text-right " href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Account</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item ddp" href="settings.php">Settings</a>
<a class="dropdown-item ddp" href="logout.php">Logout</a>
</div>
</div>
</div>
<div class="w-100 justify-content-sm-left nav" style="background: #eee;" id="navbarSupportedContent">
<div style="background:white; height: 100px; width: 100px; margin: 10px;"><img src="imgs/logo.jpg" height="100px" width="100px"></div>
<div class="ml-2">
<div class="row align-items-start">
<div class="col" style="background: #eee; margin-left: 15px !important; margin-top: 15px !important; padding-left: 0 !important;">
<h2 class="text-dark text-left" style="margin-right: auto;">Company</h2>
</div>
</div>
<div class="row align-items-start" style="margin-top: 10px;">
<div class="col" style="margin-left: 0 !important;">
<ul class="nav justify-content-left" style="margin-left: -15px !important; padding-left: 0 !important;">
<li class="nav-item nv actt">
<a style="color: #ff6600;" class="nav-link" href="LoggedIn.php">HOME</a>
</li>
<li class="nav-item nv">
<a class="nav-link" href="#!">ABOUT</a>
</li>
<li class="nav-item nv">
<a class="nav-link" href="contact.php" target="blank">CONTACT US</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</nav>
<div class="bg jumbotron" id="acnt" style="border-radius: 0; margin: 0;">
<div class="mx-0 my-0">
<?php
echo $country;
?>
<br><br>
<center>
<form method="GET" action="get_prediction.php" autocomplete="off" class="form my-2 my-lg-0" >
<div class="form-group">
<select name="Datte" class="form-control" style="width:15%;" data-toggle="tooltip" data-placement="top" title="Choose the Date and Time">
<option selected>Choose...</option>
<?php for ($num1 = 0; $num1 < sizeof($data['list']); $num1 += 1) {?>
<option value="<?php echo $num1 ?>"><?php echo $data['list'][$num1]['dt_txt'] ?></option>
<?php } ?>
</select>
</div>
<br><br>
<input type="text" name="q" value="<?php echo $city ?>" style="display:none;">
<button class="btn btn-outline-light ml-0" type="submit" name="dat" style="border-radius: 50px;">Select</button>
</form>
</center>
<?php
if(isset($_GET['dat'])){
$val = $_GET['Datte'];
?>
<hr style="border-color:#ddd;">
<h3 class="text-white"><?php echo "Date: ".$data['list'][$val]['dt_txt']."<br>";?></h3>
<?php $temperature = "<b>Temperature: ".$data['list'][$val]['main']['temp']."</b>";
$clouds = "<b>Clouds: ".$data['list'][$val]['clouds']['all']."%</b>";
$humidity = "<b>Humidity: ".$data['list'][$val]['main']['humidity']."%</b>";
$windspeed = "<b>Wind Speed: ".$data['list'][$val]['wind']['speed']."m/s</b>";
$pressure = "<b>Pressure: ".$data['list'][$val]['main']['pressure']."hpa</b>";
$logo = "<center><img src='http://openweathermap.org/img/w/".$data['list'][$val]['weather'][0]['icon'].".png' height='100px' width='100px'></center>";
$desc = "<p>".$data['list'][$val]['weather'][0]['description']."</p>";
?><div>
<div class="d-flex justify-content-center flex-row"><?php
echo $logo; ?></div>
<div class="d-flex justify-content-center flex-row"><h2 class="text-white"><?php echo $desc;?></h2></div>
<div class="d-flex justify-content-center flex-row">
<ul class="text-white list-group list-group-flush">
<li class="list-group-item" style="background: transparent;"><?php echo $temperature; ?></li>
<li class="list-group-item" style="background: transparent;"><?php echo $clouds; ?></li>
<li class="list-group-item" style="background: transparent;"><?php echo $humidity; ?></li>
<li class="list-group-item" style="background: transparent;"><?php echo $windspeed; ?></li>
<li class="list-group-item" style="background: transparent;"><?php echo $pressure; ?><br></li>
</ul>
</div>
<?php } ?>
</div>
</div>
</div>
<?php include 'footer.php';
?>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="js/bootstrap.js"></script>
<script>
$(document).ready(function(){
$('.dropdown-toggle').dropdown()
});
</script>
<script>
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
</script>
</body>
</html>