-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
109 lines (78 loc) · 2.06 KB
/
index.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
<?php
header('Content-Type: text/html');
header('Cache-Control: no-cache');
header('Pragma: no-cache');
header("Access-Control-Allow-Origin: *");
$product_id = htmlspecialchars($_GET["product_id"]);
if ($product_id == "")
$product_id = "IDN10035";
$baseurl = 'ftp://ftp.bom.gov.au/anon/gen/fwo/';
$url = $baseurl . $product_id . ".xml";
//echo $url;
$xmlStr = file_get_contents($url);
$xml = new SimpleXMLElement($xmlStr);
?>
<!-- NAVIGATION -->
<ul>
<li><a href="?product_id=IDN10035">Canberra</a></li>
<li><a href="?product_id=IDV10450">Melbourne</a></li>
<li><a href="?product_id=IDN10064">Sydney</a></li>
<li><a href="?product_id=IDQ10095">Brisbane</a></li>
<li><a href="?product_id=IDW12300">Perth</a></li>
<li><a href="?product_id=IDS10034">Adelaide</a></li>
<li><a href="?product_id=IDT13600">Hobart</a></li>
</ul>
<!-- END NAVIGATION -->
<h1>Location:
<?php
$result = $xml->xpath("//area[2]/@description");
while(list( , $node) = each($result)) {
echo $node;
}
?>
</h1>
<h2>Today</h2>
Forecast (short):
<?php
$result = $xml->xpath("//area[3]/forecast-period[1]/text[@type='precis']");
while(list( , $node) = each($result)) {
echo $node;
}
?>
<br/>
Forecast (long):
<?php
$result = $xml->xpath("//area[2]/forecast-period[1]/text[@type='forecast']");
while(list( , $node) = each($result)) {
echo $node;
}
?>
<br/>Air temperature maximum:
<?php
$result = $xml->xpath("//area[3]/forecast-period[1]/element[@type='air_temperature_maximum']");
while(list( , $node) = each($result)) {
echo $node;
}
?>
c
<br/>Chance of Rain:
<?php
$result = $xml->xpath("//area[3]/forecast-period[1]/text[@type='probability_of_precipitation']");
while(list( , $node) = each($result)) {
echo $node;
}
?>
<br/>Rainfall amount:
<?php
$result = $xml->xpath("//area[3]/forecast-period[1]/element[@type='precipitation_range']");
while(list( , $node) = each($result)) {
echo $node;
}
?>
<br/>Forecast Icon Code:
<?php
$result = $xml->xpath("//area[3]/forecast-period[1]/element[@type='forecast_icon_code']");
while(list( , $node) = each($result)) {
echo $node;
}
?>