@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | <div id="showdetails" class="showdetails"></div> |
37 | 37 | <div id="infobox" class="infobox"><h4><?php echo _("Aircrafts detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div> |
38 | 38 | <?php |
39 | - if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
39 | + if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
40 | 40 | |
41 | 41 | ?> |
42 | 42 | <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script> |
43 | 43 | <?php |
44 | - } |
|
44 | + } |
|
45 | 45 | ?> |
46 | 46 | <div id="dialog" title="<?php echo _("Session has timed-out"); ?>"> |
47 | 47 | <p><?php echo _("In order to save data consumption web page times out after 30 minutes. Close this dialog to continue."); ?></p> |
@@ -55,34 +55,34 @@ discard block |
||
55 | 55 | <li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li> |
56 | 56 | <li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li> |
57 | 57 | <?php |
58 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
58 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
59 | 59 | if (isset($globalArchive) && $globalArchive == TRUE) { |
60 | 60 | ?> |
61 | 61 | <li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li> |
62 | 62 | <?php |
63 | 63 | } |
64 | - } |
|
64 | + } |
|
65 | 65 | ?> |
66 | 66 | <li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li> |
67 | 67 | <li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li> |
68 | 68 | <li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li> |
69 | 69 | <?php |
70 | - if (isset($globalMap3D) && $globalMap3D) { |
|
70 | + if (isset($globalMap3D) && $globalMap3D) { |
|
71 | 71 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
72 | 72 | ?> |
73 | 73 | <li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li> |
74 | 74 | <?php |
75 | - } else { |
|
76 | - if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
75 | + } else { |
|
76 | + if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
77 | 77 | ?> |
78 | 78 | <li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li> |
79 | 79 | <?php |
80 | - } |
|
80 | + } |
|
81 | 81 | ?> |
82 | 82 | <li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li> |
83 | 83 | <?php |
84 | 84 | } |
85 | - } |
|
85 | + } |
|
86 | 86 | ?> |
87 | 87 | </ul> |
88 | 88 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | ?> |
157 | 157 | </div> |
158 | 158 | <?php |
159 | - if (isset($globalArchive) && $globalArchive == TRUE) { |
|
159 | + if (isset($globalArchive) && $globalArchive == TRUE) { |
|
160 | 160 | ?> |
161 | 161 | <div class="sidebar-pane" id="archive"> |
162 | 162 | <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | </form> |
217 | 217 | </div> |
218 | 218 | <?php |
219 | - } |
|
219 | + } |
|
220 | 220 | ?> |
221 | 221 | <div class="sidebar-pane" id="settings"> |
222 | 222 | <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -227,56 +227,56 @@ discard block |
||
227 | 227 | <?php |
228 | 228 | if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
229 | 229 | else $MapType = $_COOKIE['MapType']; |
230 | - ?> |
|
230 | + ?> |
|
231 | 231 | <?php |
232 | 232 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
233 | - ?> |
|
233 | + ?> |
|
234 | 234 | <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
235 | 235 | <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
236 | 236 | <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
237 | 237 | <?php |
238 | 238 | } |
239 | - ?> |
|
239 | + ?> |
|
240 | 240 | <?php |
241 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
242 | - ?> |
|
241 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
242 | + ?> |
|
243 | 243 | <?php |
244 | - if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
245 | - ?> |
|
244 | + if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
245 | + ?> |
|
246 | 246 | <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
247 | 247 | <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
248 | 248 | <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
249 | 249 | <?php |
250 | - } |
|
251 | - ?> |
|
250 | + } |
|
251 | + ?> |
|
252 | 252 | <?php |
253 | - if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
254 | - ?> |
|
253 | + if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
254 | + ?> |
|
255 | 255 | <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
256 | 256 | <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
257 | 257 | <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
258 | 258 | <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
259 | 259 | <?php |
260 | - } |
|
261 | - ?> |
|
260 | + } |
|
261 | + ?> |
|
262 | 262 | <?php |
263 | - if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
264 | - ?> |
|
263 | + if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
264 | + ?> |
|
265 | 265 | <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
266 | 266 | <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
267 | 267 | <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
268 | 268 | <?php |
269 | - } |
|
270 | - ?> |
|
269 | + } |
|
270 | + ?> |
|
271 | 271 | <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
272 | 272 | <?php |
273 | 273 | } |
274 | - ?> |
|
274 | + ?> |
|
275 | 275 | <?php |
276 | - if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
276 | + if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
277 | 277 | if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
278 | 278 | else $MapBoxId = $_COOKIE['MapTypeId']; |
279 | - ?> |
|
279 | + ?> |
|
280 | 280 | <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
281 | 281 | <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
282 | 282 | <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
@@ -290,13 +290,13 @@ discard block |
||
290 | 290 | <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
291 | 291 | <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
292 | 292 | <?php |
293 | - } |
|
294 | - ?> |
|
293 | + } |
|
294 | + ?> |
|
295 | 295 | <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
296 | 296 | </select> |
297 | 297 | </li> |
298 | 298 | <?php |
299 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
299 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
300 | 300 | ?> |
301 | 301 | <li><?php echo _("Type of Terrain:"); ?> |
302 | 302 | <select class="selectpicker" onchange="terrainType(this);"> |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | </select> |
307 | 307 | </li> |
308 | 308 | <?php |
309 | - } |
|
309 | + } |
|
310 | 310 | ?> |
311 | 311 | <?php |
312 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
312 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
313 | 313 | ?> |
314 | 314 | |
315 | 315 | <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
@@ -317,59 +317,59 @@ discard block |
||
317 | 317 | <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
318 | 318 | <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
319 | 319 | <?php |
320 | - } |
|
320 | + } |
|
321 | 321 | ?> |
322 | 322 | <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
323 | 323 | <?php |
324 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
324 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
325 | 325 | ?> |
326 | 326 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
327 | 327 | <?php |
328 | - } |
|
329 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
328 | + } |
|
329 | + if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
330 | 330 | ?> |
331 | 331 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
332 | 332 | <?php |
333 | - } |
|
333 | + } |
|
334 | 334 | ?> |
335 | 335 | |
336 | 336 | <?php |
337 | 337 | if (function_exists('array_column')) { |
338 | - if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
339 | - ?> |
|
338 | + if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
339 | + ?> |
|
340 | 340 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
341 | 341 | <?php |
342 | - } |
|
342 | + } |
|
343 | 343 | } elseif (isset($globalSources)) { |
344 | - $dispolar = false; |
|
345 | - foreach ($globalSources as $testsource) { |
|
346 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
347 | - } |
|
348 | - if ($dispolar) { |
|
349 | - ?> |
|
344 | + $dispolar = false; |
|
345 | + foreach ($globalSources as $testsource) { |
|
346 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
347 | + } |
|
348 | + if ($dispolar) { |
|
349 | + ?> |
|
350 | 350 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
351 | 351 | <?php |
352 | - } |
|
353 | - } |
|
354 | - ?> |
|
352 | + } |
|
353 | + } |
|
354 | + ?> |
|
355 | 355 | <?php |
356 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
356 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
357 | 357 | ?> |
358 | 358 | |
359 | 359 | <?php |
360 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
361 | - ?> |
|
360 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
361 | + ?> |
|
362 | 362 | <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
363 | 363 | <?php |
364 | 364 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
365 | - ?> |
|
365 | + ?> |
|
366 | 366 | <li><?php echo _("Aircraft icon color:"); ?> |
367 | 367 | <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
368 | 368 | </li> |
369 | 369 | <?php |
370 | - } |
|
371 | - } |
|
372 | - ?> |
|
370 | + } |
|
371 | + } |
|
372 | + ?> |
|
373 | 373 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
374 | 374 | <div class="range"> |
375 | 375 | <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | </div> |
378 | 378 | </li> |
379 | 379 | <?php |
380 | - } |
|
380 | + } |
|
381 | 381 | ?> |
382 | 382 | <li><?php echo _("Distance unit:"); ?> |
383 | 383 | <select class="selectpicker" onchange="unitdistance(this);"> |
@@ -410,16 +410,16 @@ discard block |
||
410 | 410 | <ul> |
411 | 411 | <?php |
412 | 412 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
413 | - ?> |
|
413 | + ?> |
|
414 | 414 | <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
415 | 415 | <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
416 | 416 | <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
417 | 417 | <?php |
418 | 418 | } |
419 | - ?> |
|
419 | + ?> |
|
420 | 420 | <?php |
421 | 421 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
422 | - ?> |
|
422 | + ?> |
|
423 | 423 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
424 | 424 | <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
425 | 425 | <?php } ?> |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | <?php } ?> |
429 | 429 | <?php |
430 | 430 | } |
431 | - ?> |
|
431 | + ?> |
|
432 | 432 | <li><?php echo _("Display airlines:"); ?> |
433 | 433 | <br/> |
434 | 434 | <select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines"> |
@@ -448,14 +448,14 @@ discard block |
||
448 | 448 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
449 | 449 | } |
450 | 450 | } |
451 | - ?> |
|
451 | + ?> |
|
452 | 452 | </select> |
453 | 453 | </li> |
454 | 454 | <?php |
455 | 455 | $Spotter = new Spotter(); |
456 | 456 | $allalliancenames = $Spotter->getAllAllianceNames(); |
457 | 457 | if (!empty($allalliancenames)) { |
458 | - ?> |
|
458 | + ?> |
|
459 | 459 | <li><?php echo _("Display alliance:"); ?> |
460 | 460 | <br/> |
461 | 461 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
@@ -469,15 +469,15 @@ discard block |
||
469 | 469 | echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>'; |
470 | 470 | } |
471 | 471 | } |
472 | - ?> |
|
472 | + ?> |
|
473 | 473 | </select> |
474 | 474 | </li> |
475 | 475 | <?php |
476 | 476 | } |
477 | - ?> |
|
477 | + ?> |
|
478 | 478 | <?php |
479 | 479 | if (isset($globalAPRS) && $globalAPRS) { |
480 | - ?> |
|
480 | + ?> |
|
481 | 481 | <li><?php echo _("Display APRS sources name:"); ?> |
482 | 482 | <select class="selectpicker" multiple onchange="sources(this);"> |
483 | 483 | <?php |
@@ -489,15 +489,15 @@ discard block |
||
489 | 489 | echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>'; |
490 | 490 | } |
491 | 491 | } |
492 | - ?> |
|
492 | + ?> |
|
493 | 493 | </select> |
494 | 494 | </li> |
495 | 495 | <?php |
496 | 496 | } |
497 | - ?> |
|
497 | + ?> |
|
498 | 498 | <?php |
499 | 499 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
500 | - ?> |
|
500 | + ?> |
|
501 | 501 | <li><?php echo _("Display airlines of type:"); ?><br/> |
502 | 502 | <select class="selectpicker" onchange="airlinestype(this);"> |
503 | 503 | <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | </li> |
509 | 509 | <?php |
510 | 510 | } |
511 | - ?> |
|
511 | + ?> |
|
512 | 512 | <li> |
513 | 513 | <?php echo _("Display flight with ident:"); ?> |
514 | 514 | <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | </form> |
522 | 522 | </div> |
523 | 523 | <?php |
524 | - if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
524 | + if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
525 | 525 | ?> |
526 | 526 | <div class="sidebar-pane" id="satellites"> |
527 | 527 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -561,14 +561,14 @@ discard block |
||
561 | 561 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
562 | 562 | } |
563 | 563 | } |
564 | - ?> |
|
564 | + ?> |
|
565 | 565 | </select> |
566 | 566 | </li> |
567 | 567 | </ul> |
568 | 568 | </form> |
569 | 569 | </div> |
570 | 570 | <?php |
571 | - } |
|
571 | + } |
|
572 | 572 | ?> |
573 | 573 | </div> |
574 | 574 | </div> |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | require_once('require/class.Satellite.php'); |
6 | 6 | |
7 | -$trackident = filter_input(INPUT_GET,'trackid',FILTER_SANITIZE_STRING); |
|
7 | +$trackident = filter_input(INPUT_GET, 'trackid', FILTER_SANITIZE_STRING); |
|
8 | 8 | if ($trackident != '') { |
9 | 9 | require_once('require/class.SpotterLive.php'); |
10 | 10 | $SpotterLive = new SpotterLive(); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $spotterid = $Spotter->getSpotterIDBasedOnFlightAwareID($trackident); |
15 | 15 | header('Location: '.$globalURL.'/flightid/'.$spotterid); |
16 | 16 | } else { |
17 | - setcookie('MapTrack',$resulttrackident[0]['flightaware_id']); |
|
17 | + setcookie('MapTrack', $resulttrackident[0]['flightaware_id']); |
|
18 | 18 | } |
19 | 19 | } else { |
20 | 20 | unset($_COOKIE['MapTrack']); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | <div class="form-group"> |
168 | 168 | <label>From (UTC):</label> |
169 | 169 | <div class='input-group date' id='datetimepicker1'> |
170 | - <input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required /> |
|
170 | + <input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a", $_COOKIE['archive_begin']); ?>" required /> |
|
171 | 171 | <span class="input-group-addon"> |
172 | 172 | <span class="glyphicon glyphicon-calendar"></span> |
173 | 173 | </span> |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | <div class="form-group"> |
177 | 177 | <label>To (UTC):</label> |
178 | 178 | <div class='input-group date' id='datetimepicker2'> |
179 | - <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" /> |
|
179 | + <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a", $_COOKIE['archive_end']); ?>" /> |
|
180 | 180 | <span class="input-group-addon"> |
181 | 181 | <span class="glyphicon glyphicon-calendar"></span> |
182 | 182 | </span> |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | <li><?php echo _("Type of Terrain:"); ?> |
302 | 302 | <select class="selectpicker" onchange="terrainType(this);"> |
303 | 303 | <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option> |
304 | - <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option> |
|
305 | - <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option> |
|
304 | + <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected'; ?>>ellipsoid</option> |
|
305 | + <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected'; ?>>vr terrain</option> |
|
306 | 306 | </select> |
307 | 307 | </li> |
308 | 308 | <?php |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
327 | 327 | <?php |
328 | 328 | } |
329 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
329 | + if (time() > mktime(0, 0, 0, 12, 1, date("Y")) && time() < mktime(0, 0, 0, 12, 31, date("Y"))) { |
|
330 | 330 | ?> |
331 | 331 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
332 | 332 | <?php |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | $Spotter = new Spotter(); |
440 | 440 | $allairlinenames = $Spotter->getAllAirlineNames(); |
441 | 441 | } |
442 | - foreach($allairlinenames as $airline) { |
|
442 | + foreach ($allairlinenames as $airline) { |
|
443 | 443 | $airline_name = $airline['airline_name']; |
444 | - if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...'; |
|
445 | - if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) { |
|
444 | + if (strlen($airline_name) > 30) $airline_name = substr($airline_name, 0, 30).'...'; |
|
445 | + if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'], explode(',', $_COOKIE['filter_Airlines']))) { |
|
446 | 446 | echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>'; |
447 | 447 | } else { |
448 | 448 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
462 | 462 | <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
463 | 463 | <?php |
464 | - foreach($allalliancenames as $alliance) { |
|
464 | + foreach ($allalliancenames as $alliance) { |
|
465 | 465 | $alliance_name = $alliance['alliance']; |
466 | 466 | if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] == $alliance_name) { |
467 | 467 | echo '<option value="'.$alliance_name.'" selected>'.$alliance_name.'</option>'; |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | <select class="selectpicker" multiple onchange="sources(this);"> |
483 | 483 | <?php |
484 | 484 | $Spotter = new Spotter(); |
485 | - foreach($Spotter->getAllSourceName('aprs') as $source) { |
|
486 | - if (isset($_COOKIE['filter_Sources']) && in_array($source['source_name'],explode(',',$_COOKIE['filter_Sources']))) { |
|
485 | + foreach ($Spotter->getAllSourceName('aprs') as $source) { |
|
486 | + if (isset($_COOKIE['filter_Sources']) && in_array($source['source_name'], explode(',', $_COOKIE['filter_Sources']))) { |
|
487 | 487 | echo '<option value="'.$source['source_name'].'" selected>'.$source['source_name'].'</option>'; |
488 | 488 | } else { |
489 | 489 | echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>'; |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | else if ($type_name == 'radar') $type_name = 'Radar Calibration'; |
556 | 556 | else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches'; |
557 | 557 | |
558 | - if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) { |
|
558 | + if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'], explode(',', $_COOKIE['sattypes']))) { |
|
559 | 559 | print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>'; |
560 | 560 | } else { |
561 | 561 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
@@ -135,11 +135,26 @@ discard block |
||
135 | 135 | <li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam();" /><?php echo _("Display NOTAM"); ?></label></div></li> |
136 | 136 | <li><?php echo _("NOTAM scope:"); ?> |
137 | 137 | <select class="selectpicker" onchange="notamscope(this);"> |
138 | - <option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option> |
|
139 | - <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option> |
|
140 | - <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option> |
|
141 | - <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option> |
|
142 | - <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option> |
|
138 | + <option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') { |
|
139 | + print ' selected'; |
|
140 | +} |
|
141 | +?>>All</option> |
|
142 | + <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') { |
|
143 | + print ' selected'; |
|
144 | +} |
|
145 | +?>>Airport/Enroute warning</option> |
|
146 | + <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') { |
|
147 | + print ' selected'; |
|
148 | +} |
|
149 | +?>>Airport warning</option> |
|
150 | + <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') { |
|
151 | + print ' selected'; |
|
152 | +} |
|
153 | +?>>Navigation warning</option> |
|
154 | + <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') { |
|
155 | + print ' selected'; |
|
156 | +} |
|
157 | +?>>Enroute warning</option> |
|
143 | 158 | </select |
144 | 159 | </li> |
145 | 160 | </ul> |
@@ -167,7 +182,12 @@ discard block |
||
167 | 182 | <div class="form-group"> |
168 | 183 | <label>From (UTC):</label> |
169 | 184 | <div class='input-group date' id='datetimepicker1'> |
170 | - <input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required /> |
|
185 | + <input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) { |
|
186 | + print $_POST['start_date']; |
|
187 | +} elseif (isset($_COOKIE['archive_begin'])) { |
|
188 | + print date("m/d/Y h:i a",$_COOKIE['archive_begin']); |
|
189 | +} |
|
190 | +?>" required /> |
|
171 | 191 | <span class="input-group-addon"> |
172 | 192 | <span class="glyphicon glyphicon-calendar"></span> |
173 | 193 | </span> |
@@ -176,7 +196,12 @@ discard block |
||
176 | 196 | <div class="form-group"> |
177 | 197 | <label>To (UTC):</label> |
178 | 198 | <div class='input-group date' id='datetimepicker2'> |
179 | - <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" /> |
|
199 | + <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) { |
|
200 | + print $_POST['end_date']; |
|
201 | +} elseif (isset($_COOKIE['archive_end'])) { |
|
202 | + print date("m/d/Y h:i a",$_COOKIE['archive_end']); |
|
203 | +} |
|
204 | +?>" /> |
|
180 | 205 | <span class="input-group-addon"> |
181 | 206 | <span class="glyphicon glyphicon-calendar"></span> |
182 | 207 | </span> |
@@ -202,8 +227,20 @@ discard block |
||
202 | 227 | |
203 | 228 | <li><?php echo _("Playback speed:"); ?> |
204 | 229 | <div class="range"> |
205 | - <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php if (isset($_POST['archivespeed'])) print $_POST['archivespeed']; elseif (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>"> |
|
206 | - <output id="archivespeedrange"><?php if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output> |
|
230 | + <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php if (isset($_POST['archivespeed'])) { |
|
231 | + print $_POST['archivespeed']; |
|
232 | +} elseif (isset($_COOKIE['archive_speed'])) { |
|
233 | + print $_COOKIE['archive_speed']; |
|
234 | +} else { |
|
235 | + print '1'; |
|
236 | +} |
|
237 | +?>"> |
|
238 | + <output id="archivespeedrange"><?php if (isset($_COOKIE['archive_speed'])) { |
|
239 | + print $_COOKIE['archive_speed']; |
|
240 | +} else { |
|
241 | + print '1'; |
|
242 | +} |
|
243 | +?></output> |
|
207 | 244 | </div> |
208 | 245 | </li> |
209 | 246 | <li><input type="submit" name="archive" value="Show archive" class="btn btn-primary" /></li> |
@@ -225,15 +262,27 @@ discard block |
||
225 | 262 | <li><?php echo _("Type of Map:"); ?> |
226 | 263 | <select class="selectpicker" onchange="mapType(this);"> |
227 | 264 | <?php |
228 | - if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
|
229 | - else $MapType = $_COOKIE['MapType']; |
|
265 | + if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') { |
|
266 | + $MapType = $globalMapProvider; |
|
267 | + } else { |
|
268 | + $MapType = $_COOKIE['MapType']; |
|
269 | + } |
|
230 | 270 | ?> |
231 | 271 | <?php |
232 | 272 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
233 | 273 | ?> |
234 | - <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
|
235 | - <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
|
236 | - <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
|
274 | + <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') { |
|
275 | + print ' selected'; |
|
276 | +} |
|
277 | +?>>Bing-Aerial</option> |
|
278 | + <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') { |
|
279 | + print ' selected'; |
|
280 | +} |
|
281 | +?>>Bing-Hybrid</option> |
|
282 | + <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') { |
|
283 | + print ' selected'; |
|
284 | +} |
|
285 | +?>>Bing-Road</option> |
|
237 | 286 | <?php |
238 | 287 | } |
239 | 288 | ?> |
@@ -243,56 +292,131 @@ discard block |
||
243 | 292 | <?php |
244 | 293 | if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
245 | 294 | ?> |
246 | - <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
|
247 | - <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
|
248 | - <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
|
295 | + <option value="Here-Aerial"<?php if ($MapType == 'Here') { |
|
296 | + print ' selected'; |
|
297 | +} |
|
298 | +?>>Here-Aerial</option> |
|
299 | + <option value="Here-Hybrid"<?php if ($MapType == 'Here') { |
|
300 | + print ' selected'; |
|
301 | +} |
|
302 | +?>>Here-Hybrid</option> |
|
303 | + <option value="Here-Road"<?php if ($MapType == 'Here') { |
|
304 | + print ' selected'; |
|
305 | +} |
|
306 | +?>>Here-Road</option> |
|
249 | 307 | <?php |
250 | 308 | } |
251 | 309 | ?> |
252 | 310 | <?php |
253 | 311 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
254 | 312 | ?> |
255 | - <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
|
256 | - <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
|
257 | - <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
|
258 | - <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
|
313 | + <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') { |
|
314 | + print ' selected'; |
|
315 | +} |
|
316 | +?>>Google Roadmap</option> |
|
317 | + <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') { |
|
318 | + print ' selected'; |
|
319 | +} |
|
320 | +?>>Google Satellite</option> |
|
321 | + <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') { |
|
322 | + print ' selected'; |
|
323 | +} |
|
324 | +?>>Google Hybrid</option> |
|
325 | + <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') { |
|
326 | + print ' selected'; |
|
327 | +} |
|
328 | +?>>Google Terrain</option> |
|
259 | 329 | <?php |
260 | 330 | } |
261 | 331 | ?> |
262 | 332 | <?php |
263 | 333 | if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
264 | 334 | ?> |
265 | - <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
|
266 | - <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
|
267 | - <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
|
335 | + <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') { |
|
336 | + print ' selected'; |
|
337 | +} |
|
338 | +?>>MapQuest-OSM</option> |
|
339 | + <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') { |
|
340 | + print ' selected'; |
|
341 | +} |
|
342 | +?>>MapQuest-Aerial</option> |
|
343 | + <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') { |
|
344 | + print ' selected'; |
|
345 | +} |
|
346 | +?>>MapQuest-Hybrid</option> |
|
268 | 347 | <?php |
269 | 348 | } |
270 | 349 | ?> |
271 | - <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
|
350 | + <option value="Yandex"<?php if ($MapType == 'Yandex') { |
|
351 | + print ' selected'; |
|
352 | +} |
|
353 | +?>>Yandex</option> |
|
272 | 354 | <?php |
273 | 355 | } |
274 | 356 | ?> |
275 | 357 | <?php |
276 | 358 | if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
277 | - if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
|
278 | - else $MapBoxId = $_COOKIE['MapTypeId']; |
|
359 | + if (!isset($_COOKIE['MapTypeId'])) { |
|
360 | + $MapBoxId = 'default'; |
|
361 | + } else { |
|
362 | + $MapBoxId = $_COOKIE['MapTypeId']; |
|
363 | + } |
|
279 | 364 | ?> |
280 | - <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
|
281 | - <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
|
282 | - <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
|
283 | - <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option> |
|
284 | - <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option> |
|
285 | - <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option> |
|
286 | - <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option> |
|
287 | - <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option> |
|
288 | - <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option> |
|
289 | - <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option> |
|
290 | - <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
|
291 | - <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
|
365 | + <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') { |
|
366 | + print ' selected'; |
|
367 | +} |
|
368 | +?>>Mapbox default</option> |
|
369 | + <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') { |
|
370 | + print ' selected'; |
|
371 | +} |
|
372 | +?>>Mapbox streets</option> |
|
373 | + <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') { |
|
374 | + print ' selected'; |
|
375 | +} |
|
376 | +?>>Mapbox light</option> |
|
377 | + <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') { |
|
378 | + print ' selected'; |
|
379 | +} |
|
380 | +?>>Mapbox dark</option> |
|
381 | + <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') { |
|
382 | + print ' selected'; |
|
383 | +} |
|
384 | +?>>Mapbox satellite</option> |
|
385 | + <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') { |
|
386 | + print ' selected'; |
|
387 | +} |
|
388 | +?>>Mapbox streets-satellite</option> |
|
389 | + <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') { |
|
390 | + print ' selected'; |
|
391 | +} |
|
392 | +?>>Mapbox streets-basic</option> |
|
393 | + <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') { |
|
394 | + print ' selected'; |
|
395 | +} |
|
396 | +?>>Mapbox comic</option> |
|
397 | + <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') { |
|
398 | + print ' selected'; |
|
399 | +} |
|
400 | +?>>Mapbox outdoors</option> |
|
401 | + <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') { |
|
402 | + print ' selected'; |
|
403 | +} |
|
404 | +?>>Mapbox pencil</option> |
|
405 | + <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') { |
|
406 | + print ' selected'; |
|
407 | +} |
|
408 | +?>>Mapbox pirates</option> |
|
409 | + <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') { |
|
410 | + print ' selected'; |
|
411 | +} |
|
412 | +?>>Mapbox emerald</option> |
|
292 | 413 | <?php |
293 | 414 | } |
294 | 415 | ?> |
295 | - <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
|
416 | + <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') { |
|
417 | + print ' selected'; |
|
418 | +} |
|
419 | +?>>OpenStreetMap</option> |
|
296 | 420 | </select> |
297 | 421 | </li> |
298 | 422 | <?php |
@@ -300,9 +424,18 @@ discard block |
||
300 | 424 | ?> |
301 | 425 | <li><?php echo _("Type of Terrain:"); ?> |
302 | 426 | <select class="selectpicker" onchange="terrainType(this);"> |
303 | - <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option> |
|
304 | - <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option> |
|
305 | - <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option> |
|
427 | + <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') { |
|
428 | + print ' selected'; |
|
429 | +} |
|
430 | +?>>stk terrain</option> |
|
431 | + <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') { |
|
432 | + print ' selected'; |
|
433 | +} |
|
434 | +?>>ellipsoid</option> |
|
435 | + <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') { |
|
436 | + print ' selected'; |
|
437 | +} |
|
438 | +?>>vr terrain</option> |
|
306 | 439 | </select> |
307 | 440 | </li> |
308 | 441 | <?php |
@@ -312,18 +445,36 @@ discard block |
||
312 | 445 | if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
313 | 446 | ?> |
314 | 447 | |
315 | - <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
|
316 | - <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || !isset($_COOKIE['flightpath'])) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li> |
|
317 | - <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
|
318 | - <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
|
448 | + <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') { |
|
449 | + print 'checked'; |
|
450 | +} |
|
451 | +?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
|
452 | + <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || !isset($_COOKIE['flightpath'])) { |
|
453 | + print 'checked'; |
|
454 | +} |
|
455 | +?> ><?php echo _("Display flight path"); ?></label></div></li> |
|
456 | + <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) { |
|
457 | + print 'checked'; |
|
458 | +} |
|
459 | +?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
|
460 | + <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) { |
|
461 | + print 'checked'; |
|
462 | +} |
|
463 | +?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
|
319 | 464 | <?php |
320 | 465 | } |
321 | 466 | ?> |
322 | - <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
|
467 | + <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') { |
|
468 | + print 'checked'; |
|
469 | +} |
|
470 | +?> ><?php echo _("Display airports on map"); ?></label></div></li> |
|
323 | 471 | <?php |
324 | 472 | if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
325 | 473 | ?> |
326 | - <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
|
474 | + <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) { |
|
475 | + print 'checked'; |
|
476 | +} |
|
477 | +?> ><?php echo _("Show mini-map"); ?></label></div></li> |
|
327 | 478 | <?php |
328 | 479 | } |
329 | 480 | if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
@@ -337,17 +488,25 @@ discard block |
||
337 | 488 | if (function_exists('array_column')) { |
338 | 489 | if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
339 | 490 | ?> |
340 | - <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
|
491 | + <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
|
492 | + print 'checked'; |
|
493 | +} |
|
494 | +?> ><?php echo _("Display polar on map"); ?></label></div></li> |
|
341 | 495 | <?php |
342 | 496 | } |
343 | 497 | } elseif (isset($globalSources)) { |
344 | 498 | $dispolar = false; |
345 | 499 | foreach ($globalSources as $testsource) { |
346 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
500 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) { |
|
501 | + $dispolar = true; |
|
502 | + } |
|
347 | 503 | } |
348 | 504 | if ($dispolar) { |
349 | 505 | ?> |
350 | - <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
|
506 | + <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
|
507 | + print 'checked'; |
|
508 | +} |
|
509 | +?> ><?php echo _("Display polar on map"); ?></label></div></li> |
|
351 | 510 | <?php |
352 | 511 | } |
353 | 512 | } |
@@ -359,12 +518,22 @@ discard block |
||
359 | 518 | <?php |
360 | 519 | if (extension_loaded('gd') && function_exists('gd_info')) { |
361 | 520 | ?> |
362 | - <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
|
521 | + <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') { |
|
522 | + print 'checked'; |
|
523 | +} |
|
524 | +?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
|
363 | 525 | <?php |
364 | 526 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
365 | 527 | ?> |
366 | 528 | <li><?php echo _("Aircraft icon color:"); ?> |
367 | - <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
|
529 | + <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) { |
|
530 | + print $_COOKIE['IconColor']; |
|
531 | +} elseif (isset($globalAircraftIconColor)) { |
|
532 | + print $globalAircraftIconColor; |
|
533 | +} else { |
|
534 | + print '1a3151'; |
|
535 | +} |
|
536 | +?>"> |
|
368 | 537 | </li> |
369 | 538 | <?php |
370 | 539 | } |
@@ -372,8 +541,22 @@ discard block |
||
372 | 541 | ?> |
373 | 542 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
374 | 543 | <div class="range"> |
375 | - <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
|
376 | - <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output> |
|
544 | + <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) { |
|
545 | + print $_COOKIE['AirportZoom']; |
|
546 | +} elseif (isset($globalAirportZoom)) { |
|
547 | + print $globalAirportZoom; |
|
548 | +} else { |
|
549 | + print '7'; |
|
550 | +} |
|
551 | +?>"> |
|
552 | + <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) { |
|
553 | + print $_COOKIE['AirportZoom']; |
|
554 | +} elseif (isset($globalAirportZoom)) { |
|
555 | + print $globalAirportZoom; |
|
556 | +} else { |
|
557 | + print '7'; |
|
558 | +} |
|
559 | +?></output> |
|
377 | 560 | </div> |
378 | 561 | </li> |
379 | 562 | <?php |
@@ -381,22 +564,46 @@ discard block |
||
381 | 564 | ?> |
382 | 565 | <li><?php echo _("Distance unit:"); ?> |
383 | 566 | <select class="selectpicker" onchange="unitdistance(this);"> |
384 | - <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option> |
|
385 | - <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option> |
|
386 | - <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option> |
|
567 | + <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) { |
|
568 | + echo ' selected'; |
|
569 | +} |
|
570 | +?>>km</option> |
|
571 | + <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
|
572 | + echo ' selected'; |
|
573 | +} |
|
574 | +?>>nm</option> |
|
575 | + <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) { |
|
576 | + echo ' selected'; |
|
577 | +} |
|
578 | +?>>mi</option> |
|
387 | 579 | </select> |
388 | 580 | </li> |
389 | 581 | <li><?php echo _("Altitude unit:"); ?> |
390 | 582 | <select class="selectpicker" onchange="unitaltitude(this);"> |
391 | - <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option> |
|
392 | - <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option> |
|
583 | + <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) { |
|
584 | + echo ' selected'; |
|
585 | +} |
|
586 | +?>>m</option> |
|
587 | + <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
|
588 | + echo ' selected'; |
|
589 | +} |
|
590 | +?>>feet</option> |
|
393 | 591 | </select> |
394 | 592 | </li> |
395 | 593 | <li><?php echo _("Speed unit:"); ?> |
396 | 594 | <select class="selectpicker" onchange="unitspeed(this);"> |
397 | - <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option> |
|
398 | - <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option> |
|
399 | - <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option> |
|
595 | + <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) { |
|
596 | + echo ' selected'; |
|
597 | +} |
|
598 | +?>>km/h</option> |
|
599 | + <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) { |
|
600 | + echo ' selected'; |
|
601 | +} |
|
602 | +?>>mph</option> |
|
603 | + <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) { |
|
604 | + echo ' selected'; |
|
605 | +} |
|
606 | +?>>knots</option> |
|
400 | 607 | </select> |
401 | 608 | </li> |
402 | 609 | |
@@ -411,9 +618,18 @@ discard block |
||
411 | 618 | <?php |
412 | 619 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
413 | 620 | ?> |
414 | - <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
|
415 | - <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
|
416 | - <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
|
621 | + <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) { |
|
622 | + print 'checked'; |
|
623 | +} |
|
624 | +?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
|
625 | + <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) { |
|
626 | + print 'checked'; |
|
627 | +} |
|
628 | +?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
|
629 | + <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) { |
|
630 | + print 'checked'; |
|
631 | +} |
|
632 | +?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
|
417 | 633 | <?php |
418 | 634 | } |
419 | 635 | ?> |
@@ -421,10 +637,16 @@ discard block |
||
421 | 637 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
422 | 638 | ?> |
423 | 639 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
424 | - <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
|
640 | + <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) { |
|
641 | + print 'checked'; |
|
642 | +} |
|
643 | +?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
|
425 | 644 | <?php } ?> |
426 | 645 | <?php if (isset($globalAPRS) && $globalAPRS) { ?> |
427 | - <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li> |
|
646 | + <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) { |
|
647 | + print 'checked'; |
|
648 | +} |
|
649 | +?> ><?php echo _("Display APRS data"); ?></label></div></li> |
|
428 | 650 | <?php } ?> |
429 | 651 | <?php |
430 | 652 | } |
@@ -441,7 +663,9 @@ discard block |
||
441 | 663 | } |
442 | 664 | foreach($allairlinenames as $airline) { |
443 | 665 | $airline_name = $airline['airline_name']; |
444 | - if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...'; |
|
666 | + if (strlen($airline_name) > 30) { |
|
667 | + $airline_name = substr($airline_name,0,30).'...'; |
|
668 | + } |
|
445 | 669 | if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) { |
446 | 670 | echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>'; |
447 | 671 | } else { |
@@ -459,7 +683,10 @@ discard block |
||
459 | 683 | <li><?php echo _("Display alliance:"); ?> |
460 | 684 | <br/> |
461 | 685 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
462 | - <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
|
686 | + <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') { |
|
687 | + echo ' selected'; |
|
688 | +} |
|
689 | +?>><?php echo _("All"); ?></option> |
|
463 | 690 | <?php |
464 | 691 | foreach($allalliancenames as $alliance) { |
465 | 692 | $alliance_name = $alliance['alliance']; |
@@ -500,10 +727,22 @@ discard block |
||
500 | 727 | ?> |
501 | 728 | <li><?php echo _("Display airlines of type:"); ?><br/> |
502 | 729 | <select class="selectpicker" onchange="airlinestype(this);"> |
503 | - <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
|
504 | - <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option> |
|
505 | - <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option> |
|
506 | - <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option> |
|
730 | + <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') { |
|
731 | + echo ' selected'; |
|
732 | +} |
|
733 | +?>><?php echo _("All"); ?></option> |
|
734 | + <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') { |
|
735 | + echo ' selected'; |
|
736 | +} |
|
737 | +?>><?php echo _("Passenger"); ?></option> |
|
738 | + <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') { |
|
739 | + echo ' selected'; |
|
740 | +} |
|
741 | +?>><?php echo _("Cargo"); ?></option> |
|
742 | + <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') { |
|
743 | + echo ' selected'; |
|
744 | +} |
|
745 | +?>><?php echo _("Military"); ?></option> |
|
507 | 746 | </select> |
508 | 747 | </li> |
509 | 748 | <?php |
@@ -511,7 +750,10 @@ discard block |
||
511 | 750 | ?> |
512 | 751 | <li> |
513 | 752 | <?php echo _("Display flight with ident:"); ?> |
514 | - <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
|
753 | + <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) { |
|
754 | + print $_COOKIE['filter_ident']; |
|
755 | +} |
|
756 | +?>" /> |
|
515 | 757 | </li> |
516 | 758 | </ul> |
517 | 759 | </form> |
@@ -527,7 +769,10 @@ discard block |
||
527 | 769 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
528 | 770 | <form> |
529 | 771 | <ul> |
530 | - <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li> |
|
772 | + <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') { |
|
773 | + print 'checked'; |
|
774 | +} |
|
775 | +?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li> |
|
531 | 776 | <li><?php echo _("Type:"); ?> |
532 | 777 | <select class="selectpicker" multiple onchange="sattypes(this);"> |
533 | 778 | <?php |
@@ -535,25 +780,45 @@ discard block |
||
535 | 780 | $types = $Satellite->get_tle_types(); |
536 | 781 | foreach ($types as $type) { |
537 | 782 | $type_name = $type['tle_type']; |
538 | - if ($type_name == 'musson') $type_name = 'Russian LEO Navigation'; |
|
539 | - else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System'; |
|
540 | - else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System'; |
|
541 | - else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational'; |
|
542 | - else if ($type_name == 'gps-ops') $type_name = 'GPS Operational'; |
|
543 | - else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System'; |
|
544 | - else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System'; |
|
545 | - else if ($type_name == 'sarsat') $type_name = 'Search & Rescue'; |
|
546 | - else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring'; |
|
547 | - else if ($type_name == 'resource') $type_name = 'Earth Resources'; |
|
548 | - else if ($type_name == 'stations') $type_name = 'Space Stations'; |
|
549 | - else if ($type_name == 'geo') $type_name = 'Geostationary'; |
|
550 | - else if ($type_name == 'amateur') $type_name = 'Amateur Radio'; |
|
551 | - else if ($type_name == 'x-comm') $type_name = 'Experimental'; |
|
552 | - else if ($type_name == 'other-comm') $type_name = 'Other Comm'; |
|
553 | - else if ($type_name == 'science') $type_name = 'Space & Earth Science'; |
|
554 | - else if ($type_name == 'military') $type_name = 'Miscellaneous Military'; |
|
555 | - else if ($type_name == 'radar') $type_name = 'Radar Calibration'; |
|
556 | - else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches'; |
|
783 | + if ($type_name == 'musson') { |
|
784 | + $type_name = 'Russian LEO Navigation'; |
|
785 | + } else if ($type_name == 'nnss') { |
|
786 | + $type_name = 'Navi Navigation Satellite System'; |
|
787 | + } else if ($type_name == 'sbas') { |
|
788 | + $type_name = 'Satellite-Based Augmentation System'; |
|
789 | + } else if ($type_name == 'glo-ops') { |
|
790 | + $type_name = 'Glonass Operational'; |
|
791 | + } else if ($type_name == 'gps-ops') { |
|
792 | + $type_name = 'GPS Operational'; |
|
793 | + } else if ($type_name == 'argos') { |
|
794 | + $type_name = 'ARGOS Data Collection System'; |
|
795 | + } else if ($type_name == 'tdrss') { |
|
796 | + $type_name = 'Tracking and Data Relay Satellite System'; |
|
797 | + } else if ($type_name == 'sarsat') { |
|
798 | + $type_name = 'Search & Rescue'; |
|
799 | + } else if ($type_name == 'dmc') { |
|
800 | + $type_name = 'Disaster Monitoring'; |
|
801 | + } else if ($type_name == 'resource') { |
|
802 | + $type_name = 'Earth Resources'; |
|
803 | + } else if ($type_name == 'stations') { |
|
804 | + $type_name = 'Space Stations'; |
|
805 | + } else if ($type_name == 'geo') { |
|
806 | + $type_name = 'Geostationary'; |
|
807 | + } else if ($type_name == 'amateur') { |
|
808 | + $type_name = 'Amateur Radio'; |
|
809 | + } else if ($type_name == 'x-comm') { |
|
810 | + $type_name = 'Experimental'; |
|
811 | + } else if ($type_name == 'other-comm') { |
|
812 | + $type_name = 'Other Comm'; |
|
813 | + } else if ($type_name == 'science') { |
|
814 | + $type_name = 'Space & Earth Science'; |
|
815 | + } else if ($type_name == 'military') { |
|
816 | + $type_name = 'Miscellaneous Military'; |
|
817 | + } else if ($type_name == 'radar') { |
|
818 | + $type_name = 'Radar Calibration'; |
|
819 | + } else if ($type_name == 'tle-new') { |
|
820 | + $type_name = 'Last 30 days launches'; |
|
821 | + } |
|
557 | 822 | |
558 | 823 | if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) { |
559 | 824 | print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>'; |
@@ -24,13 +24,21 @@ discard block |
||
24 | 24 | |
25 | 25 | print '<div class="select-item"><form action="'.$globalURL.'/airline" method="post"><select name="airline_type" class="selectpicker" data-live-search="true">'; |
26 | 26 | print '<option value="all"'; |
27 | - if ($airline_type == 'all') print 'selected="selected" '; |
|
27 | + if ($airline_type == 'all') { |
|
28 | + print 'selected="selected" '; |
|
29 | + } |
|
28 | 30 | print '>'._("All").'</option><option value="passenger"'; |
29 | - if ($airline_type == 'passenger') print 'selected="selected" '; |
|
31 | + if ($airline_type == 'passenger') { |
|
32 | + print 'selected="selected" '; |
|
33 | + } |
|
30 | 34 | print '>'._("Passenger").'</option><option value="cargo"'; |
31 | - if ($airline_type == 'cargo') print 'selected="selected" '; |
|
35 | + if ($airline_type == 'cargo') { |
|
36 | + print 'selected="selected" '; |
|
37 | + } |
|
32 | 38 | print '>'._("Cargo").'</option><option value="military"'; |
33 | - if ($airline_type == 'military') print 'selected="selected" '; |
|
39 | + if ($airline_type == 'military') { |
|
40 | + print 'selected="selected" '; |
|
41 | + } |
|
34 | 42 | print '>'._("Military").'</option></select>'; |
35 | 43 | print '<button type="submit"><i class="fa fa-angle-double-right"></i></button></form></div>'; |
36 | 44 | |
@@ -57,7 +65,9 @@ discard block |
||
57 | 65 | $firstLetter = mb_strtoupper(mb_substr($value['airline_name'], 0, 1),'UTF-8'); |
58 | 66 | if($previous !== $firstLetter) |
59 | 67 | { |
60 | - if ($previous !== null) print ' | '; |
|
68 | + if ($previous !== null) { |
|
69 | + print ' | '; |
|
70 | + } |
|
61 | 71 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
62 | 72 | } |
63 | 73 | $previous = $firstLetter; |
@@ -70,7 +80,9 @@ discard block |
||
70 | 80 | { |
71 | 81 | if($previous !== $firstLetter) |
72 | 82 | { |
73 | - if ($previous !== null) print '</div>'; |
|
83 | + if ($previous !== null) { |
|
84 | + print '</div>'; |
|
85 | + } |
|
74 | 86 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
75 | 87 | } |
76 | 88 | $previous = $firstLetter; |
@@ -82,10 +94,14 @@ discard block |
||
82 | 94 | } elseif (@getimagesize('images/airlines/'.$value['airline_icao'].'.png') || @getimagesize($globalURL.'/images/airlines/'.$value['airline_icao'].'.png')) |
83 | 95 | { |
84 | 96 | print '<img src="'.$globalURL.'/images/airlines/'.$value['airline_icao'].'.png" alt="'._("Click to see airline activity").'" title="'._("Click to see airline activity").'" /> '; |
85 | - if (isset($value['ban_eu']) && $value['ban_eu'] == 1) print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> '; |
|
97 | + if (isset($value['ban_eu']) && $value['ban_eu'] == 1) { |
|
98 | + print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> '; |
|
99 | + } |
|
86 | 100 | } else { |
87 | 101 | print $value['airline_name']; |
88 | - if (isset($value['ban_eu']) && $value['ban_eu'] == 1) print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> '; |
|
102 | + if (isset($value['ban_eu']) && $value['ban_eu'] == 1) { |
|
103 | + print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> '; |
|
104 | + } |
|
89 | 105 | } |
90 | 106 | print '</a>'; |
91 | 107 | print '</div>'; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | print '<div class="column">'; |
16 | 16 | print '<h1>'._("Airlines").'</h1>'; |
17 | 17 | if (isset($_POST['airline_type'])) { |
18 | - $airline_type = filter_input(INPUT_POST,'airline_type',FILTER_SANITIZE_STRING); |
|
18 | + $airline_type = filter_input(INPUT_POST, 'airline_type', FILTER_SANITIZE_STRING); |
|
19 | 19 | //$airline_names = $Spotter->getAllAirlineNames($airline_type); |
20 | 20 | } else { |
21 | 21 | //$airline_names = $Spotter->getAllAirlineNames(); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $Stats = new Stats(); |
38 | 38 | if (isset($_POST['airline_type'])) |
39 | 39 | { |
40 | - $airline_type = filter_input(INPUT_POST,'airline_type',FILTER_SANITIZE_STRING); |
|
40 | + $airline_type = filter_input(INPUT_POST, 'airline_type', FILTER_SANITIZE_STRING); |
|
41 | 41 | //$airline_names = $Stats->getAllAirlineNames($airline_type); |
42 | 42 | $airline_names = $Spotter->getAllAirlineNames($airline_type); |
43 | 43 | } else { |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | } |
51 | 51 | $previous = null; |
52 | 52 | print '<div class="alphabet-legend">'; |
53 | - foreach($airline_names as $value) |
|
53 | + foreach ($airline_names as $value) |
|
54 | 54 | { |
55 | 55 | //echo $value['airline_name']."\n"; |
56 | 56 | //echo mb_substr($value['airline_name'],0,1).' - '.$value['airline_name']."\n"; |
57 | - $firstLetter = mb_strtoupper(mb_substr($value['airline_name'], 0, 1),'UTF-8'); |
|
58 | - if($previous !== $firstLetter) |
|
57 | + $firstLetter = mb_strtoupper(mb_substr($value['airline_name'], 0, 1), 'UTF-8'); |
|
58 | + if ($previous !== $firstLetter) |
|
59 | 59 | { |
60 | 60 | if ($previous !== null) print ' | '; |
61 | 61 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | } |
65 | 65 | print '</div>'; |
66 | 66 | $previous = null; |
67 | - foreach($airline_names as $value) { |
|
67 | + foreach ($airline_names as $value) { |
|
68 | 68 | $firstLetter = strtoupper(substr($value['airline_name'], 0, 1)); |
69 | 69 | if ($firstLetter != "") |
70 | 70 | { |
71 | - if($previous !== $firstLetter) |
|
71 | + if ($previous !== $firstLetter) |
|
72 | 72 | { |
73 | 73 | if ($previous !== null) print '</div>'; |
74 | 74 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $limit_start = 0; |
15 | 15 | $limit_end = 25; |
16 | 16 | $absolute_difference = 25; |
17 | - } else { |
|
17 | + } else { |
|
18 | 18 | $limit_explode = explode(",", $_GET['limit']); |
19 | 19 | $limit_start = $limit_explode[0]; |
20 | 20 | $limit_end = $limit_explode[1]; |
@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | { |
39 | 39 | if (isset($spotter_array[0]['airline_name']) && isset($spotter_array[0]['airline_icao'])) { |
40 | 40 | $title = sprintf(_("Detailed View for %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']); |
41 | - } else $title = ''; |
|
41 | + } else { |
|
42 | + $title = ''; |
|
43 | + } |
|
42 | 44 | require_once('header.php'); |
43 | 45 | |
44 | 46 | print '<div class="select-item">'; |
@@ -47,7 +49,9 @@ discard block |
||
47 | 49 | print '<option></option>'; |
48 | 50 | $Stats = new Stats(); |
49 | 51 | $airline_names = $Stats->getAllAirlineNames(); |
50 | - if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames(); |
|
52 | + if (empty($airline_names)) { |
|
53 | + $airline_names = $Spotter->getAllAirlineNames(); |
|
54 | + } |
|
51 | 55 | foreach($airline_names as $airline_name) |
52 | 56 | { |
53 | 57 | if($_GET['airline'] == $airline_name['airline_icao']) |
@@ -76,10 +80,16 @@ discard block |
||
76 | 80 | print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['airline_name'].'</div>'; |
77 | 81 | print '<div><span class="label">'._("Country").'</span>'.$spotter_array[0]['airline_country'].'</div>'; |
78 | 82 | print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['airline_icao'].'</div>'; |
79 | - if (isset($spotter_array[0]['airline_iata'])) print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>'; |
|
80 | - if (isset($spotter_array[0]['airline_callsign'])) print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>'; |
|
83 | + if (isset($spotter_array[0]['airline_iata'])) { |
|
84 | + print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>'; |
|
85 | + } |
|
86 | + if (isset($spotter_array[0]['airline_callsign'])) { |
|
87 | + print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>'; |
|
88 | + } |
|
81 | 89 | print '<div><span class="label">'._("Type").'</span>'.ucwords($spotter_array[0]['airline_type']).'</div>'; |
82 | - if (isset($spotter_array[0]['ban_eu']) && $spotter_array[0]['ban_eu'] == 1) print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>'; |
|
90 | + if (isset($spotter_array[0]['ban_eu']) && $spotter_array[0]['ban_eu'] == 1) { |
|
91 | + print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>'; |
|
92 | + } |
|
83 | 93 | print '</div>'; |
84 | 94 | } else { |
85 | 95 | print '<div class="alert alert-warning">'._("This special airline profile shows all flights that do <u>not</u> have a airline associated with them.").'</div>'; |
@@ -4,17 +4,17 @@ discard block |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | |
7 | -if (!isset($_GET['airline'])){ |
|
7 | +if (!isset($_GET['airline'])) { |
|
8 | 8 | header('Location: '.$globalURL.'/airline'); |
9 | -} else{ |
|
9 | +} else { |
|
10 | 10 | $Spotter = new Spotter(); |
11 | 11 | //calculuation for the pagination |
12 | - if(!isset($_GET['limit']) || $_GET['limit'] == "") |
|
12 | + if (!isset($_GET['limit']) || $_GET['limit'] == "") |
|
13 | 13 | { |
14 | 14 | $limit_start = 0; |
15 | 15 | $limit_end = 25; |
16 | 16 | $absolute_difference = 25; |
17 | - } else { |
|
17 | + } else { |
|
18 | 18 | $limit_explode = explode(",", $_GET['limit']); |
19 | 19 | $limit_start = $limit_explode[0]; |
20 | 20 | $limit_end = $limit_explode[1]; |
@@ -28,16 +28,16 @@ discard block |
||
28 | 28 | $limit_previous_1 = $limit_start - $absolute_difference; |
29 | 29 | $limit_previous_2 = $limit_end - $absolute_difference; |
30 | 30 | |
31 | - $airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
31 | + $airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
32 | 32 | $page_url = $globalURL.'/airline/'.$airline; |
33 | 33 | |
34 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
35 | - $spotter_array = $Spotter->getSpotterDataByAirline($_GET['airline'],$limit_start.",".$absolute_difference, $sort); |
|
34 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
35 | + $spotter_array = $Spotter->getSpotterDataByAirline($_GET['airline'], $limit_start.",".$absolute_difference, $sort); |
|
36 | 36 | |
37 | 37 | if (!empty($spotter_array)) |
38 | 38 | { |
39 | 39 | if (isset($spotter_array[0]['airline_name']) && isset($spotter_array[0]['airline_icao'])) { |
40 | - $title = sprintf(_("Detailed View for %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']); |
|
40 | + $title = sprintf(_("Detailed View for %s (%s)"), $spotter_array[0]['airline_name'], $spotter_array[0]['airline_icao']); |
|
41 | 41 | } else $title = ''; |
42 | 42 | require_once('header.php'); |
43 | 43 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | $Stats = new Stats(); |
49 | 49 | $airline_names = $Stats->getAllAirlineNames(); |
50 | 50 | if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames(); |
51 | - foreach($airline_names as $airline_name) |
|
51 | + foreach ($airline_names as $airline_name) |
|
52 | 52 | { |
53 | - if($_GET['airline'] == $airline_name['airline_icao']) |
|
53 | + if ($_GET['airline'] == $airline_name['airline_icao']) |
|
54 | 54 | { |
55 | 55 | print '<option value="'.$airline_name['airline_icao'].'" selected="selected">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>'; |
56 | 56 | } else { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | include('airline-sub-menu.php'); |
89 | 89 | print '<div class="table column">'; |
90 | 90 | if (isset($spotter_array[0]['airline_name'])) { |
91 | - print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."),$spotter_array[0]['airline_name']).'</p>'; |
|
91 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."), $spotter_array[0]['airline_name']).'</p>'; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | include('table-output.php'); |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | class update_schema { |
9 | 9 | |
10 | 10 | public static function update_schedule() { |
11 | - $Connection = new Connection(); |
|
12 | - $Schedule = new Schedule(); |
|
13 | - $query = "SELECT * FROM schedule"; |
|
14 | - try { |
|
15 | - $sth = $Connection->db->prepare($query); |
|
11 | + $Connection = new Connection(); |
|
12 | + $Schedule = new Schedule(); |
|
13 | + $query = "SELECT * FROM schedule"; |
|
14 | + try { |
|
15 | + $sth = $Connection->db->prepare($query); |
|
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch(PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | - } |
|
20 | - while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | - } |
|
19 | + } |
|
20 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | + $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | /* |
@@ -43,198 +43,198 @@ discard block |
||
43 | 43 | } |
44 | 44 | */ |
45 | 45 | private static function update_from_1() { |
46 | - $Connection = new Connection(); |
|
47 | - // Add new column to routes table |
|
48 | - //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
46 | + $Connection = new Connection(); |
|
47 | + // Add new column to routes table |
|
48 | + //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
49 | 49 | $query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL"; |
50 | - try { |
|
51 | - $sth = $Connection->db->prepare($query); |
|
52 | - $sth->execute(); |
|
53 | - } catch(PDOException $e) { |
|
54 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | - } |
|
56 | - // Copy schedules data to routes table |
|
57 | - self::update_schedule(); |
|
58 | - // Delete schedule table |
|
50 | + try { |
|
51 | + $sth = $Connection->db->prepare($query); |
|
52 | + $sth->execute(); |
|
53 | + } catch(PDOException $e) { |
|
54 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | + } |
|
56 | + // Copy schedules data to routes table |
|
57 | + self::update_schedule(); |
|
58 | + // Delete schedule table |
|
59 | 59 | $query = "DROP TABLE `schedule`"; |
60 | - try { |
|
61 | - $sth = $Connection->db->prepare($query); |
|
62 | - $sth->execute(); |
|
63 | - } catch(PDOException $e) { |
|
64 | - return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | - } |
|
66 | - // Add source column |
|
67 | - $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | - try { |
|
69 | - $sth = $Connection->db->prepare($query); |
|
70 | - $sth->execute(); |
|
71 | - } catch(PDOException $e) { |
|
72 | - return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | - } |
|
60 | + try { |
|
61 | + $sth = $Connection->db->prepare($query); |
|
62 | + $sth->execute(); |
|
63 | + } catch(PDOException $e) { |
|
64 | + return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | + } |
|
66 | + // Add source column |
|
67 | + $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | + try { |
|
69 | + $sth = $Connection->db->prepare($query); |
|
70 | + $sth->execute(); |
|
71 | + } catch(PDOException $e) { |
|
72 | + return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | + } |
|
74 | 74 | // Delete unused column |
75 | 75 | $query = "ALTER TABLE `aircraft_modes` DROP `SerialNo`, DROP `OperatorFlagCode`, DROP `Manufacturer`, DROP `Type`, DROP `FirstRegDate`, DROP `CurrentRegDate`, DROP `Country`, DROP `PreviousID`, DROP `DeRegDate`, DROP `Status`, DROP `PopularName`, DROP `GenericName`, DROP `AircraftClass`, DROP `Engines`, DROP `OwnershipStatus`, DROP `RegisteredOwners`, DROP `MTOW`, DROP `TotalHours`, DROP `YearBuilt`, DROP `CofACategory`, DROP `CofAExpiry`, DROP `UserNotes`, DROP `Interested`, DROP `UserTag`, DROP `InfoUrl`, DROP `PictureUrl1`, DROP `PictureUrl2`, DROP `PictureUrl3`, DROP `UserBool1`, DROP `UserBool2`, DROP `UserBool3`, DROP `UserBool4`, DROP `UserBool5`, DROP `UserString1`, DROP `UserString2`, DROP `UserString3`, DROP `UserString4`, DROP `UserString5`, DROP `UserInt1`, DROP `UserInt2`, DROP `UserInt3`, DROP `UserInt4`, DROP `UserInt5`"; |
76 | - try { |
|
77 | - $sth = $Connection->db->prepare($query); |
|
78 | - $sth->execute(); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | - } |
|
76 | + try { |
|
77 | + $sth = $Connection->db->prepare($query); |
|
78 | + $sth->execute(); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | + } |
|
82 | 82 | // Add ModeS column |
83 | 83 | $query = "ALTER TABLE `spotter_output` ADD `ModeS` VARCHAR(255) NULL"; |
84 | - try { |
|
85 | - $sth = $Connection->db->prepare($query); |
|
86 | - $sth->execute(); |
|
87 | - } catch(PDOException $e) { |
|
88 | - return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | - } |
|
84 | + try { |
|
85 | + $sth = $Connection->db->prepare($query); |
|
86 | + $sth->execute(); |
|
87 | + } catch(PDOException $e) { |
|
88 | + return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | + } |
|
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | - try { |
|
92 | - $sth = $Connection->db->prepare($query); |
|
93 | - $sth->execute(); |
|
94 | - } catch(PDOException $e) { |
|
95 | - return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | - } |
|
97 | - // Add auto_increment for aircraft_modes |
|
98 | - $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | - try { |
|
100 | - $sth = $Connection->db->prepare($query); |
|
101 | - $sth->execute(); |
|
102 | - } catch(PDOException $e) { |
|
103 | - return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | - } |
|
105 | - $error = ''; |
|
91 | + try { |
|
92 | + $sth = $Connection->db->prepare($query); |
|
93 | + $sth->execute(); |
|
94 | + } catch(PDOException $e) { |
|
95 | + return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | + } |
|
97 | + // Add auto_increment for aircraft_modes |
|
98 | + $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | + try { |
|
100 | + $sth = $Connection->db->prepare($query); |
|
101 | + $sth->execute(); |
|
102 | + } catch(PDOException $e) { |
|
103 | + return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | + } |
|
105 | + $error = ''; |
|
106 | 106 | $error .= create_db::import_file('../db/acars_live.sql'); |
107 | 107 | $error .= create_db::import_file('../db/config.sql'); |
108 | 108 | // Update schema_version to 2 |
109 | 109 | $query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'"; |
110 | - try { |
|
111 | - $sth = $Connection->db->prepare($query); |
|
112 | - $sth->execute(); |
|
113 | - } catch(PDOException $e) { |
|
114 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | - } |
|
110 | + try { |
|
111 | + $sth = $Connection->db->prepare($query); |
|
112 | + $sth->execute(); |
|
113 | + } catch(PDOException $e) { |
|
114 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | + } |
|
116 | 116 | return $error; |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | 119 | private static function update_from_2() { |
120 | - $Connection = new Connection(); |
|
121 | - // Add new column decode to acars_live table |
|
120 | + $Connection = new Connection(); |
|
121 | + // Add new column decode to acars_live table |
|
122 | 122 | $query = "ALTER TABLE `acars_live` ADD `decode` TEXT"; |
123 | - try { |
|
124 | - $sth = $Connection->db->prepare($query); |
|
125 | - $sth->execute(); |
|
126 | - } catch(PDOException $e) { |
|
127 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | - } |
|
129 | - $error = ''; |
|
130 | - // Create table acars_archive |
|
123 | + try { |
|
124 | + $sth = $Connection->db->prepare($query); |
|
125 | + $sth->execute(); |
|
126 | + } catch(PDOException $e) { |
|
127 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | + } |
|
129 | + $error = ''; |
|
130 | + // Create table acars_archive |
|
131 | 131 | $error .= create_db::import_file('../db/acars_archive.sql'); |
132 | 132 | // Update schema_version to 3 |
133 | 133 | $query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'"; |
134 | - try { |
|
135 | - $sth = $Connection->db->prepare($query); |
|
136 | - $sth->execute(); |
|
137 | - } catch(PDOException $e) { |
|
138 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | - } |
|
134 | + try { |
|
135 | + $sth = $Connection->db->prepare($query); |
|
136 | + $sth->execute(); |
|
137 | + } catch(PDOException $e) { |
|
138 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | + } |
|
140 | 140 | return $error; |
141 | 141 | } |
142 | 142 | |
143 | 143 | private static function update_from_3() { |
144 | - $Connection = new Connection(); |
|
145 | - // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
144 | + $Connection = new Connection(); |
|
145 | + // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
146 | 146 | $query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP"; |
147 | - try { |
|
148 | - $sth = $Connection->db->prepare($query); |
|
149 | - $sth->execute(); |
|
150 | - } catch(PDOException $e) { |
|
151 | - return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | - } |
|
153 | - // Add image_source_website column to spotter_image |
|
147 | + try { |
|
148 | + $sth = $Connection->db->prepare($query); |
|
149 | + $sth->execute(); |
|
150 | + } catch(PDOException $e) { |
|
151 | + return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | + } |
|
153 | + // Add image_source_website column to spotter_image |
|
154 | 154 | $query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL"; |
155 | - try { |
|
156 | - $sth = $Connection->db->prepare($query); |
|
157 | - $sth->execute(); |
|
158 | - } catch(PDOException $e) { |
|
159 | - return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | - } |
|
161 | - $error = ''; |
|
155 | + try { |
|
156 | + $sth = $Connection->db->prepare($query); |
|
157 | + $sth->execute(); |
|
158 | + } catch(PDOException $e) { |
|
159 | + return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | + } |
|
161 | + $error = ''; |
|
162 | 162 | // Update schema_version to 4 |
163 | 163 | $query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'"; |
164 | - try { |
|
165 | - $sth = $Connection->db->prepare($query); |
|
166 | - $sth->execute(); |
|
167 | - } catch(PDOException $e) { |
|
168 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | - } |
|
164 | + try { |
|
165 | + $sth = $Connection->db->prepare($query); |
|
166 | + $sth->execute(); |
|
167 | + } catch(PDOException $e) { |
|
168 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | + } |
|
170 | 170 | return $error; |
171 | 171 | } |
172 | 172 | |
173 | 173 | private static function update_from_4() { |
174 | - $Connection = new Connection(); |
|
174 | + $Connection = new Connection(); |
|
175 | 175 | |
176 | - $error = ''; |
|
177 | - // Create table acars_label |
|
176 | + $error = ''; |
|
177 | + // Create table acars_label |
|
178 | 178 | $error .= create_db::import_file('../db/acars_label.sql'); |
179 | 179 | if ($error == '') { |
180 | - // Update schema_version to 5 |
|
181 | - $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | - try { |
|
183 | - $sth = $Connection->db->prepare($query); |
|
180 | + // Update schema_version to 5 |
|
181 | + $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | + try { |
|
183 | + $sth = $Connection->db->prepare($query); |
|
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch(PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | - } |
|
188 | - } |
|
187 | + } |
|
188 | + } |
|
189 | 189 | return $error; |
190 | 190 | } |
191 | 191 | |
192 | 192 | private static function update_from_5() { |
193 | - $Connection = new Connection(); |
|
194 | - // Add columns to translation |
|
193 | + $Connection = new Connection(); |
|
194 | + // Add columns to translation |
|
195 | 195 | $query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;"; |
196 | - try { |
|
197 | - $sth = $Connection->db->prepare($query); |
|
198 | - $sth->execute(); |
|
199 | - } catch(PDOException $e) { |
|
200 | - return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | - } |
|
202 | - // Add aircraft_shadow column to aircraft |
|
203 | - $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | - try { |
|
205 | - $sth = $Connection->db->prepare($query); |
|
206 | - $sth->execute(); |
|
207 | - } catch(PDOException $e) { |
|
208 | - return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | - } |
|
210 | - // Add aircraft_shadow column to spotter_live |
|
211 | - $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | - try { |
|
213 | - $sth = $Connection->db->prepare($query); |
|
214 | - $sth->execute(); |
|
215 | - } catch(PDOException $e) { |
|
216 | - return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | - } |
|
218 | - $error = ''; |
|
219 | - // Update table aircraft |
|
196 | + try { |
|
197 | + $sth = $Connection->db->prepare($query); |
|
198 | + $sth->execute(); |
|
199 | + } catch(PDOException $e) { |
|
200 | + return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | + } |
|
202 | + // Add aircraft_shadow column to aircraft |
|
203 | + $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | + try { |
|
205 | + $sth = $Connection->db->prepare($query); |
|
206 | + $sth->execute(); |
|
207 | + } catch(PDOException $e) { |
|
208 | + return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | + } |
|
210 | + // Add aircraft_shadow column to spotter_live |
|
211 | + $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | + try { |
|
213 | + $sth = $Connection->db->prepare($query); |
|
214 | + $sth->execute(); |
|
215 | + } catch(PDOException $e) { |
|
216 | + return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | + } |
|
218 | + $error = ''; |
|
219 | + // Update table aircraft |
|
220 | 220 | $error .= create_db::import_file('../db/aircraft.sql'); |
221 | 221 | $error .= create_db::import_file('../db/spotter_archive.sql'); |
222 | 222 | |
223 | 223 | // Update schema_version to 6 |
224 | 224 | $query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'"; |
225 | - try { |
|
226 | - $sth = $Connection->db->prepare($query); |
|
227 | - $sth->execute(); |
|
228 | - } catch(PDOException $e) { |
|
229 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | - } |
|
225 | + try { |
|
226 | + $sth = $Connection->db->prepare($query); |
|
227 | + $sth->execute(); |
|
228 | + } catch(PDOException $e) { |
|
229 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | + } |
|
231 | 231 | return $error; |
232 | 232 | } |
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | - $Connection = new Connection(); |
|
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | - $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
235 | + $Connection = new Connection(); |
|
236 | + if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | + $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
240 | 240 | ALTER TABLE spotter_live ADD INDEX(flightaware_id); |
@@ -247,147 +247,147 @@ discard block |
||
247 | 247 | ALTER TABLE aircraft ADD INDEX(icao); |
248 | 248 | ALTER TABLE airport ADD INDEX(icao); |
249 | 249 | ALTER TABLE translation ADD INDEX(Operator);"; |
250 | - try { |
|
251 | - $sth = $Connection->db->prepare($query); |
|
250 | + try { |
|
251 | + $sth = $Connection->db->prepare($query); |
|
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch(PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | - } |
|
256 | - } |
|
257 | - $error = ''; |
|
258 | - // Update table countries |
|
259 | - if ($Connection->tableExists('airspace')) { |
|
260 | - $error .= update_db::update_countries(); |
|
261 | - if ($error != '') return $error; |
|
255 | + } |
|
256 | + } |
|
257 | + $error = ''; |
|
258 | + // Update table countries |
|
259 | + if ($Connection->tableExists('airspace')) { |
|
260 | + $error .= update_db::update_countries(); |
|
261 | + if ($error != '') return $error; |
|
262 | 262 | } |
263 | 263 | // Update schema_version to 7 |
264 | 264 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
265 | - try { |
|
266 | - $sth = $Connection->db->prepare($query); |
|
267 | - $sth->execute(); |
|
268 | - } catch(PDOException $e) { |
|
269 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | - } |
|
265 | + try { |
|
266 | + $sth = $Connection->db->prepare($query); |
|
267 | + $sth->execute(); |
|
268 | + } catch(PDOException $e) { |
|
269 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | + } |
|
271 | 271 | return $error; |
272 | - } |
|
272 | + } |
|
273 | 273 | |
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | - $Connection = new Connection(); |
|
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
276 | + $Connection = new Connection(); |
|
277 | + $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | - try { |
|
280 | - $sth = $Connection->db->prepare($query); |
|
281 | - $sth->execute(); |
|
282 | - } catch(PDOException $e) { |
|
283 | - return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | - } |
|
285 | - if ($globalDBdriver == 'mysql') { |
|
286 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | - try { |
|
288 | - $sth = $Connection->db->prepare($query); |
|
279 | + try { |
|
280 | + $sth = $Connection->db->prepare($query); |
|
281 | + $sth->execute(); |
|
282 | + } catch(PDOException $e) { |
|
283 | + return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | + } |
|
285 | + if ($globalDBdriver == 'mysql') { |
|
286 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | + try { |
|
288 | + $sth = $Connection->db->prepare($query); |
|
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch(PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | - } |
|
293 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | - if ($row['engine'] == 'ARCHIVE') { |
|
292 | + } |
|
293 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | + if ($row['engine'] == 'ARCHIVE') { |
|
295 | 295 | $query = "CREATE TABLE copy LIKE spotter_archive; |
296 | 296 | ALTER TABLE copy ENGINE=ARCHIVE; |
297 | 297 | ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
298 | 298 | INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`; |
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | - } else { |
|
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | - } |
|
304 | - } else { |
|
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | - } |
|
307 | - try { |
|
308 | - $sth = $Connection->db->prepare($query); |
|
309 | - $sth->execute(); |
|
310 | - } catch(PDOException $e) { |
|
311 | - return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | - } |
|
301 | + } else { |
|
302 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | + } |
|
304 | + } else { |
|
305 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | + } |
|
307 | + try { |
|
308 | + $sth = $Connection->db->prepare($query); |
|
309 | + $sth->execute(); |
|
310 | + } catch(PDOException $e) { |
|
311 | + return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | + } |
|
313 | 313 | |
314 | - $error = ''; |
|
315 | - // Update table aircraft |
|
314 | + $error = ''; |
|
315 | + // Update table aircraft |
|
316 | 316 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | 317 | if ($error != '') return $error; |
318 | 318 | // Update schema_version to 6 |
319 | 319 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | - try { |
|
321 | - $sth = $Connection->db->prepare($query); |
|
322 | - $sth->execute(); |
|
323 | - } catch(PDOException $e) { |
|
324 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | - } |
|
320 | + try { |
|
321 | + $sth = $Connection->db->prepare($query); |
|
322 | + $sth->execute(); |
|
323 | + } catch(PDOException $e) { |
|
324 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | + } |
|
326 | 326 | return $error; |
327 | 327 | } |
328 | 328 | |
329 | 329 | private static function update_from_8() { |
330 | - $Connection = new Connection(); |
|
331 | - $error = ''; |
|
332 | - // Update table aircraft |
|
330 | + $Connection = new Connection(); |
|
331 | + $error = ''; |
|
332 | + // Update table aircraft |
|
333 | 333 | $error .= create_db::import_file('../db/notam.sql'); |
334 | 334 | if ($error != '') return $error; |
335 | 335 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 336 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 337 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
338 | 338 | INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());"; |
339 | - try { |
|
340 | - $sth = $Connection->db->prepare($query); |
|
341 | - $sth->execute(); |
|
342 | - } catch(PDOException $e) { |
|
343 | - return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | - } |
|
339 | + try { |
|
340 | + $sth = $Connection->db->prepare($query); |
|
341 | + $sth->execute(); |
|
342 | + } catch(PDOException $e) { |
|
343 | + return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | + } |
|
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | - try { |
|
347 | - $sth = $Connection->db->prepare($query); |
|
348 | - $sth->execute(); |
|
349 | - } catch(PDOException $e) { |
|
350 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | - } |
|
346 | + try { |
|
347 | + $sth = $Connection->db->prepare($query); |
|
348 | + $sth->execute(); |
|
349 | + } catch(PDOException $e) { |
|
350 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | + } |
|
352 | 352 | return $error; |
353 | 353 | } |
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | - $Connection = new Connection(); |
|
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
356 | + $Connection = new Connection(); |
|
357 | + $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | - try { |
|
360 | - $sth = $Connection->db->prepare($query); |
|
361 | - $sth->execute(); |
|
362 | - } catch(PDOException $e) { |
|
363 | - return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | - } |
|
359 | + try { |
|
360 | + $sth = $Connection->db->prepare($query); |
|
361 | + $sth->execute(); |
|
362 | + } catch(PDOException $e) { |
|
363 | + return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | + } |
|
365 | 365 | $error = ''; |
366 | - // Update table atc |
|
366 | + // Update table atc |
|
367 | 367 | $error .= create_db::import_file('../db/atc.sql'); |
368 | 368 | if ($error != '') return $error; |
369 | 369 | |
370 | 370 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | - try { |
|
372 | - $sth = $Connection->db->prepare($query); |
|
373 | - $sth->execute(); |
|
374 | - } catch(PDOException $e) { |
|
375 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | - } |
|
371 | + try { |
|
372 | + $sth = $Connection->db->prepare($query); |
|
373 | + $sth->execute(); |
|
374 | + } catch(PDOException $e) { |
|
375 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | + } |
|
377 | 377 | return $error; |
378 | 378 | } |
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | - $Connection = new Connection(); |
|
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | - try { |
|
384 | - $sth = $Connection->db->prepare($query); |
|
385 | - $sth->execute(); |
|
386 | - } catch(PDOException $e) { |
|
387 | - return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | - } |
|
381 | + $Connection = new Connection(); |
|
382 | + $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | + try { |
|
384 | + $sth = $Connection->db->prepare($query); |
|
385 | + $sth->execute(); |
|
386 | + } catch(PDOException $e) { |
|
387 | + return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | + } |
|
389 | 389 | $error = ''; |
390 | - // Add tables |
|
390 | + // Add tables |
|
391 | 391 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | 392 | if ($error != '') return $error; |
393 | 393 | $error .= create_db::import_file('../db/metar.sql'); |
@@ -398,76 +398,76 @@ discard block |
||
398 | 398 | if ($error != '') return $error; |
399 | 399 | |
400 | 400 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | - try { |
|
402 | - $sth = $Connection->db->prepare($query); |
|
403 | - $sth->execute(); |
|
404 | - } catch(PDOException $e) { |
|
405 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | - } |
|
401 | + try { |
|
402 | + $sth = $Connection->db->prepare($query); |
|
403 | + $sth->execute(); |
|
404 | + } catch(PDOException $e) { |
|
405 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | + } |
|
407 | 407 | return $error; |
408 | 408 | } |
409 | 409 | |
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | - $Connection = new Connection(); |
|
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | - try { |
|
415 | - $sth = $Connection->db->prepare($query); |
|
416 | - $sth->execute(); |
|
417 | - } catch(PDOException $e) { |
|
418 | - return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | - } |
|
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | - try { |
|
422 | - $sth = $Connection->db->prepare($query); |
|
423 | - $sth->execute(); |
|
424 | - } catch(PDOException $e) { |
|
425 | - return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | - } |
|
427 | - if ($globalDBdriver == 'mysql') { |
|
428 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | - try { |
|
430 | - $sth = $Connection->db->prepare($query); |
|
412 | + $Connection = new Connection(); |
|
413 | + $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | + try { |
|
415 | + $sth = $Connection->db->prepare($query); |
|
431 | 416 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
417 | + } catch(PDOException $e) { |
|
418 | + return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | + } |
|
420 | + $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | + try { |
|
422 | + $sth = $Connection->db->prepare($query); |
|
423 | + $sth->execute(); |
|
424 | + } catch(PDOException $e) { |
|
425 | + return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | + } |
|
427 | + if ($globalDBdriver == 'mysql') { |
|
428 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | + try { |
|
430 | + $sth = $Connection->db->prepare($query); |
|
431 | + $sth->execute(); |
|
432 | + } catch(PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | - } |
|
435 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | - if ($row['engine'] == 'ARCHIVE') { |
|
434 | + } |
|
435 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | + if ($row['engine'] == 'ARCHIVE') { |
|
437 | 437 | $query = "CREATE TABLE copy LIKE spotter_archive; |
438 | 438 | ALTER TABLE copy ENGINE=ARCHIVE; |
439 | 439 | ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE; |
440 | 440 | INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`; |
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | - } else { |
|
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | - } |
|
446 | - } else { |
|
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | - } |
|
449 | - try { |
|
450 | - $sth = $Connection->db->prepare($query); |
|
451 | - $sth->execute(); |
|
452 | - } catch(PDOException $e) { |
|
453 | - return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | - } |
|
443 | + } else { |
|
444 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | + } |
|
446 | + } else { |
|
447 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | + } |
|
449 | + try { |
|
450 | + $sth = $Connection->db->prepare($query); |
|
451 | + $sth->execute(); |
|
452 | + } catch(PDOException $e) { |
|
453 | + return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | + } |
|
455 | 455 | |
456 | 456 | $error = ''; |
457 | 457 | |
458 | 458 | $query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'"; |
459 | - try { |
|
460 | - $sth = $Connection->db->prepare($query); |
|
461 | - $sth->execute(); |
|
462 | - } catch(PDOException $e) { |
|
463 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | - } |
|
459 | + try { |
|
460 | + $sth = $Connection->db->prepare($query); |
|
461 | + $sth->execute(); |
|
462 | + } catch(PDOException $e) { |
|
463 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | + } |
|
465 | 465 | return $error; |
466 | 466 | } |
467 | 467 | private static function update_from_12() { |
468 | - $Connection = new Connection(); |
|
468 | + $Connection = new Connection(); |
|
469 | 469 | $error = ''; |
470 | - // Add tables |
|
470 | + // Add tables |
|
471 | 471 | $error .= create_db::import_file('../db/stats.sql'); |
472 | 472 | if ($error != '') return $error; |
473 | 473 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
@@ -484,166 +484,166 @@ discard block |
||
484 | 484 | if ($error != '') return $error; |
485 | 485 | |
486 | 486 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | - try { |
|
488 | - $sth = $Connection->db->prepare($query); |
|
489 | - $sth->execute(); |
|
490 | - } catch(PDOException $e) { |
|
491 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | - } |
|
487 | + try { |
|
488 | + $sth = $Connection->db->prepare($query); |
|
489 | + $sth->execute(); |
|
490 | + } catch(PDOException $e) { |
|
491 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | + } |
|
493 | 493 | return $error; |
494 | 494 | } |
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | - $Connection = new Connection(); |
|
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
497 | + $Connection = new Connection(); |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | + $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch(PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | - } |
|
505 | + } |
|
506 | 506 | } |
507 | - $error = ''; |
|
507 | + $error = ''; |
|
508 | 508 | $query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'"; |
509 | - try { |
|
510 | - $sth = $Connection->db->prepare($query); |
|
511 | - $sth->execute(); |
|
512 | - } catch(PDOException $e) { |
|
513 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | - } |
|
509 | + try { |
|
510 | + $sth = $Connection->db->prepare($query); |
|
511 | + $sth->execute(); |
|
512 | + } catch(PDOException $e) { |
|
513 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | + } |
|
515 | 515 | return $error; |
516 | 516 | } |
517 | 517 | |
518 | 518 | private static function update_from_14() { |
519 | - $Connection = new Connection(); |
|
519 | + $Connection = new Connection(); |
|
520 | 520 | $error = ''; |
521 | - // Add tables |
|
522 | - if (!$Connection->tableExists('stats_flight')) { |
|
521 | + // Add tables |
|
522 | + if (!$Connection->tableExists('stats_flight')) { |
|
523 | 523 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | 524 | if ($error != '') return $error; |
525 | 525 | } |
526 | 526 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | - try { |
|
528 | - $sth = $Connection->db->prepare($query); |
|
529 | - $sth->execute(); |
|
530 | - } catch(PDOException $e) { |
|
531 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | - } |
|
527 | + try { |
|
528 | + $sth = $Connection->db->prepare($query); |
|
529 | + $sth->execute(); |
|
530 | + } catch(PDOException $e) { |
|
531 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | + } |
|
533 | 533 | return $error; |
534 | 534 | } |
535 | 535 | |
536 | 536 | |
537 | 537 | private static function update_from_15() { |
538 | - $Connection = new Connection(); |
|
538 | + $Connection = new Connection(); |
|
539 | 539 | $error = ''; |
540 | - // Add tables |
|
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | - try { |
|
543 | - $sth = $Connection->db->prepare($query); |
|
544 | - $sth->execute(); |
|
545 | - } catch(PDOException $e) { |
|
546 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | - } |
|
540 | + // Add tables |
|
541 | + $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | + try { |
|
543 | + $sth = $Connection->db->prepare($query); |
|
544 | + $sth->execute(); |
|
545 | + } catch(PDOException $e) { |
|
546 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | + } |
|
548 | 548 | if ($error != '') return $error; |
549 | 549 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | - try { |
|
551 | - $sth = $Connection->db->prepare($query); |
|
552 | - $sth->execute(); |
|
553 | - } catch(PDOException $e) { |
|
554 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | - } |
|
550 | + try { |
|
551 | + $sth = $Connection->db->prepare($query); |
|
552 | + $sth->execute(); |
|
553 | + } catch(PDOException $e) { |
|
554 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | + } |
|
556 | 556 | return $error; |
557 | 557 | } |
558 | 558 | |
559 | 559 | private static function update_from_16() { |
560 | - $Connection = new Connection(); |
|
560 | + $Connection = new Connection(); |
|
561 | 561 | $error = ''; |
562 | - // Add tables |
|
563 | - if (!$Connection->tableExists('stats_registration')) { |
|
562 | + // Add tables |
|
563 | + if (!$Connection->tableExists('stats_registration')) { |
|
564 | 564 | $error .= create_db::import_file('../db/stats_registration.sql'); |
565 | 565 | } |
566 | - if (!$Connection->tableExists('stats_callsign')) { |
|
566 | + if (!$Connection->tableExists('stats_callsign')) { |
|
567 | 567 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 568 | } |
569 | 569 | if ($error != '') return $error; |
570 | 570 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | - try { |
|
572 | - $sth = $Connection->db->prepare($query); |
|
573 | - $sth->execute(); |
|
574 | - } catch(PDOException $e) { |
|
575 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | - } |
|
571 | + try { |
|
572 | + $sth = $Connection->db->prepare($query); |
|
573 | + $sth->execute(); |
|
574 | + } catch(PDOException $e) { |
|
575 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | + } |
|
577 | 577 | return $error; |
578 | 578 | } |
579 | 579 | |
580 | 580 | private static function update_from_17() { |
581 | - $Connection = new Connection(); |
|
581 | + $Connection = new Connection(); |
|
582 | 582 | $error = ''; |
583 | - // Add tables |
|
584 | - if (!$Connection->tableExists('stats_country')) { |
|
583 | + // Add tables |
|
584 | + if (!$Connection->tableExists('stats_country')) { |
|
585 | 585 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 586 | } |
587 | 587 | if ($error != '') return $error; |
588 | 588 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | - try { |
|
590 | - $sth = $Connection->db->prepare($query); |
|
591 | - $sth->execute(); |
|
592 | - } catch(PDOException $e) { |
|
593 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | - } |
|
589 | + try { |
|
590 | + $sth = $Connection->db->prepare($query); |
|
591 | + $sth->execute(); |
|
592 | + } catch(PDOException $e) { |
|
593 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | + } |
|
595 | 595 | return $error; |
596 | 596 | } |
597 | 597 | private static function update_from_18() { |
598 | - $Connection = new Connection(); |
|
598 | + $Connection = new Connection(); |
|
599 | 599 | $error = ''; |
600 | - // Modify stats_airport table |
|
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | - $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | - try { |
|
604 | - $sth = $Connection->db->prepare($query); |
|
605 | - $sth->execute(); |
|
606 | - } catch(PDOException $e) { |
|
607 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | - } |
|
609 | - } |
|
600 | + // Modify stats_airport table |
|
601 | + if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | + $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | + try { |
|
604 | + $sth = $Connection->db->prepare($query); |
|
605 | + $sth->execute(); |
|
606 | + } catch(PDOException $e) { |
|
607 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | + } |
|
609 | + } |
|
610 | 610 | if ($error != '') return $error; |
611 | 611 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | - try { |
|
613 | - $sth = $Connection->db->prepare($query); |
|
614 | - $sth->execute(); |
|
615 | - } catch(PDOException $e) { |
|
616 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | - } |
|
612 | + try { |
|
613 | + $sth = $Connection->db->prepare($query); |
|
614 | + $sth->execute(); |
|
615 | + } catch(PDOException $e) { |
|
616 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | + } |
|
618 | 618 | return $error; |
619 | 619 | } |
620 | 620 | |
621 | 621 | private static function update_from_19() { |
622 | - $Connection = new Connection(); |
|
622 | + $Connection = new Connection(); |
|
623 | 623 | $error = ''; |
624 | - // Update airport table |
|
624 | + // Update airport table |
|
625 | 625 | $error .= create_db::import_file('../db/airport.sql'); |
626 | 626 | if ($error != '') return 'Import airport.sql : '.$error; |
627 | 627 | // Remove primary key on Spotter_Archive |
628 | 628 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | - try { |
|
630 | - $sth = $Connection->db->prepare($query); |
|
631 | - $sth->execute(); |
|
632 | - } catch(PDOException $e) { |
|
633 | - return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | - } |
|
629 | + try { |
|
630 | + $sth = $Connection->db->prepare($query); |
|
631 | + $sth->execute(); |
|
632 | + } catch(PDOException $e) { |
|
633 | + return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | + } |
|
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | - try { |
|
637 | - $sth = $Connection->db->prepare($query); |
|
638 | - $sth->execute(); |
|
639 | - } catch(PDOException $e) { |
|
640 | - return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | - } |
|
636 | + try { |
|
637 | + $sth = $Connection->db->prepare($query); |
|
638 | + $sth->execute(); |
|
639 | + } catch(PDOException $e) { |
|
640 | + return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | + } |
|
642 | 642 | if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
643 | 643 | // Add column over_country |
644 | - $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
644 | + $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
645 | 645 | try { |
646 | - $sth = $Connection->db->prepare($query); |
|
646 | + $sth = $Connection->db->prepare($query); |
|
647 | 647 | $sth->execute(); |
648 | 648 | } catch(PDOException $e) { |
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | } |
652 | 652 | if (!$Connection->checkColumnName('spotter_live','over_country')) { |
653 | 653 | // Add column over_country |
654 | - $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
654 | + $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
655 | 655 | try { |
656 | - $sth = $Connection->db->prepare($query); |
|
656 | + $sth = $Connection->db->prepare($query); |
|
657 | 657 | $sth->execute(); |
658 | 658 | } catch(PDOException $e) { |
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -661,74 +661,74 @@ discard block |
||
661 | 661 | } |
662 | 662 | if (!$Connection->checkColumnName('spotter_output','source_name')) { |
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | - $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
664 | + $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | 668 | } catch(PDOException $e) { |
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | - } |
|
671 | - } |
|
670 | + } |
|
671 | + } |
|
672 | 672 | if (!$Connection->checkColumnName('spotter_live','source_name')) { |
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | - $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
674 | + $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | 678 | } catch(PDOException $e) { |
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | - } |
|
681 | - } |
|
680 | + } |
|
681 | + } |
|
682 | 682 | if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | - $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
684 | + $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | 688 | } catch(PDOException $e) { |
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | - } |
|
691 | - } |
|
690 | + } |
|
691 | + } |
|
692 | 692 | if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | - $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
694 | + $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | 698 | } catch(PDOException $e) { |
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | - } |
|
701 | - } |
|
700 | + } |
|
701 | + } |
|
702 | 702 | if ($error != '') return $error; |
703 | 703 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | - try { |
|
705 | - $sth = $Connection->db->prepare($query); |
|
706 | - $sth->execute(); |
|
707 | - } catch(PDOException $e) { |
|
708 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | - } |
|
704 | + try { |
|
705 | + $sth = $Connection->db->prepare($query); |
|
706 | + $sth->execute(); |
|
707 | + } catch(PDOException $e) { |
|
708 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | + } |
|
710 | 710 | return $error; |
711 | 711 | } |
712 | 712 | |
713 | 713 | private static function update_from_20() { |
714 | 714 | global $globalIVAO, $globalVATSIM, $globalphpVMS; |
715 | - $Connection = new Connection(); |
|
715 | + $Connection = new Connection(); |
|
716 | 716 | $error = ''; |
717 | - // Update airline table |
|
718 | - if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
717 | + // Update airline table |
|
718 | + if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | 722 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 723 | // Add column over_country |
724 | - $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | - try { |
|
724 | + $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | + try { |
|
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | 728 | } catch(PDOException $e) { |
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | - } |
|
731 | - } |
|
730 | + } |
|
731 | + } |
|
732 | 732 | if ($error != '') return $error; |
733 | 733 | /* |
734 | 734 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
@@ -738,12 +738,12 @@ discard block |
||
738 | 738 | } |
739 | 739 | */ |
740 | 740 | $query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'"; |
741 | - try { |
|
742 | - $sth = $Connection->db->prepare($query); |
|
743 | - $sth->execute(); |
|
744 | - } catch(PDOException $e) { |
|
745 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | - } |
|
741 | + try { |
|
742 | + $sth = $Connection->db->prepare($query); |
|
743 | + $sth->execute(); |
|
744 | + } catch(PDOException $e) { |
|
745 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | + } |
|
747 | 747 | return $error; |
748 | 748 | } |
749 | 749 | |
@@ -762,35 +762,35 @@ discard block |
||
762 | 762 | if ($error != '') return $error; |
763 | 763 | } |
764 | 764 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | - try { |
|
766 | - $sth = $Connection->db->prepare($query); |
|
767 | - $sth->execute(); |
|
768 | - } catch(PDOException $e) { |
|
769 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | - } |
|
765 | + try { |
|
766 | + $sth = $Connection->db->prepare($query); |
|
767 | + $sth->execute(); |
|
768 | + } catch(PDOException $e) { |
|
769 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | + } |
|
771 | 771 | return $error; |
772 | 772 | } |
773 | 773 | |
774 | 774 | private static function update_from_22() { |
775 | 775 | global $globalDBdriver; |
776 | - $Connection = new Connection(); |
|
776 | + $Connection = new Connection(); |
|
777 | 777 | $error = ''; |
778 | 778 | // Add table stats polar |
779 | - if (!$Connection->tableExists('stats_source')) { |
|
779 | + if (!$Connection->tableExists('stats_source')) { |
|
780 | 780 | if ($globalDBdriver == 'mysql') { |
781 | - $error .= create_db::import_file('../db/stats_source.sql'); |
|
781 | + $error .= create_db::import_file('../db/stats_source.sql'); |
|
782 | 782 | } else { |
783 | 783 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 784 | } |
785 | 785 | if ($error != '') return $error; |
786 | 786 | } |
787 | 787 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | - try { |
|
789 | - $sth = $Connection->db->prepare($query); |
|
790 | - $sth->execute(); |
|
791 | - } catch(PDOException $e) { |
|
792 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | - } |
|
788 | + try { |
|
789 | + $sth = $Connection->db->prepare($query); |
|
790 | + $sth->execute(); |
|
791 | + } catch(PDOException $e) { |
|
792 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | + } |
|
794 | 794 | return $error; |
795 | 795 | } |
796 | 796 | |
@@ -821,14 +821,14 @@ discard block |
||
821 | 821 | } |
822 | 822 | if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | - $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
824 | + $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | 828 | } catch(PDOException $e) { |
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | - } |
|
831 | - } |
|
830 | + } |
|
831 | + } |
|
832 | 832 | |
833 | 833 | $query = "UPDATE config SET value = '24' WHERE name = 'schema_version'"; |
834 | 834 | try { |
@@ -1176,7 +1176,7 @@ discard block |
||
1176 | 1176 | } catch(PDOException $e) { |
1177 | 1177 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
1178 | 1178 | } |
1179 | - } |
|
1179 | + } |
|
1180 | 1180 | if (!$Connection->checkColumnName('aircraft','mfr')) { |
1181 | 1181 | // Add mfr to aircraft |
1182 | 1182 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | } catch(PDOException $e) { |
1251 | 1251 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
1252 | 1252 | } |
1253 | - } |
|
1253 | + } |
|
1254 | 1254 | if (!$Connection->indexExists('accidents','registration_idx')) { |
1255 | 1255 | // Add index key |
1256 | 1256 | $query = "create index registration_idx on accidents (registration)"; |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | } catch(PDOException $e) { |
1261 | 1261 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
1262 | 1262 | } |
1263 | - } |
|
1263 | + } |
|
1264 | 1264 | if (!$Connection->indexExists('accidents','rdts')) { |
1265 | 1265 | // Add index key |
1266 | 1266 | $query = "create index rdts on accidents (registration,date,type,source)"; |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | } catch(PDOException $e) { |
1271 | 1271 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
1272 | 1272 | } |
1273 | - } |
|
1273 | + } |
|
1274 | 1274 | |
1275 | 1275 | $query = "UPDATE config SET value = '31' WHERE name = 'schema_version'"; |
1276 | 1276 | try { |
@@ -1384,161 +1384,161 @@ discard block |
||
1384 | 1384 | } |
1385 | 1385 | |
1386 | 1386 | |
1387 | - public static function check_version($update = false) { |
|
1388 | - global $globalDBname; |
|
1389 | - $version = 0; |
|
1390 | - $Connection = new Connection(); |
|
1391 | - if ($Connection->tableExists('aircraft')) { |
|
1392 | - if (!$Connection->tableExists('config')) { |
|
1393 | - $version = '1'; |
|
1394 | - if ($update) return self::update_from_1(); |
|
1395 | - else return $version; |
|
1387 | + public static function check_version($update = false) { |
|
1388 | + global $globalDBname; |
|
1389 | + $version = 0; |
|
1390 | + $Connection = new Connection(); |
|
1391 | + if ($Connection->tableExists('aircraft')) { |
|
1392 | + if (!$Connection->tableExists('config')) { |
|
1393 | + $version = '1'; |
|
1394 | + if ($update) return self::update_from_1(); |
|
1395 | + else return $version; |
|
1396 | 1396 | } else { |
1397 | - $Connection = new Connection(); |
|
1398 | - $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1399 | - try { |
|
1400 | - $sth = $Connection->db->prepare($query); |
|
1401 | - $sth->execute(); |
|
1402 | - } catch(PDOException $e) { |
|
1397 | + $Connection = new Connection(); |
|
1398 | + $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1399 | + try { |
|
1400 | + $sth = $Connection->db->prepare($query); |
|
1401 | + $sth->execute(); |
|
1402 | + } catch(PDOException $e) { |
|
1403 | 1403 | return "error : ".$e->getMessage()."\n"; |
1404 | - } |
|
1405 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1406 | - if ($update) { |
|
1407 | - if ($result['value'] == '2') { |
|
1408 | - $error = self::update_from_2(); |
|
1409 | - if ($error != '') return $error; |
|
1410 | - else return self::check_version(true); |
|
1411 | - } elseif ($result['value'] == '3') { |
|
1412 | - $error = self::update_from_3(); |
|
1413 | - if ($error != '') return $error; |
|
1414 | - else return self::check_version(true); |
|
1415 | - } elseif ($result['value'] == '4') { |
|
1416 | - $error = self::update_from_4(); |
|
1417 | - if ($error != '') return $error; |
|
1418 | - else return self::check_version(true); |
|
1419 | - } elseif ($result['value'] == '5') { |
|
1420 | - $error = self::update_from_5(); |
|
1421 | - if ($error != '') return $error; |
|
1422 | - else return self::check_version(true); |
|
1423 | - } elseif ($result['value'] == '6') { |
|
1424 | - $error = self::update_from_6(); |
|
1425 | - if ($error != '') return $error; |
|
1426 | - else return self::check_version(true); |
|
1427 | - } elseif ($result['value'] == '7') { |
|
1428 | - $error = self::update_from_7(); |
|
1429 | - if ($error != '') return $error; |
|
1430 | - else return self::check_version(true); |
|
1431 | - } elseif ($result['value'] == '8') { |
|
1432 | - $error = self::update_from_8(); |
|
1433 | - if ($error != '') return $error; |
|
1434 | - else return self::check_version(true); |
|
1435 | - } elseif ($result['value'] == '9') { |
|
1436 | - $error = self::update_from_9(); |
|
1437 | - if ($error != '') return $error; |
|
1438 | - else return self::check_version(true); |
|
1439 | - } elseif ($result['value'] == '10') { |
|
1440 | - $error = self::update_from_10(); |
|
1441 | - if ($error != '') return $error; |
|
1442 | - else return self::check_version(true); |
|
1443 | - } elseif ($result['value'] == '11') { |
|
1444 | - $error = self::update_from_11(); |
|
1445 | - if ($error != '') return $error; |
|
1446 | - else return self::check_version(true); |
|
1447 | - } elseif ($result['value'] == '12') { |
|
1448 | - $error = self::update_from_12(); |
|
1449 | - if ($error != '') return $error; |
|
1450 | - else return self::check_version(true); |
|
1451 | - } elseif ($result['value'] == '13') { |
|
1452 | - $error = self::update_from_13(); |
|
1453 | - if ($error != '') return $error; |
|
1454 | - else return self::check_version(true); |
|
1455 | - } elseif ($result['value'] == '14') { |
|
1456 | - $error = self::update_from_14(); |
|
1457 | - if ($error != '') return $error; |
|
1458 | - else return self::check_version(true); |
|
1459 | - } elseif ($result['value'] == '15') { |
|
1460 | - $error = self::update_from_15(); |
|
1461 | - if ($error != '') return $error; |
|
1462 | - else return self::check_version(true); |
|
1463 | - } elseif ($result['value'] == '16') { |
|
1464 | - $error = self::update_from_16(); |
|
1465 | - if ($error != '') return $error; |
|
1466 | - else return self::check_version(true); |
|
1467 | - } elseif ($result['value'] == '17') { |
|
1468 | - $error = self::update_from_17(); |
|
1469 | - if ($error != '') return $error; |
|
1470 | - else return self::check_version(true); |
|
1471 | - } elseif ($result['value'] == '18') { |
|
1472 | - $error = self::update_from_18(); |
|
1473 | - if ($error != '') return $error; |
|
1474 | - else return self::check_version(true); |
|
1475 | - } elseif ($result['value'] == '19') { |
|
1476 | - $error = self::update_from_19(); |
|
1477 | - if ($error != '') return $error; |
|
1478 | - else return self::check_version(true); |
|
1479 | - } elseif ($result['value'] == '20') { |
|
1480 | - $error = self::update_from_20(); |
|
1481 | - if ($error != '') return $error; |
|
1482 | - else return self::check_version(true); |
|
1483 | - } elseif ($result['value'] == '21') { |
|
1484 | - $error = self::update_from_21(); |
|
1485 | - if ($error != '') return $error; |
|
1486 | - else return self::check_version(true); |
|
1487 | - } elseif ($result['value'] == '22') { |
|
1488 | - $error = self::update_from_22(); |
|
1489 | - if ($error != '') return $error; |
|
1490 | - else return self::check_version(true); |
|
1491 | - } elseif ($result['value'] == '23') { |
|
1492 | - $error = self::update_from_23(); |
|
1493 | - if ($error != '') return $error; |
|
1494 | - else return self::check_version(true); |
|
1495 | - } elseif ($result['value'] == '24') { |
|
1496 | - $error = self::update_from_24(); |
|
1497 | - if ($error != '') return $error; |
|
1498 | - else return self::check_version(true); |
|
1499 | - } elseif ($result['value'] == '25') { |
|
1500 | - $error = self::update_from_25(); |
|
1501 | - if ($error != '') return $error; |
|
1502 | - else return self::check_version(true); |
|
1503 | - } elseif ($result['value'] == '26') { |
|
1504 | - $error = self::update_from_26(); |
|
1505 | - if ($error != '') return $error; |
|
1506 | - else return self::check_version(true); |
|
1507 | - } elseif ($result['value'] == '27') { |
|
1508 | - $error = self::update_from_27(); |
|
1509 | - if ($error != '') return $error; |
|
1510 | - else return self::check_version(true); |
|
1511 | - } elseif ($result['value'] == '28') { |
|
1512 | - $error = self::update_from_28(); |
|
1513 | - if ($error != '') return $error; |
|
1514 | - else return self::check_version(true); |
|
1515 | - } elseif ($result['value'] == '29') { |
|
1516 | - $error = self::update_from_29(); |
|
1517 | - if ($error != '') return $error; |
|
1518 | - else return self::check_version(true); |
|
1519 | - } elseif ($result['value'] == '30') { |
|
1520 | - $error = self::update_from_30(); |
|
1521 | - if ($error != '') return $error; |
|
1522 | - else return self::check_version(true); |
|
1523 | - } elseif ($result['value'] == '31') { |
|
1524 | - $error = self::update_from_31(); |
|
1525 | - if ($error != '') return $error; |
|
1526 | - else return self::check_version(true); |
|
1527 | - } elseif ($result['value'] == '32') { |
|
1528 | - $error = self::update_from_32(); |
|
1529 | - if ($error != '') return $error; |
|
1530 | - else return self::check_version(true); |
|
1531 | - } elseif ($result['value'] == '33') { |
|
1532 | - $error = self::update_from_33(); |
|
1533 | - if ($error != '') return $error; |
|
1534 | - else return self::check_version(true); |
|
1535 | - } else return ''; |
|
1536 | - } |
|
1537 | - else return $result['value']; |
|
1404 | + } |
|
1405 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1406 | + if ($update) { |
|
1407 | + if ($result['value'] == '2') { |
|
1408 | + $error = self::update_from_2(); |
|
1409 | + if ($error != '') return $error; |
|
1410 | + else return self::check_version(true); |
|
1411 | + } elseif ($result['value'] == '3') { |
|
1412 | + $error = self::update_from_3(); |
|
1413 | + if ($error != '') return $error; |
|
1414 | + else return self::check_version(true); |
|
1415 | + } elseif ($result['value'] == '4') { |
|
1416 | + $error = self::update_from_4(); |
|
1417 | + if ($error != '') return $error; |
|
1418 | + else return self::check_version(true); |
|
1419 | + } elseif ($result['value'] == '5') { |
|
1420 | + $error = self::update_from_5(); |
|
1421 | + if ($error != '') return $error; |
|
1422 | + else return self::check_version(true); |
|
1423 | + } elseif ($result['value'] == '6') { |
|
1424 | + $error = self::update_from_6(); |
|
1425 | + if ($error != '') return $error; |
|
1426 | + else return self::check_version(true); |
|
1427 | + } elseif ($result['value'] == '7') { |
|
1428 | + $error = self::update_from_7(); |
|
1429 | + if ($error != '') return $error; |
|
1430 | + else return self::check_version(true); |
|
1431 | + } elseif ($result['value'] == '8') { |
|
1432 | + $error = self::update_from_8(); |
|
1433 | + if ($error != '') return $error; |
|
1434 | + else return self::check_version(true); |
|
1435 | + } elseif ($result['value'] == '9') { |
|
1436 | + $error = self::update_from_9(); |
|
1437 | + if ($error != '') return $error; |
|
1438 | + else return self::check_version(true); |
|
1439 | + } elseif ($result['value'] == '10') { |
|
1440 | + $error = self::update_from_10(); |
|
1441 | + if ($error != '') return $error; |
|
1442 | + else return self::check_version(true); |
|
1443 | + } elseif ($result['value'] == '11') { |
|
1444 | + $error = self::update_from_11(); |
|
1445 | + if ($error != '') return $error; |
|
1446 | + else return self::check_version(true); |
|
1447 | + } elseif ($result['value'] == '12') { |
|
1448 | + $error = self::update_from_12(); |
|
1449 | + if ($error != '') return $error; |
|
1450 | + else return self::check_version(true); |
|
1451 | + } elseif ($result['value'] == '13') { |
|
1452 | + $error = self::update_from_13(); |
|
1453 | + if ($error != '') return $error; |
|
1454 | + else return self::check_version(true); |
|
1455 | + } elseif ($result['value'] == '14') { |
|
1456 | + $error = self::update_from_14(); |
|
1457 | + if ($error != '') return $error; |
|
1458 | + else return self::check_version(true); |
|
1459 | + } elseif ($result['value'] == '15') { |
|
1460 | + $error = self::update_from_15(); |
|
1461 | + if ($error != '') return $error; |
|
1462 | + else return self::check_version(true); |
|
1463 | + } elseif ($result['value'] == '16') { |
|
1464 | + $error = self::update_from_16(); |
|
1465 | + if ($error != '') return $error; |
|
1466 | + else return self::check_version(true); |
|
1467 | + } elseif ($result['value'] == '17') { |
|
1468 | + $error = self::update_from_17(); |
|
1469 | + if ($error != '') return $error; |
|
1470 | + else return self::check_version(true); |
|
1471 | + } elseif ($result['value'] == '18') { |
|
1472 | + $error = self::update_from_18(); |
|
1473 | + if ($error != '') return $error; |
|
1474 | + else return self::check_version(true); |
|
1475 | + } elseif ($result['value'] == '19') { |
|
1476 | + $error = self::update_from_19(); |
|
1477 | + if ($error != '') return $error; |
|
1478 | + else return self::check_version(true); |
|
1479 | + } elseif ($result['value'] == '20') { |
|
1480 | + $error = self::update_from_20(); |
|
1481 | + if ($error != '') return $error; |
|
1482 | + else return self::check_version(true); |
|
1483 | + } elseif ($result['value'] == '21') { |
|
1484 | + $error = self::update_from_21(); |
|
1485 | + if ($error != '') return $error; |
|
1486 | + else return self::check_version(true); |
|
1487 | + } elseif ($result['value'] == '22') { |
|
1488 | + $error = self::update_from_22(); |
|
1489 | + if ($error != '') return $error; |
|
1490 | + else return self::check_version(true); |
|
1491 | + } elseif ($result['value'] == '23') { |
|
1492 | + $error = self::update_from_23(); |
|
1493 | + if ($error != '') return $error; |
|
1494 | + else return self::check_version(true); |
|
1495 | + } elseif ($result['value'] == '24') { |
|
1496 | + $error = self::update_from_24(); |
|
1497 | + if ($error != '') return $error; |
|
1498 | + else return self::check_version(true); |
|
1499 | + } elseif ($result['value'] == '25') { |
|
1500 | + $error = self::update_from_25(); |
|
1501 | + if ($error != '') return $error; |
|
1502 | + else return self::check_version(true); |
|
1503 | + } elseif ($result['value'] == '26') { |
|
1504 | + $error = self::update_from_26(); |
|
1505 | + if ($error != '') return $error; |
|
1506 | + else return self::check_version(true); |
|
1507 | + } elseif ($result['value'] == '27') { |
|
1508 | + $error = self::update_from_27(); |
|
1509 | + if ($error != '') return $error; |
|
1510 | + else return self::check_version(true); |
|
1511 | + } elseif ($result['value'] == '28') { |
|
1512 | + $error = self::update_from_28(); |
|
1513 | + if ($error != '') return $error; |
|
1514 | + else return self::check_version(true); |
|
1515 | + } elseif ($result['value'] == '29') { |
|
1516 | + $error = self::update_from_29(); |
|
1517 | + if ($error != '') return $error; |
|
1518 | + else return self::check_version(true); |
|
1519 | + } elseif ($result['value'] == '30') { |
|
1520 | + $error = self::update_from_30(); |
|
1521 | + if ($error != '') return $error; |
|
1522 | + else return self::check_version(true); |
|
1523 | + } elseif ($result['value'] == '31') { |
|
1524 | + $error = self::update_from_31(); |
|
1525 | + if ($error != '') return $error; |
|
1526 | + else return self::check_version(true); |
|
1527 | + } elseif ($result['value'] == '32') { |
|
1528 | + $error = self::update_from_32(); |
|
1529 | + if ($error != '') return $error; |
|
1530 | + else return self::check_version(true); |
|
1531 | + } elseif ($result['value'] == '33') { |
|
1532 | + $error = self::update_from_33(); |
|
1533 | + if ($error != '') return $error; |
|
1534 | + else return self::check_version(true); |
|
1535 | + } else return ''; |
|
1536 | + } |
|
1537 | + else return $result['value']; |
|
1538 | 1538 | } |
1539 | 1539 | |
1540 | - } else return $version; |
|
1541 | - } |
|
1540 | + } else return $version; |
|
1541 | + } |
|
1542 | 1542 | |
1543 | 1543 | } |
1544 | 1544 | //echo update_schema::check_version(); |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | try { |
15 | 15 | $sth = $Connection->db->prepare($query); |
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch (PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | 19 | } |
20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | try { |
51 | 51 | $sth = $Connection->db->prepare($query); |
52 | 52 | $sth->execute(); |
53 | - } catch(PDOException $e) { |
|
53 | + } catch (PDOException $e) { |
|
54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
55 | 55 | } |
56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $Connection->db->prepare($query); |
62 | 62 | $sth->execute(); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
65 | 65 | } |
66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | $sth = $Connection->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
73 | 73 | } |
74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | try { |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
81 | 81 | } |
82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | try { |
85 | 85 | $sth = $Connection->db->prepare($query); |
86 | 86 | $sth->execute(); |
87 | - } catch(PDOException $e) { |
|
87 | + } catch (PDOException $e) { |
|
88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
89 | 89 | } |
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | 91 | try { |
92 | 92 | $sth = $Connection->db->prepare($query); |
93 | 93 | $sth->execute(); |
94 | - } catch(PDOException $e) { |
|
94 | + } catch (PDOException $e) { |
|
95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
96 | 96 | } |
97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | try { |
100 | 100 | $sth = $Connection->db->prepare($query); |
101 | 101 | $sth->execute(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
104 | 104 | } |
105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $sth = $Connection->db->prepare($query); |
112 | 112 | $sth->execute(); |
113 | - } catch(PDOException $e) { |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
115 | 115 | } |
116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | try { |
124 | 124 | $sth = $Connection->db->prepare($query); |
125 | 125 | $sth->execute(); |
126 | - } catch(PDOException $e) { |
|
126 | + } catch (PDOException $e) { |
|
127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
128 | 128 | } |
129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | try { |
135 | 135 | $sth = $Connection->db->prepare($query); |
136 | 136 | $sth->execute(); |
137 | - } catch(PDOException $e) { |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
139 | 139 | } |
140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | try { |
148 | 148 | $sth = $Connection->db->prepare($query); |
149 | 149 | $sth->execute(); |
150 | - } catch(PDOException $e) { |
|
150 | + } catch (PDOException $e) { |
|
151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
152 | 152 | } |
153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | try { |
156 | 156 | $sth = $Connection->db->prepare($query); |
157 | 157 | $sth->execute(); |
158 | - } catch(PDOException $e) { |
|
158 | + } catch (PDOException $e) { |
|
159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
160 | 160 | } |
161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $Connection->db->prepare($query); |
166 | 166 | $sth->execute(); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
169 | 169 | } |
170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | try { |
183 | 183 | $sth = $Connection->db->prepare($query); |
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch (PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | 187 | } |
188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $Connection->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
201 | 201 | } |
202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | try { |
205 | 205 | $sth = $Connection->db->prepare($query); |
206 | 206 | $sth->execute(); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
209 | 209 | } |
210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $Connection->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
217 | 217 | } |
218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | try { |
226 | 226 | $sth = $Connection->db->prepare($query); |
227 | 227 | $sth->execute(); |
228 | - } catch(PDOException $e) { |
|
228 | + } catch (PDOException $e) { |
|
229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
230 | 230 | } |
231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | 235 | $Connection = new Connection(); |
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
236 | + if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { |
|
237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | 255 | } |
256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
270 | 270 | } |
271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | 276 | $Connection = new Connection(); |
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | 279 | try { |
280 | 280 | $sth = $Connection->db->prepare($query); |
281 | 281 | $sth->execute(); |
282 | - } catch(PDOException $e) { |
|
282 | + } catch (PDOException $e) { |
|
283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
284 | 284 | } |
285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | try { |
288 | 288 | $sth = $Connection->db->prepare($query); |
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch (PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | 292 | } |
293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | 301 | } else { |
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | 303 | } |
304 | 304 | } else { |
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | 306 | } |
307 | 307 | try { |
308 | 308 | $sth = $Connection->db->prepare($query); |
309 | 309 | $sth->execute(); |
310 | - } catch(PDOException $e) { |
|
310 | + } catch (PDOException $e) { |
|
311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
312 | 312 | } |
313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
325 | 325 | } |
326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | try { |
340 | 340 | $sth = $Connection->db->prepare($query); |
341 | 341 | $sth->execute(); |
342 | - } catch(PDOException $e) { |
|
342 | + } catch (PDOException $e) { |
|
343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
344 | 344 | } |
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | 346 | try { |
347 | 347 | $sth = $Connection->db->prepare($query); |
348 | 348 | $sth->execute(); |
349 | - } catch(PDOException $e) { |
|
349 | + } catch (PDOException $e) { |
|
350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
351 | 351 | } |
352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | 356 | $Connection = new Connection(); |
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | 359 | try { |
360 | 360 | $sth = $Connection->db->prepare($query); |
361 | 361 | $sth->execute(); |
362 | - } catch(PDOException $e) { |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
364 | 364 | } |
365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $sth = $Connection->db->prepare($query); |
373 | 373 | $sth->execute(); |
374 | - } catch(PDOException $e) { |
|
374 | + } catch (PDOException $e) { |
|
375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
376 | 376 | } |
377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | 381 | $Connection = new Connection(); |
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | 383 | try { |
384 | 384 | $sth = $Connection->db->prepare($query); |
385 | 385 | $sth->execute(); |
386 | - } catch(PDOException $e) { |
|
386 | + } catch (PDOException $e) { |
|
387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
388 | 388 | } |
389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | try { |
402 | 402 | $sth = $Connection->db->prepare($query); |
403 | 403 | $sth->execute(); |
404 | - } catch(PDOException $e) { |
|
404 | + } catch (PDOException $e) { |
|
405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
406 | 406 | } |
407 | 407 | return $error; |
@@ -410,18 +410,18 @@ discard block |
||
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | 412 | $Connection = new Connection(); |
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | 414 | try { |
415 | 415 | $sth = $Connection->db->prepare($query); |
416 | 416 | $sth->execute(); |
417 | - } catch(PDOException $e) { |
|
417 | + } catch (PDOException $e) { |
|
418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
419 | 419 | } |
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | 421 | try { |
422 | 422 | $sth = $Connection->db->prepare($query); |
423 | 423 | $sth->execute(); |
424 | - } catch(PDOException $e) { |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
426 | 426 | } |
427 | 427 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | try { |
430 | 430 | $sth = $Connection->db->prepare($query); |
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch (PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | 434 | } |
435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -441,15 +441,15 @@ discard block |
||
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | 443 | } else { |
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | 445 | } |
446 | 446 | } else { |
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | 448 | } |
449 | 449 | try { |
450 | 450 | $sth = $Connection->db->prepare($query); |
451 | 451 | $sth->execute(); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
454 | 454 | } |
455 | 455 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | try { |
460 | 460 | $sth = $Connection->db->prepare($query); |
461 | 461 | $sth->execute(); |
462 | - } catch(PDOException $e) { |
|
462 | + } catch (PDOException $e) { |
|
463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
464 | 464 | } |
465 | 465 | return $error; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $Connection->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
492 | 492 | } |
493 | 493 | return $error; |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | 497 | $Connection = new Connection(); |
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { |
|
499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch (PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | 505 | } |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | try { |
510 | 510 | $sth = $Connection->db->prepare($query); |
511 | 511 | $sth->execute(); |
512 | - } catch(PDOException $e) { |
|
512 | + } catch (PDOException $e) { |
|
513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
514 | 514 | } |
515 | 515 | return $error; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $Connection->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
532 | 532 | } |
533 | 533 | return $error; |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | $Connection = new Connection(); |
539 | 539 | $error = ''; |
540 | 540 | // Add tables |
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | 542 | try { |
543 | 543 | $sth = $Connection->db->prepare($query); |
544 | 544 | $sth->execute(); |
545 | - } catch(PDOException $e) { |
|
545 | + } catch (PDOException $e) { |
|
546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 547 | } |
548 | 548 | if ($error != '') return $error; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | try { |
551 | 551 | $sth = $Connection->db->prepare($query); |
552 | 552 | $sth->execute(); |
553 | - } catch(PDOException $e) { |
|
553 | + } catch (PDOException $e) { |
|
554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
555 | 555 | } |
556 | 556 | return $error; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | try { |
572 | 572 | $sth = $Connection->db->prepare($query); |
573 | 573 | $sth->execute(); |
574 | - } catch(PDOException $e) { |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
576 | 576 | } |
577 | 577 | return $error; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | try { |
590 | 590 | $sth = $Connection->db->prepare($query); |
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
594 | 594 | } |
595 | 595 | return $error; |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | $Connection = new Connection(); |
599 | 599 | $error = ''; |
600 | 600 | // Modify stats_airport table |
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
601 | + if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { |
|
602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
603 | 603 | try { |
604 | 604 | $sth = $Connection->db->prepare($query); |
605 | 605 | $sth->execute(); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 608 | } |
609 | 609 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | try { |
613 | 613 | $sth = $Connection->db->prepare($query); |
614 | 614 | $sth->execute(); |
615 | - } catch(PDOException $e) { |
|
615 | + } catch (PDOException $e) { |
|
616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
617 | 617 | } |
618 | 618 | return $error; |
@@ -629,73 +629,73 @@ discard block |
||
629 | 629 | try { |
630 | 630 | $sth = $Connection->db->prepare($query); |
631 | 631 | $sth->execute(); |
632 | - } catch(PDOException $e) { |
|
632 | + } catch (PDOException $e) { |
|
633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
634 | 634 | } |
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | 636 | try { |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
641 | 641 | } |
642 | - if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
|
642 | + if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { |
|
643 | 643 | // Add column over_country |
644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
645 | 645 | try { |
646 | 646 | $sth = $Connection->db->prepare($query); |
647 | 647 | $sth->execute(); |
648 | - } catch(PDOException $e) { |
|
648 | + } catch (PDOException $e) { |
|
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
650 | 650 | } |
651 | 651 | } |
652 | - if (!$Connection->checkColumnName('spotter_live','over_country')) { |
|
652 | + if (!$Connection->checkColumnName('spotter_live', 'over_country')) { |
|
653 | 653 | // Add column over_country |
654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
655 | 655 | try { |
656 | 656 | $sth = $Connection->db->prepare($query); |
657 | 657 | $sth->execute(); |
658 | - } catch(PDOException $e) { |
|
658 | + } catch (PDOException $e) { |
|
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
660 | 660 | } |
661 | 661 | } |
662 | - if (!$Connection->checkColumnName('spotter_output','source_name')) { |
|
662 | + if (!$Connection->checkColumnName('spotter_output', 'source_name')) { |
|
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | - } catch(PDOException $e) { |
|
668 | + } catch (PDOException $e) { |
|
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | 670 | } |
671 | 671 | } |
672 | - if (!$Connection->checkColumnName('spotter_live','source_name')) { |
|
672 | + if (!$Connection->checkColumnName('spotter_live', 'source_name')) { |
|
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | - } catch(PDOException $e) { |
|
678 | + } catch (PDOException $e) { |
|
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | 680 | } |
681 | 681 | } |
682 | - if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
|
682 | + if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { |
|
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | - } catch(PDOException $e) { |
|
688 | + } catch (PDOException $e) { |
|
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | 690 | } |
691 | 691 | } |
692 | - if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
|
692 | + if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { |
|
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | - } catch(PDOException $e) { |
|
698 | + } catch (PDOException $e) { |
|
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 700 | } |
701 | 701 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | try { |
705 | 705 | $sth = $Connection->db->prepare($query); |
706 | 706 | $sth->execute(); |
707 | - } catch(PDOException $e) { |
|
707 | + } catch (PDOException $e) { |
|
708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
709 | 709 | } |
710 | 710 | return $error; |
@@ -719,13 +719,13 @@ discard block |
||
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | - if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
|
722 | + if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { |
|
723 | 723 | // Add column over_country |
724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
725 | 725 | try { |
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | - } catch(PDOException $e) { |
|
728 | + } catch (PDOException $e) { |
|
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 730 | } |
731 | 731 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | try { |
742 | 742 | $sth = $Connection->db->prepare($query); |
743 | 743 | $sth->execute(); |
744 | - } catch(PDOException $e) { |
|
744 | + } catch (PDOException $e) { |
|
745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
746 | 746 | } |
747 | 747 | return $error; |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | private static function update_from_21() { |
751 | 751 | $Connection = new Connection(); |
752 | 752 | $error = ''; |
753 | - if (!$Connection->checkColumnName('stats_airport','stats_type')) { |
|
753 | + if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { |
|
754 | 754 | // Rename type to stats_type |
755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
756 | 756 | try { |
757 | 757 | $sth = $Connection->db->prepare($query); |
758 | 758 | $sth->execute(); |
759 | - } catch(PDOException $e) { |
|
759 | + } catch (PDOException $e) { |
|
760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 761 | } |
762 | 762 | if ($error != '') return $error; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | try { |
766 | 766 | $sth = $Connection->db->prepare($query); |
767 | 767 | $sth->execute(); |
768 | - } catch(PDOException $e) { |
|
768 | + } catch (PDOException $e) { |
|
769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
770 | 770 | } |
771 | 771 | return $error; |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | try { |
789 | 789 | $sth = $Connection->db->prepare($query); |
790 | 790 | $sth->execute(); |
791 | - } catch(PDOException $e) { |
|
791 | + } catch (PDOException $e) { |
|
792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
793 | 793 | } |
794 | 794 | return $error; |
@@ -815,17 +815,17 @@ discard block |
||
815 | 815 | try { |
816 | 816 | $sth = $Connection->db->prepare($query); |
817 | 817 | $sth->execute(); |
818 | - } catch(PDOException $e) { |
|
818 | + } catch (PDOException $e) { |
|
819 | 819 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; |
820 | 820 | } |
821 | 821 | } |
822 | - if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
|
822 | + if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { |
|
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | 824 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | - } catch(PDOException $e) { |
|
828 | + } catch (PDOException $e) { |
|
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | 830 | } |
831 | 831 | } |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | try { |
835 | 835 | $sth = $Connection->db->prepare($query); |
836 | 836 | $sth->execute(); |
837 | - } catch(PDOException $e) { |
|
837 | + } catch (PDOException $e) { |
|
838 | 838 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
839 | 839 | } |
840 | 840 | return $error; |
@@ -850,23 +850,23 @@ discard block |
||
850 | 850 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 851 | } |
852 | 852 | if ($error != '') return 'Import airlines.sql : '.$error; |
853 | - if (!$Connection->checkColumnName('airlines','forsource')) { |
|
853 | + if (!$Connection->checkColumnName('airlines', 'forsource')) { |
|
854 | 854 | // Add forsource to airlines |
855 | 855 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
856 | 856 | try { |
857 | 857 | $sth = $Connection->db->prepare($query); |
858 | 858 | $sth->execute(); |
859 | - } catch(PDOException $e) { |
|
859 | + } catch (PDOException $e) { |
|
860 | 860 | return "error (add forsource column) : ".$e->getMessage()."\n"; |
861 | 861 | } |
862 | 862 | } |
863 | - if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { |
|
863 | + if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { |
|
864 | 864 | // Add forsource to airlines |
865 | 865 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
866 | 866 | try { |
867 | 867 | $sth = $Connection->db->prepare($query); |
868 | 868 | $sth->execute(); |
869 | - } catch(PDOException $e) { |
|
869 | + } catch (PDOException $e) { |
|
870 | 870 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; |
871 | 871 | } |
872 | 872 | // Add unique key |
@@ -878,17 +878,17 @@ discard block |
||
878 | 878 | try { |
879 | 879 | $sth = $Connection->db->prepare($query); |
880 | 880 | $sth->execute(); |
881 | - } catch(PDOException $e) { |
|
881 | + } catch (PDOException $e) { |
|
882 | 882 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; |
883 | 883 | } |
884 | 884 | } |
885 | - if (!$Connection->checkColumnName('stats_airport','stats_airline')) { |
|
885 | + if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { |
|
886 | 886 | // Add forsource to airlines |
887 | 887 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
888 | 888 | try { |
889 | 889 | $sth = $Connection->db->prepare($query); |
890 | 890 | $sth->execute(); |
891 | - } catch(PDOException $e) { |
|
891 | + } catch (PDOException $e) { |
|
892 | 892 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; |
893 | 893 | } |
894 | 894 | // Add unique key |
@@ -900,17 +900,17 @@ discard block |
||
900 | 900 | try { |
901 | 901 | $sth = $Connection->db->prepare($query); |
902 | 902 | $sth->execute(); |
903 | - } catch(PDOException $e) { |
|
903 | + } catch (PDOException $e) { |
|
904 | 904 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; |
905 | 905 | } |
906 | 906 | } |
907 | - if (!$Connection->checkColumnName('stats_country','stats_airline')) { |
|
907 | + if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { |
|
908 | 908 | // Add forsource to airlines |
909 | 909 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
910 | 910 | try { |
911 | 911 | $sth = $Connection->db->prepare($query); |
912 | 912 | $sth->execute(); |
913 | - } catch(PDOException $e) { |
|
913 | + } catch (PDOException $e) { |
|
914 | 914 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; |
915 | 915 | } |
916 | 916 | // Add unique key |
@@ -922,36 +922,36 @@ discard block |
||
922 | 922 | try { |
923 | 923 | $sth = $Connection->db->prepare($query); |
924 | 924 | $sth->execute(); |
925 | - } catch(PDOException $e) { |
|
925 | + } catch (PDOException $e) { |
|
926 | 926 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; |
927 | 927 | } |
928 | 928 | } |
929 | - if (!$Connection->checkColumnName('stats_flight','stats_airline')) { |
|
929 | + if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { |
|
930 | 930 | // Add forsource to airlines |
931 | 931 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
932 | 932 | try { |
933 | 933 | $sth = $Connection->db->prepare($query); |
934 | 934 | $sth->execute(); |
935 | - } catch(PDOException $e) { |
|
935 | + } catch (PDOException $e) { |
|
936 | 936 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; |
937 | 937 | } |
938 | 938 | } |
939 | - if (!$Connection->checkColumnName('stats','stats_airline')) { |
|
939 | + if (!$Connection->checkColumnName('stats', 'stats_airline')) { |
|
940 | 940 | // Add forsource to airlines |
941 | 941 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
942 | 942 | try { |
943 | 943 | $sth = $Connection->db->prepare($query); |
944 | 944 | $sth->execute(); |
945 | - } catch(PDOException $e) { |
|
945 | + } catch (PDOException $e) { |
|
946 | 946 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; |
947 | 947 | } |
948 | - if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { |
|
948 | + if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { |
|
949 | 949 | // Add unique key |
950 | 950 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; |
951 | 951 | try { |
952 | 952 | $sth = $Connection->db->prepare($query); |
953 | 953 | $sth->execute(); |
954 | - } catch(PDOException $e) { |
|
954 | + } catch (PDOException $e) { |
|
955 | 955 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
956 | 956 | } |
957 | 957 | } else { |
@@ -964,18 +964,18 @@ discard block |
||
964 | 964 | try { |
965 | 965 | $sth = $Connection->db->prepare($query); |
966 | 966 | $sth->execute(); |
967 | - } catch(PDOException $e) { |
|
967 | + } catch (PDOException $e) { |
|
968 | 968 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
969 | 969 | } |
970 | 970 | } |
971 | 971 | } |
972 | - if (!$Connection->checkColumnName('stats_registration','stats_airline')) { |
|
972 | + if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { |
|
973 | 973 | // Add forsource to airlines |
974 | 974 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
975 | 975 | try { |
976 | 976 | $sth = $Connection->db->prepare($query); |
977 | 977 | $sth->execute(); |
978 | - } catch(PDOException $e) { |
|
978 | + } catch (PDOException $e) { |
|
979 | 979 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; |
980 | 980 | } |
981 | 981 | // Add unique key |
@@ -987,17 +987,17 @@ discard block |
||
987 | 987 | try { |
988 | 988 | $sth = $Connection->db->prepare($query); |
989 | 989 | $sth->execute(); |
990 | - } catch(PDOException $e) { |
|
990 | + } catch (PDOException $e) { |
|
991 | 991 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; |
992 | 992 | } |
993 | 993 | } |
994 | - if (!$Connection->checkColumnName('stats_callsign','filter_name')) { |
|
994 | + if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { |
|
995 | 995 | // Add forsource to airlines |
996 | 996 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
997 | 997 | try { |
998 | 998 | $sth = $Connection->db->prepare($query); |
999 | 999 | $sth->execute(); |
1000 | - } catch(PDOException $e) { |
|
1000 | + } catch (PDOException $e) { |
|
1001 | 1001 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; |
1002 | 1002 | } |
1003 | 1003 | // Add unique key |
@@ -1009,17 +1009,17 @@ discard block |
||
1009 | 1009 | try { |
1010 | 1010 | $sth = $Connection->db->prepare($query); |
1011 | 1011 | $sth->execute(); |
1012 | - } catch(PDOException $e) { |
|
1012 | + } catch (PDOException $e) { |
|
1013 | 1013 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | - if (!$Connection->checkColumnName('stats_airline','filter_name')) { |
|
1016 | + if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { |
|
1017 | 1017 | // Add forsource to airlines |
1018 | 1018 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1019 | 1019 | try { |
1020 | 1020 | $sth = $Connection->db->prepare($query); |
1021 | 1021 | $sth->execute(); |
1022 | - } catch(PDOException $e) { |
|
1022 | + } catch (PDOException $e) { |
|
1023 | 1023 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; |
1024 | 1024 | } |
1025 | 1025 | // Add unique key |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | try { |
1032 | 1032 | $sth = $Connection->db->prepare($query); |
1033 | 1033 | $sth->execute(); |
1034 | - } catch(PDOException $e) { |
|
1034 | + } catch (PDOException $e) { |
|
1035 | 1035 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1036 | 1036 | } |
1037 | 1037 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | try { |
1041 | 1041 | $sth = $Connection->db->prepare($query); |
1042 | 1042 | $sth->execute(); |
1043 | - } catch(PDOException $e) { |
|
1043 | + } catch (PDOException $e) { |
|
1044 | 1044 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1045 | 1045 | } |
1046 | 1046 | return $error; |
@@ -1050,13 +1050,13 @@ discard block |
||
1050 | 1050 | global $globalDBdriver; |
1051 | 1051 | $Connection = new Connection(); |
1052 | 1052 | $error = ''; |
1053 | - if (!$Connection->checkColumnName('stats_owner','stats_airline')) { |
|
1053 | + if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { |
|
1054 | 1054 | // Add forsource to airlines |
1055 | 1055 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1056 | 1056 | try { |
1057 | 1057 | $sth = $Connection->db->prepare($query); |
1058 | 1058 | $sth->execute(); |
1059 | - } catch(PDOException $e) { |
|
1059 | + } catch (PDOException $e) { |
|
1060 | 1060 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; |
1061 | 1061 | } |
1062 | 1062 | // Add unique key |
@@ -1068,17 +1068,17 @@ discard block |
||
1068 | 1068 | try { |
1069 | 1069 | $sth = $Connection->db->prepare($query); |
1070 | 1070 | $sth->execute(); |
1071 | - } catch(PDOException $e) { |
|
1071 | + } catch (PDOException $e) { |
|
1072 | 1072 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; |
1073 | 1073 | } |
1074 | 1074 | } |
1075 | - if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { |
|
1075 | + if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { |
|
1076 | 1076 | // Add forsource to airlines |
1077 | 1077 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1078 | 1078 | try { |
1079 | 1079 | $sth = $Connection->db->prepare($query); |
1080 | 1080 | $sth->execute(); |
1081 | - } catch(PDOException $e) { |
|
1081 | + } catch (PDOException $e) { |
|
1082 | 1082 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; |
1083 | 1083 | } |
1084 | 1084 | // Add unique key |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | try { |
1091 | 1091 | $sth = $Connection->db->prepare($query); |
1092 | 1092 | $sth->execute(); |
1093 | - } catch(PDOException $e) { |
|
1093 | + } catch (PDOException $e) { |
|
1094 | 1094 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1095 | 1095 | } |
1096 | 1096 | } |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | try { |
1099 | 1099 | $sth = $Connection->db->prepare($query); |
1100 | 1100 | $sth->execute(); |
1101 | - } catch(PDOException $e) { |
|
1101 | + } catch (PDOException $e) { |
|
1102 | 1102 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1103 | 1103 | } |
1104 | 1104 | return $error; |
@@ -1108,12 +1108,12 @@ discard block |
||
1108 | 1108 | global $globalDBdriver; |
1109 | 1109 | $Connection = new Connection(); |
1110 | 1110 | $error = ''; |
1111 | - if (!$Connection->checkColumnName('atc','format_source')) { |
|
1111 | + if (!$Connection->checkColumnName('atc', 'format_source')) { |
|
1112 | 1112 | $query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL"; |
1113 | 1113 | try { |
1114 | 1114 | $sth = $Connection->db->prepare($query); |
1115 | 1115 | $sth->execute(); |
1116 | - } catch(PDOException $e) { |
|
1116 | + } catch (PDOException $e) { |
|
1117 | 1117 | return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n"; |
1118 | 1118 | } |
1119 | 1119 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | try { |
1122 | 1122 | $sth = $Connection->db->prepare($query); |
1123 | 1123 | $sth->execute(); |
1124 | - } catch(PDOException $e) { |
|
1124 | + } catch (PDOException $e) { |
|
1125 | 1125 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1126 | 1126 | } |
1127 | 1127 | return $error; |
@@ -1131,13 +1131,13 @@ discard block |
||
1131 | 1131 | global $globalDBdriver; |
1132 | 1132 | $Connection = new Connection(); |
1133 | 1133 | $error = ''; |
1134 | - if (!$Connection->checkColumnName('stats_pilot','format_source')) { |
|
1134 | + if (!$Connection->checkColumnName('stats_pilot', 'format_source')) { |
|
1135 | 1135 | // Add forsource to airlines |
1136 | 1136 | $query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''"; |
1137 | 1137 | try { |
1138 | 1138 | $sth = $Connection->db->prepare($query); |
1139 | 1139 | $sth->execute(); |
1140 | - } catch(PDOException $e) { |
|
1140 | + } catch (PDOException $e) { |
|
1141 | 1141 | return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n"; |
1142 | 1142 | } |
1143 | 1143 | // Add unique key |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | try { |
1150 | 1150 | $sth = $Connection->db->prepare($query); |
1151 | 1151 | $sth->execute(); |
1152 | - } catch(PDOException $e) { |
|
1152 | + } catch (PDOException $e) { |
|
1153 | 1153 | return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1154 | 1154 | } |
1155 | 1155 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | try { |
1158 | 1158 | $sth = $Connection->db->prepare($query); |
1159 | 1159 | $sth->execute(); |
1160 | - } catch(PDOException $e) { |
|
1160 | + } catch (PDOException $e) { |
|
1161 | 1161 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1162 | 1162 | } |
1163 | 1163 | return $error; |
@@ -1167,23 +1167,23 @@ discard block |
||
1167 | 1167 | global $globalDBdriver; |
1168 | 1168 | $Connection = new Connection(); |
1169 | 1169 | $error = ''; |
1170 | - if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) { |
|
1170 | + if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) { |
|
1171 | 1171 | // Add unique key |
1172 | 1172 | $query = "alter table spotter_live add index(latitude,longitude)"; |
1173 | 1173 | try { |
1174 | 1174 | $sth = $Connection->db->prepare($query); |
1175 | 1175 | $sth->execute(); |
1176 | - } catch(PDOException $e) { |
|
1176 | + } catch (PDOException $e) { |
|
1177 | 1177 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
1178 | 1178 | } |
1179 | 1179 | } |
1180 | - if (!$Connection->checkColumnName('aircraft','mfr')) { |
|
1180 | + if (!$Connection->checkColumnName('aircraft', 'mfr')) { |
|
1181 | 1181 | // Add mfr to aircraft |
1182 | 1182 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
1183 | 1183 | try { |
1184 | 1184 | $sth = $Connection->db->prepare($query); |
1185 | 1185 | $sth->execute(); |
1186 | - } catch(PDOException $e) { |
|
1186 | + } catch (PDOException $e) { |
|
1187 | 1187 | return "error (add mfr column in aircraft) : ".$e->getMessage()."\n"; |
1188 | 1188 | } |
1189 | 1189 | } |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | try { |
1200 | 1200 | $sth = $Connection->db->prepare($query); |
1201 | 1201 | $sth->execute(); |
1202 | - } catch(PDOException $e) { |
|
1202 | + } catch (PDOException $e) { |
|
1203 | 1203 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1204 | 1204 | } |
1205 | 1205 | return $error; |
@@ -1209,13 +1209,13 @@ discard block |
||
1209 | 1209 | global $globalDBdriver; |
1210 | 1210 | $Connection = new Connection(); |
1211 | 1211 | $error = ''; |
1212 | - if ($Connection->checkColumnName('aircraft','mfr')) { |
|
1212 | + if ($Connection->checkColumnName('aircraft', 'mfr')) { |
|
1213 | 1213 | // drop mfr to aircraft |
1214 | 1214 | $query = "ALTER TABLE aircraft DROP COLUMN mfr"; |
1215 | 1215 | try { |
1216 | 1216 | $sth = $Connection->db->prepare($query); |
1217 | 1217 | $sth->execute(); |
1218 | - } catch(PDOException $e) { |
|
1218 | + } catch (PDOException $e) { |
|
1219 | 1219 | return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n"; |
1220 | 1220 | } |
1221 | 1221 | } |
@@ -1231,7 +1231,7 @@ discard block |
||
1231 | 1231 | try { |
1232 | 1232 | $sth = $Connection->db->prepare($query); |
1233 | 1233 | $sth->execute(); |
1234 | - } catch(PDOException $e) { |
|
1234 | + } catch (PDOException $e) { |
|
1235 | 1235 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1236 | 1236 | } |
1237 | 1237 | return $error; |
@@ -1241,33 +1241,33 @@ discard block |
||
1241 | 1241 | global $globalDBdriver; |
1242 | 1242 | $Connection = new Connection(); |
1243 | 1243 | $error = ''; |
1244 | - if (!$Connection->indexExists('notam','ref_idx')) { |
|
1244 | + if (!$Connection->indexExists('notam', 'ref_idx')) { |
|
1245 | 1245 | // Add index key |
1246 | 1246 | $query = "create index ref_idx on notam (ref)"; |
1247 | 1247 | try { |
1248 | 1248 | $sth = $Connection->db->prepare($query); |
1249 | 1249 | $sth->execute(); |
1250 | - } catch(PDOException $e) { |
|
1250 | + } catch (PDOException $e) { |
|
1251 | 1251 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
1252 | 1252 | } |
1253 | 1253 | } |
1254 | - if (!$Connection->indexExists('accidents','registration_idx')) { |
|
1254 | + if (!$Connection->indexExists('accidents', 'registration_idx')) { |
|
1255 | 1255 | // Add index key |
1256 | 1256 | $query = "create index registration_idx on accidents (registration)"; |
1257 | 1257 | try { |
1258 | 1258 | $sth = $Connection->db->prepare($query); |
1259 | 1259 | $sth->execute(); |
1260 | - } catch(PDOException $e) { |
|
1260 | + } catch (PDOException $e) { |
|
1261 | 1261 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
1262 | 1262 | } |
1263 | 1263 | } |
1264 | - if (!$Connection->indexExists('accidents','rdts')) { |
|
1264 | + if (!$Connection->indexExists('accidents', 'rdts')) { |
|
1265 | 1265 | // Add index key |
1266 | 1266 | $query = "create index rdts on accidents (registration,date,type,source)"; |
1267 | 1267 | try { |
1268 | 1268 | $sth = $Connection->db->prepare($query); |
1269 | 1269 | $sth->execute(); |
1270 | - } catch(PDOException $e) { |
|
1270 | + } catch (PDOException $e) { |
|
1271 | 1271 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
1272 | 1272 | } |
1273 | 1273 | } |
@@ -1276,7 +1276,7 @@ discard block |
||
1276 | 1276 | try { |
1277 | 1277 | $sth = $Connection->db->prepare($query); |
1278 | 1278 | $sth->execute(); |
1279 | - } catch(PDOException $e) { |
|
1279 | + } catch (PDOException $e) { |
|
1280 | 1280 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1281 | 1281 | } |
1282 | 1282 | return $error; |
@@ -1286,23 +1286,23 @@ discard block |
||
1286 | 1286 | global $globalDBdriver; |
1287 | 1287 | $Connection = new Connection(); |
1288 | 1288 | $error = ''; |
1289 | - if (!$Connection->checkColumnName('accidents','airline_name')) { |
|
1289 | + if (!$Connection->checkColumnName('accidents', 'airline_name')) { |
|
1290 | 1290 | // Add airline_name to accidents |
1291 | 1291 | $query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL"; |
1292 | 1292 | try { |
1293 | 1293 | $sth = $Connection->db->prepare($query); |
1294 | 1294 | $sth->execute(); |
1295 | - } catch(PDOException $e) { |
|
1295 | + } catch (PDOException $e) { |
|
1296 | 1296 | return "error (add airline_name column in accidents) : ".$e->getMessage()."\n"; |
1297 | 1297 | } |
1298 | 1298 | } |
1299 | - if (!$Connection->checkColumnName('accidents','airline_icao')) { |
|
1299 | + if (!$Connection->checkColumnName('accidents', 'airline_icao')) { |
|
1300 | 1300 | // Add airline_icao to accidents |
1301 | 1301 | $query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL"; |
1302 | 1302 | try { |
1303 | 1303 | $sth = $Connection->db->prepare($query); |
1304 | 1304 | $sth->execute(); |
1305 | - } catch(PDOException $e) { |
|
1305 | + } catch (PDOException $e) { |
|
1306 | 1306 | return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n"; |
1307 | 1307 | } |
1308 | 1308 | } |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | try { |
1311 | 1311 | $sth = $Connection->db->prepare($query); |
1312 | 1312 | $sth->execute(); |
1313 | - } catch(PDOException $e) { |
|
1313 | + } catch (PDOException $e) { |
|
1314 | 1314 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1315 | 1315 | } |
1316 | 1316 | return $error; |
@@ -1320,13 +1320,13 @@ discard block |
||
1320 | 1320 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1321 | 1321 | $Connection = new Connection(); |
1322 | 1322 | $error = ''; |
1323 | - if (!$Connection->checkColumnName('airlines','alliance')) { |
|
1323 | + if (!$Connection->checkColumnName('airlines', 'alliance')) { |
|
1324 | 1324 | // Add alliance to airlines |
1325 | 1325 | $query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL"; |
1326 | 1326 | try { |
1327 | 1327 | $sth = $Connection->db->prepare($query); |
1328 | 1328 | $sth->execute(); |
1329 | - } catch(PDOException $e) { |
|
1329 | + } catch (PDOException $e) { |
|
1330 | 1330 | return "error (add alliance column in airlines) : ".$e->getMessage()."\n"; |
1331 | 1331 | } |
1332 | 1332 | } |
@@ -1353,7 +1353,7 @@ discard block |
||
1353 | 1353 | try { |
1354 | 1354 | $sth = $Connection->db->prepare($query); |
1355 | 1355 | $sth->execute(); |
1356 | - } catch(PDOException $e) { |
|
1356 | + } catch (PDOException $e) { |
|
1357 | 1357 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1358 | 1358 | } |
1359 | 1359 | return $error; |
@@ -1363,13 +1363,13 @@ discard block |
||
1363 | 1363 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1364 | 1364 | $Connection = new Connection(); |
1365 | 1365 | $error = ''; |
1366 | - if (!$Connection->checkColumnName('airlines','ban_eu')) { |
|
1366 | + if (!$Connection->checkColumnName('airlines', 'ban_eu')) { |
|
1367 | 1367 | // Add ban_eu to airlines |
1368 | 1368 | $query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'"; |
1369 | 1369 | try { |
1370 | 1370 | $sth = $Connection->db->prepare($query); |
1371 | 1371 | $sth->execute(); |
1372 | - } catch(PDOException $e) { |
|
1372 | + } catch (PDOException $e) { |
|
1373 | 1373 | return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n"; |
1374 | 1374 | } |
1375 | 1375 | } |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | try { |
1378 | 1378 | $sth = $Connection->db->prepare($query); |
1379 | 1379 | $sth->execute(); |
1380 | - } catch(PDOException $e) { |
|
1380 | + } catch (PDOException $e) { |
|
1381 | 1381 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1382 | 1382 | } |
1383 | 1383 | return $error; |
@@ -1399,7 +1399,7 @@ discard block |
||
1399 | 1399 | try { |
1400 | 1400 | $sth = $Connection->db->prepare($query); |
1401 | 1401 | $sth->execute(); |
1402 | - } catch(PDOException $e) { |
|
1402 | + } catch (PDOException $e) { |
|
1403 | 1403 | return "error : ".$e->getMessage()."\n"; |
1404 | 1404 | } |
1405 | 1405 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -258,7 +258,9 @@ discard block |
||
258 | 258 | // Update table countries |
259 | 259 | if ($Connection->tableExists('airspace')) { |
260 | 260 | $error .= update_db::update_countries(); |
261 | - if ($error != '') return $error; |
|
261 | + if ($error != '') { |
|
262 | + return $error; |
|
263 | + } |
|
262 | 264 | } |
263 | 265 | // Update schema_version to 7 |
264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
314 | 316 | $error = ''; |
315 | 317 | // Update table aircraft |
316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | - if ($error != '') return $error; |
|
319 | + if ($error != '') { |
|
320 | + return $error; |
|
321 | + } |
|
318 | 322 | // Update schema_version to 6 |
319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
331 | 335 | $error = ''; |
332 | 336 | // Update table aircraft |
333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
334 | - if ($error != '') return $error; |
|
338 | + if ($error != '') { |
|
339 | + return $error; |
|
340 | + } |
|
335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
365 | 371 | $error = ''; |
366 | 372 | // Update table atc |
367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
368 | - if ($error != '') return $error; |
|
374 | + if ($error != '') { |
|
375 | + return $error; |
|
376 | + } |
|
369 | 377 | |
370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
389 | 397 | $error = ''; |
390 | 398 | // Add tables |
391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | - if ($error != '') return $error; |
|
400 | + if ($error != '') { |
|
401 | + return $error; |
|
402 | + } |
|
393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
394 | - if ($error != '') return $error; |
|
404 | + if ($error != '') { |
|
405 | + return $error; |
|
406 | + } |
|
395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
396 | - if ($error != '') return $error; |
|
408 | + if ($error != '') { |
|
409 | + return $error; |
|
410 | + } |
|
397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
398 | - if ($error != '') return $error; |
|
412 | + if ($error != '') { |
|
413 | + return $error; |
|
414 | + } |
|
399 | 415 | |
400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
469 | 485 | $error = ''; |
470 | 486 | // Add tables |
471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
472 | - if ($error != '') return $error; |
|
488 | + if ($error != '') { |
|
489 | + return $error; |
|
490 | + } |
|
473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
474 | - if ($error != '') return $error; |
|
492 | + if ($error != '') { |
|
493 | + return $error; |
|
494 | + } |
|
475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
476 | - if ($error != '') return $error; |
|
496 | + if ($error != '') { |
|
497 | + return $error; |
|
498 | + } |
|
477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
478 | - if ($error != '') return $error; |
|
500 | + if ($error != '') { |
|
501 | + return $error; |
|
502 | + } |
|
479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
480 | - if ($error != '') return $error; |
|
504 | + if ($error != '') { |
|
505 | + return $error; |
|
506 | + } |
|
481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
482 | - if ($error != '') return $error; |
|
508 | + if ($error != '') { |
|
509 | + return $error; |
|
510 | + } |
|
483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
484 | - if ($error != '') return $error; |
|
512 | + if ($error != '') { |
|
513 | + return $error; |
|
514 | + } |
|
485 | 515 | |
486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
521 | 551 | // Add tables |
522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | - if ($error != '') return $error; |
|
554 | + if ($error != '') { |
|
555 | + return $error; |
|
556 | + } |
|
525 | 557 | } |
526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
545 | 577 | } catch(PDOException $e) { |
546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 579 | } |
548 | - if ($error != '') return $error; |
|
580 | + if ($error != '') { |
|
581 | + return $error; |
|
582 | + } |
|
549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | 584 | try { |
551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 602 | } |
569 | - if ($error != '') return $error; |
|
603 | + if ($error != '') { |
|
604 | + return $error; |
|
605 | + } |
|
570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | 607 | try { |
572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
584 | 620 | if (!$Connection->tableExists('stats_country')) { |
585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 622 | } |
587 | - if ($error != '') return $error; |
|
623 | + if ($error != '') { |
|
624 | + return $error; |
|
625 | + } |
|
588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | 627 | try { |
590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 646 | } |
609 | 647 | } |
610 | - if ($error != '') return $error; |
|
648 | + if ($error != '') { |
|
649 | + return $error; |
|
650 | + } |
|
611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | 652 | try { |
613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
623 | 663 | $error = ''; |
624 | 664 | // Update airport table |
625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
666 | + if ($error != '') { |
|
667 | + return 'Import airport.sql : '.$error; |
|
668 | + } |
|
627 | 669 | // Remove primary key on Spotter_Archive |
628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 742 | } |
701 | 743 | } |
702 | - if ($error != '') return $error; |
|
744 | + if ($error != '') { |
|
745 | + return $error; |
|
746 | + } |
|
703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | 748 | try { |
705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
717 | 761 | // Update airline table |
718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
764 | + if ($error != '') { |
|
765 | + return 'Import airlines.sql : '.$error; |
|
766 | + } |
|
721 | 767 | } |
722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 776 | } |
731 | 777 | } |
732 | - if ($error != '') return $error; |
|
778 | + if ($error != '') { |
|
779 | + return $error; |
|
780 | + } |
|
733 | 781 | /* |
734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
759 | 807 | } catch(PDOException $e) { |
760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 809 | } |
762 | - if ($error != '') return $error; |
|
810 | + if ($error != '') { |
|
811 | + return $error; |
|
812 | + } |
|
763 | 813 | } |
764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
782 | 832 | } else { |
783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 834 | } |
785 | - if ($error != '') return $error; |
|
835 | + if ($error != '') { |
|
836 | + return $error; |
|
837 | + } |
|
786 | 838 | } |
787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | 840 | try { |
@@ -804,12 +856,16 @@ discard block |
||
804 | 856 | if ($globalDBdriver == 'mysql') { |
805 | 857 | if (!$Connection->tableExists('tle')) { |
806 | 858 | $error .= create_db::import_file('../db/tle.sql'); |
807 | - if ($error != '') return $error; |
|
859 | + if ($error != '') { |
|
860 | + return $error; |
|
861 | + } |
|
808 | 862 | } |
809 | 863 | } else { |
810 | 864 | if (!$Connection->tableExists('tle')) { |
811 | 865 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
812 | - if ($error != '') return $error; |
|
866 | + if ($error != '') { |
|
867 | + return $error; |
|
868 | + } |
|
813 | 869 | } |
814 | 870 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
815 | 871 | try { |
@@ -849,7 +905,9 @@ discard block |
||
849 | 905 | } else { |
850 | 906 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 907 | } |
852 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
908 | + if ($error != '') { |
|
909 | + return 'Import airlines.sql : '.$error; |
|
910 | + } |
|
853 | 911 | if (!$Connection->checkColumnName('airlines','forsource')) { |
854 | 912 | // Add forsource to airlines |
855 | 913 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1332,20 +1390,28 @@ discard block |
||
1332 | 1390 | } |
1333 | 1391 | if ($globalDBdriver == 'mysql') { |
1334 | 1392 | $error .= create_db::import_file('../db/airlines.sql'); |
1335 | - if ($error != '') return $error; |
|
1393 | + if ($error != '') { |
|
1394 | + return $error; |
|
1395 | + } |
|
1336 | 1396 | } else { |
1337 | 1397 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
1338 | - if ($error != '') return $error; |
|
1398 | + if ($error != '') { |
|
1399 | + return $error; |
|
1400 | + } |
|
1339 | 1401 | } |
1340 | 1402 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
1341 | 1403 | include_once('class/class.update_db.php'); |
1342 | 1404 | if (isset($globalVATSIM) && $globalVATSIM) { |
1343 | 1405 | $error .= update_db::update_vatsim(); |
1344 | - if ($error != '') return $error; |
|
1406 | + if ($error != '') { |
|
1407 | + return $error; |
|
1408 | + } |
|
1345 | 1409 | } |
1346 | 1410 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
1347 | 1411 | $error .= update_db::update_IVAO(); |
1348 | - if ($error != '') return $error; |
|
1412 | + if ($error != '') { |
|
1413 | + return $error; |
|
1414 | + } |
|
1349 | 1415 | } |
1350 | 1416 | } |
1351 | 1417 | |
@@ -1391,8 +1457,11 @@ discard block |
||
1391 | 1457 | if ($Connection->tableExists('aircraft')) { |
1392 | 1458 | if (!$Connection->tableExists('config')) { |
1393 | 1459 | $version = '1'; |
1394 | - if ($update) return self::update_from_1(); |
|
1395 | - else return $version; |
|
1460 | + if ($update) { |
|
1461 | + return self::update_from_1(); |
|
1462 | + } else { |
|
1463 | + return $version; |
|
1464 | + } |
|
1396 | 1465 | } else { |
1397 | 1466 | $Connection = new Connection(); |
1398 | 1467 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -1406,138 +1475,239 @@ discard block |
||
1406 | 1475 | if ($update) { |
1407 | 1476 | if ($result['value'] == '2') { |
1408 | 1477 | $error = self::update_from_2(); |
1409 | - if ($error != '') return $error; |
|
1410 | - else return self::check_version(true); |
|
1478 | + if ($error != '') { |
|
1479 | + return $error; |
|
1480 | + } else { |
|
1481 | + return self::check_version(true); |
|
1482 | + } |
|
1411 | 1483 | } elseif ($result['value'] == '3') { |
1412 | 1484 | $error = self::update_from_3(); |
1413 | - if ($error != '') return $error; |
|
1414 | - else return self::check_version(true); |
|
1485 | + if ($error != '') { |
|
1486 | + return $error; |
|
1487 | + } else { |
|
1488 | + return self::check_version(true); |
|
1489 | + } |
|
1415 | 1490 | } elseif ($result['value'] == '4') { |
1416 | 1491 | $error = self::update_from_4(); |
1417 | - if ($error != '') return $error; |
|
1418 | - else return self::check_version(true); |
|
1492 | + if ($error != '') { |
|
1493 | + return $error; |
|
1494 | + } else { |
|
1495 | + return self::check_version(true); |
|
1496 | + } |
|
1419 | 1497 | } elseif ($result['value'] == '5') { |
1420 | 1498 | $error = self::update_from_5(); |
1421 | - if ($error != '') return $error; |
|
1422 | - else return self::check_version(true); |
|
1499 | + if ($error != '') { |
|
1500 | + return $error; |
|
1501 | + } else { |
|
1502 | + return self::check_version(true); |
|
1503 | + } |
|
1423 | 1504 | } elseif ($result['value'] == '6') { |
1424 | 1505 | $error = self::update_from_6(); |
1425 | - if ($error != '') return $error; |
|
1426 | - else return self::check_version(true); |
|
1506 | + if ($error != '') { |
|
1507 | + return $error; |
|
1508 | + } else { |
|
1509 | + return self::check_version(true); |
|
1510 | + } |
|
1427 | 1511 | } elseif ($result['value'] == '7') { |
1428 | 1512 | $error = self::update_from_7(); |
1429 | - if ($error != '') return $error; |
|
1430 | - else return self::check_version(true); |
|
1513 | + if ($error != '') { |
|
1514 | + return $error; |
|
1515 | + } else { |
|
1516 | + return self::check_version(true); |
|
1517 | + } |
|
1431 | 1518 | } elseif ($result['value'] == '8') { |
1432 | 1519 | $error = self::update_from_8(); |
1433 | - if ($error != '') return $error; |
|
1434 | - else return self::check_version(true); |
|
1520 | + if ($error != '') { |
|
1521 | + return $error; |
|
1522 | + } else { |
|
1523 | + return self::check_version(true); |
|
1524 | + } |
|
1435 | 1525 | } elseif ($result['value'] == '9') { |
1436 | 1526 | $error = self::update_from_9(); |
1437 | - if ($error != '') return $error; |
|
1438 | - else return self::check_version(true); |
|
1527 | + if ($error != '') { |
|
1528 | + return $error; |
|
1529 | + } else { |
|
1530 | + return self::check_version(true); |
|
1531 | + } |
|
1439 | 1532 | } elseif ($result['value'] == '10') { |
1440 | 1533 | $error = self::update_from_10(); |
1441 | - if ($error != '') return $error; |
|
1442 | - else return self::check_version(true); |
|
1534 | + if ($error != '') { |
|
1535 | + return $error; |
|
1536 | + } else { |
|
1537 | + return self::check_version(true); |
|
1538 | + } |
|
1443 | 1539 | } elseif ($result['value'] == '11') { |
1444 | 1540 | $error = self::update_from_11(); |
1445 | - if ($error != '') return $error; |
|
1446 | - else return self::check_version(true); |
|
1541 | + if ($error != '') { |
|
1542 | + return $error; |
|
1543 | + } else { |
|
1544 | + return self::check_version(true); |
|
1545 | + } |
|
1447 | 1546 | } elseif ($result['value'] == '12') { |
1448 | 1547 | $error = self::update_from_12(); |
1449 | - if ($error != '') return $error; |
|
1450 | - else return self::check_version(true); |
|
1548 | + if ($error != '') { |
|
1549 | + return $error; |
|
1550 | + } else { |
|
1551 | + return self::check_version(true); |
|
1552 | + } |
|
1451 | 1553 | } elseif ($result['value'] == '13') { |
1452 | 1554 | $error = self::update_from_13(); |
1453 | - if ($error != '') return $error; |
|
1454 | - else return self::check_version(true); |
|
1555 | + if ($error != '') { |
|
1556 | + return $error; |
|
1557 | + } else { |
|
1558 | + return self::check_version(true); |
|
1559 | + } |
|
1455 | 1560 | } elseif ($result['value'] == '14') { |
1456 | 1561 | $error = self::update_from_14(); |
1457 | - if ($error != '') return $error; |
|
1458 | - else return self::check_version(true); |
|
1562 | + if ($error != '') { |
|
1563 | + return $error; |
|
1564 | + } else { |
|
1565 | + return self::check_version(true); |
|
1566 | + } |
|
1459 | 1567 | } elseif ($result['value'] == '15') { |
1460 | 1568 | $error = self::update_from_15(); |
1461 | - if ($error != '') return $error; |
|
1462 | - else return self::check_version(true); |
|
1569 | + if ($error != '') { |
|
1570 | + return $error; |
|
1571 | + } else { |
|
1572 | + return self::check_version(true); |
|
1573 | + } |
|
1463 | 1574 | } elseif ($result['value'] == '16') { |
1464 | 1575 | $error = self::update_from_16(); |
1465 | - if ($error != '') return $error; |
|
1466 | - else return self::check_version(true); |
|
1576 | + if ($error != '') { |
|
1577 | + return $error; |
|
1578 | + } else { |
|
1579 | + return self::check_version(true); |
|
1580 | + } |
|
1467 | 1581 | } elseif ($result['value'] == '17') { |
1468 | 1582 | $error = self::update_from_17(); |
1469 | - if ($error != '') return $error; |
|
1470 | - else return self::check_version(true); |
|
1583 | + if ($error != '') { |
|
1584 | + return $error; |
|
1585 | + } else { |
|
1586 | + return self::check_version(true); |
|
1587 | + } |
|
1471 | 1588 | } elseif ($result['value'] == '18') { |
1472 | 1589 | $error = self::update_from_18(); |
1473 | - if ($error != '') return $error; |
|
1474 | - else return self::check_version(true); |
|
1590 | + if ($error != '') { |
|
1591 | + return $error; |
|
1592 | + } else { |
|
1593 | + return self::check_version(true); |
|
1594 | + } |
|
1475 | 1595 | } elseif ($result['value'] == '19') { |
1476 | 1596 | $error = self::update_from_19(); |
1477 | - if ($error != '') return $error; |
|
1478 | - else return self::check_version(true); |
|
1597 | + if ($error != '') { |
|
1598 | + return $error; |
|
1599 | + } else { |
|
1600 | + return self::check_version(true); |
|
1601 | + } |
|
1479 | 1602 | } elseif ($result['value'] == '20') { |
1480 | 1603 | $error = self::update_from_20(); |
1481 | - if ($error != '') return $error; |
|
1482 | - else return self::check_version(true); |
|
1604 | + if ($error != '') { |
|
1605 | + return $error; |
|
1606 | + } else { |
|
1607 | + return self::check_version(true); |
|
1608 | + } |
|
1483 | 1609 | } elseif ($result['value'] == '21') { |
1484 | 1610 | $error = self::update_from_21(); |
1485 | - if ($error != '') return $error; |
|
1486 | - else return self::check_version(true); |
|
1611 | + if ($error != '') { |
|
1612 | + return $error; |
|
1613 | + } else { |
|
1614 | + return self::check_version(true); |
|
1615 | + } |
|
1487 | 1616 | } elseif ($result['value'] == '22') { |
1488 | 1617 | $error = self::update_from_22(); |
1489 | - if ($error != '') return $error; |
|
1490 | - else return self::check_version(true); |
|
1618 | + if ($error != '') { |
|
1619 | + return $error; |
|
1620 | + } else { |
|
1621 | + return self::check_version(true); |
|
1622 | + } |
|
1491 | 1623 | } elseif ($result['value'] == '23') { |
1492 | 1624 | $error = self::update_from_23(); |
1493 | - if ($error != '') return $error; |
|
1494 | - else return self::check_version(true); |
|
1625 | + if ($error != '') { |
|
1626 | + return $error; |
|
1627 | + } else { |
|
1628 | + return self::check_version(true); |
|
1629 | + } |
|
1495 | 1630 | } elseif ($result['value'] == '24') { |
1496 | 1631 | $error = self::update_from_24(); |
1497 | - if ($error != '') return $error; |
|
1498 | - else return self::check_version(true); |
|
1632 | + if ($error != '') { |
|
1633 | + return $error; |
|
1634 | + } else { |
|
1635 | + return self::check_version(true); |
|
1636 | + } |
|
1499 | 1637 | } elseif ($result['value'] == '25') { |
1500 | 1638 | $error = self::update_from_25(); |
1501 | - if ($error != '') return $error; |
|
1502 | - else return self::check_version(true); |
|
1639 | + if ($error != '') { |
|
1640 | + return $error; |
|
1641 | + } else { |
|
1642 | + return self::check_version(true); |
|
1643 | + } |
|
1503 | 1644 | } elseif ($result['value'] == '26') { |
1504 | 1645 | $error = self::update_from_26(); |
1505 | - if ($error != '') return $error; |
|
1506 | - else return self::check_version(true); |
|
1646 | + if ($error != '') { |
|
1647 | + return $error; |
|
1648 | + } else { |
|
1649 | + return self::check_version(true); |
|
1650 | + } |
|
1507 | 1651 | } elseif ($result['value'] == '27') { |
1508 | 1652 | $error = self::update_from_27(); |
1509 | - if ($error != '') return $error; |
|
1510 | - else return self::check_version(true); |
|
1653 | + if ($error != '') { |
|
1654 | + return $error; |
|
1655 | + } else { |
|
1656 | + return self::check_version(true); |
|
1657 | + } |
|
1511 | 1658 | } elseif ($result['value'] == '28') { |
1512 | 1659 | $error = self::update_from_28(); |
1513 | - if ($error != '') return $error; |
|
1514 | - else return self::check_version(true); |
|
1660 | + if ($error != '') { |
|
1661 | + return $error; |
|
1662 | + } else { |
|
1663 | + return self::check_version(true); |
|
1664 | + } |
|
1515 | 1665 | } elseif ($result['value'] == '29') { |
1516 | 1666 | $error = self::update_from_29(); |
1517 | - if ($error != '') return $error; |
|
1518 | - else return self::check_version(true); |
|
1667 | + if ($error != '') { |
|
1668 | + return $error; |
|
1669 | + } else { |
|
1670 | + return self::check_version(true); |
|
1671 | + } |
|
1519 | 1672 | } elseif ($result['value'] == '30') { |
1520 | 1673 | $error = self::update_from_30(); |
1521 | - if ($error != '') return $error; |
|
1522 | - else return self::check_version(true); |
|
1674 | + if ($error != '') { |
|
1675 | + return $error; |
|
1676 | + } else { |
|
1677 | + return self::check_version(true); |
|
1678 | + } |
|
1523 | 1679 | } elseif ($result['value'] == '31') { |
1524 | 1680 | $error = self::update_from_31(); |
1525 | - if ($error != '') return $error; |
|
1526 | - else return self::check_version(true); |
|
1681 | + if ($error != '') { |
|
1682 | + return $error; |
|
1683 | + } else { |
|
1684 | + return self::check_version(true); |
|
1685 | + } |
|
1527 | 1686 | } elseif ($result['value'] == '32') { |
1528 | 1687 | $error = self::update_from_32(); |
1529 | - if ($error != '') return $error; |
|
1530 | - else return self::check_version(true); |
|
1688 | + if ($error != '') { |
|
1689 | + return $error; |
|
1690 | + } else { |
|
1691 | + return self::check_version(true); |
|
1692 | + } |
|
1531 | 1693 | } elseif ($result['value'] == '33') { |
1532 | 1694 | $error = self::update_from_33(); |
1533 | - if ($error != '') return $error; |
|
1534 | - else return self::check_version(true); |
|
1535 | - } else return ''; |
|
1695 | + if ($error != '') { |
|
1696 | + return $error; |
|
1697 | + } else { |
|
1698 | + return self::check_version(true); |
|
1699 | + } |
|
1700 | + } else { |
|
1701 | + return ''; |
|
1702 | + } |
|
1703 | + } else { |
|
1704 | + return $result['value']; |
|
1536 | 1705 | } |
1537 | - else return $result['value']; |
|
1538 | 1706 | } |
1539 | 1707 | |
1540 | - } else return $version; |
|
1708 | + } else { |
|
1709 | + return $version; |
|
1710 | + } |
|
1541 | 1711 | } |
1542 | 1712 | |
1543 | 1713 | } |
@@ -6,6 +6,9 @@ discard block |
||
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 34; |
8 | 8 | |
9 | + /** |
|
10 | + * @param string $dbname |
|
11 | + */ |
|
9 | 12 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
10 | 13 | global $globalDBdriver; |
11 | 14 | if ($dbc === null) { |
@@ -132,6 +135,9 @@ discard block |
||
132 | 135 | return true; |
133 | 136 | } |
134 | 137 | |
138 | + /** |
|
139 | + * @param string $table |
|
140 | + */ |
|
135 | 141 | public function tableExists($table) |
136 | 142 | { |
137 | 143 | global $globalDBdriver, $globalDBname; |
@@ -181,6 +187,11 @@ discard block |
||
181 | 187 | /* |
182 | 188 | * Check if index exist |
183 | 189 | */ |
190 | + |
|
191 | + /** |
|
192 | + * @param string $table |
|
193 | + * @param string $index |
|
194 | + */ |
|
184 | 195 | public function indexExists($table,$index) |
185 | 196 | { |
186 | 197 | global $globalDBdriver, $globalDBname; |
@@ -227,6 +238,11 @@ discard block |
||
227 | 238 | * Check if a column name exist in a table |
228 | 239 | * @return Boolean column exist or not |
229 | 240 | */ |
241 | + |
|
242 | + /** |
|
243 | + * @param string $table |
|
244 | + * @param string $name |
|
245 | + */ |
|
230 | 246 | public function checkColumnName($table,$name) |
231 | 247 | { |
232 | 248 | global $globalDBdriver, $globalDBname; |
@@ -7,18 +7,18 @@ discard block |
||
7 | 7 | public $latest_schema = 34; |
8 | 8 | |
9 | 9 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
10 | - global $globalDBdriver; |
|
11 | - if ($dbc === null) { |
|
10 | + global $globalDBdriver; |
|
11 | + if ($dbc === null) { |
|
12 | 12 | if ($this->db === null && $dbname === null) { |
13 | - if ($user === null && $pass === null) { |
|
13 | + if ($user === null && $pass === null) { |
|
14 | 14 | $this->createDBConnection(); |
15 | - } else { |
|
15 | + } else { |
|
16 | 16 | $this->createDBConnection(null,$user,$pass); |
17 | - } |
|
17 | + } |
|
18 | 18 | } else { |
19 | - $this->createDBConnection($dbname); |
|
19 | + $this->createDBConnection($dbname); |
|
20 | 20 | } |
21 | - } elseif ($dbname === null || $dbname === 'default') { |
|
21 | + } elseif ($dbname === null || $dbname === 'default') { |
|
22 | 22 | $this->db = $dbc; |
23 | 23 | if ($this->connectionExists() === false) { |
24 | 24 | /* |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | */ |
29 | 29 | $this->createDBConnection(); |
30 | 30 | } |
31 | - } else { |
|
31 | + } else { |
|
32 | 32 | //$this->connectionExists(); |
33 | 33 | $this->dbs[$dbname] = $dbc; |
34 | - } |
|
34 | + } |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function db() { |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | - * Creates the database connection |
|
51 | - * |
|
52 | - * @return Boolean of the database connection |
|
53 | - * |
|
54 | - */ |
|
50 | + * Creates the database connection |
|
51 | + * |
|
52 | + * @return Boolean of the database connection |
|
53 | + * |
|
54 | + */ |
|
55 | 55 | |
56 | 56 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
57 | 57 | { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | if($results->rowCount()>0) { |
151 | - return true; |
|
151 | + return true; |
|
152 | 152 | } |
153 | 153 | else return false; |
154 | 154 | } |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | $sum = $sum->fetchColumn(0); |
166 | 166 | } else $sum = 0; |
167 | 167 | if (intval($sum) !== 2) { |
168 | - return false; |
|
168 | + return false; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | } catch(PDOException $e) { |
172 | 172 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
173 | - throw $e; |
|
174 | - } |
|
175 | - //echo 'error ! '.$e->getMessage(); |
|
173 | + throw $e; |
|
174 | + } |
|
175 | + //echo 'error ! '.$e->getMessage(); |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | return true; |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | $version = 0; |
271 | 271 | if ($this->tableExists('aircraft')) { |
272 | 272 | if (!$this->tableExists('config')) { |
273 | - $version = '1'; |
|
274 | - return $version; |
|
273 | + $version = '1'; |
|
274 | + return $version; |
|
275 | 275 | } else { |
276 | 276 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
277 | 277 | try { |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | * @return Boolean if latest version or not |
293 | 293 | */ |
294 | 294 | public function latest() { |
295 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
296 | - else return false; |
|
295 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
296 | + else return false; |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | } |
@@ -1,19 +1,19 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | |
4 | -class Connection{ |
|
4 | +class Connection { |
|
5 | 5 | public $db = null; |
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 34; |
8 | 8 | |
9 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
9 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
10 | 10 | global $globalDBdriver; |
11 | 11 | if ($dbc === null) { |
12 | 12 | if ($this->db === null && $dbname === null) { |
13 | 13 | if ($user === null && $pass === null) { |
14 | 14 | $this->createDBConnection(); |
15 | 15 | } else { |
16 | - $this->createDBConnection(null,$user,$pass); |
|
16 | + $this->createDBConnection(null, $user, $pass); |
|
17 | 17 | } |
18 | 18 | } else { |
19 | 19 | $this->createDBConnection($dbname); |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | while (true) { |
92 | 92 | try { |
93 | 93 | if ($globalDBSdriver == 'mysql') { |
94 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
94 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
95 | 95 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
96 | 96 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
97 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
98 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
99 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
100 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
101 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
97 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
98 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
99 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
100 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
101 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
102 | 102 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
103 | 103 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
104 | 104 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
109 | 109 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
110 | 110 | } else { |
111 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
111 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
112 | 112 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
113 | 113 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
114 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
115 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
116 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
117 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
118 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
114 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
115 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
116 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
117 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
118 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
119 | 119 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
120 | 120 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
121 | 121 | } |
122 | 122 | break; |
123 | - } catch(PDOException $e) { |
|
123 | + } catch (PDOException $e) { |
|
124 | 124 | $i++; |
125 | 125 | if (isset($globalDebug) && $globalDebug) echo $e->getMessage()."\n"; |
126 | 126 | //exit; |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | try { |
145 | 145 | //$Connection = new Connection(); |
146 | 146 | $results = $this->db->query($query); |
147 | - } catch(PDOException $e) { |
|
147 | + } catch (PDOException $e) { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | - if($results->rowCount()>0) { |
|
150 | + if ($results->rowCount() > 0) { |
|
151 | 151 | return true; |
152 | 152 | } |
153 | 153 | else return false; |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | return false; |
169 | 169 | } |
170 | 170 | |
171 | - } catch(PDOException $e) { |
|
172 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
171 | + } catch (PDOException $e) { |
|
172 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
173 | 173 | throw $e; |
174 | 174 | } |
175 | 175 | //echo 'error ! '.$e->getMessage(); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | /* |
182 | 182 | * Check if index exist |
183 | 183 | */ |
184 | - public function indexExists($table,$index) |
|
184 | + public function indexExists($table, $index) |
|
185 | 185 | { |
186 | 186 | global $globalDBdriver, $globalDBname; |
187 | 187 | if ($globalDBdriver == 'mysql') { |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | try { |
193 | 193 | //$Connection = new Connection(); |
194 | 194 | $results = $this->db->query($query); |
195 | - } catch(PDOException $e) { |
|
195 | + } catch (PDOException $e) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
199 | - if($nb[0]['nb'] > 0) { |
|
199 | + if ($nb[0]['nb'] > 0) { |
|
200 | 200 | return true; |
201 | 201 | } |
202 | 202 | else return false; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
212 | 212 | try { |
213 | 213 | $results = $this->db->query($query); |
214 | - } catch(PDOException $e) { |
|
214 | + } catch (PDOException $e) { |
|
215 | 215 | return "error : ".$e->getMessage()."\n"; |
216 | 216 | } |
217 | 217 | $columns = array(); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * Check if a column name exist in a table |
228 | 228 | * @return Boolean column exist or not |
229 | 229 | */ |
230 | - public function checkColumnName($table,$name) |
|
230 | + public function checkColumnName($table, $name) |
|
231 | 231 | { |
232 | 232 | global $globalDBdriver, $globalDBname; |
233 | 233 | if ($globalDBdriver == 'mysql') { |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | } |
238 | 238 | try { |
239 | 239 | $sth = $this->db()->prepare($query); |
240 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
241 | - } catch(PDOException $e) { |
|
240 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
241 | + } catch (PDOException $e) { |
|
242 | 242 | echo "error : ".$e->getMessage()."\n"; |
243 | 243 | } |
244 | 244 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | try { |
278 | 278 | $sth = $this->db->prepare($query); |
279 | 279 | $sth->execute(); |
280 | - } catch(PDOException $e) { |
|
280 | + } catch (PDOException $e) { |
|
281 | 281 | return "error : ".$e->getMessage()."\n"; |
282 | 282 | } |
283 | 283 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -64,8 +64,11 @@ discard block |
||
64 | 64 | $globalDBSname = $globalDBname; |
65 | 65 | $globalDBSuser = $globalDBuser; |
66 | 66 | $globalDBSpass = $globalDBpass; |
67 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
68 | - else $globalDBSport = $globalDBport; |
|
67 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
68 | + $globalDBSport = 3306; |
|
69 | + } else { |
|
70 | + $globalDBSport = $globalDBport; |
|
71 | + } |
|
69 | 72 | } else { |
70 | 73 | $DBname = 'default'; |
71 | 74 | $globalDBSdriver = $globalDBdriver; |
@@ -73,8 +76,11 @@ discard block |
||
73 | 76 | $globalDBSname = $globalDBname; |
74 | 77 | $globalDBSuser = $user; |
75 | 78 | $globalDBSpass = $pass; |
76 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
77 | - else $globalDBSport = $globalDBport; |
|
79 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
80 | + $globalDBSport = 3306; |
|
81 | + } else { |
|
82 | + $globalDBSport = $globalDBport; |
|
83 | + } |
|
78 | 84 | } |
79 | 85 | } else { |
80 | 86 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
@@ -82,11 +88,16 @@ discard block |
||
82 | 88 | $globalDBSname = $globalDB[$DBname]['name']; |
83 | 89 | $globalDBSuser = $globalDB[$DBname]['user']; |
84 | 90 | $globalDBSpass = $globalDB[$DBname]['pass']; |
85 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
86 | - else $globalDBSport = 3306; |
|
91 | + if (isset($globalDB[$DBname]['port'])) { |
|
92 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
93 | + } else { |
|
94 | + $globalDBSport = 3306; |
|
95 | + } |
|
87 | 96 | } |
88 | 97 | // Set number of try to connect to DB |
89 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
98 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
99 | + $globalDBretry = 5; |
|
100 | + } |
|
90 | 101 | $i = 0; |
91 | 102 | while (true) { |
92 | 103 | try { |
@@ -95,10 +106,16 @@ discard block |
||
95 | 106 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
96 | 107 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
97 | 108 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
98 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
99 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
100 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
101 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
109 | + if (!isset($globalDBTimeOut)) { |
|
110 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
111 | + } else { |
|
112 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
113 | + } |
|
114 | + if (!isset($globalDBPersistent)) { |
|
115 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
116 | + } else { |
|
117 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
118 | + } |
|
102 | 119 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
103 | 120 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
104 | 121 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -112,23 +129,35 @@ discard block |
||
112 | 129 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
113 | 130 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
114 | 131 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
115 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
116 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
117 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
118 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
132 | + if (!isset($globalDBTimeOut)) { |
|
133 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
134 | + } else { |
|
135 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
136 | + } |
|
137 | + if (!isset($globalDBPersistent)) { |
|
138 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
139 | + } else { |
|
140 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
141 | + } |
|
119 | 142 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
120 | 143 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
121 | 144 | } |
122 | 145 | break; |
123 | 146 | } catch(PDOException $e) { |
124 | 147 | $i++; |
125 | - if (isset($globalDebug) && $globalDebug) echo $e->getMessage()."\n"; |
|
148 | + if (isset($globalDebug) && $globalDebug) { |
|
149 | + echo $e->getMessage()."\n"; |
|
150 | + } |
|
126 | 151 | //exit; |
127 | - if ($i > $globalDBretry) return false; |
|
152 | + if ($i > $globalDBretry) { |
|
153 | + return false; |
|
154 | + } |
|
128 | 155 | //return false; |
129 | 156 | } |
130 | 157 | } |
131 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
158 | + if ($DBname === 'default') { |
|
159 | + $this->db = $this->dbs['default']; |
|
160 | + } |
|
132 | 161 | return true; |
133 | 162 | } |
134 | 163 | |
@@ -140,7 +169,9 @@ discard block |
||
140 | 169 | } else { |
141 | 170 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
142 | 171 | } |
143 | - if ($this->db == NULL) return false; |
|
172 | + if ($this->db == NULL) { |
|
173 | + return false; |
|
174 | + } |
|
144 | 175 | try { |
145 | 176 | //$Connection = new Connection(); |
146 | 177 | $results = $this->db->query($query); |
@@ -149,21 +180,28 @@ discard block |
||
149 | 180 | } |
150 | 181 | if($results->rowCount()>0) { |
151 | 182 | return true; |
183 | + } else { |
|
184 | + return false; |
|
152 | 185 | } |
153 | - else return false; |
|
154 | 186 | } |
155 | 187 | |
156 | 188 | public function connectionExists() |
157 | 189 | { |
158 | 190 | global $globalDBdriver, $globalDBCheckConnection; |
159 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
191 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
192 | + return true; |
|
193 | + } |
|
160 | 194 | $query = "SELECT 1 + 1"; |
161 | - if ($this->db === null) return false; |
|
195 | + if ($this->db === null) { |
|
196 | + return false; |
|
197 | + } |
|
162 | 198 | try { |
163 | 199 | $sum = @$this->db->query($query); |
164 | 200 | if ($sum instanceof \PDOStatement) { |
165 | 201 | $sum = $sum->fetchColumn(0); |
166 | - } else $sum = 0; |
|
202 | + } else { |
|
203 | + $sum = 0; |
|
204 | + } |
|
167 | 205 | if (intval($sum) !== 2) { |
168 | 206 | return false; |
169 | 207 | } |
@@ -198,8 +236,9 @@ discard block |
||
198 | 236 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
199 | 237 | if($nb[0]['nb'] > 0) { |
200 | 238 | return true; |
239 | + } else { |
|
240 | + return false; |
|
201 | 241 | } |
202 | - else return false; |
|
203 | 242 | } |
204 | 243 | |
205 | 244 | /* |
@@ -243,9 +282,12 @@ discard block |
||
243 | 282 | } |
244 | 283 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
245 | 284 | $sth->closeCursor(); |
246 | - if ($result['nb'] > 0) return true; |
|
247 | - else return false; |
|
248 | -/* } else { |
|
285 | + if ($result['nb'] > 0) { |
|
286 | + return true; |
|
287 | + } else { |
|
288 | + return false; |
|
289 | + } |
|
290 | + /* } else { |
|
249 | 291 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
250 | 292 | try { |
251 | 293 | $results = $this->db->query($query); |
@@ -284,7 +326,9 @@ discard block |
||
284 | 326 | $sth->closeCursor(); |
285 | 327 | return $result['value']; |
286 | 328 | } |
287 | - } else return $version; |
|
329 | + } else { |
|
330 | + return $version; |
|
331 | + } |
|
288 | 332 | } |
289 | 333 | |
290 | 334 | /* |
@@ -292,8 +336,11 @@ discard block |
||
292 | 336 | * @return Boolean if latest version or not |
293 | 337 | */ |
294 | 338 | public function latest() { |
295 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
296 | - else return false; |
|
339 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
340 | + return true; |
|
341 | + } else { |
|
342 | + return false; |
|
343 | + } |
|
297 | 344 | } |
298 | 345 | |
299 | 346 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | /** |
15 | 15 | * Get SQL query part for filter used |
16 | 16 | * @param Array $filter the filter |
17 | - * @return Array the SQL part |
|
17 | + * @return string the SQL part |
|
18 | 18 | */ |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
21 | 21 | $filters = array(); |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Gets all the spotter information based on the latest data entry |
|
90 | - * |
|
91 | - * @return Array the spotter information |
|
92 | - * |
|
93 | - */ |
|
89 | + * Gets all the spotter information based on the latest data entry |
|
90 | + * |
|
91 | + * @return Array the spotter information |
|
92 | + * |
|
93 | + */ |
|
94 | 94 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
95 | 95 | { |
96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Gets Minimal Live Spotter data |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
135 | + * Gets Minimal Live Spotter data |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | 140 | public function getMinLiveSpotterData($filter = array()) |
141 | 141 | { |
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -189,11 +189,11 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | - * Gets Minimal Live Spotter data since xx seconds |
|
193 | - * |
|
194 | - * @return Array the spotter information |
|
195 | - * |
|
196 | - */ |
|
192 | + * Gets Minimal Live Spotter data since xx seconds |
|
193 | + * |
|
194 | + * @return Array the spotter information |
|
195 | + * |
|
196 | + */ |
|
197 | 197 | public function getMinLastLiveSpotterData($filter = array()) |
198 | 198 | { |
199 | 199 | global $globalDBdriver, $globalLiveInterval; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
212 | 212 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
213 | 213 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
214 | - } else { |
|
214 | + } else { |
|
215 | 215 | /* |
216 | 216 | $query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
217 | 217 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | // echo $query; |
224 | 224 | } |
225 | 225 | |
226 | - try { |
|
226 | + try { |
|
227 | 227 | $sth = $this->db->prepare($query); |
228 | 228 | $sth->execute(); |
229 | 229 | } catch(PDOException $e) { |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
238 | - * Gets number of latest data entry |
|
239 | - * |
|
240 | - * @return String number of entry |
|
241 | - * |
|
242 | - */ |
|
238 | + * Gets number of latest data entry |
|
239 | + * |
|
240 | + * @return String number of entry |
|
241 | + * |
|
242 | + */ |
|
243 | 243 | public function getLiveSpotterCount($filter = array()) |
244 | 244 | { |
245 | 245 | global $globalDBdriver, $globalLiveInterval; |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | - * Gets all the spotter information based on the latest data entry and coord |
|
270 | - * |
|
271 | - * @return Array the spotter information |
|
272 | - * |
|
273 | - */ |
|
269 | + * Gets all the spotter information based on the latest data entry and coord |
|
270 | + * |
|
271 | + * @return Array the spotter information |
|
272 | + * |
|
273 | + */ |
|
274 | 274 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
275 | 275 | { |
276 | 276 | global $globalDBdriver, $globalLiveInterval; |
@@ -295,11 +295,11 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
298 | - * Gets all the spotter information based on a user's latitude and longitude |
|
299 | - * |
|
300 | - * @return Array the spotter information |
|
301 | - * |
|
302 | - */ |
|
298 | + * Gets all the spotter information based on a user's latitude and longitude |
|
299 | + * |
|
300 | + * @return Array the spotter information |
|
301 | + * |
|
302 | + */ |
|
303 | 303 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
304 | 304 | { |
305 | 305 | $Spotter = new Spotter($this->db); |
@@ -309,145 +309,145 @@ discard block |
||
309 | 309 | return false; |
310 | 310 | } |
311 | 311 | } |
312 | - if ($lng != '') |
|
313 | - { |
|
314 | - if (!is_numeric($lng)) |
|
315 | - { |
|
316 | - return false; |
|
317 | - } |
|
318 | - } |
|
319 | - |
|
320 | - if ($radius != '') |
|
321 | - { |
|
322 | - if (!is_numeric($radius)) |
|
323 | - { |
|
324 | - return false; |
|
325 | - } |
|
326 | - } |
|
312 | + if ($lng != '') |
|
313 | + { |
|
314 | + if (!is_numeric($lng)) |
|
315 | + { |
|
316 | + return false; |
|
317 | + } |
|
318 | + } |
|
319 | + |
|
320 | + if ($radius != '') |
|
321 | + { |
|
322 | + if (!is_numeric($radius)) |
|
323 | + { |
|
324 | + return false; |
|
325 | + } |
|
326 | + } |
|
327 | 327 | $additional_query = ''; |
328 | - if ($interval != '') |
|
329 | - { |
|
330 | - if (!is_string($interval)) |
|
331 | - { |
|
332 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
333 | - return false; |
|
334 | - } else { |
|
335 | - if ($interval == '1m') |
|
336 | - { |
|
337 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
338 | - } else if ($interval == '15m'){ |
|
339 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
340 | - } |
|
341 | - } |
|
342 | - } else { |
|
343 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
344 | - } |
|
345 | - |
|
346 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
328 | + if ($interval != '') |
|
329 | + { |
|
330 | + if (!is_string($interval)) |
|
331 | + { |
|
332 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
333 | + return false; |
|
334 | + } else { |
|
335 | + if ($interval == '1m') |
|
336 | + { |
|
337 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
338 | + } else if ($interval == '15m'){ |
|
339 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
340 | + } |
|
341 | + } |
|
342 | + } else { |
|
343 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
344 | + } |
|
345 | + |
|
346 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
347 | 347 | WHERE spotter_live.latitude <> '' |
348 | 348 | AND spotter_live.longitude <> '' |
349 | 349 | ".$additional_query." |
350 | 350 | HAVING distance < :radius |
351 | 351 | ORDER BY distance"; |
352 | 352 | |
353 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
353 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
354 | 354 | |
355 | - return $spotter_array; |
|
356 | - } |
|
355 | + return $spotter_array; |
|
356 | + } |
|
357 | 357 | |
358 | 358 | |
359 | - /** |
|
360 | - * Gets all the spotter information based on a particular callsign |
|
361 | - * |
|
362 | - * @return Array the spotter information |
|
363 | - * |
|
364 | - */ |
|
359 | + /** |
|
360 | + * Gets all the spotter information based on a particular callsign |
|
361 | + * |
|
362 | + * @return Array the spotter information |
|
363 | + * |
|
364 | + */ |
|
365 | 365 | public function getLastLiveSpotterDataByIdent($ident) |
366 | 366 | { |
367 | 367 | $Spotter = new Spotter($this->db); |
368 | 368 | date_default_timezone_set('UTC'); |
369 | 369 | |
370 | 370 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
371 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
371 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
372 | 372 | |
373 | 373 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
374 | 374 | |
375 | 375 | return $spotter_array; |
376 | 376 | } |
377 | 377 | |
378 | - /** |
|
379 | - * Gets all the spotter information based on a particular callsign |
|
380 | - * |
|
381 | - * @return Array the spotter information |
|
382 | - * |
|
383 | - */ |
|
378 | + /** |
|
379 | + * Gets all the spotter information based on a particular callsign |
|
380 | + * |
|
381 | + * @return Array the spotter information |
|
382 | + * |
|
383 | + */ |
|
384 | 384 | public function getDateLiveSpotterDataByIdent($ident,$date) |
385 | 385 | { |
386 | 386 | $Spotter = new Spotter($this->db); |
387 | 387 | date_default_timezone_set('UTC'); |
388 | 388 | |
389 | 389 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
390 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
390 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
391 | 391 | |
392 | - $date = date('c',$date); |
|
392 | + $date = date('c',$date); |
|
393 | 393 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
394 | 394 | |
395 | 395 | return $spotter_array; |
396 | 396 | } |
397 | 397 | |
398 | - /** |
|
399 | - * Gets last spotter information based on a particular callsign |
|
400 | - * |
|
401 | - * @return Array the spotter information |
|
402 | - * |
|
403 | - */ |
|
398 | + /** |
|
399 | + * Gets last spotter information based on a particular callsign |
|
400 | + * |
|
401 | + * @return Array the spotter information |
|
402 | + * |
|
403 | + */ |
|
404 | 404 | public function getLastLiveSpotterDataById($id) |
405 | 405 | { |
406 | 406 | $Spotter = new Spotter($this->db); |
407 | 407 | date_default_timezone_set('UTC'); |
408 | 408 | |
409 | 409 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
410 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
410 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
411 | 411 | |
412 | 412 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
413 | 413 | |
414 | 414 | return $spotter_array; |
415 | 415 | } |
416 | 416 | |
417 | - /** |
|
418 | - * Gets last spotter information based on a particular callsign |
|
419 | - * |
|
420 | - * @return Array the spotter information |
|
421 | - * |
|
422 | - */ |
|
417 | + /** |
|
418 | + * Gets last spotter information based on a particular callsign |
|
419 | + * |
|
420 | + * @return Array the spotter information |
|
421 | + * |
|
422 | + */ |
|
423 | 423 | public function getDateLiveSpotterDataById($id,$date) |
424 | 424 | { |
425 | 425 | $Spotter = new Spotter($this->db); |
426 | 426 | date_default_timezone_set('UTC'); |
427 | 427 | |
428 | 428 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
429 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
430 | - $date = date('c',$date); |
|
429 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
430 | + $date = date('c',$date); |
|
431 | 431 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
432 | 432 | |
433 | 433 | return $spotter_array; |
434 | 434 | } |
435 | 435 | |
436 | - /** |
|
437 | - * Gets altitude information based on a particular callsign |
|
438 | - * |
|
439 | - * @return Array the spotter information |
|
440 | - * |
|
441 | - */ |
|
436 | + /** |
|
437 | + * Gets altitude information based on a particular callsign |
|
438 | + * |
|
439 | + * @return Array the spotter information |
|
440 | + * |
|
441 | + */ |
|
442 | 442 | public function getAltitudeLiveSpotterDataByIdent($ident) |
443 | 443 | { |
444 | 444 | |
445 | 445 | date_default_timezone_set('UTC'); |
446 | 446 | |
447 | 447 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
448 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
448 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
449 | 449 | |
450 | - try { |
|
450 | + try { |
|
451 | 451 | |
452 | 452 | $sth = $this->db->prepare($query); |
453 | 453 | $sth->execute(array(':ident' => $ident)); |
@@ -460,12 +460,12 @@ discard block |
||
460 | 460 | return $spotter_array; |
461 | 461 | } |
462 | 462 | |
463 | - /** |
|
464 | - * Gets all the spotter information based on a particular id |
|
465 | - * |
|
466 | - * @return Array the spotter information |
|
467 | - * |
|
468 | - */ |
|
463 | + /** |
|
464 | + * Gets all the spotter information based on a particular id |
|
465 | + * |
|
466 | + * @return Array the spotter information |
|
467 | + * |
|
468 | + */ |
|
469 | 469 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
470 | 470 | { |
471 | 471 | global $globalDBdriver, $globalLiveInterval; |
@@ -493,18 +493,18 @@ discard block |
||
493 | 493 | return $spotter_array; |
494 | 494 | } |
495 | 495 | |
496 | - /** |
|
497 | - * Gets all the spotter information based on a particular ident |
|
498 | - * |
|
499 | - * @return Array the spotter information |
|
500 | - * |
|
501 | - */ |
|
496 | + /** |
|
497 | + * Gets all the spotter information based on a particular ident |
|
498 | + * |
|
499 | + * @return Array the spotter information |
|
500 | + * |
|
501 | + */ |
|
502 | 502 | public function getAllLiveSpotterDataByIdent($ident) |
503 | 503 | { |
504 | 504 | date_default_timezone_set('UTC'); |
505 | 505 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
506 | 506 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
507 | - try { |
|
507 | + try { |
|
508 | 508 | |
509 | 509 | $sth = $this->db->prepare($query); |
510 | 510 | $sth->execute(array(':ident' => $ident)); |
@@ -518,23 +518,23 @@ discard block |
||
518 | 518 | |
519 | 519 | |
520 | 520 | /** |
521 | - * Deletes all info in the table |
|
522 | - * |
|
523 | - * @return String success or false |
|
524 | - * |
|
525 | - */ |
|
521 | + * Deletes all info in the table |
|
522 | + * |
|
523 | + * @return String success or false |
|
524 | + * |
|
525 | + */ |
|
526 | 526 | public function deleteLiveSpotterData() |
527 | 527 | { |
528 | 528 | global $globalDBdriver; |
529 | 529 | if ($globalDBdriver == 'mysql') { |
530 | 530 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
531 | 531 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
532 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
532 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
533 | 533 | } else { |
534 | 534 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
535 | 535 | } |
536 | 536 | |
537 | - try { |
|
537 | + try { |
|
538 | 538 | |
539 | 539 | $sth = $this->db->prepare($query); |
540 | 540 | $sth->execute(); |
@@ -546,18 +546,18 @@ discard block |
||
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
549 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
550 | - * |
|
551 | - * @return String success or false |
|
552 | - * |
|
553 | - */ |
|
549 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
550 | + * |
|
551 | + * @return String success or false |
|
552 | + * |
|
553 | + */ |
|
554 | 554 | public function deleteLiveSpotterDataNotUpdated() |
555 | 555 | { |
556 | 556 | global $globalDBdriver, $globalDebug; |
557 | 557 | if ($globalDBdriver == 'mysql') { |
558 | 558 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
559 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
560 | - try { |
|
559 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
560 | + try { |
|
561 | 561 | |
562 | 562 | $sth = $this->db->prepare($query); |
563 | 563 | $sth->execute(); |
@@ -565,8 +565,8 @@ discard block |
||
565 | 565 | return "error"; |
566 | 566 | } |
567 | 567 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
568 | - $i = 0; |
|
569 | - $j =0; |
|
568 | + $i = 0; |
|
569 | + $j =0; |
|
570 | 570 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
571 | 571 | foreach($all as $row) |
572 | 572 | { |
@@ -574,20 +574,20 @@ discard block |
||
574 | 574 | $j++; |
575 | 575 | if ($j == 30) { |
576 | 576 | if ($globalDebug) echo "."; |
577 | - try { |
|
577 | + try { |
|
578 | 578 | |
579 | 579 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
580 | 580 | $sth->execute(); |
581 | 581 | } catch(PDOException $e) { |
582 | 582 | return "error"; |
583 | 583 | } |
584 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
585 | - $j = 0; |
|
584 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
585 | + $j = 0; |
|
586 | 586 | } |
587 | 587 | $query_delete .= "'".$row['flightaware_id']."',"; |
588 | 588 | } |
589 | 589 | if ($i > 0) { |
590 | - try { |
|
590 | + try { |
|
591 | 591 | |
592 | 592 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
593 | 593 | $sth->execute(); |
@@ -598,9 +598,9 @@ discard block |
||
598 | 598 | return "success"; |
599 | 599 | } elseif ($globalDBdriver == 'pgsql') { |
600 | 600 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
601 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
602 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
603 | - try { |
|
601 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
602 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
603 | + try { |
|
604 | 604 | |
605 | 605 | $sth = $this->db->prepare($query); |
606 | 606 | $sth->execute(); |
@@ -644,17 +644,17 @@ discard block |
||
644 | 644 | } |
645 | 645 | |
646 | 646 | /** |
647 | - * Deletes all info in the table for an ident |
|
648 | - * |
|
649 | - * @return String success or false |
|
650 | - * |
|
651 | - */ |
|
647 | + * Deletes all info in the table for an ident |
|
648 | + * |
|
649 | + * @return String success or false |
|
650 | + * |
|
651 | + */ |
|
652 | 652 | public function deleteLiveSpotterDataByIdent($ident) |
653 | 653 | { |
654 | 654 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
655 | 655 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
656 | 656 | |
657 | - try { |
|
657 | + try { |
|
658 | 658 | |
659 | 659 | $sth = $this->db->prepare($query); |
660 | 660 | $sth->execute(array(':ident' => $ident)); |
@@ -666,17 +666,17 @@ discard block |
||
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
669 | - * Deletes all info in the table for an id |
|
670 | - * |
|
671 | - * @return String success or false |
|
672 | - * |
|
673 | - */ |
|
669 | + * Deletes all info in the table for an id |
|
670 | + * |
|
671 | + * @return String success or false |
|
672 | + * |
|
673 | + */ |
|
674 | 674 | public function deleteLiveSpotterDataById($id) |
675 | 675 | { |
676 | 676 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
677 | 677 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
678 | 678 | |
679 | - try { |
|
679 | + try { |
|
680 | 680 | |
681 | 681 | $sth = $this->db->prepare($query); |
682 | 682 | $sth->execute(array(':id' => $id)); |
@@ -689,11 +689,11 @@ discard block |
||
689 | 689 | |
690 | 690 | |
691 | 691 | /** |
692 | - * Gets the aircraft ident within the last hour |
|
693 | - * |
|
694 | - * @return String the ident |
|
695 | - * |
|
696 | - */ |
|
692 | + * Gets the aircraft ident within the last hour |
|
693 | + * |
|
694 | + * @return String the ident |
|
695 | + * |
|
696 | + */ |
|
697 | 697 | public function getIdentFromLastHour($ident) |
698 | 698 | { |
699 | 699 | global $globalDBdriver, $globalTimezone; |
@@ -719,14 +719,14 @@ discard block |
||
719 | 719 | $ident_result = $row['ident']; |
720 | 720 | } |
721 | 721 | return $ident_result; |
722 | - } |
|
722 | + } |
|
723 | 723 | |
724 | 724 | /** |
725 | - * Check recent aircraft |
|
726 | - * |
|
727 | - * @return String the ident |
|
728 | - * |
|
729 | - */ |
|
725 | + * Check recent aircraft |
|
726 | + * |
|
727 | + * @return String the ident |
|
728 | + * |
|
729 | + */ |
|
730 | 730 | public function checkIdentRecent($ident) |
731 | 731 | { |
732 | 732 | global $globalDBdriver, $globalTimezone; |
@@ -752,14 +752,14 @@ discard block |
||
752 | 752 | $ident_result = $row['flightaware_id']; |
753 | 753 | } |
754 | 754 | return $ident_result; |
755 | - } |
|
755 | + } |
|
756 | 756 | |
757 | 757 | /** |
758 | - * Check recent aircraft by id |
|
759 | - * |
|
760 | - * @return String the ident |
|
761 | - * |
|
762 | - */ |
|
758 | + * Check recent aircraft by id |
|
759 | + * |
|
760 | + * @return String the ident |
|
761 | + * |
|
762 | + */ |
|
763 | 763 | public function checkIdRecent($id) |
764 | 764 | { |
765 | 765 | global $globalDBdriver, $globalTimezone; |
@@ -785,14 +785,14 @@ discard block |
||
785 | 785 | $ident_result = $row['flightaware_id']; |
786 | 786 | } |
787 | 787 | return $ident_result; |
788 | - } |
|
788 | + } |
|
789 | 789 | |
790 | 790 | /** |
791 | - * Check recent aircraft by ModeS |
|
792 | - * |
|
793 | - * @return String the ModeS |
|
794 | - * |
|
795 | - */ |
|
791 | + * Check recent aircraft by ModeS |
|
792 | + * |
|
793 | + * @return String the ModeS |
|
794 | + * |
|
795 | + */ |
|
796 | 796 | public function checkModeSRecent($modes) |
797 | 797 | { |
798 | 798 | global $globalDBdriver, $globalTimezone; |
@@ -819,19 +819,19 @@ discard block |
||
819 | 819 | $ident_result = $row['flightaware_id']; |
820 | 820 | } |
821 | 821 | return $ident_result; |
822 | - } |
|
822 | + } |
|
823 | 823 | |
824 | 824 | /** |
825 | - * Adds a new spotter data |
|
826 | - * |
|
827 | - * @param String $flightaware_id the ID from flightaware |
|
828 | - * @param String $ident the flight ident |
|
829 | - * @param String $aircraft_icao the aircraft type |
|
830 | - * @param String $departure_airport_icao the departure airport |
|
831 | - * @param String $arrival_airport_icao the arrival airport |
|
832 | - * @return String success or false |
|
833 | - * |
|
834 | - */ |
|
825 | + * Adds a new spotter data |
|
826 | + * |
|
827 | + * @param String $flightaware_id the ID from flightaware |
|
828 | + * @param String $ident the flight ident |
|
829 | + * @param String $aircraft_icao the aircraft type |
|
830 | + * @param String $departure_airport_icao the departure airport |
|
831 | + * @param String $arrival_airport_icao the arrival airport |
|
832 | + * @return String success or false |
|
833 | + * |
|
834 | + */ |
|
835 | 835 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
836 | 836 | { |
837 | 837 | global $globalURL, $globalArchive, $globalDebug; |
@@ -966,10 +966,10 @@ discard block |
||
966 | 966 | $arrival_airport_country = ''; |
967 | 967 | |
968 | 968 | |
969 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
970 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
971 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
972 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
969 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
970 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
971 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
972 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
973 | 973 | |
974 | 974 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
975 | 975 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -979,14 +979,14 @@ discard block |
||
979 | 979 | |
980 | 980 | $sth = $this->db->prepare($query); |
981 | 981 | $sth->execute($query_values); |
982 | - } catch(PDOException $e) { |
|
983 | - return "error : ".$e->getMessage(); |
|
984 | - } |
|
982 | + } catch(PDOException $e) { |
|
983 | + return "error : ".$e->getMessage(); |
|
984 | + } |
|
985 | 985 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
986 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
987 | - $SpotterArchive = new SpotterArchive($this->db); |
|
988 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
989 | - if ($globalDebug) echo $result.')'; |
|
986 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
987 | + $SpotterArchive = new SpotterArchive($this->db); |
|
988 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
989 | + if ($globalDebug) echo $result.')'; |
|
990 | 990 | } |
991 | 991 | return "success"; |
992 | 992 |
@@ -16,45 +16,45 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | - foreach($filters as $flt) { |
|
32 | + foreach ($filters as $flt) { |
|
33 | 33 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
34 | 34 | if ($flt['airlines'][0] != '') { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
43 | 43 | if (isset($flt['source'])) { |
44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
45 | 45 | } else { |
46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
50 | 50 | if (isset($flt['source'])) { |
51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | } |
55 | 55 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
56 | 56 | if ($filter['airlines'][0] != '') { |
57 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
57 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -64,19 +64,19 @@ discard block |
||
64 | 64 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
65 | 65 | } |
66 | 66 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
67 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
67 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
68 | 68 | } |
69 | 69 | if (isset($filter['source']) && !empty($filter['source'])) { |
70 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
70 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
71 | 71 | } |
72 | 72 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
73 | 73 | $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
74 | 74 | } |
75 | 75 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
76 | 76 | if ($filter_query_where == '') { |
77 | - $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
77 | + $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
78 | 78 | } else { |
79 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
79 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | if ($limit != '') |
103 | 103 | { |
104 | 104 | $limit_array = explode(',', $limit); |
105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
108 | 108 | { |
109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } else { |
127 | 127 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
128 | 128 | } |
129 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
129 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
130 | 130 | |
131 | 131 | return $spotter_array; |
132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
143 | 143 | date_default_timezone_set('UTC'); |
144 | 144 | |
145 | - $filter_query = $this->getFilter($filter,true,true); |
|
145 | + $filter_query = $this->getFilter($filter, true, true); |
|
146 | 146 | |
147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $query = 'SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
154 | 154 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
155 | 155 | */ |
156 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
156 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
157 | 157 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
158 | 158 | |
159 | 159 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date ORDER BY spotter_live.date GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
169 | 169 | */ |
170 | 170 | |
171 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
171 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
172 | 172 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
173 | 173 | |
174 | 174 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | try { |
180 | 180 | $sth = $this->db->prepare($query); |
181 | 181 | $sth->execute(); |
182 | - } catch(PDOException $e) { |
|
182 | + } catch (PDOException $e) { |
|
183 | 183 | echo $e->getMessage(); |
184 | 184 | die; |
185 | 185 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | global $globalDBdriver, $globalLiveInterval; |
200 | 200 | date_default_timezone_set('UTC'); |
201 | 201 | |
202 | - $filter_query = $this->getFilter($filter,true,true); |
|
202 | + $filter_query = $this->getFilter($filter, true, true); |
|
203 | 203 | |
204 | 204 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
205 | 205 | if ($globalDBdriver == 'mysql') { |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
209 | 209 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
210 | 210 | */ |
211 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
211 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
212 | 212 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
213 | 213 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
214 | 214 | } else { |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
218 | 218 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
219 | 219 | */ |
220 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
220 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
221 | 221 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
222 | 222 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
223 | 223 | // echo $query; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | try { |
227 | 227 | $sth = $this->db->prepare($query); |
228 | 228 | $sth->execute(); |
229 | - } catch(PDOException $e) { |
|
229 | + } catch (PDOException $e) { |
|
230 | 230 | echo $e->getMessage(); |
231 | 231 | die; |
232 | 232 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | public function getLiveSpotterCount($filter = array()) |
244 | 244 | { |
245 | 245 | global $globalDBdriver, $globalLiveInterval; |
246 | - $filter_query = $this->getFilter($filter,true,true); |
|
246 | + $filter_query = $this->getFilter($filter, true, true); |
|
247 | 247 | |
248 | 248 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
249 | 249 | if ($globalDBdriver == 'mysql') { |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | try { |
257 | 257 | $sth = $this->db->prepare($query); |
258 | 258 | $sth->execute(); |
259 | - } catch(PDOException $e) { |
|
259 | + } catch (PDOException $e) { |
|
260 | 260 | echo $e->getMessage(); |
261 | 261 | die; |
262 | 262 | } |
@@ -279,10 +279,10 @@ discard block |
||
279 | 279 | $filter_query = $this->getFilter($filter); |
280 | 280 | |
281 | 281 | if (is_array($coord)) { |
282 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
283 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
284 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
285 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
282 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
283 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
284 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
285 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
286 | 286 | } else return array(); |
287 | 287 | if ($globalDBdriver == 'mysql') { |
288 | 288 | //$query = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | if ($interval == '1m') |
336 | 336 | { |
337 | 337 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
338 | - } else if ($interval == '15m'){ |
|
338 | + } else if ($interval == '15m') { |
|
339 | 339 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
340 | 340 | } |
341 | 341 | } |
@@ -343,14 +343,14 @@ discard block |
||
343 | 343 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
344 | 344 | } |
345 | 345 | |
346 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
346 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
347 | 347 | WHERE spotter_live.latitude <> '' |
348 | 348 | AND spotter_live.longitude <> '' |
349 | 349 | ".$additional_query." |
350 | 350 | HAVING distance < :radius |
351 | 351 | ORDER BY distance"; |
352 | 352 | |
353 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
353 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
354 | 354 | |
355 | 355 | return $spotter_array; |
356 | 356 | } |
@@ -368,9 +368,9 @@ discard block |
||
368 | 368 | date_default_timezone_set('UTC'); |
369 | 369 | |
370 | 370 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
371 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
371 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
372 | 372 | |
373 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
373 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
374 | 374 | |
375 | 375 | return $spotter_array; |
376 | 376 | } |
@@ -381,16 +381,16 @@ discard block |
||
381 | 381 | * @return Array the spotter information |
382 | 382 | * |
383 | 383 | */ |
384 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
384 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
385 | 385 | { |
386 | 386 | $Spotter = new Spotter($this->db); |
387 | 387 | date_default_timezone_set('UTC'); |
388 | 388 | |
389 | 389 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
390 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
390 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
391 | 391 | |
392 | - $date = date('c',$date); |
|
393 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
392 | + $date = date('c', $date); |
|
393 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
394 | 394 | |
395 | 395 | return $spotter_array; |
396 | 396 | } |
@@ -407,9 +407,9 @@ discard block |
||
407 | 407 | date_default_timezone_set('UTC'); |
408 | 408 | |
409 | 409 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
410 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
410 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
411 | 411 | |
412 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
412 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
413 | 413 | |
414 | 414 | return $spotter_array; |
415 | 415 | } |
@@ -420,15 +420,15 @@ discard block |
||
420 | 420 | * @return Array the spotter information |
421 | 421 | * |
422 | 422 | */ |
423 | - public function getDateLiveSpotterDataById($id,$date) |
|
423 | + public function getDateLiveSpotterDataById($id, $date) |
|
424 | 424 | { |
425 | 425 | $Spotter = new Spotter($this->db); |
426 | 426 | date_default_timezone_set('UTC'); |
427 | 427 | |
428 | 428 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
429 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
430 | - $date = date('c',$date); |
|
431 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
429 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
430 | + $date = date('c', $date); |
|
431 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
432 | 432 | |
433 | 433 | return $spotter_array; |
434 | 434 | } |
@@ -445,13 +445,13 @@ discard block |
||
445 | 445 | date_default_timezone_set('UTC'); |
446 | 446 | |
447 | 447 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
448 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
448 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
449 | 449 | |
450 | 450 | try { |
451 | 451 | |
452 | 452 | $sth = $this->db->prepare($query); |
453 | 453 | $sth->execute(array(':ident' => $ident)); |
454 | - } catch(PDOException $e) { |
|
454 | + } catch (PDOException $e) { |
|
455 | 455 | echo $e->getMessage(); |
456 | 456 | die; |
457 | 457 | } |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | * @return Array the spotter information |
467 | 467 | * |
468 | 468 | */ |
469 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
469 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
470 | 470 | { |
471 | 471 | global $globalDBdriver, $globalLiveInterval; |
472 | 472 | date_default_timezone_set('UTC'); |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | try { |
486 | 486 | $sth = $this->db->prepare($query); |
487 | 487 | $sth->execute(array(':id' => $id)); |
488 | - } catch(PDOException $e) { |
|
488 | + } catch (PDOException $e) { |
|
489 | 489 | echo $e->getMessage(); |
490 | 490 | die; |
491 | 491 | } |
@@ -503,12 +503,12 @@ discard block |
||
503 | 503 | { |
504 | 504 | date_default_timezone_set('UTC'); |
505 | 505 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
506 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
506 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
507 | 507 | try { |
508 | 508 | |
509 | 509 | $sth = $this->db->prepare($query); |
510 | 510 | $sth->execute(array(':ident' => $ident)); |
511 | - } catch(PDOException $e) { |
|
511 | + } catch (PDOException $e) { |
|
512 | 512 | echo $e->getMessage(); |
513 | 513 | die; |
514 | 514 | } |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | |
539 | 539 | $sth = $this->db->prepare($query); |
540 | 540 | $sth->execute(); |
541 | - } catch(PDOException $e) { |
|
541 | + } catch (PDOException $e) { |
|
542 | 542 | return "error"; |
543 | 543 | } |
544 | 544 | |
@@ -561,14 +561,14 @@ discard block |
||
561 | 561 | |
562 | 562 | $sth = $this->db->prepare($query); |
563 | 563 | $sth->execute(); |
564 | - } catch(PDOException $e) { |
|
564 | + } catch (PDOException $e) { |
|
565 | 565 | return "error"; |
566 | 566 | } |
567 | 567 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
568 | 568 | $i = 0; |
569 | - $j =0; |
|
569 | + $j = 0; |
|
570 | 570 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
571 | - foreach($all as $row) |
|
571 | + foreach ($all as $row) |
|
572 | 572 | { |
573 | 573 | $i++; |
574 | 574 | $j++; |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | if ($globalDebug) echo "."; |
577 | 577 | try { |
578 | 578 | |
579 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
579 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
580 | 580 | $sth->execute(); |
581 | - } catch(PDOException $e) { |
|
581 | + } catch (PDOException $e) { |
|
582 | 582 | return "error"; |
583 | 583 | } |
584 | 584 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -589,9 +589,9 @@ discard block |
||
589 | 589 | if ($i > 0) { |
590 | 590 | try { |
591 | 591 | |
592 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
592 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
593 | 593 | $sth->execute(); |
594 | - } catch(PDOException $e) { |
|
594 | + } catch (PDOException $e) { |
|
595 | 595 | return "error"; |
596 | 596 | } |
597 | 597 | } |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | |
605 | 605 | $sth = $this->db->prepare($query); |
606 | 606 | $sth->execute(); |
607 | - } catch(PDOException $e) { |
|
607 | + } catch (PDOException $e) { |
|
608 | 608 | return "error"; |
609 | 609 | } |
610 | 610 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -652,13 +652,13 @@ discard block |
||
652 | 652 | public function deleteLiveSpotterDataByIdent($ident) |
653 | 653 | { |
654 | 654 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
655 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
655 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
656 | 656 | |
657 | 657 | try { |
658 | 658 | |
659 | 659 | $sth = $this->db->prepare($query); |
660 | 660 | $sth->execute(array(':ident' => $ident)); |
661 | - } catch(PDOException $e) { |
|
661 | + } catch (PDOException $e) { |
|
662 | 662 | return "error"; |
663 | 663 | } |
664 | 664 | |
@@ -674,13 +674,13 @@ discard block |
||
674 | 674 | public function deleteLiveSpotterDataById($id) |
675 | 675 | { |
676 | 676 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
677 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
677 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
678 | 678 | |
679 | 679 | try { |
680 | 680 | |
681 | 681 | $sth = $this->db->prepare($query); |
682 | 682 | $sth->execute(array(':id' => $id)); |
683 | - } catch(PDOException $e) { |
|
683 | + } catch (PDOException $e) { |
|
684 | 684 | return "error"; |
685 | 685 | } |
686 | 686 | |
@@ -698,13 +698,13 @@ discard block |
||
698 | 698 | { |
699 | 699 | global $globalDBdriver, $globalTimezone; |
700 | 700 | if ($globalDBdriver == 'mysql') { |
701 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
701 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
702 | 702 | WHERE spotter_live.ident = :ident |
703 | 703 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
704 | 704 | AND spotter_live.date < UTC_TIMESTAMP()'; |
705 | 705 | $query_data = array(':ident' => $ident); |
706 | 706 | } else { |
707 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
707 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
708 | 708 | WHERE spotter_live.ident = :ident |
709 | 709 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
710 | 710 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -713,8 +713,8 @@ discard block |
||
713 | 713 | |
714 | 714 | $sth = $this->db->prepare($query); |
715 | 715 | $sth->execute($query_data); |
716 | - $ident_result=''; |
|
717 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
716 | + $ident_result = ''; |
|
717 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
718 | 718 | { |
719 | 719 | $ident_result = $row['ident']; |
720 | 720 | } |
@@ -731,13 +731,13 @@ discard block |
||
731 | 731 | { |
732 | 732 | global $globalDBdriver, $globalTimezone; |
733 | 733 | if ($globalDBdriver == 'mysql') { |
734 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
734 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
735 | 735 | WHERE spotter_live.ident = :ident |
736 | 736 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
737 | 737 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
738 | 738 | $query_data = array(':ident' => $ident); |
739 | 739 | } else { |
740 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
740 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
741 | 741 | WHERE spotter_live.ident = :ident |
742 | 742 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
743 | 743 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -746,8 +746,8 @@ discard block |
||
746 | 746 | |
747 | 747 | $sth = $this->db->prepare($query); |
748 | 748 | $sth->execute($query_data); |
749 | - $ident_result=''; |
|
750 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
749 | + $ident_result = ''; |
|
750 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
751 | 751 | { |
752 | 752 | $ident_result = $row['flightaware_id']; |
753 | 753 | } |
@@ -764,13 +764,13 @@ discard block |
||
764 | 764 | { |
765 | 765 | global $globalDBdriver, $globalTimezone; |
766 | 766 | if ($globalDBdriver == 'mysql') { |
767 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
767 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
768 | 768 | WHERE spotter_live.flightaware_id = :id |
769 | 769 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
770 | 770 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
771 | 771 | $query_data = array(':id' => $id); |
772 | 772 | } else { |
773 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
773 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
774 | 774 | WHERE spotter_live.flightaware_id = :id |
775 | 775 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
776 | 776 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -779,8 +779,8 @@ discard block |
||
779 | 779 | |
780 | 780 | $sth = $this->db->prepare($query); |
781 | 781 | $sth->execute($query_data); |
782 | - $ident_result=''; |
|
783 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
782 | + $ident_result = ''; |
|
783 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
784 | 784 | { |
785 | 785 | $ident_result = $row['flightaware_id']; |
786 | 786 | } |
@@ -797,13 +797,13 @@ discard block |
||
797 | 797 | { |
798 | 798 | global $globalDBdriver, $globalTimezone; |
799 | 799 | if ($globalDBdriver == 'mysql') { |
800 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
800 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
801 | 801 | WHERE spotter_live.ModeS = :modes |
802 | 802 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
803 | 803 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
804 | 804 | $query_data = array(':modes' => $modes); |
805 | 805 | } else { |
806 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
806 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
807 | 807 | WHERE spotter_live.ModeS = :modes |
808 | 808 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
809 | 809 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -812,8 +812,8 @@ discard block |
||
812 | 812 | |
813 | 813 | $sth = $this->db->prepare($query); |
814 | 814 | $sth->execute($query_data); |
815 | - $ident_result=''; |
|
816 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
815 | + $ident_result = ''; |
|
816 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
817 | 817 | { |
818 | 818 | //$ident_result = $row['spotter_live_id']; |
819 | 819 | $ident_result = $row['flightaware_id']; |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | * @return String success or false |
833 | 833 | * |
834 | 834 | */ |
835 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
835 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
836 | 836 | { |
837 | 837 | global $globalURL, $globalArchive, $globalDebug; |
838 | 838 | $Common = new Common(); |
@@ -925,26 +925,26 @@ discard block |
||
925 | 925 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
926 | 926 | |
927 | 927 | |
928 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
929 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
930 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
931 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
932 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
933 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
934 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
935 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
936 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
937 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
938 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
939 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
940 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
941 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
942 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
943 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
944 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
945 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
946 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
947 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
929 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
930 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
931 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
932 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
933 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
934 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
935 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
936 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
937 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
938 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
939 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
940 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
941 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
942 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
943 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
944 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
945 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
946 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
947 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
948 | 948 | |
949 | 949 | $airline_name = ''; |
950 | 950 | $airline_icao = ''; |
@@ -966,26 +966,26 @@ discard block |
||
966 | 966 | $arrival_airport_country = ''; |
967 | 967 | |
968 | 968 | |
969 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
970 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
971 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
972 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
969 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
970 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
971 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
972 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
973 | 973 | |
974 | - $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
|
974 | + $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
|
975 | 975 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
976 | 976 | |
977 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
977 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
978 | 978 | try { |
979 | 979 | |
980 | 980 | $sth = $this->db->prepare($query); |
981 | 981 | $sth->execute($query_values); |
982 | - } catch(PDOException $e) { |
|
982 | + } catch (PDOException $e) { |
|
983 | 983 | return "error : ".$e->getMessage(); |
984 | 984 | } |
985 | 985 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
986 | 986 | if ($globalDebug) echo '(Add to SBS archive : '; |
987 | 987 | $SpotterArchive = new SpotterArchive($this->db); |
988 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
988 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
989 | 989 | if ($globalDebug) echo $result.')'; |
990 | 990 | } |
991 | 991 | return "success"; |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | |
995 | 995 | public function getOrderBy() |
996 | 996 | { |
997 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
997 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
998 | 998 | return $orderby; |
999 | 999 | } |
1000 | 1000 |
@@ -26,7 +26,9 @@ discard block |
||
26 | 26 | $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
27 | 27 | } |
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) { |
|
30 | + $filter = array_merge($filter,$globalFilter); |
|
31 | + } |
|
30 | 32 | $filter_query_join = ''; |
31 | 33 | $filter_query_where = ''; |
32 | 34 | foreach($filters as $flt) { |
@@ -79,8 +81,11 @@ discard block |
||
79 | 81 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
80 | 82 | } |
81 | 83 | } |
82 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
83 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
84 | + if ($filter_query_where == '' && $where) { |
|
85 | + $filter_query_where = ' WHERE'; |
|
86 | + } elseif ($filter_query_where != '' && $and) { |
|
87 | + $filter_query_where .= ' AND'; |
|
88 | + } |
|
84 | 89 | $filter_query = $filter_query_join.$filter_query_where; |
85 | 90 | return $filter_query; |
86 | 91 | } |
@@ -119,7 +124,9 @@ discard block |
||
119 | 124 | } |
120 | 125 | } |
121 | 126 | |
122 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
127 | + if (!isset($globalLiveInterval)) { |
|
128 | + $globalLiveInterval = '200'; |
|
129 | + } |
|
123 | 130 | if ($globalDBdriver == 'mysql') { |
124 | 131 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
125 | 132 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -144,7 +151,9 @@ discard block |
||
144 | 151 | |
145 | 152 | $filter_query = $this->getFilter($filter,true,true); |
146 | 153 | |
147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
154 | + if (!isset($globalLiveInterval)) { |
|
155 | + $globalLiveInterval = '200'; |
|
156 | + } |
|
148 | 157 | if ($globalDBdriver == 'mysql') { |
149 | 158 | // $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query"; |
150 | 159 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao'; |
@@ -201,7 +210,9 @@ discard block |
||
201 | 210 | |
202 | 211 | $filter_query = $this->getFilter($filter,true,true); |
203 | 212 | |
204 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
213 | + if (!isset($globalLiveInterval)) { |
|
214 | + $globalLiveInterval = '200'; |
|
215 | + } |
|
205 | 216 | if ($globalDBdriver == 'mysql') { |
206 | 217 | /* |
207 | 218 | $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -245,7 +256,9 @@ discard block |
||
245 | 256 | global $globalDBdriver, $globalLiveInterval; |
246 | 257 | $filter_query = $this->getFilter($filter,true,true); |
247 | 258 | |
248 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
259 | + if (!isset($globalLiveInterval)) { |
|
260 | + $globalLiveInterval = '200'; |
|
261 | + } |
|
249 | 262 | if ($globalDBdriver == 'mysql') { |
250 | 263 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
251 | 264 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -275,7 +288,9 @@ discard block |
||
275 | 288 | { |
276 | 289 | global $globalDBdriver, $globalLiveInterval; |
277 | 290 | $Spotter = new Spotter($this->db); |
278 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
291 | + if (!isset($globalLiveInterval)) { |
|
292 | + $globalLiveInterval = '200'; |
|
293 | + } |
|
279 | 294 | $filter_query = $this->getFilter($filter); |
280 | 295 | |
281 | 296 | if (is_array($coord)) { |
@@ -283,7 +298,9 @@ discard block |
||
283 | 298 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
284 | 299 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
285 | 300 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
286 | - } else return array(); |
|
301 | + } else { |
|
302 | + return array(); |
|
303 | + } |
|
287 | 304 | if ($globalDBdriver == 'mysql') { |
288 | 305 | //$query = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
289 | 306 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -474,11 +491,15 @@ discard block |
||
474 | 491 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
475 | 492 | if ($globalDBdriver == 'mysql') { |
476 | 493 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
477 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
494 | + if ($liveinterval) { |
|
495 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
496 | + } |
|
478 | 497 | $query .= ' ORDER BY date'; |
479 | 498 | } else { |
480 | 499 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
481 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
500 | + if ($liveinterval) { |
|
501 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
502 | + } |
|
482 | 503 | $query .= ' ORDER BY date'; |
483 | 504 | } |
484 | 505 | |
@@ -573,7 +594,9 @@ discard block |
||
573 | 594 | $i++; |
574 | 595 | $j++; |
575 | 596 | if ($j == 30) { |
576 | - if ($globalDebug) echo "."; |
|
597 | + if ($globalDebug) { |
|
598 | + echo "."; |
|
599 | + } |
|
577 | 600 | try { |
578 | 601 | |
579 | 602 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -880,7 +903,9 @@ discard block |
||
880 | 903 | { |
881 | 904 | return false; |
882 | 905 | } |
883 | - } else return ''; |
|
906 | + } else { |
|
907 | + return ''; |
|
908 | + } |
|
884 | 909 | |
885 | 910 | if ($longitude != '') |
886 | 911 | { |
@@ -888,7 +913,9 @@ discard block |
||
888 | 913 | { |
889 | 914 | return false; |
890 | 915 | } |
891 | - } else return ''; |
|
916 | + } else { |
|
917 | + return ''; |
|
918 | + } |
|
892 | 919 | |
893 | 920 | if ($waypoints != '') |
894 | 921 | { |
@@ -904,7 +931,9 @@ discard block |
||
904 | 931 | { |
905 | 932 | return false; |
906 | 933 | } |
907 | - } else $altitude = 0; |
|
934 | + } else { |
|
935 | + $altitude = 0; |
|
936 | + } |
|
908 | 937 | |
909 | 938 | if ($heading != '') |
910 | 939 | { |
@@ -912,7 +941,9 @@ discard block |
||
912 | 941 | { |
913 | 942 | return false; |
914 | 943 | } |
915 | - } else $heading = 0; |
|
944 | + } else { |
|
945 | + $heading = 0; |
|
946 | + } |
|
916 | 947 | |
917 | 948 | if ($groundspeed != '') |
918 | 949 | { |
@@ -920,9 +951,13 @@ discard block |
||
920 | 951 | { |
921 | 952 | return false; |
922 | 953 | } |
923 | - } else $groundspeed = 0; |
|
954 | + } else { |
|
955 | + $groundspeed = 0; |
|
956 | + } |
|
924 | 957 | date_default_timezone_set('UTC'); |
925 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
958 | + if ($date == '') { |
|
959 | + $date = date("Y-m-d H:i:s", time()); |
|
960 | + } |
|
926 | 961 | |
927 | 962 | |
928 | 963 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -966,10 +1001,18 @@ discard block |
||
966 | 1001 | $arrival_airport_country = ''; |
967 | 1002 | |
968 | 1003 | |
969 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
970 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
971 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
972 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1004 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1005 | + $squawk = NULL; |
|
1006 | + } |
|
1007 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1008 | + $verticalrate = NULL; |
|
1009 | + } |
|
1010 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1011 | + $groundspeed = 0; |
|
1012 | + } |
|
1013 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1014 | + $heading = 0; |
|
1015 | + } |
|
973 | 1016 | |
974 | 1017 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
975 | 1018 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -983,10 +1026,14 @@ discard block |
||
983 | 1026 | return "error : ".$e->getMessage(); |
984 | 1027 | } |
985 | 1028 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
986 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1029 | + if ($globalDebug) { |
|
1030 | + echo '(Add to SBS archive : '; |
|
1031 | + } |
|
987 | 1032 | $SpotterArchive = new SpotterArchive($this->db); |
988 | 1033 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
989 | - if ($globalDebug) echo $result.')'; |
|
1034 | + if ($globalDebug) { |
|
1035 | + echo $result.')'; |
|
1036 | + } |
|
990 | 1037 | } |
991 | 1038 | return "success"; |
992 | 1039 |
@@ -125,6 +125,9 @@ discard block |
||
125 | 125 | public $tag_start = 0; |
126 | 126 | private $dom = null; |
127 | 127 | |
128 | + /** |
|
129 | + * @param simple_html_dom $dom |
|
130 | + */ |
|
128 | 131 | function __construct($dom) |
129 | 132 | { |
130 | 133 | $this->dom = $dom; |
@@ -1501,6 +1504,11 @@ discard block |
||
1501 | 1504 | } |
1502 | 1505 | |
1503 | 1506 | // parse attributes |
1507 | + |
|
1508 | + /** |
|
1509 | + * @param simple_html_dom_node $node |
|
1510 | + * @param string[] $space |
|
1511 | + */ |
|
1504 | 1512 | protected function parse_attr($node, $name, &$space) |
1505 | 1513 | { |
1506 | 1514 | // Per sourceforge: http://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037 |
@@ -1538,6 +1546,11 @@ discard block |
||
1538 | 1546 | } |
1539 | 1547 | |
1540 | 1548 | // link node's parent |
1549 | + |
|
1550 | + /** |
|
1551 | + * @param simple_html_dom_node $node |
|
1552 | + * @param boolean $is_child |
|
1553 | + */ |
|
1541 | 1554 | protected function link_nodes(&$node, $is_child) |
1542 | 1555 | { |
1543 | 1556 | $node->parent = $this->parent; |
@@ -1549,6 +1562,10 @@ discard block |
||
1549 | 1562 | } |
1550 | 1563 | |
1551 | 1564 | // as a text node |
1565 | + |
|
1566 | + /** |
|
1567 | + * @param string $tag |
|
1568 | + */ |
|
1552 | 1569 | protected function as_text_node($tag) |
1553 | 1570 | { |
1554 | 1571 | $node = new simple_html_dom_node($this); |
@@ -1559,12 +1576,18 @@ discard block |
||
1559 | 1576 | return true; |
1560 | 1577 | } |
1561 | 1578 | |
1579 | + /** |
|
1580 | + * @param string $chars |
|
1581 | + */ |
|
1562 | 1582 | protected function skip($chars) |
1563 | 1583 | { |
1564 | 1584 | $this->pos += strspn($this->doc, $chars, $this->pos); |
1565 | 1585 | $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1566 | 1586 | } |
1567 | 1587 | |
1588 | + /** |
|
1589 | + * @param string $chars |
|
1590 | + */ |
|
1568 | 1591 | protected function copy_skip($chars) |
1569 | 1592 | { |
1570 | 1593 | $pos = $this->pos; |
@@ -1575,6 +1598,9 @@ discard block |
||
1575 | 1598 | return substr($this->doc, $pos, $len); |
1576 | 1599 | } |
1577 | 1600 | |
1601 | + /** |
|
1602 | + * @param string $chars |
|
1603 | + */ |
|
1578 | 1604 | protected function copy_until($chars) |
1579 | 1605 | { |
1580 | 1606 | $pos = $this->pos; |
@@ -1584,6 +1610,9 @@ discard block |
||
1584 | 1610 | return substr($this->doc, $pos, $len); |
1585 | 1611 | } |
1586 | 1612 | |
1613 | + /** |
|
1614 | + * @param string $char |
|
1615 | + */ |
|
1587 | 1616 | protected function copy_until_char($char) |
1588 | 1617 | { |
1589 | 1618 | if ($this->char===null) return ''; |
@@ -1602,6 +1631,9 @@ discard block |
||
1602 | 1631 | return substr($this->doc, $pos_old, $pos-$pos_old); |
1603 | 1632 | } |
1604 | 1633 | |
1634 | + /** |
|
1635 | + * @param string $char |
|
1636 | + */ |
|
1605 | 1637 | protected function copy_until_char_escape($char) |
1606 | 1638 | { |
1607 | 1639 | if ($this->char===null) return ''; |
@@ -1633,6 +1665,10 @@ discard block |
||
1633 | 1665 | |
1634 | 1666 | // remove noise from html content |
1635 | 1667 | // save the noise in the $this->noise array. |
1668 | + |
|
1669 | + /** |
|
1670 | + * @param string $pattern |
|
1671 | + */ |
|
1636 | 1672 | protected function remove_noise($pattern, $remove_tag=false) |
1637 | 1673 | { |
1638 | 1674 | global $debug_object; |
@@ -1658,6 +1694,10 @@ discard block |
||
1658 | 1694 | } |
1659 | 1695 | |
1660 | 1696 | // restore noise to html content |
1697 | + |
|
1698 | + /** |
|
1699 | + * @param string|null $text |
|
1700 | + */ |
|
1661 | 1701 | function restore_noise($text) |
1662 | 1702 | { |
1663 | 1703 | global $debug_object; |
@@ -824,11 +824,11 @@ |
||
824 | 824 | } |
825 | 825 | |
826 | 826 | /** |
827 | - * Returns true if $string is valid UTF-8 and false otherwise. |
|
828 | - * |
|
829 | - * @param mixed $str String to be tested |
|
830 | - * @return boolean |
|
831 | - */ |
|
827 | + * Returns true if $string is valid UTF-8 and false otherwise. |
|
828 | + * |
|
829 | + * @param mixed $str String to be tested |
|
830 | + * @return boolean |
|
831 | + */ |
|
832 | 832 | static function is_utf8($str) |
833 | 833 | { |
834 | 834 | $c=0; $b=0; |
@@ -45,21 +45,21 @@ discard block |
||
45 | 45 | */ |
46 | 46 | define('HDOM_TYPE_ELEMENT', 1); |
47 | 47 | define('HDOM_TYPE_COMMENT', 2); |
48 | -define('HDOM_TYPE_TEXT', 3); |
|
49 | -define('HDOM_TYPE_ENDTAG', 4); |
|
50 | -define('HDOM_TYPE_ROOT', 5); |
|
48 | +define('HDOM_TYPE_TEXT', 3); |
|
49 | +define('HDOM_TYPE_ENDTAG', 4); |
|
50 | +define('HDOM_TYPE_ROOT', 5); |
|
51 | 51 | define('HDOM_TYPE_UNKNOWN', 6); |
52 | 52 | define('HDOM_QUOTE_DOUBLE', 0); |
53 | 53 | define('HDOM_QUOTE_SINGLE', 1); |
54 | -define('HDOM_QUOTE_NO', 3); |
|
55 | -define('HDOM_INFO_BEGIN', 0); |
|
56 | -define('HDOM_INFO_END', 1); |
|
57 | -define('HDOM_INFO_QUOTE', 2); |
|
58 | -define('HDOM_INFO_SPACE', 3); |
|
59 | -define('HDOM_INFO_TEXT', 4); |
|
60 | -define('HDOM_INFO_INNER', 5); |
|
61 | -define('HDOM_INFO_OUTER', 6); |
|
62 | -define('HDOM_INFO_ENDSPACE',7); |
|
54 | +define('HDOM_QUOTE_NO', 3); |
|
55 | +define('HDOM_INFO_BEGIN', 0); |
|
56 | +define('HDOM_INFO_END', 1); |
|
57 | +define('HDOM_INFO_QUOTE', 2); |
|
58 | +define('HDOM_INFO_SPACE', 3); |
|
59 | +define('HDOM_INFO_TEXT', 4); |
|
60 | +define('HDOM_INFO_INNER', 5); |
|
61 | +define('HDOM_INFO_OUTER', 6); |
|
62 | +define('HDOM_INFO_ENDSPACE', 7); |
|
63 | 63 | define('DEFAULT_TARGET_CHARSET', 'UTF-8'); |
64 | 64 | define('DEFAULT_BR_TEXT', "\r\n"); |
65 | 65 | define('DEFAULT_SPAN_TEXT', " "); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | // ----------------------------------------------------------------------------- |
69 | 69 | // get html dom from file |
70 | 70 | // $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1. |
71 | -function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
71 | +function file_get_html($url, $use_include_path = false, $context = null, $offset = -1, $maxLen = -1, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
72 | 72 | { |
73 | 73 | // We DO force the tags to be terminated. |
74 | 74 | $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | // get html dom from string |
89 | -function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
89 | +function str_get_html($str, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
90 | 90 | { |
91 | 91 | $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText); |
92 | 92 | if (empty($str) || strlen($str) > MAX_FILE_SIZE) |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | // dump html dom tree |
102 | -function dump_html_tree($node, $show_attr=true, $deep=0) |
|
102 | +function dump_html_tree($node, $show_attr = true, $deep = 0) |
|
103 | 103 | { |
104 | 104 | $node->dump($node); |
105 | 105 | } |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | // dump node's tree |
154 | - function dump($show_attr=true, $deep=0) |
|
154 | + function dump($show_attr = true, $deep = 0) |
|
155 | 155 | { |
156 | 156 | $lead = str_repeat(' ', $deep); |
157 | 157 | |
158 | 158 | echo $lead.$this->tag; |
159 | - if ($show_attr && count($this->attr)>0) |
|
159 | + if ($show_attr && count($this->attr) > 0) |
|
160 | 160 | { |
161 | 161 | echo '('; |
162 | 162 | foreach ($this->attr as $k=>$v) |
@@ -169,18 +169,18 @@ discard block |
||
169 | 169 | { |
170 | 170 | foreach ($this->nodes as $c) |
171 | 171 | { |
172 | - $c->dump($show_attr, $deep+1); |
|
172 | + $c->dump($show_attr, $deep + 1); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | 177 | |
178 | 178 | // Debugging function to dump a single dom node with a bunch of information about it. |
179 | - function dump_node($echo=true) |
|
179 | + function dump_node($echo = true) |
|
180 | 180 | { |
181 | 181 | |
182 | 182 | $string = $this->tag; |
183 | - if (count($this->attr)>0) |
|
183 | + if (count($this->attr) > 0) |
|
184 | 184 | { |
185 | 185 | $string .= '('; |
186 | 186 | foreach ($this->attr as $k=>$v) |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | } |
190 | 190 | $string .= ')'; |
191 | 191 | } |
192 | - if (count($this->_)>0) |
|
192 | + if (count($this->_) > 0) |
|
193 | 193 | { |
194 | 194 | $string .= ' $_ ('; |
195 | 195 | foreach ($this->_ as $k=>$v) |
@@ -211,22 +211,22 @@ discard block |
||
211 | 211 | |
212 | 212 | if (isset($this->text)) |
213 | 213 | { |
214 | - $string .= " text: (" . $this->text . ")"; |
|
214 | + $string .= " text: (".$this->text.")"; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | $string .= " HDOM_INNER_INFO: '"; |
218 | 218 | if (isset($node->_[HDOM_INFO_INNER])) |
219 | 219 | { |
220 | - $string .= $node->_[HDOM_INFO_INNER] . "'"; |
|
220 | + $string .= $node->_[HDOM_INFO_INNER]."'"; |
|
221 | 221 | } |
222 | 222 | else |
223 | 223 | { |
224 | 224 | $string .= ' NULL '; |
225 | 225 | } |
226 | 226 | |
227 | - $string .= " children: " . count($this->children); |
|
228 | - $string .= " nodes: " . count($this->nodes); |
|
229 | - $string .= " tag_start: " . $this->tag_start; |
|
227 | + $string .= " children: ".count($this->children); |
|
228 | + $string .= " nodes: ".count($this->nodes); |
|
229 | + $string .= " tag_start: ".$this->tag_start; |
|
230 | 230 | $string .= "\n"; |
231 | 231 | |
232 | 232 | if ($echo) |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | // returns the parent of node |
244 | 244 | // If a node is passed in, it will reset the parent of the current node to that one. |
245 | - function parent($parent=null) |
|
245 | + function parent($parent = null) |
|
246 | 246 | { |
247 | 247 | // I am SURE that this doesn't work properly. |
248 | 248 | // It fails to unset the current node from it's current parents nodes or children list first. |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | // returns children of node |
266 | - function children($idx=-1) |
|
266 | + function children($idx = -1) |
|
267 | 267 | { |
268 | - if ($idx===-1) |
|
268 | + if ($idx === -1) |
|
269 | 269 | { |
270 | 270 | return $this->children; |
271 | 271 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | // returns the first child of node |
280 | 280 | function first_child() |
281 | 281 | { |
282 | - if (count($this->children)>0) |
|
282 | + if (count($this->children) > 0) |
|
283 | 283 | { |
284 | 284 | return $this->children[0]; |
285 | 285 | } |
@@ -289,9 +289,9 @@ discard block |
||
289 | 289 | // returns the last child of node |
290 | 290 | function last_child() |
291 | 291 | { |
292 | - if (($count=count($this->children))>0) |
|
292 | + if (($count = count($this->children)) > 0) |
|
293 | 293 | { |
294 | - return $this->children[$count-1]; |
|
294 | + return $this->children[$count - 1]; |
|
295 | 295 | } |
296 | 296 | return null; |
297 | 297 | } |
@@ -299,18 +299,18 @@ discard block |
||
299 | 299 | // returns the next sibling of node |
300 | 300 | function next_sibling() |
301 | 301 | { |
302 | - if ($this->parent===null) |
|
302 | + if ($this->parent === null) |
|
303 | 303 | { |
304 | 304 | return null; |
305 | 305 | } |
306 | 306 | |
307 | 307 | $idx = 0; |
308 | 308 | $count = count($this->parent->children); |
309 | - while ($idx<$count && $this!==$this->parent->children[$idx]) |
|
309 | + while ($idx < $count && $this !== $this->parent->children[$idx]) |
|
310 | 310 | { |
311 | 311 | ++$idx; |
312 | 312 | } |
313 | - if (++$idx>=$count) |
|
313 | + if (++$idx >= $count) |
|
314 | 314 | { |
315 | 315 | return null; |
316 | 316 | } |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | // returns the previous sibling of node |
321 | 321 | function prev_sibling() |
322 | 322 | { |
323 | - if ($this->parent===null) return null; |
|
323 | + if ($this->parent === null) return null; |
|
324 | 324 | $idx = 0; |
325 | 325 | $count = count($this->parent->children); |
326 | - while ($idx<$count && $this!==$this->parent->children[$idx]) |
|
326 | + while ($idx < $count && $this !== $this->parent->children[$idx]) |
|
327 | 327 | ++$idx; |
328 | - if (--$idx<0) return null; |
|
328 | + if (--$idx < 0) return null; |
|
329 | 329 | return $this->parent->children[$idx]; |
330 | 330 | } |
331 | 331 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | |
341 | 341 | while (!is_null($returnDom)) |
342 | 342 | { |
343 | - if (is_object($debug_object)) { $debug_object->debug_log(2, "Current tag is: " . $returnDom->tag); } |
|
343 | + if (is_object($debug_object)) { $debug_object->debug_log(2, "Current tag is: ".$returnDom->tag); } |
|
344 | 344 | |
345 | 345 | if ($returnDom->tag == $tag) |
346 | 346 | { |
@@ -374,16 +374,16 @@ discard block |
||
374 | 374 | { |
375 | 375 | if (!empty($this->text)) |
376 | 376 | { |
377 | - $text = " with text: " . $this->text; |
|
377 | + $text = " with text: ".$this->text; |
|
378 | 378 | } |
379 | 379 | } |
380 | - $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text); |
|
380 | + $debug_object->debug_log(1, 'Innertext of tag: '.$this->tag.$text); |
|
381 | 381 | } |
382 | 382 | |
383 | - if ($this->tag==='root') return $this->innertext(); |
|
383 | + if ($this->tag === 'root') return $this->innertext(); |
|
384 | 384 | |
385 | 385 | // trigger callback |
386 | - if ($this->dom && $this->dom->callback!==null) |
|
386 | + if ($this->dom && $this->dom->callback !== null) |
|
387 | 387 | { |
388 | 388 | call_user_func_array($this->dom->callback, array($this)); |
389 | 389 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | } |
419 | 419 | |
420 | 420 | // render end tag |
421 | - if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) |
|
421 | + if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END] != 0) |
|
422 | 422 | $ret .= '</'.$this->tag.'>'; |
423 | 423 | return $ret; |
424 | 424 | } |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | case HDOM_TYPE_COMMENT: return ''; |
434 | 434 | case HDOM_TYPE_UNKNOWN: return ''; |
435 | 435 | } |
436 | - if (strcasecmp($this->tag, 'script')===0) return ''; |
|
437 | - if (strcasecmp($this->tag, 'style')===0) return ''; |
|
436 | + if (strcasecmp($this->tag, 'script') === 0) return ''; |
|
437 | + if (strcasecmp($this->tag, 'style') === 0) return ''; |
|
438 | 438 | |
439 | 439 | $ret = ''; |
440 | 440 | // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. |
@@ -480,12 +480,12 @@ discard block |
||
480 | 480 | ++$i; |
481 | 481 | |
482 | 482 | // skip removed attribute |
483 | - if ($val===null || $val===false) |
|
483 | + if ($val === null || $val === false) |
|
484 | 484 | continue; |
485 | 485 | |
486 | 486 | $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; |
487 | 487 | //no value attr: nowrap, checked selected... |
488 | - if ($val===true) |
|
488 | + if ($val === true) |
|
489 | 489 | $ret .= $key; |
490 | 490 | else { |
491 | 491 | switch ($this->_[HDOM_INFO_QUOTE][$i]) |
@@ -498,34 +498,34 @@ discard block |
||
498 | 498 | } |
499 | 499 | } |
500 | 500 | $ret = $this->dom->restore_noise($ret); |
501 | - return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>'; |
|
501 | + return $ret.$this->_[HDOM_INFO_ENDSPACE].'>'; |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | // find elements by css selector |
505 | 505 | //PaperG - added ability for find to lowercase the value of the selector. |
506 | - function find($selector, $idx=null, $lowercase=false) |
|
506 | + function find($selector, $idx = null, $lowercase = false) |
|
507 | 507 | { |
508 | 508 | $selectors = $this->parse_selector($selector); |
509 | - if (($count=count($selectors))===0) return array(); |
|
509 | + if (($count = count($selectors)) === 0) return array(); |
|
510 | 510 | $found_keys = array(); |
511 | 511 | |
512 | 512 | // find each selector |
513 | - for ($c=0; $c<$count; ++$c) |
|
513 | + for ($c = 0; $c < $count; ++$c) |
|
514 | 514 | { |
515 | 515 | // The change on the below line was documented on the sourceforge code tracker id 2788009 |
516 | 516 | // used to be: if (($levle=count($selectors[0]))===0) return array(); |
517 | - if (($levle=count($selectors[$c]))===0) return array(); |
|
517 | + if (($levle = count($selectors[$c])) === 0) return array(); |
|
518 | 518 | if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); |
519 | 519 | |
520 | 520 | $head = array($this->_[HDOM_INFO_BEGIN]=>1); |
521 | 521 | |
522 | 522 | // handle descendant selectors, no recursive! |
523 | - for ($l=0; $l<$levle; ++$l) |
|
523 | + for ($l = 0; $l < $levle; ++$l) |
|
524 | 524 | { |
525 | 525 | $ret = array(); |
526 | 526 | foreach ($head as $k=>$v) |
527 | 527 | { |
528 | - $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k]; |
|
528 | + $n = ($k === -1) ? $this->dom->root : $this->dom->nodes[$k]; |
|
529 | 529 | //PaperG - Pass this optional parameter on to the seek function. |
530 | 530 | $n->seek($selectors[$c][$l], $ret, $lowercase); |
531 | 531 | } |
@@ -550,13 +550,13 @@ discard block |
||
550 | 550 | |
551 | 551 | // return nth-element or array |
552 | 552 | if (is_null($idx)) return $found; |
553 | - else if ($idx<0) $idx = count($found) + $idx; |
|
553 | + else if ($idx < 0) $idx = count($found) + $idx; |
|
554 | 554 | return (isset($found[$idx])) ? $found[$idx] : null; |
555 | 555 | } |
556 | 556 | |
557 | 557 | // seek for given conditions |
558 | 558 | // PaperG - added parameter to allow for case insensitive testing of the value of a selector. |
559 | - protected function seek($selector, &$ret, $lowercase=false) |
|
559 | + protected function seek($selector, &$ret, $lowercase = false) |
|
560 | 560 | { |
561 | 561 | global $debug_object; |
562 | 562 | if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } |
@@ -569,8 +569,8 @@ discard block |
||
569 | 569 | $count = 0; |
570 | 570 | foreach ($this->children as $c) |
571 | 571 | { |
572 | - if ($tag==='*' || $tag===$c->tag) { |
|
573 | - if (++$count==$key) { |
|
572 | + if ($tag === '*' || $tag === $c->tag) { |
|
573 | + if (++$count == $key) { |
|
574 | 574 | $ret[$c->_[HDOM_INFO_BEGIN]] = 1; |
575 | 575 | return; |
576 | 576 | } |
@@ -580,38 +580,38 @@ discard block |
||
580 | 580 | } |
581 | 581 | |
582 | 582 | $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0; |
583 | - if ($end==0) { |
|
583 | + if ($end == 0) { |
|
584 | 584 | $parent = $this->parent; |
585 | - while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) { |
|
585 | + while (!isset($parent->_[HDOM_INFO_END]) && $parent !== null) { |
|
586 | 586 | $end -= 1; |
587 | 587 | $parent = $parent->parent; |
588 | 588 | } |
589 | 589 | $end += $parent->_[HDOM_INFO_END]; |
590 | 590 | } |
591 | 591 | |
592 | - for ($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) { |
|
592 | + for ($i = $this->_[HDOM_INFO_BEGIN] + 1; $i < $end; ++$i) { |
|
593 | 593 | $node = $this->dom->nodes[$i]; |
594 | 594 | |
595 | 595 | $pass = true; |
596 | 596 | |
597 | - if ($tag==='*' && !$key) { |
|
597 | + if ($tag === '*' && !$key) { |
|
598 | 598 | if (in_array($node, $this->children, true)) |
599 | 599 | $ret[$i] = 1; |
600 | 600 | continue; |
601 | 601 | } |
602 | 602 | |
603 | 603 | // compare tag |
604 | - if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;} |
|
604 | + if ($tag && $tag != $node->tag && $tag !== '*') {$pass = false; } |
|
605 | 605 | // compare key |
606 | 606 | if ($pass && $key) { |
607 | 607 | if ($no_key) { |
608 | - if (isset($node->attr[$key])) $pass=false; |
|
608 | + if (isset($node->attr[$key])) $pass = false; |
|
609 | 609 | } else { |
610 | - if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false; |
|
610 | + if (($key != "plaintext") && !isset($node->attr[$key])) $pass = false; |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | // compare value |
614 | - if ($pass && $key && $val && $val!=='*') { |
|
614 | + if ($pass && $key && $val && $val !== '*') { |
|
615 | 615 | // If they have told us that this is a "plaintext" search then we want the plaintext of the node - right? |
616 | 616 | if ($key == "plaintext") { |
617 | 617 | // $node->plaintext actually returns $node->text(); |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | // this is a normal search, we want the value of that attribute of the tag. |
621 | 621 | $nodeKeyValue = $node->attr[$key]; |
622 | 622 | } |
623 | - if (is_object($debug_object)) {$debug_object->debug_log(2, "testing node: " . $node->tag . " for attribute: " . $key . $exp . $val . " where nodes value is: " . $nodeKeyValue);} |
|
623 | + if (is_object($debug_object)) {$debug_object->debug_log(2, "testing node: ".$node->tag." for attribute: ".$key.$exp.$val." where nodes value is: ".$nodeKeyValue); } |
|
624 | 624 | |
625 | 625 | //PaperG - If lowercase is set, do a case insensitive test of the value of the selector. |
626 | 626 | if ($lowercase) { |
@@ -628,11 +628,11 @@ discard block |
||
628 | 628 | } else { |
629 | 629 | $check = $this->match($exp, $val, $nodeKeyValue); |
630 | 630 | } |
631 | - if (is_object($debug_object)) {$debug_object->debug_log(2, "after match: " . ($check ? "true" : "false"));} |
|
631 | + if (is_object($debug_object)) {$debug_object->debug_log(2, "after match: ".($check ? "true" : "false")); } |
|
632 | 632 | |
633 | 633 | // handle multiple class |
634 | - if (!$check && strcasecmp($key, 'class')===0) { |
|
635 | - foreach (explode(' ',$node->attr[$key]) as $k) { |
|
634 | + if (!$check && strcasecmp($key, 'class') === 0) { |
|
635 | + foreach (explode(' ', $node->attr[$key]) as $k) { |
|
636 | 636 | // Without this, there were cases where leading, trailing, or double spaces lead to our comparing blanks - bad form. |
637 | 637 | if (!empty($k)) { |
638 | 638 | if ($lowercase) { |
@@ -650,24 +650,24 @@ discard block |
||
650 | 650 | unset($node); |
651 | 651 | } |
652 | 652 | // It's passed by reference so this is actually what this function returns. |
653 | - if (is_object($debug_object)) {$debug_object->debug_log(1, "EXIT - ret: ", $ret);} |
|
653 | + if (is_object($debug_object)) {$debug_object->debug_log(1, "EXIT - ret: ", $ret); } |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | protected function match($exp, $pattern, $value) { |
657 | 657 | global $debug_object; |
658 | - if (is_object($debug_object)) {$debug_object->debug_log_entry(1);} |
|
658 | + if (is_object($debug_object)) {$debug_object->debug_log_entry(1); } |
|
659 | 659 | |
660 | 660 | switch ($exp) { |
661 | 661 | case '=': |
662 | - return ($value===$pattern); |
|
662 | + return ($value === $pattern); |
|
663 | 663 | case '!=': |
664 | - return ($value!==$pattern); |
|
664 | + return ($value !== $pattern); |
|
665 | 665 | case '^=': |
666 | - return preg_match("/^".preg_quote($pattern,'/')."/", $value); |
|
666 | + return preg_match("/^".preg_quote($pattern, '/')."/", $value); |
|
667 | 667 | case '$=': |
668 | - return preg_match("/".preg_quote($pattern,'/')."$/", $value); |
|
668 | + return preg_match("/".preg_quote($pattern, '/')."$/", $value); |
|
669 | 669 | case '*=': |
670 | - if ($pattern[0]=='/') { |
|
670 | + if ($pattern[0] == '/') { |
|
671 | 671 | return preg_match($pattern, $value); |
672 | 672 | } |
673 | 673 | return preg_match("/".$pattern."/i", $value); |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | |
678 | 678 | protected function parse_selector($selector_string) { |
679 | 679 | global $debug_object; |
680 | - if (is_object($debug_object)) {$debug_object->debug_log_entry(1);} |
|
680 | + if (is_object($debug_object)) {$debug_object->debug_log_entry(1); } |
|
681 | 681 | |
682 | 682 | // pattern of CSS selectors, modified from mootools |
683 | 683 | // Paperg: Add the colon to the attrbute, so that it properly finds <tag attr:ibute="something" > like google does. |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | // $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is"; |
689 | 689 | $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is"; |
690 | 690 | preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER); |
691 | - if (is_object($debug_object)) {$debug_object->debug_log(2, "Matches Array: ", $matches);} |
|
691 | + if (is_object($debug_object)) {$debug_object->debug_log(2, "Matches Array: ", $matches); } |
|
692 | 692 | |
693 | 693 | $selectors = array(); |
694 | 694 | $result = array(); |
@@ -696,29 +696,29 @@ discard block |
||
696 | 696 | |
697 | 697 | foreach ($matches as $m) { |
698 | 698 | $m[0] = trim($m[0]); |
699 | - if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue; |
|
699 | + if ($m[0] === '' || $m[0] === '/' || $m[0] === '//') continue; |
|
700 | 700 | // for browser generated xpath |
701 | - if ($m[1]==='tbody') continue; |
|
701 | + if ($m[1] === 'tbody') continue; |
|
702 | 702 | |
703 | 703 | list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); |
704 | - if (!empty($m[2])) {$key='id'; $val=$m[2];} |
|
705 | - if (!empty($m[3])) {$key='class'; $val=$m[3];} |
|
706 | - if (!empty($m[4])) {$key=$m[4];} |
|
707 | - if (!empty($m[5])) {$exp=$m[5];} |
|
708 | - if (!empty($m[6])) {$val=$m[6];} |
|
704 | + if (!empty($m[2])) {$key = 'id'; $val = $m[2]; } |
|
705 | + if (!empty($m[3])) {$key = 'class'; $val = $m[3]; } |
|
706 | + if (!empty($m[4])) {$key = $m[4]; } |
|
707 | + if (!empty($m[5])) {$exp = $m[5]; } |
|
708 | + if (!empty($m[6])) {$val = $m[6]; } |
|
709 | 709 | |
710 | 710 | // convert to lowercase |
711 | - if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);} |
|
711 | + if ($this->dom->lowercase) {$tag = strtolower($tag); $key = strtolower($key); } |
|
712 | 712 | //elements that do NOT have the specified attribute |
713 | - if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;} |
|
713 | + if (isset($key[0]) && $key[0] === '!') {$key = substr($key, 1); $no_key = true; } |
|
714 | 714 | |
715 | 715 | $result[] = array($tag, $key, $val, $exp, $no_key); |
716 | - if (trim($m[7])===',') { |
|
716 | + if (trim($m[7]) === ',') { |
|
717 | 717 | $selectors[] = $result; |
718 | 718 | $result = array(); |
719 | 719 | } |
720 | 720 | } |
721 | - if (count($result)>0) |
|
721 | + if (count($result) > 0) |
|
722 | 722 | $selectors[] = $result; |
723 | 723 | return $selectors; |
724 | 724 | } |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | function __set($name, $value) |
743 | 743 | { |
744 | 744 | global $debug_object; |
745 | - if (is_object($debug_object)) {$debug_object->debug_log_entry(1);} |
|
745 | + if (is_object($debug_object)) {$debug_object->debug_log_entry(1); } |
|
746 | 746 | |
747 | 747 | switch ($name) |
748 | 748 | { |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | function convert_text($text) |
781 | 781 | { |
782 | 782 | global $debug_object; |
783 | - if (is_object($debug_object)) {$debug_object->debug_log_entry(1);} |
|
783 | + if (is_object($debug_object)) {$debug_object->debug_log_entry(1); } |
|
784 | 784 | |
785 | 785 | $converted_text = $text; |
786 | 786 | |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | $sourceCharset = strtoupper($this->dom->_charset); |
793 | 793 | $targetCharset = strtoupper($this->dom->_target_charset); |
794 | 794 | } |
795 | - if (is_object($debug_object)) {$debug_object->debug_log(3, "source charset: " . $sourceCharset . " target charaset: " . $targetCharset);} |
|
795 | + if (is_object($debug_object)) {$debug_object->debug_log(3, "source charset: ".$sourceCharset." target charaset: ".$targetCharset); } |
|
796 | 796 | |
797 | 797 | if (!empty($sourceCharset) && !empty($targetCharset) && (strcasecmp($sourceCharset, $targetCharset) != 0)) |
798 | 798 | { |
@@ -831,27 +831,27 @@ discard block |
||
831 | 831 | */ |
832 | 832 | static function is_utf8($str) |
833 | 833 | { |
834 | - $c=0; $b=0; |
|
835 | - $bits=0; |
|
836 | - $len=strlen($str); |
|
837 | - for($i=0; $i<$len; $i++) |
|
834 | + $c = 0; $b = 0; |
|
835 | + $bits = 0; |
|
836 | + $len = strlen($str); |
|
837 | + for ($i = 0; $i < $len; $i++) |
|
838 | 838 | { |
839 | - $c=ord($str[$i]); |
|
840 | - if($c > 128) |
|
839 | + $c = ord($str[$i]); |
|
840 | + if ($c > 128) |
|
841 | 841 | { |
842 | - if(($c >= 254)) return false; |
|
843 | - elseif($c >= 252) $bits=6; |
|
844 | - elseif($c >= 248) $bits=5; |
|
845 | - elseif($c >= 240) $bits=4; |
|
846 | - elseif($c >= 224) $bits=3; |
|
847 | - elseif($c >= 192) $bits=2; |
|
842 | + if (($c >= 254)) return false; |
|
843 | + elseif ($c >= 252) $bits = 6; |
|
844 | + elseif ($c >= 248) $bits = 5; |
|
845 | + elseif ($c >= 240) $bits = 4; |
|
846 | + elseif ($c >= 224) $bits = 3; |
|
847 | + elseif ($c >= 192) $bits = 2; |
|
848 | 848 | else return false; |
849 | - if(($i+$bits) > $len) return false; |
|
850 | - while($bits > 1) |
|
849 | + if (($i + $bits) > $len) return false; |
|
850 | + while ($bits > 1) |
|
851 | 851 | { |
852 | 852 | $i++; |
853 | - $b=ord($str[$i]); |
|
854 | - if($b < 128 || $b > 191) return false; |
|
853 | + $b = ord($str[$i]); |
|
854 | + if ($b < 128 || $b > 191) return false; |
|
855 | 855 | $bits--; |
856 | 856 | } |
857 | 857 | } |
@@ -955,24 +955,24 @@ discard block |
||
955 | 955 | } |
956 | 956 | |
957 | 957 | // camel naming conventions |
958 | - function getAllAttributes() {return $this->attr;} |
|
959 | - function getAttribute($name) {return $this->__get($name);} |
|
960 | - function setAttribute($name, $value) {$this->__set($name, $value);} |
|
961 | - function hasAttribute($name) {return $this->__isset($name);} |
|
962 | - function removeAttribute($name) {$this->__set($name, null);} |
|
963 | - function getElementById($id) {return $this->find("#$id", 0);} |
|
964 | - function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);} |
|
965 | - function getElementByTagName($name) {return $this->find($name, 0);} |
|
966 | - function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);} |
|
967 | - function parentNode() {return $this->parent();} |
|
968 | - function childNodes($idx=-1) {return $this->children($idx);} |
|
969 | - function firstChild() {return $this->first_child();} |
|
970 | - function lastChild() {return $this->last_child();} |
|
971 | - function nextSibling() {return $this->next_sibling();} |
|
972 | - function previousSibling() {return $this->prev_sibling();} |
|
973 | - function hasChildNodes() {return $this->has_child();} |
|
974 | - function nodeName() {return $this->tag;} |
|
975 | - function appendChild($node) {$node->parent($this); return $node;} |
|
958 | + function getAllAttributes() {return $this->attr; } |
|
959 | + function getAttribute($name) {return $this->__get($name); } |
|
960 | + function setAttribute($name, $value) {$this->__set($name, $value); } |
|
961 | + function hasAttribute($name) {return $this->__isset($name); } |
|
962 | + function removeAttribute($name) {$this->__set($name, null); } |
|
963 | + function getElementById($id) {return $this->find("#$id", 0); } |
|
964 | + function getElementsById($id, $idx = null) {return $this->find("#$id", $idx); } |
|
965 | + function getElementByTagName($name) {return $this->find($name, 0); } |
|
966 | + function getElementsByTagName($name, $idx = null) {return $this->find($name, $idx); } |
|
967 | + function parentNode() {return $this->parent(); } |
|
968 | + function childNodes($idx = -1) {return $this->children($idx); } |
|
969 | + function firstChild() {return $this->first_child(); } |
|
970 | + function lastChild() {return $this->last_child(); } |
|
971 | + function nextSibling() {return $this->next_sibling(); } |
|
972 | + function previousSibling() {return $this->prev_sibling(); } |
|
973 | + function hasChildNodes() {return $this->has_child(); } |
|
974 | + function nodeName() {return $this->tag; } |
|
975 | + function appendChild($node) {$node->parent($this); return $node; } |
|
976 | 976 | |
977 | 977 | } |
978 | 978 | |
@@ -1028,11 +1028,11 @@ discard block |
||
1028 | 1028 | 'option'=>array('option'=>1), |
1029 | 1029 | ); |
1030 | 1030 | |
1031 | - function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
1031 | + function __construct($str = null, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
1032 | 1032 | { |
1033 | 1033 | if ($str) |
1034 | 1034 | { |
1035 | - if (preg_match("/^http:\/\//i",$str) || is_file($str)) |
|
1035 | + if (preg_match("/^http:\/\//i", $str) || is_file($str)) |
|
1036 | 1036 | { |
1037 | 1037 | $this->load_file($str); |
1038 | 1038 | } |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | } |
1044 | 1044 | // Forcing tags to be closed implies that we don't trust the html, but it can lead to parsing errors if we SHOULD trust the html. |
1045 | 1045 | if (!$forceTagsClosed) { |
1046 | - $this->optional_closing_array=array(); |
|
1046 | + $this->optional_closing_array = array(); |
|
1047 | 1047 | } |
1048 | 1048 | $this->_target_charset = $target_charset; |
1049 | 1049 | } |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | // load html from string |
1057 | - function load($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
1057 | + function load($str, $lowercase = true, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
1058 | 1058 | { |
1059 | 1059 | global $debug_object; |
1060 | 1060 | |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | $args = func_get_args(); |
1097 | 1097 | $this->load(call_user_func_array('file_get_contents', $args), true); |
1098 | 1098 | // Throw an error if we can't properly load the dom. |
1099 | - if (($error=error_get_last())!==null) { |
|
1099 | + if (($error = error_get_last()) !== null) { |
|
1100 | 1100 | $this->clear(); |
1101 | 1101 | return false; |
1102 | 1102 | } |
@@ -1115,16 +1115,16 @@ discard block |
||
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | // save dom as string |
1118 | - function save($filepath='') |
|
1118 | + function save($filepath = '') |
|
1119 | 1119 | { |
1120 | 1120 | $ret = $this->root->innertext(); |
1121 | - if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX); |
|
1121 | + if ($filepath !== '') file_put_contents($filepath, $ret, LOCK_EX); |
|
1122 | 1122 | return $ret; |
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | // find dom node by css selector |
1126 | 1126 | // Paperg - allow us to specify that we want case insensitive testing of the value of the selector. |
1127 | - function find($selector, $idx=null, $lowercase=false) |
|
1127 | + function find($selector, $idx = null, $lowercase = false) |
|
1128 | 1128 | { |
1129 | 1129 | return $this->root->find($selector, $idx, $lowercase); |
1130 | 1130 | } |
@@ -1132,22 +1132,22 @@ discard block |
||
1132 | 1132 | // clean up memory due to php5 circular references memory leak... |
1133 | 1133 | function clear() |
1134 | 1134 | { |
1135 | - foreach ($this->nodes as $n) {$n->clear(); $n = null;} |
|
1135 | + foreach ($this->nodes as $n) {$n->clear(); $n = null; } |
|
1136 | 1136 | // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear. |
1137 | - if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;} |
|
1138 | - if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);} |
|
1139 | - if (isset($this->root)) {$this->root->clear(); unset($this->root);} |
|
1137 | + if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null; } |
|
1138 | + if (isset($this->parent)) {$this->parent->clear(); unset($this->parent); } |
|
1139 | + if (isset($this->root)) {$this->root->clear(); unset($this->root); } |
|
1140 | 1140 | unset($this->doc); |
1141 | 1141 | unset($this->noise); |
1142 | 1142 | } |
1143 | 1143 | |
1144 | - function dump($show_attr=true) |
|
1144 | + function dump($show_attr = true) |
|
1145 | 1145 | { |
1146 | 1146 | $this->root->dump($show_attr); |
1147 | 1147 | } |
1148 | 1148 | |
1149 | 1149 | // prepare HTML data and init everything |
1150 | - protected function prepare($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
1150 | + protected function prepare($str, $lowercase = true, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
1151 | 1151 | { |
1152 | 1152 | $this->clear(); |
1153 | 1153 | |
@@ -1178,13 +1178,13 @@ discard block |
||
1178 | 1178 | $this->root->_[HDOM_INFO_BEGIN] = -1; |
1179 | 1179 | $this->root->nodetype = HDOM_TYPE_ROOT; |
1180 | 1180 | $this->parent = $this->root; |
1181 | - if ($this->size>0) $this->char = $this->doc[0]; |
|
1181 | + if ($this->size > 0) $this->char = $this->doc[0]; |
|
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | // parse html content |
1185 | 1185 | protected function parse() |
1186 | 1186 | { |
1187 | - if (($s = $this->copy_until_char('<'))==='') |
|
1187 | + if (($s = $this->copy_until_char('<')) === '') |
|
1188 | 1188 | { |
1189 | 1189 | return $this->read_tag(); |
1190 | 1190 | } |
@@ -1213,18 +1213,18 @@ discard block |
||
1213 | 1213 | if ($success) |
1214 | 1214 | { |
1215 | 1215 | $charset = $matches[1]; |
1216 | - if (is_object($debug_object)) {$debug_object->debug_log(2, 'header content-type found charset of: ' . $charset);} |
|
1216 | + if (is_object($debug_object)) {$debug_object->debug_log(2, 'header content-type found charset of: '.$charset); } |
|
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | } |
1220 | 1220 | |
1221 | 1221 | if (empty($charset)) |
1222 | 1222 | { |
1223 | - $el = $this->root->find('meta[http-equiv=Content-Type]',0, true); |
|
1223 | + $el = $this->root->find('meta[http-equiv=Content-Type]', 0, true); |
|
1224 | 1224 | if (!empty($el)) |
1225 | 1225 | { |
1226 | 1226 | $fullvalue = $el->content; |
1227 | - if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag found' . $fullvalue);} |
|
1227 | + if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag found'.$fullvalue); } |
|
1228 | 1228 | |
1229 | 1229 | if (!empty($fullvalue)) |
1230 | 1230 | { |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | else |
1237 | 1237 | { |
1238 | 1238 | // If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1 |
1239 | - if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');} |
|
1239 | + if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.'); } |
|
1240 | 1240 | $charset = 'ISO-8859-1'; |
1241 | 1241 | } |
1242 | 1242 | } |
@@ -1251,14 +1251,14 @@ discard block |
||
1251 | 1251 | if (function_exists('mb_detect_encoding')) |
1252 | 1252 | { |
1253 | 1253 | // Have php try to detect the encoding from the text given to us. |
1254 | - $charset = mb_detect_encoding($this->root->plaintext . "ascii", $encoding_list = array( "UTF-8", "CP1252" ) ); |
|
1255 | - if (is_object($debug_object)) {$debug_object->debug_log(2, 'mb_detect found: ' . $charset);} |
|
1254 | + $charset = mb_detect_encoding($this->root->plaintext."ascii", $encoding_list = array("UTF-8", "CP1252")); |
|
1255 | + if (is_object($debug_object)) {$debug_object->debug_log(2, 'mb_detect found: '.$charset); } |
|
1256 | 1256 | } |
1257 | 1257 | |
1258 | 1258 | // and if this doesn't work... then we need to just wrongheadedly assume it's UTF-8 so that we can move on - cause this will usually give us most of what we need... |
1259 | 1259 | if ($charset === false) |
1260 | 1260 | { |
1261 | - if (is_object($debug_object)) {$debug_object->debug_log(2, 'since mb_detect failed - using default of utf-8');} |
|
1261 | + if (is_object($debug_object)) {$debug_object->debug_log(2, 'since mb_detect failed - using default of utf-8'); } |
|
1262 | 1262 | $charset = 'UTF-8'; |
1263 | 1263 | } |
1264 | 1264 | } |
@@ -1266,11 +1266,11 @@ discard block |
||
1266 | 1266 | // Since CP1252 is a superset, if we get one of it's subsets, we want it instead. |
1267 | 1267 | if ((strtolower($charset) == strtolower('ISO-8859-1')) || (strtolower($charset) == strtolower('Latin1')) || (strtolower($charset) == strtolower('Latin-1'))) |
1268 | 1268 | { |
1269 | - if (is_object($debug_object)) {$debug_object->debug_log(2, 'replacing ' . $charset . ' with CP1252 as its a superset');} |
|
1269 | + if (is_object($debug_object)) {$debug_object->debug_log(2, 'replacing '.$charset.' with CP1252 as its a superset'); } |
|
1270 | 1270 | $charset = 'CP1252'; |
1271 | 1271 | } |
1272 | 1272 | |
1273 | - if (is_object($debug_object)) {$debug_object->debug_log(1, 'EXIT - ' . $charset);} |
|
1273 | + if (is_object($debug_object)) {$debug_object->debug_log(1, 'EXIT - '.$charset); } |
|
1274 | 1274 | |
1275 | 1275 | return $this->_charset = $charset; |
1276 | 1276 | } |
@@ -1278,41 +1278,41 @@ discard block |
||
1278 | 1278 | // read tag info |
1279 | 1279 | protected function read_tag() |
1280 | 1280 | { |
1281 | - if ($this->char!=='<') |
|
1281 | + if ($this->char !== '<') |
|
1282 | 1282 | { |
1283 | 1283 | $this->root->_[HDOM_INFO_END] = $this->cursor; |
1284 | 1284 | return false; |
1285 | 1285 | } |
1286 | 1286 | $begin_tag_pos = $this->pos; |
1287 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1287 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1288 | 1288 | |
1289 | 1289 | // end tag |
1290 | - if ($this->char==='/') |
|
1290 | + if ($this->char === '/') |
|
1291 | 1291 | { |
1292 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1292 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1293 | 1293 | // This represents the change in the simple_html_dom trunk from revision 180 to 181. |
1294 | 1294 | // $this->skip($this->token_blank_t); |
1295 | 1295 | $this->skip($this->token_blank); |
1296 | 1296 | $tag = $this->copy_until_char('>'); |
1297 | 1297 | |
1298 | 1298 | // skip attributes in end tag |
1299 | - if (($pos = strpos($tag, ' '))!==false) |
|
1299 | + if (($pos = strpos($tag, ' ')) !== false) |
|
1300 | 1300 | $tag = substr($tag, 0, $pos); |
1301 | 1301 | |
1302 | 1302 | $parent_lower = strtolower($this->parent->tag); |
1303 | 1303 | $tag_lower = strtolower($tag); |
1304 | 1304 | |
1305 | - if ($parent_lower!==$tag_lower) |
|
1305 | + if ($parent_lower !== $tag_lower) |
|
1306 | 1306 | { |
1307 | 1307 | if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower])) |
1308 | 1308 | { |
1309 | 1309 | $this->parent->_[HDOM_INFO_END] = 0; |
1310 | 1310 | $org_parent = $this->parent; |
1311 | 1311 | |
1312 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
1312 | + while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) |
|
1313 | 1313 | $this->parent = $this->parent->parent; |
1314 | 1314 | |
1315 | - if (strtolower($this->parent->tag)!==$tag_lower) { |
|
1315 | + if (strtolower($this->parent->tag) !== $tag_lower) { |
|
1316 | 1316 | $this->parent = $org_parent; // restore origonal parent |
1317 | 1317 | if ($this->parent->parent) $this->parent = $this->parent->parent; |
1318 | 1318 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
@@ -1324,17 +1324,17 @@ discard block |
||
1324 | 1324 | $this->parent->_[HDOM_INFO_END] = 0; |
1325 | 1325 | $org_parent = $this->parent; |
1326 | 1326 | |
1327 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
1327 | + while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) |
|
1328 | 1328 | $this->parent = $this->parent->parent; |
1329 | 1329 | |
1330 | - if (strtolower($this->parent->tag)!==$tag_lower) |
|
1330 | + if (strtolower($this->parent->tag) !== $tag_lower) |
|
1331 | 1331 | { |
1332 | 1332 | $this->parent = $org_parent; // restore origonal parent |
1333 | 1333 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1334 | 1334 | return $this->as_text_node($tag); |
1335 | 1335 | } |
1336 | 1336 | } |
1337 | - else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
1337 | + else if (($this->parent->parent) && strtolower($this->parent->parent->tag) === $tag_lower) |
|
1338 | 1338 | { |
1339 | 1339 | $this->parent->_[HDOM_INFO_END] = 0; |
1340 | 1340 | $this->parent = $this->parent->parent; |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1347 | 1347 | if ($this->parent->parent) $this->parent = $this->parent->parent; |
1348 | 1348 | |
1349 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1349 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1350 | 1350 | return true; |
1351 | 1351 | } |
1352 | 1352 | |
@@ -1357,25 +1357,25 @@ discard block |
||
1357 | 1357 | $node->tag_start = $begin_tag_pos; |
1358 | 1358 | |
1359 | 1359 | // doctype, cdata & comments... |
1360 | - if (isset($tag[0]) && $tag[0]==='!') { |
|
1361 | - $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>'); |
|
1360 | + if (isset($tag[0]) && $tag[0] === '!') { |
|
1361 | + $node->_[HDOM_INFO_TEXT] = '<'.$tag.$this->copy_until_char('>'); |
|
1362 | 1362 | |
1363 | - if (isset($tag[2]) && $tag[1]==='-' && $tag[2]==='-') { |
|
1363 | + if (isset($tag[2]) && $tag[1] === '-' && $tag[2] === '-') { |
|
1364 | 1364 | $node->nodetype = HDOM_TYPE_COMMENT; |
1365 | 1365 | $node->tag = 'comment'; |
1366 | 1366 | } else { |
1367 | 1367 | $node->nodetype = HDOM_TYPE_UNKNOWN; |
1368 | 1368 | $node->tag = 'unknown'; |
1369 | 1369 | } |
1370 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
1370 | + if ($this->char === '>') $node->_[HDOM_INFO_TEXT] .= '>'; |
|
1371 | 1371 | $this->link_nodes($node, true); |
1372 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1372 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1373 | 1373 | return true; |
1374 | 1374 | } |
1375 | 1375 | |
1376 | 1376 | // text |
1377 | - if ($pos=strpos($tag, '<')!==false) { |
|
1378 | - $tag = '<' . substr($tag, 0, -1); |
|
1377 | + if ($pos = strpos($tag, '<') !== false) { |
|
1378 | + $tag = '<'.substr($tag, 0, -1); |
|
1379 | 1379 | $node->_[HDOM_INFO_TEXT] = $tag; |
1380 | 1380 | $this->link_nodes($node, false); |
1381 | 1381 | $this->char = $this->doc[--$this->pos]; // prev |
@@ -1383,15 +1383,15 @@ discard block |
||
1383 | 1383 | } |
1384 | 1384 | |
1385 | 1385 | if (!preg_match("/^[\w-:]+$/", $tag)) { |
1386 | - $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>'); |
|
1387 | - if ($this->char==='<') { |
|
1386 | + $node->_[HDOM_INFO_TEXT] = '<'.$tag.$this->copy_until('<>'); |
|
1387 | + if ($this->char === '<') { |
|
1388 | 1388 | $this->link_nodes($node, false); |
1389 | 1389 | return true; |
1390 | 1390 | } |
1391 | 1391 | |
1392 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
1392 | + if ($this->char === '>') $node->_[HDOM_INFO_TEXT] .= '>'; |
|
1393 | 1393 | $this->link_nodes($node, false); |
1394 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1394 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1395 | 1395 | return true; |
1396 | 1396 | } |
1397 | 1397 | |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | $node->tag = ($this->lowercase) ? $tag_lower : $tag; |
1402 | 1402 | |
1403 | 1403 | // handle optional closing tags |
1404 | - if (isset($this->optional_closing_tags[$tag_lower]) ) |
|
1404 | + if (isset($this->optional_closing_tags[$tag_lower])) |
|
1405 | 1405 | { |
1406 | 1406 | while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)])) |
1407 | 1407 | { |
@@ -1417,67 +1417,67 @@ discard block |
||
1417 | 1417 | // attributes |
1418 | 1418 | do |
1419 | 1419 | { |
1420 | - if ($this->char!==null && $space[0]==='') |
|
1420 | + if ($this->char !== null && $space[0] === '') |
|
1421 | 1421 | { |
1422 | 1422 | break; |
1423 | 1423 | } |
1424 | 1424 | $name = $this->copy_until($this->token_equal); |
1425 | - if ($guard===$this->pos) |
|
1425 | + if ($guard === $this->pos) |
|
1426 | 1426 | { |
1427 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1427 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1428 | 1428 | continue; |
1429 | 1429 | } |
1430 | 1430 | $guard = $this->pos; |
1431 | 1431 | |
1432 | 1432 | // handle endless '<' |
1433 | - if ($this->pos>=$this->size-1 && $this->char!=='>') { |
|
1433 | + if ($this->pos >= $this->size - 1 && $this->char !== '>') { |
|
1434 | 1434 | $node->nodetype = HDOM_TYPE_TEXT; |
1435 | 1435 | $node->_[HDOM_INFO_END] = 0; |
1436 | - $node->_[HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name; |
|
1436 | + $node->_[HDOM_INFO_TEXT] = '<'.$tag.$space[0].$name; |
|
1437 | 1437 | $node->tag = 'text'; |
1438 | 1438 | $this->link_nodes($node, false); |
1439 | 1439 | return true; |
1440 | 1440 | } |
1441 | 1441 | |
1442 | 1442 | // handle mismatch '<' |
1443 | - if ($this->doc[$this->pos-1]=='<') { |
|
1443 | + if ($this->doc[$this->pos - 1] == '<') { |
|
1444 | 1444 | $node->nodetype = HDOM_TYPE_TEXT; |
1445 | 1445 | $node->tag = 'text'; |
1446 | 1446 | $node->attr = array(); |
1447 | 1447 | $node->_[HDOM_INFO_END] = 0; |
1448 | - $node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1); |
|
1448 | + $node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos - $begin_tag_pos - 1); |
|
1449 | 1449 | $this->pos -= 2; |
1450 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1450 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1451 | 1451 | $this->link_nodes($node, false); |
1452 | 1452 | return true; |
1453 | 1453 | } |
1454 | 1454 | |
1455 | - if ($name!=='/' && $name!=='') { |
|
1455 | + if ($name !== '/' && $name !== '') { |
|
1456 | 1456 | $space[1] = $this->copy_skip($this->token_blank); |
1457 | 1457 | $name = $this->restore_noise($name); |
1458 | 1458 | if ($this->lowercase) $name = strtolower($name); |
1459 | - if ($this->char==='=') { |
|
1460 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1459 | + if ($this->char === '=') { |
|
1460 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1461 | 1461 | $this->parse_attr($node, $name, $space); |
1462 | 1462 | } |
1463 | 1463 | else { |
1464 | 1464 | //no value attr: nowrap, checked selected... |
1465 | 1465 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
1466 | 1466 | $node->attr[$name] = true; |
1467 | - if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev |
|
1467 | + if ($this->char != '>') $this->char = $this->doc[--$this->pos]; // prev |
|
1468 | 1468 | } |
1469 | 1469 | $node->_[HDOM_INFO_SPACE][] = $space; |
1470 | 1470 | $space = array($this->copy_skip($this->token_blank), '', ''); |
1471 | 1471 | } |
1472 | 1472 | else |
1473 | 1473 | break; |
1474 | - } while ($this->char!=='>' && $this->char!=='/'); |
|
1474 | + } while ($this->char !== '>' && $this->char !== '/'); |
|
1475 | 1475 | |
1476 | 1476 | $this->link_nodes($node, true); |
1477 | 1477 | $node->_[HDOM_INFO_ENDSPACE] = $space[0]; |
1478 | 1478 | |
1479 | 1479 | // check self closing |
1480 | - if ($this->copy_until_char_escape('>')==='/') |
|
1480 | + if ($this->copy_until_char_escape('>') === '/') |
|
1481 | 1481 | { |
1482 | 1482 | $node->_[HDOM_INFO_ENDSPACE] .= '/'; |
1483 | 1483 | $node->_[HDOM_INFO_END] = 0; |
@@ -1487,7 +1487,7 @@ discard block |
||
1487 | 1487 | // reset parent |
1488 | 1488 | if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node; |
1489 | 1489 | } |
1490 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1490 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1491 | 1491 | |
1492 | 1492 | // If it's a BR tag, we need to set it's text to the default text. |
1493 | 1493 | // This way when we see it in plaintext, we can generate formatting that the user wants. |
@@ -1514,15 +1514,15 @@ discard block |
||
1514 | 1514 | switch ($this->char) { |
1515 | 1515 | case '"': |
1516 | 1516 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE; |
1517 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1517 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1518 | 1518 | $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"')); |
1519 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1519 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1520 | 1520 | break; |
1521 | 1521 | case '\'': |
1522 | 1522 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_SINGLE; |
1523 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1523 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1524 | 1524 | $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\'')); |
1525 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1525 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1526 | 1526 | break; |
1527 | 1527 | default: |
1528 | 1528 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
@@ -1553,16 +1553,16 @@ discard block |
||
1553 | 1553 | { |
1554 | 1554 | $node = new simple_html_dom_node($this); |
1555 | 1555 | ++$this->cursor; |
1556 | - $node->_[HDOM_INFO_TEXT] = '</' . $tag . '>'; |
|
1556 | + $node->_[HDOM_INFO_TEXT] = '</'.$tag.'>'; |
|
1557 | 1557 | $this->link_nodes($node, false); |
1558 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1558 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1559 | 1559 | return true; |
1560 | 1560 | } |
1561 | 1561 | |
1562 | 1562 | protected function skip($chars) |
1563 | 1563 | { |
1564 | 1564 | $this->pos += strspn($this->doc, $chars, $this->pos); |
1565 | - $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1565 | + $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1566 | 1566 | } |
1567 | 1567 | |
1568 | 1568 | protected function copy_skip($chars) |
@@ -1570,8 +1570,8 @@ discard block |
||
1570 | 1570 | $pos = $this->pos; |
1571 | 1571 | $len = strspn($this->doc, $chars, $pos); |
1572 | 1572 | $this->pos += $len; |
1573 | - $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1574 | - if ($len===0) return ''; |
|
1573 | + $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1574 | + if ($len === 0) return ''; |
|
1575 | 1575 | return substr($this->doc, $pos, $len); |
1576 | 1576 | } |
1577 | 1577 | |
@@ -1580,70 +1580,70 @@ discard block |
||
1580 | 1580 | $pos = $this->pos; |
1581 | 1581 | $len = strcspn($this->doc, $chars, $pos); |
1582 | 1582 | $this->pos += $len; |
1583 | - $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1583 | + $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1584 | 1584 | return substr($this->doc, $pos, $len); |
1585 | 1585 | } |
1586 | 1586 | |
1587 | 1587 | protected function copy_until_char($char) |
1588 | 1588 | { |
1589 | - if ($this->char===null) return ''; |
|
1589 | + if ($this->char === null) return ''; |
|
1590 | 1590 | |
1591 | - if (($pos = strpos($this->doc, $char, $this->pos))===false) { |
|
1592 | - $ret = substr($this->doc, $this->pos, $this->size-$this->pos); |
|
1591 | + if (($pos = strpos($this->doc, $char, $this->pos)) === false) { |
|
1592 | + $ret = substr($this->doc, $this->pos, $this->size - $this->pos); |
|
1593 | 1593 | $this->char = null; |
1594 | 1594 | $this->pos = $this->size; |
1595 | 1595 | return $ret; |
1596 | 1596 | } |
1597 | 1597 | |
1598 | - if ($pos===$this->pos) return ''; |
|
1598 | + if ($pos === $this->pos) return ''; |
|
1599 | 1599 | $pos_old = $this->pos; |
1600 | 1600 | $this->char = $this->doc[$pos]; |
1601 | 1601 | $this->pos = $pos; |
1602 | - return substr($this->doc, $pos_old, $pos-$pos_old); |
|
1602 | + return substr($this->doc, $pos_old, $pos - $pos_old); |
|
1603 | 1603 | } |
1604 | 1604 | |
1605 | 1605 | protected function copy_until_char_escape($char) |
1606 | 1606 | { |
1607 | - if ($this->char===null) return ''; |
|
1607 | + if ($this->char === null) return ''; |
|
1608 | 1608 | |
1609 | 1609 | $start = $this->pos; |
1610 | 1610 | while (1) |
1611 | 1611 | { |
1612 | - if (($pos = strpos($this->doc, $char, $start))===false) |
|
1612 | + if (($pos = strpos($this->doc, $char, $start)) === false) |
|
1613 | 1613 | { |
1614 | - $ret = substr($this->doc, $this->pos, $this->size-$this->pos); |
|
1614 | + $ret = substr($this->doc, $this->pos, $this->size - $this->pos); |
|
1615 | 1615 | $this->char = null; |
1616 | 1616 | $this->pos = $this->size; |
1617 | 1617 | return $ret; |
1618 | 1618 | } |
1619 | 1619 | |
1620 | - if ($pos===$this->pos) return ''; |
|
1620 | + if ($pos === $this->pos) return ''; |
|
1621 | 1621 | |
1622 | - if ($this->doc[$pos-1]==='\\') { |
|
1623 | - $start = $pos+1; |
|
1622 | + if ($this->doc[$pos - 1] === '\\') { |
|
1623 | + $start = $pos + 1; |
|
1624 | 1624 | continue; |
1625 | 1625 | } |
1626 | 1626 | |
1627 | 1627 | $pos_old = $this->pos; |
1628 | 1628 | $this->char = $this->doc[$pos]; |
1629 | 1629 | $this->pos = $pos; |
1630 | - return substr($this->doc, $pos_old, $pos-$pos_old); |
|
1630 | + return substr($this->doc, $pos_old, $pos - $pos_old); |
|
1631 | 1631 | } |
1632 | 1632 | } |
1633 | 1633 | |
1634 | 1634 | // remove noise from html content |
1635 | 1635 | // save the noise in the $this->noise array. |
1636 | - protected function remove_noise($pattern, $remove_tag=false) |
|
1636 | + protected function remove_noise($pattern, $remove_tag = false) |
|
1637 | 1637 | { |
1638 | 1638 | global $debug_object; |
1639 | 1639 | if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } |
1640 | 1640 | |
1641 | 1641 | $count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
1642 | 1642 | |
1643 | - for ($i=$count-1; $i>-1; --$i) |
|
1643 | + for ($i = $count - 1; $i > -1; --$i) |
|
1644 | 1644 | { |
1645 | - $key = '___noise___'.sprintf('% 5d', count($this->noise)+1000); |
|
1646 | - if (is_object($debug_object)) { $debug_object->debug_log(2, 'key is: ' . $key); } |
|
1645 | + $key = '___noise___'.sprintf('% 5d', count($this->noise) + 1000); |
|
1646 | + if (is_object($debug_object)) { $debug_object->debug_log(2, 'key is: '.$key); } |
|
1647 | 1647 | $idx = ($remove_tag) ? 0 : 1; |
1648 | 1648 | $this->noise[$key] = $matches[$i][$idx][0]; |
1649 | 1649 | $this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0])); |
@@ -1651,7 +1651,7 @@ discard block |
||
1651 | 1651 | |
1652 | 1652 | // reset the length of content |
1653 | 1653 | $this->size = strlen($this->doc); |
1654 | - if ($this->size>0) |
|
1654 | + if ($this->size > 0) |
|
1655 | 1655 | { |
1656 | 1656 | $this->char = $this->doc[0]; |
1657 | 1657 | } |
@@ -1663,28 +1663,28 @@ discard block |
||
1663 | 1663 | global $debug_object; |
1664 | 1664 | if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } |
1665 | 1665 | |
1666 | - while (($pos=strpos($text, '___noise___'))!==false) |
|
1666 | + while (($pos = strpos($text, '___noise___')) !== false) |
|
1667 | 1667 | { |
1668 | 1668 | // Sometimes there is a broken piece of markup, and we don't GET the pos+11 etc... token which indicates a problem outside of us... |
1669 | - if (strlen($text) > $pos+15) |
|
1669 | + if (strlen($text) > $pos + 15) |
|
1670 | 1670 | { |
1671 | - $key = '___noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13].$text[$pos+14].$text[$pos+15]; |
|
1672 | - if (is_object($debug_object)) { $debug_object->debug_log(2, 'located key of: ' . $key); } |
|
1671 | + $key = '___noise___'.$text[$pos + 11].$text[$pos + 12].$text[$pos + 13].$text[$pos + 14].$text[$pos + 15]; |
|
1672 | + if (is_object($debug_object)) { $debug_object->debug_log(2, 'located key of: '.$key); } |
|
1673 | 1673 | |
1674 | 1674 | if (isset($this->noise[$key])) |
1675 | 1675 | { |
1676 | - $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16); |
|
1676 | + $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos + 16); |
|
1677 | 1677 | } |
1678 | 1678 | else |
1679 | 1679 | { |
1680 | 1680 | // do this to prevent an infinite loop. |
1681 | - $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16); |
|
1681 | + $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key.substr($text, $pos + 16); |
|
1682 | 1682 | } |
1683 | 1683 | } |
1684 | 1684 | else |
1685 | 1685 | { |
1686 | 1686 | // There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem. |
1687 | - $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11); |
|
1687 | + $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY'.substr($text, $pos + 11); |
|
1688 | 1688 | } |
1689 | 1689 | } |
1690 | 1690 | return $text; |
@@ -1696,9 +1696,9 @@ discard block |
||
1696 | 1696 | global $debug_object; |
1697 | 1697 | if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } |
1698 | 1698 | |
1699 | - foreach($this->noise as $noiseElement) |
|
1699 | + foreach ($this->noise as $noiseElement) |
|
1700 | 1700 | { |
1701 | - if (strpos($noiseElement, $text)!==false) |
|
1701 | + if (strpos($noiseElement, $text) !== false) |
|
1702 | 1702 | { |
1703 | 1703 | return $noiseElement; |
1704 | 1704 | } |
@@ -1727,16 +1727,16 @@ discard block |
||
1727 | 1727 | } |
1728 | 1728 | |
1729 | 1729 | // camel naming conventions |
1730 | - function childNodes($idx=-1) {return $this->root->childNodes($idx);} |
|
1731 | - function firstChild() {return $this->root->first_child();} |
|
1732 | - function lastChild() {return $this->root->last_child();} |
|
1733 | - function createElement($name, $value=null) {return @str_get_html("<$name>$value</$name>")->first_child();} |
|
1734 | - function createTextNode($value) {return @end(str_get_html($value)->nodes);} |
|
1735 | - function getElementById($id) {return $this->find("#$id", 0);} |
|
1736 | - function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);} |
|
1737 | - function getElementByTagName($name) {return $this->find($name, 0);} |
|
1738 | - function getElementsByTagName($name, $idx=-1) {return $this->find($name, $idx);} |
|
1739 | - function loadFile() {$args = func_get_args();$this->load_file($args);} |
|
1730 | + function childNodes($idx = -1) {return $this->root->childNodes($idx); } |
|
1731 | + function firstChild() {return $this->root->first_child(); } |
|
1732 | + function lastChild() {return $this->root->last_child(); } |
|
1733 | + function createElement($name, $value = null) {return @str_get_html("<$name>$value</$name>")->first_child(); } |
|
1734 | + function createTextNode($value) {return @end(str_get_html($value)->nodes); } |
|
1735 | + function getElementById($id) {return $this->find("#$id", 0); } |
|
1736 | + function getElementsById($id, $idx = null) {return $this->find("#$id", $idx); } |
|
1737 | + function getElementByTagName($name) {return $this->find($name, 0); } |
|
1738 | + function getElementsByTagName($name, $idx = -1) {return $this->find($name, $idx); } |
|
1739 | + function loadFile() {$args = func_get_args(); $this->load_file($args); } |
|
1740 | 1740 | } |
1741 | 1741 | |
1742 | 1742 | ?> |
1743 | 1743 | \ No newline at end of file |
@@ -159,8 +159,9 @@ discard block |
||
159 | 159 | if ($show_attr && count($this->attr)>0) |
160 | 160 | { |
161 | 161 | echo '('; |
162 | - foreach ($this->attr as $k=>$v) |
|
163 | - echo "[$k]=>\"".$this->$k.'", '; |
|
162 | + foreach ($this->attr as $k=>$v) { |
|
163 | + echo "[$k]=>\"".$this->$k.'", '; |
|
164 | + } |
|
164 | 165 | echo ')'; |
165 | 166 | } |
166 | 167 | echo "\n"; |
@@ -218,8 +219,7 @@ discard block |
||
218 | 219 | if (isset($node->_[HDOM_INFO_INNER])) |
219 | 220 | { |
220 | 221 | $string .= $node->_[HDOM_INFO_INNER] . "'"; |
221 | - } |
|
222 | - else |
|
222 | + } else |
|
223 | 223 | { |
224 | 224 | $string .= ' NULL '; |
225 | 225 | } |
@@ -233,8 +233,7 @@ discard block |
||
233 | 233 | { |
234 | 234 | echo $string; |
235 | 235 | return; |
236 | - } |
|
237 | - else |
|
236 | + } else |
|
238 | 237 | { |
239 | 238 | return $string; |
240 | 239 | } |
@@ -320,12 +319,17 @@ discard block |
||
320 | 319 | // returns the previous sibling of node |
321 | 320 | function prev_sibling() |
322 | 321 | { |
323 | - if ($this->parent===null) return null; |
|
322 | + if ($this->parent===null) { |
|
323 | + return null; |
|
324 | + } |
|
324 | 325 | $idx = 0; |
325 | 326 | $count = count($this->parent->children); |
326 | - while ($idx<$count && $this!==$this->parent->children[$idx]) |
|
327 | - ++$idx; |
|
328 | - if (--$idx<0) return null; |
|
327 | + while ($idx<$count && $this!==$this->parent->children[$idx]) { |
|
328 | + ++$idx; |
|
329 | + } |
|
330 | + if (--$idx<0) { |
|
331 | + return null; |
|
332 | + } |
|
329 | 333 | return $this->parent->children[$idx]; |
330 | 334 | } |
331 | 335 | |
@@ -354,12 +358,17 @@ discard block |
||
354 | 358 | // get dom node's inner html |
355 | 359 | function innertext() |
356 | 360 | { |
357 | - if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; |
|
358 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
361 | + if (isset($this->_[HDOM_INFO_INNER])) { |
|
362 | + return $this->_[HDOM_INFO_INNER]; |
|
363 | + } |
|
364 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
365 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
366 | + } |
|
359 | 367 | |
360 | 368 | $ret = ''; |
361 | - foreach ($this->nodes as $n) |
|
362 | - $ret .= $n->outertext(); |
|
369 | + foreach ($this->nodes as $n) { |
|
370 | + $ret .= $n->outertext(); |
|
371 | + } |
|
363 | 372 | return $ret; |
364 | 373 | } |
365 | 374 | |
@@ -380,7 +389,9 @@ discard block |
||
380 | 389 | $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text); |
381 | 390 | } |
382 | 391 | |
383 | - if ($this->tag==='root') return $this->innertext(); |
|
392 | + if ($this->tag==='root') { |
|
393 | + return $this->innertext(); |
|
394 | + } |
|
384 | 395 | |
385 | 396 | // trigger callback |
386 | 397 | if ($this->dom && $this->dom->callback!==null) |
@@ -388,8 +399,12 @@ discard block |
||
388 | 399 | call_user_func_array($this->dom->callback, array($this)); |
389 | 400 | } |
390 | 401 | |
391 | - if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER]; |
|
392 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
402 | + if (isset($this->_[HDOM_INFO_OUTER])) { |
|
403 | + return $this->_[HDOM_INFO_OUTER]; |
|
404 | + } |
|
405 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
406 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
407 | + } |
|
393 | 408 | |
394 | 409 | // render begin tag |
395 | 410 | if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) |
@@ -418,23 +433,30 @@ discard block |
||
418 | 433 | } |
419 | 434 | |
420 | 435 | // render end tag |
421 | - if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) |
|
422 | - $ret .= '</'.$this->tag.'>'; |
|
436 | + if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) { |
|
437 | + $ret .= '</'.$this->tag.'>'; |
|
438 | + } |
|
423 | 439 | return $ret; |
424 | 440 | } |
425 | 441 | |
426 | 442 | // get dom node's plain text |
427 | 443 | function text() |
428 | 444 | { |
429 | - if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; |
|
445 | + if (isset($this->_[HDOM_INFO_INNER])) { |
|
446 | + return $this->_[HDOM_INFO_INNER]; |
|
447 | + } |
|
430 | 448 | switch ($this->nodetype) |
431 | 449 | { |
432 | 450 | case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
433 | 451 | case HDOM_TYPE_COMMENT: return ''; |
434 | 452 | case HDOM_TYPE_UNKNOWN: return ''; |
435 | 453 | } |
436 | - if (strcasecmp($this->tag, 'script')===0) return ''; |
|
437 | - if (strcasecmp($this->tag, 'style')===0) return ''; |
|
454 | + if (strcasecmp($this->tag, 'script')===0) { |
|
455 | + return ''; |
|
456 | + } |
|
457 | + if (strcasecmp($this->tag, 'style')===0) { |
|
458 | + return ''; |
|
459 | + } |
|
438 | 460 | |
439 | 461 | $ret = ''; |
440 | 462 | // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. |
@@ -470,7 +492,9 @@ discard block |
||
470 | 492 | function makeup() |
471 | 493 | { |
472 | 494 | // text, comment, unknown |
473 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
495 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
496 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
497 | + } |
|
474 | 498 | |
475 | 499 | $ret = '<'.$this->tag; |
476 | 500 | $i = -1; |
@@ -480,14 +504,15 @@ discard block |
||
480 | 504 | ++$i; |
481 | 505 | |
482 | 506 | // skip removed attribute |
483 | - if ($val===null || $val===false) |
|
484 | - continue; |
|
507 | + if ($val===null || $val===false) { |
|
508 | + continue; |
|
509 | + } |
|
485 | 510 | |
486 | 511 | $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; |
487 | 512 | //no value attr: nowrap, checked selected... |
488 | - if ($val===true) |
|
489 | - $ret .= $key; |
|
490 | - else { |
|
513 | + if ($val===true) { |
|
514 | + $ret .= $key; |
|
515 | + } else { |
|
491 | 516 | switch ($this->_[HDOM_INFO_QUOTE][$i]) |
492 | 517 | { |
493 | 518 | case HDOM_QUOTE_DOUBLE: $quote = '"'; break; |
@@ -506,7 +531,9 @@ discard block |
||
506 | 531 | function find($selector, $idx=null, $lowercase=false) |
507 | 532 | { |
508 | 533 | $selectors = $this->parse_selector($selector); |
509 | - if (($count=count($selectors))===0) return array(); |
|
534 | + if (($count=count($selectors))===0) { |
|
535 | + return array(); |
|
536 | + } |
|
510 | 537 | $found_keys = array(); |
511 | 538 | |
512 | 539 | // find each selector |
@@ -514,8 +541,12 @@ discard block |
||
514 | 541 | { |
515 | 542 | // The change on the below line was documented on the sourceforge code tracker id 2788009 |
516 | 543 | // used to be: if (($levle=count($selectors[0]))===0) return array(); |
517 | - if (($levle=count($selectors[$c]))===0) return array(); |
|
518 | - if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); |
|
544 | + if (($levle=count($selectors[$c]))===0) { |
|
545 | + return array(); |
|
546 | + } |
|
547 | + if (!isset($this->_[HDOM_INFO_BEGIN])) { |
|
548 | + return array(); |
|
549 | + } |
|
519 | 550 | |
520 | 551 | $head = array($this->_[HDOM_INFO_BEGIN]=>1); |
521 | 552 | |
@@ -545,12 +576,16 @@ discard block |
||
545 | 576 | ksort($found_keys); |
546 | 577 | |
547 | 578 | $found = array(); |
548 | - foreach ($found_keys as $k=>$v) |
|
549 | - $found[] = $this->dom->nodes[$k]; |
|
579 | + foreach ($found_keys as $k=>$v) { |
|
580 | + $found[] = $this->dom->nodes[$k]; |
|
581 | + } |
|
550 | 582 | |
551 | 583 | // return nth-element or array |
552 | - if (is_null($idx)) return $found; |
|
553 | - else if ($idx<0) $idx = count($found) + $idx; |
|
584 | + if (is_null($idx)) { |
|
585 | + return $found; |
|
586 | + } else if ($idx<0) { |
|
587 | + $idx = count($found) + $idx; |
|
588 | + } |
|
554 | 589 | return (isset($found[$idx])) ? $found[$idx] : null; |
555 | 590 | } |
556 | 591 | |
@@ -595,8 +630,9 @@ discard block |
||
595 | 630 | $pass = true; |
596 | 631 | |
597 | 632 | if ($tag==='*' && !$key) { |
598 | - if (in_array($node, $this->children, true)) |
|
599 | - $ret[$i] = 1; |
|
633 | + if (in_array($node, $this->children, true)) { |
|
634 | + $ret[$i] = 1; |
|
635 | + } |
|
600 | 636 | continue; |
601 | 637 | } |
602 | 638 | |
@@ -605,9 +641,13 @@ discard block |
||
605 | 641 | // compare key |
606 | 642 | if ($pass && $key) { |
607 | 643 | if ($no_key) { |
608 | - if (isset($node->attr[$key])) $pass=false; |
|
644 | + if (isset($node->attr[$key])) { |
|
645 | + $pass=false; |
|
646 | + } |
|
609 | 647 | } else { |
610 | - if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false; |
|
648 | + if (($key != "plaintext") && !isset($node->attr[$key])) { |
|
649 | + $pass=false; |
|
650 | + } |
|
611 | 651 | } |
612 | 652 | } |
613 | 653 | // compare value |
@@ -640,13 +680,19 @@ discard block |
||
640 | 680 | } else { |
641 | 681 | $check = $this->match($exp, $val, $k); |
642 | 682 | } |
643 | - if ($check) break; |
|
683 | + if ($check) { |
|
684 | + break; |
|
685 | + } |
|
644 | 686 | } |
645 | 687 | } |
646 | 688 | } |
647 | - if (!$check) $pass = false; |
|
689 | + if (!$check) { |
|
690 | + $pass = false; |
|
691 | + } |
|
692 | + } |
|
693 | + if ($pass) { |
|
694 | + $ret[$i] = 1; |
|
648 | 695 | } |
649 | - if ($pass) $ret[$i] = 1; |
|
650 | 696 | unset($node); |
651 | 697 | } |
652 | 698 | // It's passed by reference so this is actually what this function returns. |
@@ -696,9 +742,13 @@ discard block |
||
696 | 742 | |
697 | 743 | foreach ($matches as $m) { |
698 | 744 | $m[0] = trim($m[0]); |
699 | - if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue; |
|
745 | + if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') { |
|
746 | + continue; |
|
747 | + } |
|
700 | 748 | // for browser generated xpath |
701 | - if ($m[1]==='tbody') continue; |
|
749 | + if ($m[1]==='tbody') { |
|
750 | + continue; |
|
751 | + } |
|
702 | 752 | |
703 | 753 | list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); |
704 | 754 | if (!empty($m[2])) {$key='id'; $val=$m[2];} |
@@ -718,8 +768,9 @@ discard block |
||
718 | 768 | $result = array(); |
719 | 769 | } |
720 | 770 | } |
721 | - if (count($result)>0) |
|
722 | - $selectors[] = $result; |
|
771 | + if (count($result)>0) { |
|
772 | + $selectors[] = $result; |
|
773 | + } |
|
723 | 774 | return $selectors; |
724 | 775 | } |
725 | 776 | |
@@ -748,7 +799,9 @@ discard block |
||
748 | 799 | { |
749 | 800 | case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value; |
750 | 801 | case 'innertext': |
751 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value; |
|
802 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
803 | + return $this->_[HDOM_INFO_TEXT] = $value; |
|
804 | + } |
|
752 | 805 | return $this->_[HDOM_INFO_INNER] = $value; |
753 | 806 | } |
754 | 807 | if (!isset($this->attr[$name])) |
@@ -772,8 +825,9 @@ discard block |
||
772 | 825 | } |
773 | 826 | |
774 | 827 | function __unset($name) { |
775 | - if (isset($this->attr[$name])) |
|
776 | - unset($this->attr[$name]); |
|
828 | + if (isset($this->attr[$name])) { |
|
829 | + unset($this->attr[$name]); |
|
830 | + } |
|
777 | 831 | } |
778 | 832 | |
779 | 833 | // PaperG - Function to convert the text from one character set to another if the two sets are not the same. |
@@ -800,8 +854,7 @@ discard block |
||
800 | 854 | if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text))) |
801 | 855 | { |
802 | 856 | $converted_text = $text; |
803 | - } |
|
804 | - else |
|
857 | + } else |
|
805 | 858 | { |
806 | 859 | $converted_text = iconv($sourceCharset, $targetCharset, $text); |
807 | 860 | } |
@@ -839,19 +892,31 @@ discard block |
||
839 | 892 | $c=ord($str[$i]); |
840 | 893 | if($c > 128) |
841 | 894 | { |
842 | - if(($c >= 254)) return false; |
|
843 | - elseif($c >= 252) $bits=6; |
|
844 | - elseif($c >= 248) $bits=5; |
|
845 | - elseif($c >= 240) $bits=4; |
|
846 | - elseif($c >= 224) $bits=3; |
|
847 | - elseif($c >= 192) $bits=2; |
|
848 | - else return false; |
|
849 | - if(($i+$bits) > $len) return false; |
|
895 | + if(($c >= 254)) { |
|
896 | + return false; |
|
897 | + } elseif($c >= 252) { |
|
898 | + $bits=6; |
|
899 | + } elseif($c >= 248) { |
|
900 | + $bits=5; |
|
901 | + } elseif($c >= 240) { |
|
902 | + $bits=4; |
|
903 | + } elseif($c >= 224) { |
|
904 | + $bits=3; |
|
905 | + } elseif($c >= 192) { |
|
906 | + $bits=2; |
|
907 | + } else { |
|
908 | + return false; |
|
909 | + } |
|
910 | + if(($i+$bits) > $len) { |
|
911 | + return false; |
|
912 | + } |
|
850 | 913 | while($bits > 1) |
851 | 914 | { |
852 | 915 | $i++; |
853 | 916 | $b=ord($str[$i]); |
854 | - if($b < 128 || $b > 191) return false; |
|
917 | + if($b < 128 || $b > 191) { |
|
918 | + return false; |
|
919 | + } |
|
855 | 920 | $bits--; |
856 | 921 | } |
857 | 922 | } |
@@ -1035,8 +1100,7 @@ discard block |
||
1035 | 1100 | if (preg_match("/^http:\/\//i",$str) || is_file($str)) |
1036 | 1101 | { |
1037 | 1102 | $this->load_file($str); |
1038 | - } |
|
1039 | - else |
|
1103 | + } else |
|
1040 | 1104 | { |
1041 | 1105 | $this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText); |
1042 | 1106 | } |
@@ -1118,7 +1182,9 @@ discard block |
||
1118 | 1182 | function save($filepath='') |
1119 | 1183 | { |
1120 | 1184 | $ret = $this->root->innertext(); |
1121 | - if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX); |
|
1185 | + if ($filepath!=='') { |
|
1186 | + file_put_contents($filepath, $ret, LOCK_EX); |
|
1187 | + } |
|
1122 | 1188 | return $ret; |
1123 | 1189 | } |
1124 | 1190 | |
@@ -1134,7 +1200,10 @@ discard block |
||
1134 | 1200 | { |
1135 | 1201 | foreach ($this->nodes as $n) {$n->clear(); $n = null;} |
1136 | 1202 | // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear. |
1137 | - if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;} |
|
1203 | + if (isset($this->children)) { |
|
1204 | + foreach ($this->children as $n) {$n->clear(); |
|
1205 | + } |
|
1206 | + $n = null;} |
|
1138 | 1207 | if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);} |
1139 | 1208 | if (isset($this->root)) {$this->root->clear(); unset($this->root);} |
1140 | 1209 | unset($this->doc); |
@@ -1178,7 +1247,9 @@ discard block |
||
1178 | 1247 | $this->root->_[HDOM_INFO_BEGIN] = -1; |
1179 | 1248 | $this->root->nodetype = HDOM_TYPE_ROOT; |
1180 | 1249 | $this->parent = $this->root; |
1181 | - if ($this->size>0) $this->char = $this->doc[0]; |
|
1250 | + if ($this->size>0) { |
|
1251 | + $this->char = $this->doc[0]; |
|
1252 | + } |
|
1182 | 1253 | } |
1183 | 1254 | |
1184 | 1255 | // parse html content |
@@ -1232,8 +1303,7 @@ discard block |
||
1232 | 1303 | if ($success) |
1233 | 1304 | { |
1234 | 1305 | $charset = $matches[1]; |
1235 | - } |
|
1236 | - else |
|
1306 | + } else |
|
1237 | 1307 | { |
1238 | 1308 | // If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1 |
1239 | 1309 | if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');} |
@@ -1296,8 +1366,9 @@ discard block |
||
1296 | 1366 | $tag = $this->copy_until_char('>'); |
1297 | 1367 | |
1298 | 1368 | // skip attributes in end tag |
1299 | - if (($pos = strpos($tag, ' '))!==false) |
|
1300 | - $tag = substr($tag, 0, $pos); |
|
1369 | + if (($pos = strpos($tag, ' '))!==false) { |
|
1370 | + $tag = substr($tag, 0, $pos); |
|
1371 | + } |
|
1301 | 1372 | |
1302 | 1373 | $parent_lower = strtolower($this->parent->tag); |
1303 | 1374 | $tag_lower = strtolower($tag); |
@@ -1309,23 +1380,26 @@ discard block |
||
1309 | 1380 | $this->parent->_[HDOM_INFO_END] = 0; |
1310 | 1381 | $org_parent = $this->parent; |
1311 | 1382 | |
1312 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
1313 | - $this->parent = $this->parent->parent; |
|
1383 | + while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) { |
|
1384 | + $this->parent = $this->parent->parent; |
|
1385 | + } |
|
1314 | 1386 | |
1315 | 1387 | if (strtolower($this->parent->tag)!==$tag_lower) { |
1316 | 1388 | $this->parent = $org_parent; // restore origonal parent |
1317 | - if ($this->parent->parent) $this->parent = $this->parent->parent; |
|
1389 | + if ($this->parent->parent) { |
|
1390 | + $this->parent = $this->parent->parent; |
|
1391 | + } |
|
1318 | 1392 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1319 | 1393 | return $this->as_text_node($tag); |
1320 | 1394 | } |
1321 | - } |
|
1322 | - else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) |
|
1395 | + } else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) |
|
1323 | 1396 | { |
1324 | 1397 | $this->parent->_[HDOM_INFO_END] = 0; |
1325 | 1398 | $org_parent = $this->parent; |
1326 | 1399 | |
1327 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
1328 | - $this->parent = $this->parent->parent; |
|
1400 | + while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) { |
|
1401 | + $this->parent = $this->parent->parent; |
|
1402 | + } |
|
1329 | 1403 | |
1330 | 1404 | if (strtolower($this->parent->tag)!==$tag_lower) |
1331 | 1405 | { |
@@ -1333,18 +1407,19 @@ discard block |
||
1333 | 1407 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1334 | 1408 | return $this->as_text_node($tag); |
1335 | 1409 | } |
1336 | - } |
|
1337 | - else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
1410 | + } else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
1338 | 1411 | { |
1339 | 1412 | $this->parent->_[HDOM_INFO_END] = 0; |
1340 | 1413 | $this->parent = $this->parent->parent; |
1414 | + } else { |
|
1415 | + return $this->as_text_node($tag); |
|
1341 | 1416 | } |
1342 | - else |
|
1343 | - return $this->as_text_node($tag); |
|
1344 | 1417 | } |
1345 | 1418 | |
1346 | 1419 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1347 | - if ($this->parent->parent) $this->parent = $this->parent->parent; |
|
1420 | + if ($this->parent->parent) { |
|
1421 | + $this->parent = $this->parent->parent; |
|
1422 | + } |
|
1348 | 1423 | |
1349 | 1424 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1350 | 1425 | return true; |
@@ -1367,7 +1442,9 @@ discard block |
||
1367 | 1442 | $node->nodetype = HDOM_TYPE_UNKNOWN; |
1368 | 1443 | $node->tag = 'unknown'; |
1369 | 1444 | } |
1370 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
1445 | + if ($this->char==='>') { |
|
1446 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
1447 | + } |
|
1371 | 1448 | $this->link_nodes($node, true); |
1372 | 1449 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1373 | 1450 | return true; |
@@ -1389,7 +1466,9 @@ discard block |
||
1389 | 1466 | return true; |
1390 | 1467 | } |
1391 | 1468 | |
1392 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
1469 | + if ($this->char==='>') { |
|
1470 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
1471 | + } |
|
1393 | 1472 | $this->link_nodes($node, false); |
1394 | 1473 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1395 | 1474 | return true; |
@@ -1455,22 +1534,26 @@ discard block |
||
1455 | 1534 | if ($name!=='/' && $name!=='') { |
1456 | 1535 | $space[1] = $this->copy_skip($this->token_blank); |
1457 | 1536 | $name = $this->restore_noise($name); |
1458 | - if ($this->lowercase) $name = strtolower($name); |
|
1537 | + if ($this->lowercase) { |
|
1538 | + $name = strtolower($name); |
|
1539 | + } |
|
1459 | 1540 | if ($this->char==='=') { |
1460 | 1541 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1461 | 1542 | $this->parse_attr($node, $name, $space); |
1462 | - } |
|
1463 | - else { |
|
1543 | + } else { |
|
1464 | 1544 | //no value attr: nowrap, checked selected... |
1465 | 1545 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
1466 | 1546 | $node->attr[$name] = true; |
1467 | - if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev |
|
1547 | + if ($this->char!='>') { |
|
1548 | + $this->char = $this->doc[--$this->pos]; |
|
1549 | + } |
|
1550 | + // prev |
|
1468 | 1551 | } |
1469 | 1552 | $node->_[HDOM_INFO_SPACE][] = $space; |
1470 | 1553 | $space = array($this->copy_skip($this->token_blank), '', ''); |
1554 | + } else { |
|
1555 | + break; |
|
1471 | 1556 | } |
1472 | - else |
|
1473 | - break; |
|
1474 | 1557 | } while ($this->char!=='>' && $this->char!=='/'); |
1475 | 1558 | |
1476 | 1559 | $this->link_nodes($node, true); |
@@ -1481,11 +1564,12 @@ discard block |
||
1481 | 1564 | { |
1482 | 1565 | $node->_[HDOM_INFO_ENDSPACE] .= '/'; |
1483 | 1566 | $node->_[HDOM_INFO_END] = 0; |
1484 | - } |
|
1485 | - else |
|
1567 | + } else |
|
1486 | 1568 | { |
1487 | 1569 | // reset parent |
1488 | - if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node; |
|
1570 | + if (!isset($this->self_closing_tags[strtolower($node->tag)])) { |
|
1571 | + $this->parent = $node; |
|
1572 | + } |
|
1489 | 1573 | } |
1490 | 1574 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1491 | 1575 | |
@@ -1571,7 +1655,9 @@ discard block |
||
1571 | 1655 | $len = strspn($this->doc, $chars, $pos); |
1572 | 1656 | $this->pos += $len; |
1573 | 1657 | $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1574 | - if ($len===0) return ''; |
|
1658 | + if ($len===0) { |
|
1659 | + return ''; |
|
1660 | + } |
|
1575 | 1661 | return substr($this->doc, $pos, $len); |
1576 | 1662 | } |
1577 | 1663 | |
@@ -1586,7 +1672,9 @@ discard block |
||
1586 | 1672 | |
1587 | 1673 | protected function copy_until_char($char) |
1588 | 1674 | { |
1589 | - if ($this->char===null) return ''; |
|
1675 | + if ($this->char===null) { |
|
1676 | + return ''; |
|
1677 | + } |
|
1590 | 1678 | |
1591 | 1679 | if (($pos = strpos($this->doc, $char, $this->pos))===false) { |
1592 | 1680 | $ret = substr($this->doc, $this->pos, $this->size-$this->pos); |
@@ -1595,7 +1683,9 @@ discard block |
||
1595 | 1683 | return $ret; |
1596 | 1684 | } |
1597 | 1685 | |
1598 | - if ($pos===$this->pos) return ''; |
|
1686 | + if ($pos===$this->pos) { |
|
1687 | + return ''; |
|
1688 | + } |
|
1599 | 1689 | $pos_old = $this->pos; |
1600 | 1690 | $this->char = $this->doc[$pos]; |
1601 | 1691 | $this->pos = $pos; |
@@ -1604,7 +1694,9 @@ discard block |
||
1604 | 1694 | |
1605 | 1695 | protected function copy_until_char_escape($char) |
1606 | 1696 | { |
1607 | - if ($this->char===null) return ''; |
|
1697 | + if ($this->char===null) { |
|
1698 | + return ''; |
|
1699 | + } |
|
1608 | 1700 | |
1609 | 1701 | $start = $this->pos; |
1610 | 1702 | while (1) |
@@ -1617,7 +1709,9 @@ discard block |
||
1617 | 1709 | return $ret; |
1618 | 1710 | } |
1619 | 1711 | |
1620 | - if ($pos===$this->pos) return ''; |
|
1712 | + if ($pos===$this->pos) { |
|
1713 | + return ''; |
|
1714 | + } |
|
1621 | 1715 | |
1622 | 1716 | if ($this->doc[$pos-1]==='\\') { |
1623 | 1717 | $start = $pos+1; |
@@ -1674,14 +1768,12 @@ discard block |
||
1674 | 1768 | if (isset($this->noise[$key])) |
1675 | 1769 | { |
1676 | 1770 | $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16); |
1677 | - } |
|
1678 | - else |
|
1771 | + } else |
|
1679 | 1772 | { |
1680 | 1773 | // do this to prevent an infinite loop. |
1681 | 1774 | $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16); |
1682 | 1775 | } |
1683 | - } |
|
1684 | - else |
|
1776 | + } else |
|
1685 | 1777 | { |
1686 | 1778 | // There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem. |
1687 | 1779 | $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11); |
@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
8 | -$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
8 | +$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
9 | 9 | |
10 | 10 | if (!empty($spotter_array)) |
11 | 11 | { |
12 | - $title = sprintf(_("Most Common Aircraft Manufacturer on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
12 | + $title = sprintf(_("Most Common Aircraft Manufacturer on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
13 | 13 | |
14 | 14 | require_once('header.php'); |
15 | 15 | print '<div class="select-item">'; |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
28 | 28 | print '<br />'; |
29 | 29 | print '<div class="info column">'; |
30 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
30 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
31 | 31 | print '</div>'; |
32 | 32 | |
33 | 33 | include('date-sub-menu.php'); |
34 | 34 | print '<div class="column">'; |
35 | 35 | print '<h2>'._("Most Common Aircraft Manufacturer").'</h2>'; |
36 | - print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
36 | + print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
37 | 37 | |
38 | 38 | $manufacturers_array = $Spotter->countAllAircraftManufacturerByDate($date); |
39 | 39 | if (!empty($manufacturers_array)) |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | print '</thead>'; |
49 | 49 | print '<tbody>'; |
50 | 50 | $i = 1; |
51 | - foreach($manufacturers_array as $manufacturer_item) |
|
51 | + foreach ($manufacturers_array as $manufacturer_item) |
|
52 | 52 | { |
53 | 53 | print '<tr>'; |
54 | 54 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
8 | -$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
8 | +$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
9 | 9 | |
10 | 10 | if (!empty($spotter_array)) |
11 | 11 | { |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
28 | 28 | print '<br />'; |
29 | 29 | print '<div class="info column">'; |
30 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
30 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
31 | 31 | print '</div>'; |
32 | 32 | |
33 | 33 | include('date-sub-menu.php'); |
34 | 34 | print '<div class="column">'; |
35 | 35 | print '<h2>'._("Most Common Aircraft by Registration").'</h2>'; |
36 | - print '<p>'.sprintf(_("The statistic below shows the most common aircraft by registration of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
36 | + print '<p>'.sprintf(_("The statistic below shows the most common aircraft by registration of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
37 | 37 | |
38 | 38 | $aircraft_array = $Spotter->countAllAircraftRegistrationByDate($date); |
39 | 39 | if (!empty($aircraft_array)) |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | print '</thead>'; |
51 | 51 | print '<tbody>'; |
52 | 52 | $i = 1; |
53 | - foreach($aircraft_array as $aircraft_item) |
|
53 | + foreach ($aircraft_array as $aircraft_item) |
|
54 | 54 | { |
55 | 55 | print '<tr>'; |
56 | 56 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | if (isset($aircraft_item['aircraft_type'])) { |
61 | 61 | print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$aircraft_item['image_thumbnail'].'" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_type'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:").' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>'; |
62 | 62 | } else { |
63 | - print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$aircraft_item['image_thumbnail'].'" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:");' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>'; |
|
63 | + print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$aircraft_item['image_thumbnail'].'" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:"); ' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>'; |
|
64 | 64 | } |
65 | 65 | print '</td>'; |
66 | 66 | } else { |