@@ -5,8 +5,11 @@ discard block |
||
5 | 5 | setcookie("MapFormat",'2d'); |
6 | 6 | |
7 | 7 | // Compressed GeoJson is used if true |
8 | -if (!isset($globalJsonCompress)) $compress = true; |
|
9 | -else $compress = $globalJsonCompress; |
|
8 | +if (!isset($globalJsonCompress)) { |
|
9 | + $compress = true; |
|
10 | +} else { |
|
11 | + $compress = $globalJsonCompress; |
|
12 | +} |
|
10 | 13 | ?> |
11 | 14 | |
12 | 15 | |
@@ -157,9 +160,13 @@ discard block |
||
157 | 160 | if (callsign != ""){ markerTrackerLabel += callsign; } |
158 | 161 | if (type != ""){ markerTrackerLabel += ' - '+type; } |
159 | 162 | <?php |
160 | - if (isset($_COOKIE['TrackerIconColor'])) $IconColor = $_COOKIE['TrackerIconColor']; |
|
161 | - elseif (isset($globalTrackerIconColor)) $IconColor = $globalTrackerIconColor; |
|
162 | - else $IconColor = '1a3151'; |
|
163 | + if (isset($_COOKIE['TrackerIconColor'])) { |
|
164 | + $IconColor = $_COOKIE['TrackerIconColor']; |
|
165 | + } elseif (isset($globalTrackerIconColor)) { |
|
166 | + $IconColor = $globalTrackerIconColor; |
|
167 | + } else { |
|
168 | + $IconColor = '1a3151'; |
|
169 | + } |
|
163 | 170 | if (!isset($ident) && !isset($famtrackid)) { |
164 | 171 | ?> |
165 | 172 | //info_tracker_update(feature.properties.fc); |
@@ -193,7 +200,12 @@ discard block |
||
193 | 200 | <?php |
194 | 201 | } else { |
195 | 202 | ?> |
196 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
203 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
204 | + print $archiveupdatetime*1000; |
|
205 | +} else { |
|
206 | + print $globalMapRefresh*1000+20000; |
|
207 | +} |
|
208 | +?>+feature.properties.sqt*1000); |
|
197 | 209 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
198 | 210 | <?php |
199 | 211 | } |
@@ -249,7 +261,12 @@ discard block |
||
249 | 261 | <?php |
250 | 262 | } else { |
251 | 263 | ?> |
252 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
264 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
265 | + print $archiveupdatetime*1000; |
|
266 | +} else { |
|
267 | + print $globalMapRefresh*1000+20000; |
|
268 | +} |
|
269 | +?>+feature.properties.sqt*1000); |
|
253 | 270 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
254 | 271 | <?php |
255 | 272 | } |
@@ -304,7 +321,12 @@ discard block |
||
304 | 321 | <?php |
305 | 322 | } else { |
306 | 323 | ?> |
307 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
324 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
325 | + print $archiveupdatetime*1000; |
|
326 | +} else { |
|
327 | + print $globalMapRefresh*1000+20000; |
|
328 | +} |
|
329 | +?>+feature.properties.sqt*1000); |
|
308 | 330 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
309 | 331 | <?php |
310 | 332 | } |
@@ -595,14 +617,24 @@ discard block |
||
595 | 617 | if (isset($archive) && $archive) { |
596 | 618 | ?> |
597 | 619 | //then load it again every 30 seconds |
598 | -// var reload = setInterval(function(){if (noTimeout) getLiveTrackerData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>); |
|
620 | +// var reload = setInterval(function(){if (noTimeout) getLiveTrackerData(0)},<?php if (isset($globalMapRefresh)) { |
|
621 | + print ($globalMapRefresh*1000)/2; |
|
622 | +} else { |
|
623 | + print '15000'; |
|
624 | +} |
|
625 | +?>); |
|
599 | 626 | reloadTrackerPage = setInterval(function(){if (noTimeout) getLiveTrackerData(0)},<?php print $archiveupdatetime*1000; ?>); |
600 | 627 | <?php |
601 | 628 | } else { |
602 | 629 | ?> |
603 | 630 | //then load it again every 30 seconds |
604 | 631 | reloadTrackerPage = setInterval( |
605 | - function(){if (noTimeout) getLiveTrackerData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
632 | + function(){if (noTimeout) getLiveTrackerData(0)},<?php if (isset($globalMapRefresh)) { |
|
633 | + print $globalMapRefresh*1000; |
|
634 | +} else { |
|
635 | + print '30000'; |
|
636 | +} |
|
637 | +?>); |
|
606 | 638 | <?php |
607 | 639 | } |
608 | 640 | ?> |
@@ -74,7 +74,9 @@ discard block |
||
74 | 74 | if ($error != '') { |
75 | 75 | $_SESSION['error'] = $error; |
76 | 76 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create database')); |
77 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
77 | + } else { |
|
78 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
79 | + } |
|
78 | 80 | $_SESSION['install'] = 'database_import'; |
79 | 81 | $_SESSION['next'] = 'Create and import tables'; |
80 | 82 | $result = array('error' => $error,'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -89,7 +91,9 @@ discard block |
||
89 | 91 | if ($error != '') { |
90 | 92 | $_SESSION['error'] = $error; |
91 | 93 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
92 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
94 | + } else { |
|
95 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
96 | + } |
|
93 | 97 | if ($globalSBS1 && !$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
94 | 98 | $_SESSION['install'] = 'populate'; |
95 | 99 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B'; |
@@ -104,7 +108,9 @@ discard block |
||
104 | 108 | if ($error != '') { |
105 | 109 | $_SESSION['error'] = $error; |
106 | 110 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Update schema if needed')); |
107 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
111 | + } else { |
|
112 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
113 | + } |
|
108 | 114 | $_SESSION['install'] = 'sources'; |
109 | 115 | $_SESSION['next'] = 'Insert data in source table'; |
110 | 116 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -117,7 +123,9 @@ discard block |
||
117 | 123 | if ($error != '') { |
118 | 124 | $_SESSION['error'] = $error; |
119 | 125 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate waypoints database')); |
120 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
126 | + } else { |
|
127 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
128 | + } |
|
121 | 129 | $_SESSION['install'] = 'airspace'; |
122 | 130 | $_SESSION['next'] = 'Populate airspace table'; |
123 | 131 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -129,7 +137,9 @@ discard block |
||
129 | 137 | if ($error != '') { |
130 | 138 | $_SESSION['error'] = $error; |
131 | 139 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate airspace database')); |
132 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate airspace database')); |
|
140 | + } else { |
|
141 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate airspace database')); |
|
142 | + } |
|
133 | 143 | $_SESSION['install'] = 'countries'; |
134 | 144 | $_SESSION['next'] = 'Populate countries table'; |
135 | 145 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -141,7 +151,9 @@ discard block |
||
141 | 151 | if ($error != '') { |
142 | 152 | $_SESSION['error'] = $error; |
143 | 153 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database')); |
144 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
154 | + } else { |
|
155 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
156 | + } |
|
145 | 157 | if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
146 | 158 | $_SESSION['install'] = 'notam'; |
147 | 159 | $_SESSION['next'] = 'Populate NOTAM table with externals data'; |
@@ -173,7 +185,9 @@ discard block |
||
173 | 185 | if ($error != '') { |
174 | 186 | $_SESSION['error'] = $error; |
175 | 187 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
176 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
188 | + } else { |
|
189 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
190 | + } |
|
177 | 191 | $_SESSION['install'] = 'populate_flarm'; |
178 | 192 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for FLARM'; |
179 | 193 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -194,18 +208,26 @@ discard block |
||
194 | 208 | if ($error != '') { |
195 | 209 | $_SESSION['error'] = $error; |
196 | 210 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM')); |
197 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
211 | + } else { |
|
212 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
213 | + } |
|
198 | 214 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
199 | 215 | $_SESSION['install'] = 'vatsim'; |
200 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
201 | - else $_SESSION['next'] = 'Insert VATSIM data'; |
|
216 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
217 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
218 | + } else { |
|
219 | + $_SESSION['next'] = 'Insert VATSIM data'; |
|
220 | + } |
|
202 | 221 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
203 | 222 | $_SESSION['install'] = 'vatsim'; |
204 | 223 | $_SESSION['next'] = 'Insert VATSIM data'; |
205 | 224 | } elseif (isset($globalIVAO) && $globalIVAO) { |
206 | 225 | $_SESSION['install'] = 'vatsim'; |
207 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
208 | - else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
226 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
227 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
228 | + } else { |
|
229 | + $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
230 | + } |
|
209 | 231 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
210 | 232 | $_SESSION['install'] = 'vatsim'; |
211 | 233 | $_SESSION['next'] = 'Insert phpVMS data'; |
@@ -230,7 +252,9 @@ discard block |
||
230 | 252 | if ($error != '') { |
231 | 253 | $_SESSION['error'] = $error; |
232 | 254 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate routes table with externals data')); |
233 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
255 | + } else { |
|
256 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
257 | + } |
|
234 | 258 | $_SESSION['install'] = 'translation'; |
235 | 259 | $_SESSION['next'] = 'Populate translation table with externals data'; |
236 | 260 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -250,7 +274,9 @@ discard block |
||
250 | 274 | if ($error != '') { |
251 | 275 | $_SESSION['error'] = $error; |
252 | 276 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data')); |
253 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
277 | + } else { |
|
278 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
279 | + } |
|
254 | 280 | if ($_SESSION['waypoints'] == 1) { |
255 | 281 | $_SESSION['install'] = 'waypoints'; |
256 | 282 | $_SESSION['next'] = 'Populate waypoints table'; |
@@ -283,7 +309,9 @@ discard block |
||
283 | 309 | if ($error != '') { |
284 | 310 | $_SESSION['error'] = $error; |
285 | 311 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data')); |
286 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
312 | + } else { |
|
313 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
314 | + } |
|
287 | 315 | $_SESSION['install'] = 'sources'; |
288 | 316 | $_SESSION['next'] = 'Insert data in source table'; |
289 | 317 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -304,12 +332,16 @@ discard block |
||
304 | 332 | if ($error != '') { |
305 | 333 | $_SESSION['error'] = $error; |
306 | 334 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data')); |
307 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
335 | + } else { |
|
336 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
337 | + } |
|
308 | 338 | } else { |
309 | 339 | if ($error != '') { |
310 | 340 | $_SESSION['error'] = $error; |
311 | 341 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data (no source defined)')); |
312 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
342 | + } else { |
|
343 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
344 | + } |
|
313 | 345 | } |
314 | 346 | if (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) { |
315 | 347 | $_SESSION['install'] = 'owner'; |
@@ -357,7 +389,9 @@ discard block |
||
357 | 389 | $Source = new Source(); |
358 | 390 | $Source->deleteAllLocation(); |
359 | 391 | foreach ($sources as $src) { |
360 | - if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
392 | + if (isset($src['latitude']) && $src['latitude'] != '') { |
|
393 | + $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
394 | + } |
|
361 | 395 | } |
362 | 396 | $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert data in source table')); |
363 | 397 | unset($_SESSION['sources']); |
@@ -368,15 +402,21 @@ discard block |
||
368 | 402 | */ |
369 | 403 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
370 | 404 | $_SESSION['install'] = 'vatsim'; |
371 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
372 | - else $_SESSION['next'] = 'Insert VATSIM data'; |
|
405 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
406 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
407 | + } else { |
|
408 | + $_SESSION['next'] = 'Insert VATSIM data'; |
|
409 | + } |
|
373 | 410 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
374 | 411 | $_SESSION['install'] = 'vatsim'; |
375 | 412 | $_SESSION['next'] = 'Insert VATSIM data'; |
376 | 413 | } elseif (isset($globalIVAO) && $globalIVAO) { |
377 | 414 | $_SESSION['install'] = 'vatsim'; |
378 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
379 | - else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
415 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
416 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
417 | + } else { |
|
418 | + $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
419 | + } |
|
380 | 420 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
381 | 421 | $_SESSION['install'] = 'vatsim'; |
382 | 422 | $_SESSION['next'] = 'Insert phpVMS data'; |
@@ -397,33 +437,43 @@ discard block |
||
397 | 437 | if ($error != '') { |
398 | 438 | $_SESSION['error'] = $error; |
399 | 439 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
400 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
440 | + } else { |
|
441 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
442 | + } |
|
401 | 443 | } else { |
402 | 444 | $error .= update_db::update_vatsim(); |
403 | 445 | if ($error != '') { |
404 | 446 | $_SESSION['error'] = $error; |
405 | 447 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
406 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
448 | + } else { |
|
449 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
450 | + } |
|
407 | 451 | } |
408 | 452 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
409 | 453 | $error .= update_db::update_vatsim(); |
410 | 454 | if ($error != '') { |
411 | 455 | $_SESSION['error'] = $error; |
412 | 456 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
413 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
457 | + } else { |
|
458 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
459 | + } |
|
414 | 460 | } elseif (isset($globalIVAO) && $globalIVAO) { |
415 | 461 | if (file_exists('tmp/ivae_feb2013.zip')) { |
416 | 462 | $error .= update_db::update_IVAO(); |
417 | 463 | if ($error != '') { |
418 | 464 | $_SESSION['error'] = $error; |
419 | 465 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
420 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
466 | + } else { |
|
467 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
468 | + } |
|
421 | 469 | } else { |
422 | 470 | $error .= update_db::update_vatsim(); |
423 | 471 | if ($error != '') { |
424 | 472 | $_SESSION['error'] = $error; |
425 | 473 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data (IVAO not found)')); |
426 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
474 | + } else { |
|
475 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
476 | + } |
|
427 | 477 | } |
428 | 478 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
429 | 479 | $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert phpVMS data')); |
@@ -10,7 +10,9 @@ discard block |
||
10 | 10 | public static function import_file($filename) { |
11 | 11 | $filename = filter_var($filename,FILTER_SANITIZE_STRING); |
12 | 12 | $Connection = new Connection(); |
13 | - if (!$Connection->connectionExists()) return 'error: DB connection failed'; |
|
13 | + if (!$Connection->connectionExists()) { |
|
14 | + return 'error: DB connection failed'; |
|
15 | + } |
|
14 | 16 | //Connection::$db->beginTransaction(); |
15 | 17 | $templine = ''; |
16 | 18 | $handle = @fopen($filename,"r"); |
@@ -19,7 +21,9 @@ discard block |
||
19 | 21 | //foreach ($lines as $line) |
20 | 22 | while (($line = fgets($handle,4096)) !== false) |
21 | 23 | { |
22 | - if (substr($line,0,2) == '--' || $line == '') continue; |
|
24 | + if (substr($line,0,2) == '--' || $line == '') { |
|
25 | + continue; |
|
26 | + } |
|
23 | 27 | $templine .= $line; |
24 | 28 | if (substr(trim($line), -1,1) == ';') |
25 | 29 | { |
@@ -45,7 +49,9 @@ discard block |
||
45 | 49 | //foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename) |
46 | 50 | while(false !== ($filename = readdir($dh))) |
47 | 51 | { |
48 | - if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename); |
|
52 | + if (preg_match('/\.sql$/',$filename)) { |
|
53 | + $error .= create_db::import_file($directory.$filename); |
|
54 | + } |
|
49 | 55 | } |
50 | 56 | return $error; |
51 | 57 | } |
@@ -58,19 +64,29 @@ discard block |
||
58 | 64 | $db = filter_var($db,FILTER_SANITIZE_STRING); |
59 | 65 | $db_type = filter_var($db_type,FILTER_SANITIZE_STRING); |
60 | 66 | $host = filter_var($host,FILTER_SANITIZE_STRING); |
61 | - if ($db_type == 'mysql' && $port == '') $port = 3306; |
|
62 | - elseif ($port == '') $port = 5432; |
|
67 | + if ($db_type == 'mysql' && $port == '') { |
|
68 | + $port = 3306; |
|
69 | + } elseif ($port == '') { |
|
70 | + $port = 5432; |
|
71 | + } |
|
63 | 72 | // Dirty hack |
64 | 73 | if ($host != 'localhost' && $host != '127.0.0.1') { |
65 | 74 | $grantright = $_SERVER['SERVER_ADDR']; |
66 | - } else $grantright = 'localhost'; |
|
75 | + } else { |
|
76 | + $grantright = 'localhost'; |
|
77 | + } |
|
67 | 78 | try { |
68 | - if ($host == 'localhost') $dbh = new PDO($db_type.':host=127.0.0.1',$root,$root_pass); |
|
69 | - else $dbh = new PDO($db_type.':host='.$host.';port='.$port,$root,$root_pass); |
|
79 | + if ($host == 'localhost') { |
|
80 | + $dbh = new PDO($db_type.':host=127.0.0.1',$root,$root_pass); |
|
81 | + } else { |
|
82 | + $dbh = new PDO($db_type.':host='.$host.';port='.$port,$root,$root_pass); |
|
83 | + } |
|
70 | 84 | $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
71 | 85 | if ($db_type == 'mysql') { |
72 | 86 | $dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
73 | - if ($grantright == 'localhost') $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
|
87 | + if ($grantright == 'localhost') { |
|
88 | + $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
|
89 | + } |
|
74 | 90 | } else if ($db_type == 'pgsql') { |
75 | 91 | $dbh->exec("CREATE DATABASE ".$db.";"); |
76 | 92 | $dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."'; |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | public function __construct($dbc = null) { |
13 | 13 | $Connection = new Connection($dbc); |
14 | 14 | $this->db = $Connection->db(); |
15 | - if ($this->db === null) die('Error: No DB connection.'); |
|
15 | + if ($this->db === null) { |
|
16 | + die('Error: No DB connection.'); |
|
17 | + } |
|
16 | 18 | } |
17 | 19 | |
18 | 20 | public function get_tle($name) { |
@@ -24,8 +26,11 @@ discard block |
||
24 | 26 | echo $e->getMessage(); |
25 | 27 | } |
26 | 28 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
27 | - if (isset($result[0])) return $result[0]; |
|
28 | - else return array(); |
|
29 | + if (isset($result[0])) { |
|
30 | + return $result[0]; |
|
31 | + } else { |
|
32 | + return array(); |
|
33 | + } |
|
29 | 34 | } |
30 | 35 | public function get_tle_types() { |
31 | 36 | $query = 'SELECT DISTINCT tle_type FROM tle ORDER BY tle_type'; |
@@ -36,8 +41,11 @@ discard block |
||
36 | 41 | echo $e->getMessage(); |
37 | 42 | } |
38 | 43 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
39 | - if (isset($result[0])) return $result; |
|
40 | - else return array(); |
|
44 | + if (isset($result[0])) { |
|
45 | + return $result; |
|
46 | + } else { |
|
47 | + return array(); |
|
48 | + } |
|
41 | 49 | } |
42 | 50 | public function get_tle_names() { |
43 | 51 | $query = 'SELECT DISTINCT tle_name, tle_type FROM tle'; |
@@ -48,8 +56,11 @@ discard block |
||
48 | 56 | echo $e->getMessage(); |
49 | 57 | } |
50 | 58 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
51 | - if (isset($result[0])) return $result; |
|
52 | - else return array(); |
|
59 | + if (isset($result[0])) { |
|
60 | + return $result; |
|
61 | + } else { |
|
62 | + return array(); |
|
63 | + } |
|
53 | 64 | } |
54 | 65 | public function get_tle_names_type($type) { |
55 | 66 | $query = 'SELECT tle_name, tle_type FROM tle WHERE tle_type = :type ORDER BY tle_name'; |
@@ -60,8 +71,11 @@ discard block |
||
60 | 71 | echo $e->getMessage(); |
61 | 72 | } |
62 | 73 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
63 | - if (isset($result[0])) return $result; |
|
64 | - else return array(); |
|
74 | + if (isset($result[0])) { |
|
75 | + return $result; |
|
76 | + } else { |
|
77 | + return array(); |
|
78 | + } |
|
65 | 79 | } |
66 | 80 | |
67 | 81 | public function position_all($timestamp_begin = '',$timestamp_end = '',$second = 10) { |
@@ -79,8 +93,11 @@ discard block |
||
79 | 93 | $result = array(); |
80 | 94 | foreach ($all_sat as $sat) { |
81 | 95 | $position = $this->position($sat['tle_name'],$timestamp_begin,$timestamp_end,$second); |
82 | - if (isset($position[0])) $result = array_merge($position,$result); |
|
83 | - else $result[] = $position; |
|
96 | + if (isset($position[0])) { |
|
97 | + $result = array_merge($position,$result); |
|
98 | + } else { |
|
99 | + $result[] = $position; |
|
100 | + } |
|
84 | 101 | } |
85 | 102 | return $result; |
86 | 103 | } |
@@ -96,7 +113,9 @@ discard block |
||
96 | 113 | $sat = new Predict_Sat($tle); |
97 | 114 | $predict = new Predict(); |
98 | 115 | //if ($timestamp == '') $now = Predict_Time::get_current_daynum(); |
99 | - if ($timestamp_begin == '') $timestamp_begin = time(); |
|
116 | + if ($timestamp_begin == '') { |
|
117 | + $timestamp_begin = time(); |
|
118 | + } |
|
100 | 119 | if ($timestamp_end == '') { |
101 | 120 | $now = Predict_Time::unix2daynum($timestamp_begin); |
102 | 121 | $predict->predict_calc($sat,$qth,$now); |
@@ -121,8 +140,11 @@ discard block |
||
121 | 140 | echo $e->getMessage(); |
122 | 141 | } |
123 | 142 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
124 | - if (isset($result[0])) return $result[0]; |
|
125 | - else return array(); |
|
143 | + if (isset($result[0])) { |
|
144 | + return $result[0]; |
|
145 | + } else { |
|
146 | + return array(); |
|
147 | + } |
|
126 | 148 | } |
127 | 149 | |
128 | 150 | /** |
@@ -140,7 +162,9 @@ discard block |
||
140 | 162 | FROM satellite".$filter_query." satellite.launch_site <> '' AND satellite.launch_site IS NOT NULL"; |
141 | 163 | $query_values = array(); |
142 | 164 | $query .= " GROUP BY satellite.launch_site ORDER BY launch_site_count DESC"; |
143 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
165 | + if ($limit) { |
|
166 | + $query .= " LIMIT 10 OFFSET 0"; |
|
167 | + } |
|
144 | 168 | $sth = $this->db->prepare($query); |
145 | 169 | $sth->execute($query_values); |
146 | 170 | $launch_site_array = array(); |
@@ -169,7 +193,9 @@ discard block |
||
169 | 193 | FROM satellite".$filter_query." satellite.owner <> '' AND satellite.owner IS NOT NULL"; |
170 | 194 | $query_values = array(); |
171 | 195 | $query .= " GROUP BY satellite.owner ORDER BY owner_count DESC"; |
172 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
196 | + if ($limit) { |
|
197 | + $query .= " LIMIT 10 OFFSET 0"; |
|
198 | + } |
|
173 | 199 | $sth = $this->db->prepare($query); |
174 | 200 | $sth->execute($query_values); |
175 | 201 | $owner_array = array(); |
@@ -198,7 +224,9 @@ discard block |
||
198 | 224 | FROM satellite".$filter_query." satellite.country_owner <> '' AND satellite.country_owner IS NOT NULL"; |
199 | 225 | $query_values = array(); |
200 | 226 | $query .= " GROUP BY satellite.country_owner ORDER BY country_count DESC"; |
201 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
227 | + if ($limit) { |
|
228 | + $query .= " LIMIT 10 OFFSET 0"; |
|
229 | + } |
|
202 | 230 | $sth = $this->db->prepare($query); |
203 | 231 | $sth->execute($query_values); |
204 | 232 | $owner_array = array(); |
@@ -225,20 +253,26 @@ discard block |
||
225 | 253 | date_default_timezone_set($globalTimezone); |
226 | 254 | $datetime = new DateTime(); |
227 | 255 | $offset = $datetime->format('P'); |
228 | - } else $offset = '+00:00'; |
|
256 | + } else { |
|
257 | + $offset = '+00:00'; |
|
258 | + } |
|
229 | 259 | //$filter_query = $this->getFilter($filters,true,true); |
230 | 260 | $filter_query = ' WHERE'; |
231 | 261 | if ($globalDBdriver == 'mysql') { |
232 | 262 | $query = "SELECT MONTH(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS year_name, count(*) as date_count |
233 | 263 | FROM satellite".$filter_query." satellite.launch_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
234 | - if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
264 | + if ($sincedate != '') { |
|
265 | + $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
266 | + } |
|
235 | 267 | $query .= " GROUP BY year_name, month_name |
236 | 268 | ORDER BY year_name, month_name ASC"; |
237 | 269 | $query_data = array(':offset' => $offset); |
238 | 270 | } else { |
239 | 271 | $query = "SELECT EXTRACT(MONTH FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS month_name, EXTRACT(YEAR FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count |
240 | 272 | FROM satellite".$filter_query." satellite.launch_date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 YEARS'"; |
241 | - if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
273 | + if ($sincedate != '') { |
|
274 | + $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
275 | + } |
|
242 | 276 | $query .= " GROUP BY year_name, month_name |
243 | 277 | ORDER BY year_name, month_name ASC"; |
244 | 278 | $query_data = array(':offset' => $offset); |
@@ -270,20 +304,26 @@ discard block |
||
270 | 304 | date_default_timezone_set($globalTimezone); |
271 | 305 | $datetime = new DateTime(); |
272 | 306 | $offset = $datetime->format('P'); |
273 | - } else $offset = '+00:00'; |
|
307 | + } else { |
|
308 | + $offset = '+00:00'; |
|
309 | + } |
|
274 | 310 | //$filter_query = $this->getFilter($filters,true,true); |
275 | 311 | $filter_query = ' WHERE'; |
276 | 312 | if ($globalDBdriver == 'mysql') { |
277 | 313 | $query = "SELECT YEAR(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS year_name, count(*) as date_count |
278 | 314 | FROM satellite".$filter_query." satellite.launch_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 YEAR)"; |
279 | - if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
315 | + if ($sincedate != '') { |
|
316 | + $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
317 | + } |
|
280 | 318 | $query .= " GROUP BY year_name |
281 | 319 | ORDER BY year_name ASC"; |
282 | 320 | $query_data = array(':offset' => $offset); |
283 | 321 | } else { |
284 | 322 | $query = "SELECT EXTRACT(YEAR FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count |
285 | 323 | FROM satellite".$filter_query." satellite.launch_date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '10 YEARS'"; |
286 | - if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
324 | + if ($sincedate != '') { |
|
325 | + $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
326 | + } |
|
287 | 327 | $query .= " GROUP BY year_name |
288 | 328 | ORDER BY year_name ASC"; |
289 | 329 | $query_data = array(':offset' => $offset); |
@@ -5,8 +5,11 @@ discard block |
||
5 | 5 | setcookie("MapFormat",'2d'); |
6 | 6 | |
7 | 7 | // Compressed GeoJson is used if true |
8 | -if (!isset($globalJsonCompress)) $compress = true; |
|
9 | -else $compress = $globalJsonCompress; |
|
8 | +if (!isset($globalJsonCompress)) { |
|
9 | + $compress = true; |
|
10 | +} else { |
|
11 | + $compress = $globalJsonCompress; |
|
12 | +} |
|
10 | 13 | $compress = false; |
11 | 14 | ?> |
12 | 15 | |
@@ -159,9 +162,13 @@ discard block |
||
159 | 162 | if (callsign != ""){ markerSatelliteLabel += callsign; } |
160 | 163 | if (type != ""){ markerSatelliteLabel += ' - '+type; } |
161 | 164 | <?php |
162 | - if (isset($_COOKIE['SatelliteIconColor'])) $IconColor = $_COOKIE['SatelliteIconColor']; |
|
163 | - elseif (isset($globalSatelliteIconColor)) $IconColor = $globalSatelliteIconColor; |
|
164 | - else $IconColor = '1a3151'; |
|
165 | + if (isset($_COOKIE['SatelliteIconColor'])) { |
|
166 | + $IconColor = $_COOKIE['SatelliteIconColor']; |
|
167 | + } elseif (isset($globalSatelliteIconColor)) { |
|
168 | + $IconColor = $globalSatelliteIconColor; |
|
169 | + } else { |
|
170 | + $IconColor = '1a3151'; |
|
171 | + } |
|
165 | 172 | if (!isset($ident) && !isset($famsatid)) { |
166 | 173 | ?> |
167 | 174 | info_satellite_update(feature.properties.fc); |
@@ -195,7 +202,12 @@ discard block |
||
195 | 202 | <?php |
196 | 203 | } else { |
197 | 204 | ?> |
198 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
205 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
206 | + print $archiveupdatetime*1000; |
|
207 | +} else { |
|
208 | + print $globalMapRefresh*1000+20000; |
|
209 | +} |
|
210 | +?>+feature.properties.sqt*1000); |
|
199 | 211 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
200 | 212 | <?php |
201 | 213 | } |
@@ -251,7 +263,12 @@ discard block |
||
251 | 263 | <?php |
252 | 264 | } else { |
253 | 265 | ?> |
254 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
266 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
267 | + print $archiveupdatetime*1000; |
|
268 | +} else { |
|
269 | + print $globalMapRefresh*1000+20000; |
|
270 | +} |
|
271 | +?>+feature.properties.sqt*1000); |
|
255 | 272 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
256 | 273 | <?php |
257 | 274 | } |
@@ -306,7 +323,12 @@ discard block |
||
306 | 323 | <?php |
307 | 324 | } else { |
308 | 325 | ?> |
309 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
326 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
327 | + print $archiveupdatetime*1000; |
|
328 | +} else { |
|
329 | + print $globalMapRefresh*1000+20000; |
|
330 | +} |
|
331 | +?>+feature.properties.sqt*1000); |
|
310 | 332 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
311 | 333 | <?php |
312 | 334 | } |
@@ -601,14 +623,24 @@ discard block |
||
601 | 623 | if (isset($archive) && $archive) { |
602 | 624 | ?> |
603 | 625 | //then load it again every 30 seconds |
604 | -// var reload = setInterval(function(){if (noTimeout) updateSat(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>); |
|
626 | +// var reload = setInterval(function(){if (noTimeout) updateSat(0)},<?php if (isset($globalMapRefresh)) { |
|
627 | + print ($globalMapRefresh*1000)/2; |
|
628 | +} else { |
|
629 | + print '15000'; |
|
630 | +} |
|
631 | +?>); |
|
605 | 632 | reloadSatellitePage = setInterval(function(){if (noTimeout) updateSat(0)},<?php print $archiveupdatetime*1000; ?>); |
606 | 633 | <?php |
607 | 634 | } else { |
608 | 635 | ?> |
609 | 636 | //then load it again every 30 seconds |
610 | 637 | reloadSatellitePage = setInterval( |
611 | - function(){if (noTimeout) updateSat(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
638 | + function(){if (noTimeout) updateSat(0)},<?php if (isset($globalMapRefresh)) { |
|
639 | + print $globalMapRefresh*1000; |
|
640 | +} else { |
|
641 | + print '30000'; |
|
642 | +} |
|
643 | +?>); |
|
612 | 644 | <?php |
613 | 645 | } |
614 | 646 | ?> |
@@ -64,13 +64,19 @@ discard block |
||
64 | 64 | $nextlatlon = $Satellite->position($spotter_item['name'],time()+$globalMapRefresh+20); |
65 | 65 | $nextlat = $nextlatlon['latitude']; |
66 | 66 | if (abs($nextlat-$spotter_item['latitude']) > 90) { |
67 | - if ($spotter_item['latitude'] < 0) $nexlat = -90; |
|
68 | - else $nexlat = 90; |
|
67 | + if ($spotter_item['latitude'] < 0) { |
|
68 | + $nexlat = -90; |
|
69 | + } else { |
|
70 | + $nexlat = 90; |
|
71 | + } |
|
69 | 72 | } |
70 | 73 | $nextlon = $nextlatlon['longitude']; |
71 | 74 | if (abs($nextlon-$spotter_item['longitude']) > 180) { |
72 | - if ($spotter_item['longitude'] < 0) $nextlon = -180; |
|
73 | - else $nextlon = 180; |
|
75 | + if ($spotter_item['longitude'] < 0) { |
|
76 | + $nextlon = -180; |
|
77 | + } else { |
|
78 | + $nextlon = 180; |
|
79 | + } |
|
74 | 80 | } |
75 | 81 | $output_data .= '"nextlatlon":['.$nextlat.','.$nextlon.']},'; |
76 | 82 | //$output_data .= '"heading":"'.$Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$nextlatlon['latitude'],$nextlatlon['longitude']).'",'; |
@@ -99,7 +105,9 @@ discard block |
||
99 | 105 | } |
100 | 106 | } |
101 | 107 | } |
102 | -if (isset($output_data)) $output = substr($output,0,-1); |
|
108 | +if (isset($output_data)) { |
|
109 | + $output = substr($output,0,-1); |
|
110 | +} |
|
103 | 111 | $output .= ']}'; |
104 | 112 | print $output; |
105 | 113 | ?> |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | public function __construct($dbc = null) { |
13 | 13 | $Connection = new Connection($dbc); |
14 | 14 | $this->db = $Connection->db(); |
15 | - if ($this->db === null) die('Error: No DB connection.'); |
|
15 | + if ($this->db === null) { |
|
16 | + die('Error: No DB connection.'); |
|
17 | + } |
|
16 | 18 | } |
17 | 19 | |
18 | 20 | /** |
@@ -124,7 +126,9 @@ discard block |
||
124 | 126 | $sth->closeCursor(); |
125 | 127 | if (count($row) > 0) { |
126 | 128 | return $row; |
127 | - } else return array(); |
|
129 | + } else { |
|
130 | + return array(); |
|
131 | + } |
|
128 | 132 | } |
129 | 133 | |
130 | 134 | public function checkSchedule($ident) { |
@@ -160,7 +164,9 @@ discard block |
||
160 | 164 | $Common = new Common(); |
161 | 165 | $check_date = new Datetime($date); |
162 | 166 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
163 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
167 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
168 | + return array(); |
|
169 | + } |
|
164 | 170 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
165 | 171 | $json = $Common->getData($url); |
166 | 172 | |
@@ -187,7 +193,9 @@ discard block |
||
187 | 193 | */ |
188 | 194 | |
189 | 195 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
190 | - } else return array(); |
|
196 | + } else { |
|
197 | + return array(); |
|
198 | + } |
|
191 | 199 | } |
192 | 200 | |
193 | 201 | /** |
@@ -202,7 +210,9 @@ discard block |
||
202 | 210 | date_default_timezone_set($globalTimezone); |
203 | 211 | $check_date = new Datetime($date); |
204 | 212 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
205 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
213 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
214 | + return array(); |
|
215 | + } |
|
206 | 216 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
207 | 217 | $json = $Common->getData($url); |
208 | 218 | $parsed_json = json_decode($json); |
@@ -215,7 +225,9 @@ discard block |
||
215 | 225 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
216 | 226 | |
217 | 227 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
218 | - } else return array(); |
|
228 | + } else { |
|
229 | + return array(); |
|
230 | + } |
|
219 | 231 | } |
220 | 232 | |
221 | 233 | /** |
@@ -226,7 +238,9 @@ discard block |
||
226 | 238 | private function getRyanair($callsign) { |
227 | 239 | $Common = new Common(); |
228 | 240 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
229 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
241 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
242 | + return array(); |
|
243 | + } |
|
230 | 244 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
231 | 245 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
232 | 246 | $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
@@ -240,8 +254,12 @@ discard block |
||
240 | 254 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
241 | 255 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
242 | 256 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
243 | - } else return array(); |
|
244 | - } else return array(); |
|
257 | + } else { |
|
258 | + return array(); |
|
259 | + } |
|
260 | + } else { |
|
261 | + return array(); |
|
262 | + } |
|
245 | 263 | } |
246 | 264 | |
247 | 265 | /** |
@@ -252,7 +270,9 @@ discard block |
||
252 | 270 | private function getSwiss($callsign) { |
253 | 271 | $Common = new Common(); |
254 | 272 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
255 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
273 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
274 | + return array(); |
|
275 | + } |
|
256 | 276 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
257 | 277 | $json = $Common->getData($url); |
258 | 278 | $parsed_json = json_decode($json); |
@@ -272,8 +292,12 @@ discard block |
||
272 | 292 | } |
273 | 293 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
274 | 294 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
275 | - } else return array(); |
|
276 | - } else return array(); |
|
295 | + } else { |
|
296 | + return array(); |
|
297 | + } |
|
298 | + } else { |
|
299 | + return array(); |
|
300 | + } |
|
277 | 301 | } |
278 | 302 | |
279 | 303 | /** |
@@ -287,12 +311,18 @@ discard block |
||
287 | 311 | $Common = new Common(); |
288 | 312 | $check_date = new Datetime($date); |
289 | 313 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
290 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
291 | - if ($globalBritishAirwaysKey == '') return array(); |
|
314 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
315 | + return array(); |
|
316 | + } |
|
317 | + if ($globalBritishAirwaysKey == '') { |
|
318 | + return array(); |
|
319 | + } |
|
292 | 320 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
293 | 321 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
294 | 322 | $json = $Common->getData($url,'get','',$headers); |
295 | - if ($json == '') return array(); |
|
323 | + if ($json == '') { |
|
324 | + return array(); |
|
325 | + } |
|
296 | 326 | $parsed_json = json_decode($json); |
297 | 327 | $flights = $parsed_json->{'FlightsResponse'}; |
298 | 328 | if (count($flights) > 0) { |
@@ -301,7 +331,9 @@ discard block |
||
301 | 331 | $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
302 | 332 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
303 | 333 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
304 | - } else return array(); |
|
334 | + } else { |
|
335 | + return array(); |
|
336 | + } |
|
305 | 337 | } |
306 | 338 | |
307 | 339 | /** |
@@ -315,19 +347,27 @@ discard block |
||
315 | 347 | $Common = new Common(); |
316 | 348 | $check_date = new Datetime($date); |
317 | 349 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
318 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
319 | - if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
|
350 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
351 | + return array(); |
|
352 | + } |
|
353 | + if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') { |
|
354 | + return array(); |
|
355 | + } |
|
320 | 356 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
321 | 357 | $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
322 | 358 | $data = $Common->getData($url,'post',$post); |
323 | 359 | $parsed_data = json_decode($data); |
324 | - if (!isset($parsed_data->{'access_token'})) return array(); |
|
360 | + if (!isset($parsed_data->{'access_token'})) { |
|
361 | + return array(); |
|
362 | + } |
|
325 | 363 | $token = $parsed_data->{'access_token'}; |
326 | 364 | |
327 | 365 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
328 | 366 | $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
329 | 367 | $json = $Common->getData($url,'get','',$headers); |
330 | - if ($json == '') return array(); |
|
368 | + if ($json == '') { |
|
369 | + return array(); |
|
370 | + } |
|
331 | 371 | $parsed_json = json_decode($json); |
332 | 372 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
333 | 373 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
@@ -335,7 +375,9 @@ discard block |
||
335 | 375 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
336 | 376 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
337 | 377 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
338 | - } else return array(); |
|
378 | + } else { |
|
379 | + return array(); |
|
380 | + } |
|
339 | 381 | } |
340 | 382 | |
341 | 383 | /** |
@@ -349,14 +391,20 @@ discard block |
||
349 | 391 | $Common = new Common(); |
350 | 392 | $check_date = new Datetime($date); |
351 | 393 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
352 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
353 | - if ($globalTransaviaKey == '') return array(); |
|
394 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
395 | + return array(); |
|
396 | + } |
|
397 | + if ($globalTransaviaKey == '') { |
|
398 | + return array(); |
|
399 | + } |
|
354 | 400 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
355 | 401 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
356 | 402 | $headers = array('apikey: '.$globalTransaviaKey); |
357 | 403 | $json = $Common->getData($url,'get','',$headers); |
358 | 404 | //echo 'result : '.$json; |
359 | - if ($json == '') return array(); |
|
405 | + if ($json == '') { |
|
406 | + return array(); |
|
407 | + } |
|
360 | 408 | $parsed_json = json_decode($json); |
361 | 409 | |
362 | 410 | if (isset($parsed_json->{'data'}[0])) { |
@@ -365,7 +413,9 @@ discard block |
||
365 | 413 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
366 | 414 | $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
367 | 415 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
368 | - } else return array(); |
|
416 | + } else { |
|
417 | + return array(); |
|
418 | + } |
|
369 | 419 | } |
370 | 420 | |
371 | 421 | /** |
@@ -376,7 +426,9 @@ discard block |
||
376 | 426 | public function getTunisair($callsign) { |
377 | 427 | $Common = new Common(); |
378 | 428 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
379 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
429 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
430 | + return array(); |
|
431 | + } |
|
380 | 432 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
381 | 433 | $data = $Common->getData($url); |
382 | 434 | $table = $Common->table2array($data); |
@@ -397,7 +449,9 @@ discard block |
||
397 | 449 | $Common = new Common(); |
398 | 450 | $check_date = new Datetime($date); |
399 | 451 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
400 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
452 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
453 | + return array(); |
|
454 | + } |
|
401 | 455 | $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
402 | 456 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
403 | 457 | $data = $Common->getData($url); |
@@ -407,8 +461,11 @@ discard block |
||
407 | 461 | $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
408 | 462 | preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
409 | 463 | $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
410 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
411 | - else return array(); |
|
464 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') { |
|
465 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
466 | + } else { |
|
467 | + return array(); |
|
468 | + } |
|
412 | 469 | } |
413 | 470 | return array(); |
414 | 471 | } |
@@ -423,7 +480,9 @@ discard block |
||
423 | 480 | $Common = new Common(); |
424 | 481 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
425 | 482 | $check_date = new Datetime($date); |
426 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
483 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
484 | + return array(); |
|
485 | + } |
|
427 | 486 | $url = "https://www.iberia.com/web/flightDetail.do"; |
428 | 487 | $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
429 | 488 | $data = $Common->getData($url,'post',$post); |
@@ -440,7 +499,9 @@ discard block |
||
440 | 499 | $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
441 | 500 | if ($arrivalTime == 'Hora estimada de llegada') { |
442 | 501 | $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
443 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
502 | + } else { |
|
503 | + $arrivalTime = substr($arrivalTime,0,5); |
|
504 | + } |
|
444 | 505 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
445 | 506 | } |
446 | 507 | } |
@@ -458,7 +519,9 @@ discard block |
||
458 | 519 | $Common = new Common(); |
459 | 520 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
460 | 521 | $check_date = new Datetime($date); |
461 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
522 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
523 | + return array(); |
|
524 | + } |
|
462 | 525 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
463 | 526 | $data = $Common->getData($url); |
464 | 527 | if ($data != '') { |
@@ -474,7 +537,9 @@ discard block |
||
474 | 537 | $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
475 | 538 | $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
476 | 539 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
477 | - } else return array(); |
|
540 | + } else { |
|
541 | + return array(); |
|
542 | + } |
|
478 | 543 | } |
479 | 544 | |
480 | 545 | |
@@ -494,7 +559,9 @@ discard block |
||
494 | 559 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
495 | 560 | $check_date = new Datetime($date); |
496 | 561 | $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
497 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
562 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
563 | + return array(); |
|
564 | + } |
|
498 | 565 | $data = $Common->getData($url); |
499 | 566 | if ($data != '') { |
500 | 567 | $table = $Common->text2array($data); |
@@ -518,7 +585,9 @@ discard block |
||
518 | 585 | $check_date = new Datetime($date); |
519 | 586 | $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
520 | 587 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
521 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
588 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
589 | + return array(); |
|
590 | + } |
|
522 | 591 | $data = $Common->getData($url); |
523 | 592 | if ($data != '') { |
524 | 593 | //echo $data; |
@@ -608,7 +677,9 @@ discard block |
||
608 | 677 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
609 | 678 | $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
610 | 679 | //$check_date = new Datetime($date); |
611 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
680 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
681 | + return array(); |
|
682 | + } |
|
612 | 683 | $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
613 | 684 | $data = $Common->getData($url,'post',$post); |
614 | 685 | if ($data != '') { |
@@ -640,11 +711,15 @@ discard block |
||
640 | 711 | $airline_icao = substr($callsign, 0, 3); |
641 | 712 | } |
642 | 713 | } |
643 | - if ($airline_icao == '') return array(); |
|
714 | + if ($airline_icao == '') { |
|
715 | + return array(); |
|
716 | + } |
|
644 | 717 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
645 | 718 | $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
646 | 719 | //$check_date = new Datetime($date); |
647 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
720 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
721 | + return array(); |
|
722 | + } |
|
648 | 723 | $data = $Common->getData($url); |
649 | 724 | if ($data != '') { |
650 | 725 | $table = $Common->table2array($data); |
@@ -687,7 +762,9 @@ discard block |
||
687 | 762 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
688 | 763 | $url= "http://fr.flightaware.com/live/flight/".$callsign; |
689 | 764 | //$check_date = new Datetime($date); |
690 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
765 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
766 | + return array(); |
|
767 | + } |
|
691 | 768 | $data = $Common->getData($url); |
692 | 769 | if ($data != '') { |
693 | 770 | $table = $Common->table2array($data); |
@@ -736,16 +813,22 @@ discard block |
||
736 | 813 | */ |
737 | 814 | private function getAirCanada($callsign,$date = 'NOW') { |
738 | 815 | $Common = new Common(); |
739 | - if (class_exists("DomDocument") === FALSE) return array(); |
|
816 | + if (class_exists("DomDocument") === FALSE) { |
|
817 | + return array(); |
|
818 | + } |
|
740 | 819 | date_default_timezone_set('UTC'); |
741 | 820 | $check_date = new Datetime($date); |
742 | 821 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
743 | 822 | $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
744 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
823 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
824 | + return array(); |
|
825 | + } |
|
745 | 826 | $data = $Common->getData($url); |
746 | 827 | $dom = new DomDocument(); |
747 | 828 | $dom->loadXML($data); |
748 | - if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array(); |
|
829 | + if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) { |
|
830 | + return array(); |
|
831 | + } |
|
749 | 832 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
750 | 833 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
751 | 834 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
@@ -754,7 +837,9 @@ discard block |
||
754 | 837 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
755 | 838 | $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
756 | 839 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
757 | - } else return array(); |
|
840 | + } else { |
|
841 | + return array(); |
|
842 | + } |
|
758 | 843 | } |
759 | 844 | |
760 | 845 | /** |
@@ -768,7 +853,9 @@ discard block |
||
768 | 853 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
769 | 854 | $check_date = new Datetime($date); |
770 | 855 | $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
771 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
856 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
857 | + return array(); |
|
858 | + } |
|
772 | 859 | $data = $Common->getData($url); |
773 | 860 | if ($data != '') { |
774 | 861 | $table = $Common->table2array($data); |
@@ -797,7 +884,9 @@ discard block |
||
797 | 884 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
798 | 885 | $check_date = new Datetime($date); |
799 | 886 | $url= "http://www.airberlin.com/en-US/site/aims.php"; |
800 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
887 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
888 | + return array(); |
|
889 | + } |
|
801 | 890 | $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
802 | 891 | $data = $Common->getData($url,'post',$post); |
803 | 892 | //echo $data; |
@@ -807,11 +896,19 @@ discard block |
||
807 | 896 | if ($data != '') { |
808 | 897 | $table = $Common->table2array($data); |
809 | 898 | $flight = $table; |
810 | - if (isset($flight[5][4])) $departureTime = $flight[5][4]; |
|
811 | - else $departureTime = ''; |
|
812 | - if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
|
813 | - else $departureAirport = ''; |
|
814 | - } else return array(); |
|
899 | + if (isset($flight[5][4])) { |
|
900 | + $departureTime = $flight[5][4]; |
|
901 | + } else { |
|
902 | + $departureTime = ''; |
|
903 | + } |
|
904 | + if (isset($flight[5][2])) { |
|
905 | + $departureAirport = $flight[5][2]; |
|
906 | + } else { |
|
907 | + $departureAirport = ''; |
|
908 | + } |
|
909 | + } else { |
|
910 | + return array(); |
|
911 | + } |
|
815 | 912 | $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
816 | 913 | $data = $Common->getData($url,'post',$post); |
817 | 914 | if ($data != '') { |
@@ -824,10 +921,14 @@ discard block |
||
824 | 921 | $arrivalTime = ''; |
825 | 922 | $arrivalAirport = ''; |
826 | 923 | } |
827 | - } else return array(); |
|
924 | + } else { |
|
925 | + return array(); |
|
926 | + } |
|
828 | 927 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
829 | 928 | $json = $Common->getData($url); |
830 | - if ($json == '') return array(); |
|
929 | + if ($json == '') { |
|
930 | + return array(); |
|
931 | + } |
|
831 | 932 | $parsed_json = json_decode($json); |
832 | 933 | $airports = $parsed_json->{'suggestList'}; |
833 | 934 | if (count($airports) > 0) { |
@@ -842,7 +943,9 @@ discard block |
||
842 | 943 | } |
843 | 944 | if (isset($DepartureAirportIata)) { |
844 | 945 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
845 | - } else return array(); |
|
946 | + } else { |
|
947 | + return array(); |
|
948 | + } |
|
846 | 949 | } |
847 | 950 | |
848 | 951 | |
@@ -850,7 +953,9 @@ discard block |
||
850 | 953 | public function fetchSchedule($ident,$date = 'NOW') { |
851 | 954 | global $globalSchedulesSources, $globalSchedulesFetch; |
852 | 955 | //$Common = new Common(); |
853 | - if (!$globalSchedulesFetch) return array(); |
|
956 | + if (!$globalSchedulesFetch) { |
|
957 | + return array(); |
|
958 | + } |
|
854 | 959 | $airline_icao = ''; |
855 | 960 | if (!is_numeric(substr($ident, 0, 3))) |
856 | 961 | { |
@@ -1078,14 +1183,21 @@ discard block |
||
1078 | 1183 | default: |
1079 | 1184 | // Randomly use a generic function to get hours |
1080 | 1185 | if (strlen($airline_icao) == 2) { |
1081 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1186 | + if (!isset($globalSchedulesSources)) { |
|
1187 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1188 | + } |
|
1082 | 1189 | if (count($globalSchedulesSources) > 0) { |
1083 | 1190 | $rand = mt_rand(0,count($globalSchedulesSources)-1); |
1084 | 1191 | $source = $globalSchedulesSources[$rand]; |
1085 | - if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
|
1086 | - elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
|
1192 | + if ($source == 'flightmapper') { |
|
1193 | + return $this->getFlightMapper($ident); |
|
1194 | + } elseif ($source == 'costtotravel') { |
|
1195 | + return $this->getCostToTravel($ident); |
|
1196 | + } |
|
1087 | 1197 | //elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date); |
1088 | - elseif ($source == 'flightaware') return $this->getFlightAware($ident); |
|
1198 | + elseif ($source == 'flightaware') { |
|
1199 | + return $this->getFlightAware($ident); |
|
1200 | + } |
|
1089 | 1201 | } |
1090 | 1202 | } |
1091 | 1203 | } |
@@ -37,8 +37,11 @@ discard block |
||
37 | 37 | } else { |
38 | 38 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
39 | 39 | } |
40 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
41 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
40 | + if ($timeout == '') { |
|
41 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
42 | + } else { |
|
43 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
44 | + } |
|
42 | 45 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
43 | 46 | if ($type == 'post') { |
44 | 47 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -85,8 +88,9 @@ discard block |
||
85 | 88 | private function curlResponseHeaderCallback($ch, $headerLine) { |
86 | 89 | //global $cookies; |
87 | 90 | $cookies = array(); |
88 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
89 | - $cookies[] = $cookie; |
|
91 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
92 | + $cookies[] = $cookie; |
|
93 | + } |
|
90 | 94 | return strlen($headerLine); // Needed by curl |
91 | 95 | } |
92 | 96 | |
@@ -97,11 +101,15 @@ discard block |
||
97 | 101 | curl_setopt($ch, CURLOPT_URL, $url); |
98 | 102 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
99 | 103 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
100 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
104 | + if ($referer != '') { |
|
105 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
106 | + } |
|
101 | 107 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
102 | 108 | curl_setopt($ch, CURLOPT_FILE, $fp); |
103 | 109 | curl_exec($ch); |
104 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
110 | + if (curl_errno($ch) && $globalDebug) { |
|
111 | + echo 'Download error: '.curl_error($ch); |
|
112 | + } |
|
105 | 113 | curl_close($ch); |
106 | 114 | fclose($fp); |
107 | 115 | } |
@@ -109,12 +117,16 @@ discard block |
||
109 | 117 | public static function gunzip($in_file,$out_file_name = '') { |
110 | 118 | //echo $in_file.' -> '.$out_file_name."\n"; |
111 | 119 | $buffer_size = 4096; // read 4kb at a time |
112 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
120 | + if ($out_file_name == '') { |
|
121 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
122 | + } |
|
113 | 123 | if ($in_file != '' && file_exists($in_file)) { |
114 | 124 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
115 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
116 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
117 | - else { |
|
125 | + if (function_exists('gzopen')) { |
|
126 | + $file = gzopen($in_file,'rb'); |
|
127 | + } elseif (function_exists('gzopen64')) { |
|
128 | + $file = gzopen64($in_file,'rb'); |
|
129 | + } else { |
|
118 | 130 | echo 'gzopen not available'; |
119 | 131 | die; |
120 | 132 | } |
@@ -130,11 +142,14 @@ discard block |
||
130 | 142 | public static function bunzip2($in_file,$out_file_name = '') { |
131 | 143 | //echo $in_file.' -> '.$out_file_name."\n"; |
132 | 144 | $buffer_size = 4096; // read 4kb at a time |
133 | - if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
|
145 | + if ($out_file_name == '') { |
|
146 | + $out_file_name = str_replace('.bz2', '', $in_file); |
|
147 | + } |
|
134 | 148 | if ($in_file != '' && file_exists($in_file)) { |
135 | 149 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
136 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
137 | - else { |
|
150 | + if (function_exists('bzopen')) { |
|
151 | + $file = bzopen($in_file,'rb'); |
|
152 | + } else { |
|
138 | 153 | echo 'bzopen not available'; |
139 | 154 | die; |
140 | 155 | } |
@@ -153,10 +168,16 @@ discard block |
||
153 | 168 | * @return Array array of the tables in HTML page |
154 | 169 | */ |
155 | 170 | public function table2array($data) { |
156 | - if (!is_string($data)) return array(); |
|
157 | - if ($data == '') return array(); |
|
171 | + if (!is_string($data)) { |
|
172 | + return array(); |
|
173 | + } |
|
174 | + if ($data == '') { |
|
175 | + return array(); |
|
176 | + } |
|
158 | 177 | $html = str_get_html($data); |
159 | - if ($html === false) return array(); |
|
178 | + if ($html === false) { |
|
179 | + return array(); |
|
180 | + } |
|
160 | 181 | $tabledata=array(); |
161 | 182 | foreach($html->find('tr') as $element) |
162 | 183 | { |
@@ -191,7 +212,9 @@ discard block |
||
191 | 212 | */ |
192 | 213 | public function text2array($data) { |
193 | 214 | $html = str_get_html($data); |
194 | - if ($html === false) return array(); |
|
215 | + if ($html === false) { |
|
216 | + return array(); |
|
217 | + } |
|
195 | 218 | $tabledata=array(); |
196 | 219 | foreach($html->find('p') as $element) |
197 | 220 | { |
@@ -212,7 +235,9 @@ discard block |
||
212 | 235 | * @return Float Distance in $unit |
213 | 236 | */ |
214 | 237 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
215 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
238 | + if ($lat == $latc && $lon == $lonc) { |
|
239 | + return 0; |
|
240 | + } |
|
216 | 241 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
217 | 242 | if ($unit == "km") { |
218 | 243 | return round($dist * 1.609344); |
@@ -236,10 +261,16 @@ discard block |
||
236 | 261 | public function withinThreshold ($timeDifference, $distance) { |
237 | 262 | $x = abs($timeDifference); |
238 | 263 | $d = abs($distance); |
239 | - if ($x == 0 || $d == 0) return true; |
|
264 | + if ($x == 0 || $d == 0) { |
|
265 | + return true; |
|
266 | + } |
|
240 | 267 | // may be due to Internet jitter; distance is realistic |
241 | - if ($x < 0.7 && $d < 2000) return true; |
|
242 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
268 | + if ($x < 0.7 && $d < 2000) { |
|
269 | + return true; |
|
270 | + } else { |
|
271 | + return $d/$x < 1500*0.27778; |
|
272 | + } |
|
273 | + // 1500 km/h max |
|
243 | 274 | } |
244 | 275 | |
245 | 276 | |
@@ -267,11 +298,17 @@ discard block |
||
267 | 298 | |
268 | 299 | public function convertDM($coord,$latlong) { |
269 | 300 | if ($latlong == 'latitude') { |
270 | - if ($coord < 0) $NSEW = 'S'; |
|
271 | - else $NSEW = 'N'; |
|
301 | + if ($coord < 0) { |
|
302 | + $NSEW = 'S'; |
|
303 | + } else { |
|
304 | + $NSEW = 'N'; |
|
305 | + } |
|
272 | 306 | } else { |
273 | - if ($coord < 0) $NSEW = 'W'; |
|
274 | - else $NSEW = 'E'; |
|
307 | + if ($coord < 0) { |
|
308 | + $NSEW = 'W'; |
|
309 | + } else { |
|
310 | + $NSEW = 'E'; |
|
311 | + } |
|
275 | 312 | } |
276 | 313 | $coord = abs($coord); |
277 | 314 | $deg = floor($coord); |
@@ -314,7 +351,9 @@ discard block |
||
314 | 351 | public function hex2str($hex) { |
315 | 352 | $str = ''; |
316 | 353 | $hexln = strlen($hex); |
317 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
354 | + for($i=0;$i<$hexln;$i+=2) { |
|
355 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
356 | + } |
|
318 | 357 | return $str; |
319 | 358 | } |
320 | 359 | |
@@ -351,8 +390,11 @@ discard block |
||
351 | 390 | $b = $lat2 - $lat1; |
352 | 391 | $c = -($a*$lat1+$b*$lon1); |
353 | 392 | $d = $a*$lat3+$b*$lon3+$c; |
354 | - if ($d > -$approx && $d < $approx) return true; |
|
355 | - else return false; |
|
393 | + if ($d > -$approx && $d < $approx) { |
|
394 | + return true; |
|
395 | + } else { |
|
396 | + return false; |
|
397 | + } |
|
356 | 398 | } |
357 | 399 | |
358 | 400 | public function array_merge_noappend() { |
@@ -411,7 +453,9 @@ discard block |
||
411 | 453 | return $result; |
412 | 454 | } |
413 | 455 | $handle = @opendir('./locale'); |
414 | - if ($handle === false) return $result; |
|
456 | + if ($handle === false) { |
|
457 | + return $result; |
|
458 | + } |
|
415 | 459 | while (false !== ($file = readdir($handle))) { |
416 | 460 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
417 | 461 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -478,8 +522,9 @@ discard block |
||
478 | 522 | $error = false; |
479 | 523 | if ($fp_out = gzopen($dest, $mode)) { |
480 | 524 | if ($fp_in = fopen($source,'rb')) { |
481 | - while (!feof($fp_in)) |
|
482 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
525 | + while (!feof($fp_in)) { |
|
526 | + gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
527 | + } |
|
483 | 528 | fclose($fp_in); |
484 | 529 | } else { |
485 | 530 | $error = true; |
@@ -488,14 +533,17 @@ discard block |
||
488 | 533 | } else { |
489 | 534 | $error = true; |
490 | 535 | } |
491 | - if ($error) |
|
492 | - return false; |
|
493 | - else |
|
494 | - return $dest; |
|
536 | + if ($error) { |
|
537 | + return false; |
|
538 | + } else { |
|
539 | + return $dest; |
|
540 | + } |
|
495 | 541 | } |
496 | 542 | |
497 | 543 | public function remove_accents($string) { |
498 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
544 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
545 | + return $string; |
|
546 | + } |
|
499 | 547 | $chars = array( |
500 | 548 | // Decompositions for Latin-1 Supplement |
501 | 549 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -619,7 +667,9 @@ discard block |
||
619 | 667 | $ip = gethostbyname($host); |
620 | 668 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
621 | 669 | $r = @socket_connect($s, $ip, $port); |
622 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
670 | + if (!socket_set_nonblock($s)) { |
|
671 | + echo "Unable to set nonblock on socket\n"; |
|
672 | + } |
|
623 | 673 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
624 | 674 | return $s; |
625 | 675 | } |
@@ -664,18 +714,22 @@ discard block |
||
664 | 714 | //NOTE: use a trailing slash for folders!!! |
665 | 715 | //see http://bugs.php.net/bug.php?id=27609 |
666 | 716 | //see http://bugs.php.net/bug.php?id=30931 |
667 | - if ($path{strlen($path)-1}=='/') // recursively return a temporary file path |
|
717 | + if ($path{strlen($path)-1}=='/') { |
|
718 | + // recursively return a temporary file path |
|
668 | 719 | return $this->is__writable($path.uniqid(mt_rand()).'.tmp'); |
669 | - else if (is_dir($path)) |
|
670 | - return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
720 | + } else if (is_dir($path)) { |
|
721 | + return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
722 | + } |
|
671 | 723 | // check tmp file for read/write capabilities |
672 | 724 | $rm = file_exists($path); |
673 | 725 | $f = @fopen($path, 'a'); |
674 | - if ($f===false) |
|
675 | - return false; |
|
726 | + if ($f===false) { |
|
727 | + return false; |
|
728 | + } |
|
676 | 729 | fclose($f); |
677 | - if (!$rm) |
|
678 | - unlink($path); |
|
730 | + if (!$rm) { |
|
731 | + unlink($path); |
|
732 | + } |
|
679 | 733 | return true; |
680 | 734 | } |
681 | 735 | } |
@@ -42,7 +42,9 @@ discard block |
||
42 | 42 | |
43 | 43 | public function checkAll() { |
44 | 44 | global $globalDebug; |
45 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
45 | + if ($globalDebug) { |
|
46 | + echo "Update last seen tracked data...\n"; |
|
47 | + } |
|
46 | 48 | foreach ($this->all_tracked as $key => $flight) { |
47 | 49 | if (isset($this->all_tracked[$key]['id'])) { |
48 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -55,12 +57,16 @@ discard block |
||
55 | 57 | public function del() { |
56 | 58 | global $globalDebug; |
57 | 59 | // Delete old infos |
58 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
60 | + if ($globalDebug) { |
|
61 | + echo 'Delete old values and update latest data...'."\n"; |
|
62 | + } |
|
59 | 63 | foreach ($this->all_tracked as $key => $flight) { |
60 | 64 | if (isset($flight['lastupdate'])) { |
61 | 65 | if ($flight['lastupdate'] < (time()-3000)) { |
62 | 66 | if (isset($this->all_tracked[$key]['id'])) { |
63 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
67 | + if ($globalDebug) { |
|
68 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
69 | + } |
|
64 | 70 | /* |
65 | 71 | $TrackerLive = new TrackerLive(); |
66 | 72 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
@@ -70,7 +76,9 @@ discard block |
||
70 | 76 | $Tracker = new Tracker($this->db); |
71 | 77 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
72 | 78 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
73 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
79 | + if ($globalDebug && $result != 'success') { |
|
80 | + echo '!!! ERROR : '.$result."\n"; |
|
81 | + } |
|
74 | 82 | } |
75 | 83 | // Put in archive |
76 | 84 | // $Tracker->db = null; |
@@ -83,7 +91,9 @@ discard block |
||
83 | 91 | |
84 | 92 | public function add($line) { |
85 | 93 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
86 | - if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015'; |
|
94 | + if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') { |
|
95 | + $globalCoordMinChangeTracker = '0.015'; |
|
96 | + } |
|
87 | 97 | date_default_timezone_set('UTC'); |
88 | 98 | $dataFound = false; |
89 | 99 | $send = false; |
@@ -97,19 +107,29 @@ discard block |
||
97 | 107 | // Increment message number |
98 | 108 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
99 | 109 | $current_date = date('Y-m-d'); |
100 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
101 | - else $source = ''; |
|
102 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
110 | + if (isset($line['source_name'])) { |
|
111 | + $source = $line['source_name']; |
|
112 | + } else { |
|
113 | + $source = ''; |
|
114 | + } |
|
115 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
116 | + $source = $line['format_source']; |
|
117 | + } |
|
103 | 118 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
104 | 119 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
105 | 120 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
106 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
121 | + } else { |
|
122 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
123 | + } |
|
107 | 124 | } |
108 | 125 | |
109 | 126 | |
110 | 127 | $Common = new Common(); |
111 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
112 | - else $id = trim($line['id']); |
|
128 | + if (!isset($line['id'])) { |
|
129 | + $id = trim($line['ident']); |
|
130 | + } else { |
|
131 | + $id = trim($line['id']); |
|
132 | + } |
|
113 | 133 | |
114 | 134 | if (!isset($this->all_tracked[$id])) { |
115 | 135 | $this->all_tracked[$id] = array(); |
@@ -117,31 +137,46 @@ discard block |
||
117 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
118 | 138 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
119 | 139 | if (!isset($line['id'])) { |
120 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
140 | + if (!isset($globalDaemon)) { |
|
141 | + $globalDaemon = TRUE; |
|
142 | + } |
|
121 | 143 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
122 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
123 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
144 | + } else { |
|
145 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
146 | + } |
|
147 | + if ($globalAllTracked !== FALSE) { |
|
148 | + $dataFound = true; |
|
149 | + } |
|
124 | 150 | } |
125 | 151 | |
126 | 152 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
127 | 153 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
128 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
129 | 155 | } else { |
130 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
131 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
156 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
157 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
158 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
159 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
160 | + } |
|
132 | 161 | return ''; |
133 | 162 | } |
134 | 163 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
135 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
164 | + if ($globalDebug) { |
|
165 | + echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
166 | + } |
|
136 | 167 | return ''; |
137 | 168 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
138 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
169 | + if ($globalDebug) { |
|
170 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
171 | + } |
|
139 | 172 | return ''; |
140 | 173 | } elseif (!isset($line['datetime'])) { |
141 | 174 | date_default_timezone_set('UTC'); |
142 | 175 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
143 | 176 | } else { |
144 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
177 | + if ($globalDebug) { |
|
178 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
179 | + } |
|
145 | 180 | return ''; |
146 | 181 | } |
147 | 182 | |
@@ -153,11 +188,17 @@ discard block |
||
153 | 188 | $Tracker = new Tracker($this->db); |
154 | 189 | $fromsource = NULL; |
155 | 190 | $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
156 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
191 | + if ($globalDebug && $result != 'success') { |
|
192 | + echo '!!! ERROR : '.$result."\n"; |
|
193 | + } |
|
157 | 194 | $Tracker->db = null; |
158 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
195 | + if ($globalDebugTimeElapsed) { |
|
196 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
197 | + } |
|
198 | + } |
|
199 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
159 | 201 | } |
160 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
161 | 202 | } |
162 | 203 | |
163 | 204 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -168,14 +209,21 @@ discard block |
||
168 | 209 | if ($distance > 100 && $distance < 10000) { |
169 | 210 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
170 | 211 | $speed = $speed*3.6; |
171 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
172 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
212 | + if ($speed < 1000) { |
|
213 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
214 | + } |
|
215 | + if ($globalDebug) { |
|
216 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
217 | + } |
|
173 | 218 | } |
174 | 219 | } |
175 | 220 | |
176 | 221 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
177 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
178 | - else unset($timediff); |
|
222 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
223 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
224 | + } else { |
|
225 | + unset($timediff); |
|
226 | + } |
|
179 | 227 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
180 | 228 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
181 | 229 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.1)) { |
@@ -183,20 +231,30 @@ discard block |
||
183 | 231 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
184 | 232 | $this->all_tracked[$id]['putinarchive'] = true; |
185 | 233 | |
186 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
234 | + if ($globalDebug) { |
|
235 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
236 | + } |
|
187 | 237 | $timeelapsed = microtime(true); |
188 | 238 | $Tracker = new Tracker($this->db); |
189 | 239 | $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
190 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
240 | + if (!empty($all_country)) { |
|
241 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
242 | + } |
|
191 | 243 | $Tracker->db = null; |
192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
244 | + if ($globalDebugTimeElapsed) { |
|
245 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
246 | + } |
|
193 | 247 | $this->tmd = 0; |
194 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
248 | + if ($globalDebug) { |
|
249 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
250 | + } |
|
195 | 251 | } |
196 | 252 | } |
197 | 253 | |
198 | 254 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
199 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
255 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
256 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
257 | + } |
|
200 | 258 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
201 | 259 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
202 | 260 | $dataFound = true; |
@@ -205,8 +263,12 @@ discard block |
||
205 | 263 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
206 | 264 | } |
207 | 265 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
208 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
209 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
266 | + if ($line['longitude'] > 180) { |
|
267 | + $line['longitude'] = $line['longitude'] - 360; |
|
268 | + } |
|
269 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
270 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
271 | + } |
|
210 | 272 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
211 | 273 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
212 | 274 | $dataFound = true; |
@@ -226,7 +288,9 @@ discard block |
||
226 | 288 | } |
227 | 289 | } |
228 | 290 | if (isset($line['last_update']) && $line['last_update'] != '') { |
229 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
291 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
292 | + $dataFound = true; |
|
293 | + } |
|
230 | 294 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
231 | 295 | } |
232 | 296 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -246,7 +310,9 @@ discard block |
||
246 | 310 | |
247 | 311 | if (isset($line['altitude']) && $line['altitude'] != '') { |
248 | 312 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
249 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
313 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) { |
|
314 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
315 | + } |
|
250 | 316 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
251 | 317 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
252 | 318 | //$dataFound = true; |
@@ -258,15 +324,21 @@ discard block |
||
258 | 324 | } |
259 | 325 | |
260 | 326 | if (isset($line['heading']) && $line['heading'] != '') { |
261 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
327 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
328 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
329 | + } |
|
262 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
263 | 331 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
264 | 332 | //$dataFound = true; |
265 | 333 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
266 | 334 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
267 | 335 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
268 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
269 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
336 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
337 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
338 | + } |
|
339 | + if ($globalDebug) { |
|
340 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
341 | + } |
|
270 | 342 | } |
271 | 343 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
272 | 344 | |
@@ -275,20 +347,31 @@ discard block |
||
275 | 347 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
276 | 348 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
277 | 349 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
278 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
350 | + if ($globalDebug) { |
|
351 | + echo "Check if aircraft is already in DB..."; |
|
352 | + } |
|
279 | 353 | $timeelapsed = microtime(true); |
280 | 354 | $TrackerLive = new TrackerLive($this->db); |
281 | 355 | if (isset($line['id'])) { |
282 | 356 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
357 | + if ($globalDebugTimeElapsed) { |
|
358 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
359 | + } |
|
284 | 360 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
285 | 361 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
287 | - } else $recent_ident = ''; |
|
362 | + if ($globalDebugTimeElapsed) { |
|
363 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
364 | + } |
|
365 | + } else { |
|
366 | + $recent_ident = ''; |
|
367 | + } |
|
288 | 368 | $TrackerLive->db=null; |
289 | 369 | |
290 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
291 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
370 | + if ($globalDebug && $recent_ident == '') { |
|
371 | + echo " Not in DB.\n"; |
|
372 | + } elseif ($globalDebug && $recent_ident != '') { |
|
373 | + echo " Already in DB.\n"; |
|
374 | + } |
|
292 | 375 | } else { |
293 | 376 | $recent_ident = ''; |
294 | 377 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -296,27 +379,41 @@ discard block |
||
296 | 379 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
297 | 380 | if($recent_ident == "") |
298 | 381 | { |
299 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
382 | + if ($globalDebug) { |
|
383 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
384 | + } |
|
300 | 385 | //adds the spotter data for the archive |
301 | 386 | $highlight = ''; |
302 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
387 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
388 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
389 | + } |
|
303 | 390 | $timeelapsed = microtime(true); |
304 | 391 | $Tracker = new Tracker($this->db); |
305 | 392 | $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
306 | 393 | $Tracker->db = null; |
307 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
394 | + if ($globalDebug && isset($result)) { |
|
395 | + echo $result."\n"; |
|
396 | + } |
|
397 | + if ($globalDebugTimeElapsed) { |
|
398 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
399 | + } |
|
309 | 400 | |
310 | 401 | |
311 | 402 | // Add source stat in DB |
312 | 403 | $Stats = new Stats($this->db); |
313 | 404 | if (!empty($this->stats)) { |
314 | - if ($globalDebug) echo 'Add source stats : '; |
|
405 | + if ($globalDebug) { |
|
406 | + echo 'Add source stats : '; |
|
407 | + } |
|
315 | 408 | foreach($this->stats as $date => $data) { |
316 | 409 | foreach($data as $source => $sourced) { |
317 | 410 | //print_r($sourced); |
318 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
319 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
411 | + if (isset($sourced['polar'])) { |
|
412 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
413 | + } |
|
414 | + if (isset($sourced['hist'])) { |
|
415 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
416 | + } |
|
320 | 417 | if (isset($sourced['msg'])) { |
321 | 418 | if (time() - $sourced['msg']['date'] > 10) { |
322 | 419 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -329,7 +426,9 @@ discard block |
||
329 | 426 | unset($this->stats[$date]); |
330 | 427 | } |
331 | 428 | } |
332 | - if ($globalDebug) echo 'Done'."\n"; |
|
429 | + if ($globalDebug) { |
|
430 | + echo 'Done'."\n"; |
|
431 | + } |
|
333 | 432 | |
334 | 433 | } |
335 | 434 | $Stats->db = null; |
@@ -339,12 +438,16 @@ discard block |
||
339 | 438 | $this->all_tracked[$id]['addedTracker'] = 1; |
340 | 439 | //print_r($this->all_tracked[$id]); |
341 | 440 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
342 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
441 | + if ($globalDebug) { |
|
442 | + echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
443 | + } |
|
343 | 444 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
344 | 445 | $TrackerLive = new TrackerLive($this->db); |
345 | 446 | $TrackerLive->deleteLiveTrackerData(); |
346 | 447 | $TrackerLive->db=null; |
347 | - if ($globalDebug) echo " Done\n"; |
|
448 | + if ($globalDebug) { |
|
449 | + echo " Done\n"; |
|
450 | + } |
|
348 | 451 | $this->last_delete = time(); |
349 | 452 | } |
350 | 453 | } else { |
@@ -367,19 +470,25 @@ discard block |
||
367 | 470 | |
368 | 471 | if (!$ignoreImport) { |
369 | 472 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
370 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
473 | + if ($globalDebug) { |
|
474 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
475 | + } |
|
371 | 476 | $timeelapsed = microtime(true); |
372 | 477 | $TrackerLive = new TrackerLive($this->db); |
373 | 478 | $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
374 | 479 | $TrackerLive->db = null; |
375 | 480 | $this->all_tracked[$id]['putinarchive'] = false; |
376 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
481 | + if ($globalDebugTimeElapsed) { |
|
482 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
483 | + } |
|
377 | 484 | |
378 | 485 | // Put statistics in $this->stats variable |
379 | 486 | |
380 | 487 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
381 | 488 | $source = $this->all_tracked[$id]['source_name']; |
382 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
489 | + if ($source == '') { |
|
490 | + $source = $this->all_tracked[$id]['format_source']; |
|
491 | + } |
|
383 | 492 | if (!isset($this->source_location[$source])) { |
384 | 493 | $Location = new Source($this->db); |
385 | 494 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -400,7 +509,9 @@ discard block |
||
400 | 509 | $stats_heading = round($stats_heading/22.5); |
401 | 510 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
402 | 511 | $current_date = date('Y-m-d'); |
403 | - if ($stats_heading == 16) $stats_heading = 0; |
|
512 | + if ($stats_heading == 16) { |
|
513 | + $stats_heading = 0; |
|
514 | + } |
|
404 | 515 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
405 | 516 | for ($i=0;$i<=15;$i++) { |
406 | 517 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -418,7 +529,9 @@ discard block |
||
418 | 529 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
419 | 530 | end($this->stats[$current_date][$source]['hist']); |
420 | 531 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
421 | - } else $mini = 0; |
|
532 | + } else { |
|
533 | + $mini = 0; |
|
534 | + } |
|
422 | 535 | for ($i=$mini;$i<=$distance;$i+=10) { |
423 | 536 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
424 | 537 | } |
@@ -429,19 +542,29 @@ discard block |
||
429 | 542 | } |
430 | 543 | |
431 | 544 | $this->all_tracked[$id]['lastupdate'] = time(); |
432 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
433 | - if ($globalDebug) echo $result."\n"; |
|
434 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
545 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
546 | + $send = true; |
|
547 | + } |
|
548 | + if ($globalDebug) { |
|
549 | + echo $result."\n"; |
|
550 | + } |
|
551 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
552 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
553 | + } |
|
435 | 554 | //$this->del(); |
436 | 555 | |
437 | 556 | |
438 | 557 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
558 | + if ($globalDebug) { |
|
559 | + echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
560 | + } |
|
440 | 561 | $TrackerLive = new TrackerLive($this->db); |
441 | 562 | $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
442 | 563 | $TrackerLive->db = null; |
443 | 564 | //TrackerLive->deleteLiveTrackerData(); |
444 | - if ($globalDebug) echo " Done\n"; |
|
565 | + if ($globalDebug) { |
|
566 | + echo " Done\n"; |
|
567 | + } |
|
445 | 568 | $this->last_delete_hourly = time(); |
446 | 569 | } |
447 | 570 | |
@@ -449,7 +572,9 @@ discard block |
||
449 | 572 | //$ignoreImport = false; |
450 | 573 | } |
451 | 574 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
452 | - if ($send) return $this->all_tracked[$id]; |
|
575 | + if ($send) { |
|
576 | + return $this->all_tracked[$id]; |
|
577 | + } |
|
453 | 578 | } |
454 | 579 | } |
455 | 580 | } |