forked from lightmaster/Meteobridge-Weather34-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotify.php
211 lines (203 loc) · 11.2 KB
/
notify.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
208
209
210
211
<?php
if ($notifications == 'yes') {
# Check battery levels
if ($weather['consoleLowBattery'] || $weather['stationLowBattery']) {?>
<div id="weather34lightningdialog-notify">
<div class="weather34lightningdialog-box">
<div class="weather34lightningbackground-alert"></div>
<div class="header">
<div class="weather34lightningbackground-alert"></div>
<div class="weather34lightningcontents">
<div class="left"><?php echo $notifyAlert.' '.$lang['notifyAlert'];?></div>
<div class="right"><?php echo date ("D H:i")?></div>
</div>
</div>
<div class="weather34lightningcontents weather34lightningmain-content">
<?php echo $lang['notifyLowBatteryAlert'];?><br/>
<notifyred>
<?php if ($weather['consoleLowBattery'] && $weather['stationLowBattery']) {
echo $lang['notifyConsoleLowBattery'].'<br/>';
echo $lang['notifyStationLowBattery'];
} else if ($weather['consoleLowBattery']) {
echo $lang['notifyConsoleLowBattery'];
} else if ($weather['stationLowBattery']){
echo $lang['notifyStationLowBattery'];
} else {?>
Not sure why you're seeing this...
<?php }?>
</notifyred>
</div>
</div>
</div>
<?php }
//WEATHER34 pure css UV-Index above 8 pop up alert
if ($weather["uv"]>=8){?>
<div id="weather34lightningdialog-notify">
<div class="weather34lightningdialog-box">
<div class="weather34lightningbackground-alert"></div>
<div class="header">
<div class="weather34lightningbackground-alert"></div>
<div class="weather34lightningcontents">
<div class="left"><?php echo $notification.' '.$lang['notifyTitle'];?></div>
<div class="right"><?php echo date ("D H:i")?></div>
</div>
</div>
<div class="weather34lightningcontents weather34lightningmain-content">
<?php echo $lang['notifyUVIndex'];?><br/>
<?php echo $lang['notifyUVExposure'];?> <notifyorange><?php echo $weather["uv"];?></notifyorange><?php echo $uvisvg;?>
</div>
</div>
</div>
<?php }
//WEATHER34 pure css temperature heat index above 30c/84F pop up alert
if(anyToC($weather["heat_index"])>=30){?>
<div id="weather34lightningdialog-notify">
<div class="weather34lightningdialog-box">
<div class="weather34lightningbackground-alert"></div>
<div class="header">
<div class="weather34lightningbackground-alert"></div>
<div class="weather34lightningcontents">
<div class="left"><?php echo $notification.' '.$lang['notifyTitle'];?></div>
<div class="right"><?php echo date ("D H:i")?></div>
</div>
</div>
<div class="weather34lightningcontents weather34lightningmain-content">
<?php echo $lang['Heatindexalert'];?><br/>
<?php echo $lang['notifyHeatExaustion'];?> <notifyorange><?php echo $weather["heat_index"];?>°<?php echo $weather["temp_units"];?></notifyorange>
</div>
</div>
</div>
<?php }
//WEATHER34 pure css wind gusts of 40kmh to Gale Force pop up alert
if ($notifyWind == 'yes') {
if($weather["wind_gust_speed"]*$toKnots>=39.9 || $weather["wind_speed_avg30"]*$toKnots>=21.7){?>
<div id="weather34lightningdialog-notify">
<div class="weather34lightningdialog-box">
<div class="weather34lightningbackground-alert"></div>
<div class="header">
<div class="weather34lightningbackground-alert"></div>
<div class="weather34lightningcontents">
<div class="left"><?php echo $notification.' '.$lang['notifyTitle'];?></div>
<div class="right"><?php echo date ("D H:i")?></div>
</div>
</div>
<div class="weather34lightningcontents weather34lightningmain-content">
<?php if ($weather["wind_gust_speed"]*$toKnots>=99.9 || $weather["wind_speed"]*$toKnots>=99.9) {?>
<?php echo $lang['notifyExtremeWind'];?><br/>
<?php echo $lang['notifyGustUpTo'];?> <notifyred><?php echo $weather["wind_gust_speed"];?></notifyred> <?php echo $weather["wind_units"];?><br/>
<?php echo $lang['notifySeekShelter'];
} else if($weather["wind_gust_speed"]*$toKnots>=50 || $weather["wind_speed_avg30"]*$toKnots>=34) {?>
<?php echo $lang['notifyHighWindWarning'];?><br/>
<?php echo $lang['notifyGustUpTo'];?> <notifyorange><?php echo $weather["wind_gust_speed"];?></notifyorange> <?php echo $weather["wind_units"];?><br/>
<?php echo $lang['notifySustainedAvg'];?>: <notifyorange><?php echo $weather["wind_speed_avg30"];?></notifyorange> <?php echo $weather["wind_units"];
} else {?>
<?php echo $lang['notifyWindAdvisory'];?><br/>
<?php echo $lang['notifyGustUpTo'];?> <notifyorange><?php echo $weather["wind_gust_speed"];?></notifyorange> <?php echo $weather["wind_units"];?><br/>
<?php echo $lang['notifySustainedAvg'];?>: <notifyorange><?php echo $weather["wind_speed_avg30"];?></notifyorange> <?php echo $weather["wind_units"];
}?>
</div>
</div>
</div>
<?php }
}
//WEATHER34 pure css wind chill below 0c/32F pop up alert
if(anyToC($weather["windchill"])<=0){?>
<div id="weather34lightningdialog-notify">
<div class="weather34lightningdialog-box">
<div class="weather34lightningbackground-alert"></div>
<div class="header">
<div class="weather34lightningbackground-alert"></div>
<div class="weather34lightningcontents">
<div class="left"><?php echo $notification.' '.$lang['notifyTitle'];?></div>
<div class="right"><?php echo date ("D H:i")?></div>
</div>
</div>
<div class="weather34lightningcontents weather34lightningmain-content">
<?php echo $freezing.' '.$lang['Windchillalert'];?><br/>
<?php echo $lang['notifyFreezing'];?> <notifyblue><?php echo $weather["windchill"];?>°<?php echo $weather["temp_units"];?></notifyblue>
</div>
</div>
</div>
<?php }
//WEATHER34 pure css near freezing dewpoint below 0c/32F pop up alert
if(anyToC($weather["dewpoint"])<=0){?>
<div id="weather34lightningdialog-notify">
<div class="weather34lightningdialog-box">
<div class="weather34lightningbackground-alert"></div>
<div class="header">
<div class="weather34lightningbackground-alert"></div>
<div class="weather34lightningcontents">
<div class="left"><?php echo $notification.' '.$lang['notifyTitle'];?></div>
<div class="right"><?php echo date ("D H:i")?></div>
</div>
</div>
<div class="weather34lightningcontents weather34lightningmain-content">
<?php echo $freezing.$lang['Dewpointcolderalert'];?><br/>
<?php echo $lang['notifyFreezing'];?> <notifyblue><?php echo $weather["dewpoint"];?>°<?php echo $weather["temp_units"];?></notifyblue>
</div>
</div>
</div>
<?php }
if ($notifyEarthquake == 'yes') {
//earthquakes magnitude 6+
date_default_timezone_set($TZ);
$json_string=file_get_contents('jsondata/eqnotification.txt');
$parsed_json=json_decode($json_string,true);
$magnitude = array();
$eqtitle = array();
$depth = array();
$time = array();
$lati = array();
$longi = array();
$eventime = array();
for ($i = 0; $i < 100; $i++) {
$magnitude[$i]=$parsed_json{$i}{'magnitude'};
$eqtitle[$i]=$parsed_json{$i}['title'];
$depth[$i]=$parsed_json{$i}['depth'];
$time[$i]=$parsed_json{$i}['date_time'];
$lati[$i]=$parsed_json{$i}['latitude'];
$longi[$i]=$parsed_json{$i}['longitude'];
$eventime[$i]=date($timeFormatShort, strtotime($time[$i]));
$eqdist[$i] = round(distance($lat, $lon, $lati[$i], $longi[$i]));
}
//WEATHER34 pure css earthquake >6.5 pop up alert
for ($i = 0; $i <=0; $i++){
if($magnitude[$i]>=$notifyMagnitude){?>
<div id="weather34lightningdialog-notify">
<div class="weather34lightningdialog-box">
<div class="weather34lightningbackground-alert"></div>
<div class="header">
<div class="weather34lightningbackground-alert"></div>
<div class="weather34lightningcontents">
<div class="left"><?php echo $notification.' '.$lang['notifyTitle'];?></div>
<div class="right"><?php echo date ("D H:i")?></div>
</div>
</div>
<div class="weather34lightningcontents weather34lightningmain-content">
<?php if ($magnitude[$i] >= 8) {
echo $lang['GreatE'];
} elseif ($magnitude[$i] >= 7) {
echo $lang['MajorE'];
} elseif ($magnitude[$i] >= 6) {
echo $lang['StrongE'];
} elseif ($magnitude[$i] >= 5) {
echo $lang['ModerateE'];
} elseif ($magnitude[$i] >= 4) {
echo $lang['LightE'];
} elseif ($magnitude[$i] >= 3) {
echo $lang['MinorE'];
} elseif ($magnitude[$i] >= 1) {
echo $lang['MicroE'];
} else {
echo $lang['Earthquake'];
}?>
<notifyorange><?php echo $magnitude[$i];?></notifyorange>
<br/>
<?php echo $eqtitle[$i]." ".$eventime[$i];?>
</div>
</div>
</div>
<?php }
}
}
}?>