hanze/iwa-panda2

basic token verifier, displays table with data, functions for calculating wc corrected temp and humidity(humidity does not work properly yet i think) (9ed43c53c3d839dd0aaff87b8dcb2fff3f872b3e)
Repositories | README.md

commit 9ed43c53c3d839dd0aaff87b8dcb2fff3f872b3e
parent 931940406bebfc624b1089b5cbf82a77b66c3524
Author: Johs <[email protected]>
Date:   Tue,  6 Jun 2023 23:58:36 +0200

basic token verifier, displays table with data, functions for calculating wc corrected temp and humidity(humidity does not work properly yet i think)

Diffstat:
A.idea/iwa-panda.iml9+++++++++
A.idea/modules.xml9+++++++++
MModel/Key.php64++++++++++++++++++++++++++++++++--------------------------------
3 files changed, 50 insertions(+), 32 deletions(-)

diff --git a/.idea/iwa-panda.iml b/.idea/iwa-panda.iml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="WEB_MODULE" version="4"> + <component name="NewModuleRootManager"> + <content url="file://$MODULE_DIR$" /> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> +\ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/iwa-panda.iml" filepath="$PROJECT_DIR$/.idea/iwa-panda.iml" /> + </modules> + </component> +</project> +\ No newline at end of file diff --git a/Model/Key.php b/Model/Key.php @@ -1,10 +1,13 @@ <?php Class Key{ function myfunction($key){ + if ($key['data'] != '3jvl7yb5sRr80s6lTdeOyxV9VTQZkCPRp7bKOWKFWxfL2vhsU4Hhpgcmz9qe0zEk'){ + return 'no'; + } else{ $db = new mysqli("86.92.67.21", "friedel", "hailiwa", "wap2"); $t = new Lollipop\Template(); - $array = []; - $query = "SELECT * + $weather_data = []; + $query = "SELECT temperature, dew_point, wind_speed FROM weather_data wd JOIN station s ON wd.station_name = s.name JOIN contract_station cs ON cs.station_name = s.name @@ -17,26 +20,17 @@ Class Key{ // $table = "<table"; // $data = ["tabel" => $table]; while ($row = $data->fetch_assoc()) { - $array[] = $row; - }; - if ($array != null) {?> + $weather_data[] = $row; + } + if ($weather_data != null) {?> <table class="table table-striped"> <thead> <tr> - <th> Station name </th> - <th> Date & Time </th> - <th> Validated </th> <th> Temperature </th> <th> Dewpoint </th> - <th> Sea pressure </th> - <th> Station pressure </th> - <th> Visibility </th> <th> Wind speed </th> - <th> Precipitation </th> - <th> Snow depth </th> - <th> Events </th> - <th> Cloud count </th> - <th> Wind direction </th> + <th> Wind chill corrected temp </th> + <th> Humidity </th> </tr> </thead> <tbody> @@ -44,30 +38,36 @@ Class Key{ </tbody> <?php foreach($weather_data as $data) { - $link = "/search_data?station=" . $data->station_name; echo "<tr>"; - echo "<td><a href='" . $link . "'>" . $data->station_name . "</a></td>"; - echo "<td>" . $data->date_time . "</td>"; - echo "<td>" . $data->validated . "</td>"; - echo "<td>" . $data->temperature . "</td>"; - echo "<td>" . $data->dew_point . "</td>"; - echo "<td>" . $data->pressure_sea . "</td>"; - echo "<td>" . $data->pressure_station . "</td>"; - echo "<td>" . $data->visibility . "</td>"; - echo "<td>" . $data->wind_speed . "</td>"; - echo "<td>" . $data->precipitation . "</td>"; - echo "<td>" . $data->snow_depth . "</td>"; - echo "<td>" . $data->events . "</td>"; - echo "<td>" . $data->cloud_count . "</td>"; - echo "<td>" . $data->wind_direction . "</td>"; + echo "<td>" . $data["temperature"] . "</td>"; + echo "<td>" . $data['dew_point'] . "</td>"; + echo "<td>" . $data['wind_speed'] . "</td>"; + echo "<td>" . windchill($data["temperature"], $data['wind_speed']) . "</td>"; + echo "<td>" . humid($data["temperature"], $data['dew_point']) . "</td>"; echo "</tr>"; } ?> </tbody> </table> - return $array; +<?php + + return json_encode($weather_data); } } +} +} +function windchill($temp, $wind){ + return 13.12 + 0.6215*$temp - 11.37 * ($wind^0.16) + 0.3965* $temp * ($wind^0.16); +} + +function humid($temp, $dewp){ + $specific_humidity = 6.11 * (10^(7.5 * $dewp) / (237.3 + $dewp)); + $saturation_point = 6.11 * (10^(7.5 * $temp) / (237.3 + $temp)); + $rel_humid = $specific_humidity / $saturation_point * 100; + echo ($specific_humidity); + return $rel_humid; +} +?>