summaryrefslogtreecommitdiff
path: root/index.php
blob: c3caaca5c84b5c223eac49b590aa7768bd9ccd74 (plain)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php

libxml_use_internal_errors(true);
date_default_timezone_set("Europe/Jersey");
$timenow = time();

$json = file_get_contents("https://prodgojweatherstorage.blob.core.windows.net/data/jerseyForecast.json");
$arr_json = json_decode($json, true);

$curtemp = $arr_json['currentTemprature'];

// Today

$maxtemp[0] = $arr_json['forecastDay']['0']['maxTemp'];
$mintemp[0] = $arr_json['forecastDay']['0']['minTemp'];
$wind[0] = $arr_json['forecastDay']['0']['windSpeed'];
$winddirection[0] = $arr_json['forecastDay']['0']['windDirection'];
$uv[0] = $arr_json['forecastDay']['0']['uvIndex'];
$morning[0] = $arr_json['forecastDay']['0']['morningDescripiton']; // Try to...
$afternoon[0] = $arr_json['forecastDay']['0']['afternoonDescripiton']; // ...find a...
$night[0] = $arr_json['forecastDay']['0']['nightDescripiton']; // ...day summary
$sunset[0] = $arr_json['forecastDay']['0']['sunSet'];
$frost[0] = $arr_json['forecastDay']['0']['frost'];
$winddesc[0] = $arr_json['forecastDay']['0']['windDescription'];

// Tomorrow

$maxtemp[1] = $arr_json['forecastDay']['1']['maxTemp'];
$mintemp[1] = $arr_json['forecastDay']['1']['minTemp'];
$wind[1] = $arr_json['forecastDay']['1']['windSpeed'];
$winddirection[1] = $arr_json['forecastDay']['1']['windDirection'];
$uv[1] = $arr_json['forecastDay']['1']['uvIndex'];
$morning[1] = $arr_json['forecastDay']['1']['morningDescripiton'];
$afternoon[1] = $arr_json['forecastDay']['1']['afternoonDescripiton'];
$night[1] = $arr_json['forecastDay']['1']['nightDescripiton'];
$frost[1] = $arr_json['forecastDay']['1']['frost'];
$winddesc[1] = $arr_json['forecastDay']['1']['windDescription'];

// Title summary

if ($timenow >= strtotime($sunset[0])) {
  $summary[0] = "$sunset[0]: $night[0]";
} else if ($timenow >= strtotime("12:00:00")) {
  $summary[0] = "12:00: $afternoon[0] $sunset[0]: $night[0]";
} else {
  $summary[0] = "00:00: $morning[0] 12:00: $afternoon[0] $sunset[0]: $night[0]";
}

echo "<title>Max $maxtemp[0], Min $mintemp[0], Cur $curtemp, UV $uv[0], Wind $wind[0] $winddirection[0], $summary[0] $frost[0]</title>\n\n";

echo "</head>\n\n";
echo "<body>\n\n";

echo "<p>Forecasts | <a href=\"./graphs.php\">Graphs</a></p>\n\n";

echo "<h2>Today</h2>\n\n";
//echo "<p><em>$valid[0]</em><br><br>\n"; // If a day summary is found, use a sensible time range here
echo "<strong>Max:</strong> $maxtemp[0], <strong>Min:</strong> $mintemp[0], <strong>Current</strong>: $curtemp, <strong>UV Index</strong>: $uv[0], <strong>Wind</strong>: $wind[0] $winddirection[0]<br><br>\n";
echo "<strong>Morning:</strong> $morning[0]<br><br>\n";
echo "<strong>Afternoon:</strong> $afternoon[0]<br><br>\n";
echo "<strong>Night:</strong> $night[0]<br><br>\n";
echo "<strong>Frost:</strong> $frost[0]<br><br>\n";
echo "<strong>Wind:</strong> $winddesc[0]<br><br>\n";

echo "<h2>Tomorrow</h2>\n\n";
//echo "<p><em>$valid[1]</em><br><br>\n";
echo "<strong>Max</strong>: $maxtemp[1], <strong>Min</strong>: $mintemp[1], <strong>UV Index</strong>: $uv[1], <strong>Wind</strong>: $wind[1] $winddirection[1]<br><br>\n";
echo "<strong>Morning:</strong> $morning[1]<br><br>\n";
echo "<strong>Afternoon:</strong> $afternoon[1]<br><br>\n";
echo "<strong>Night:</strong> $night[1]<br><br>\n";
echo "<strong>Frost:</strong> $frost[1]<br><br>\n";
echo "<strong>Wind:</strong> $winddesc[1]</p>";

?>

<p><small><a href="http://www.blatech.co.uk/l_bratch/w.of.je/tree/master">Source?</a></small></p>

</body>

</html>