@@ -4,10 +4,15 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | setcookie("MapFormat",'2d'); |
| 6 | 6 | |
| 7 | -if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = ''; |
|
| 7 | +if (!isset($globalOpenWeatherMapKey)) { |
|
| 8 | + $globalOpenWeatherMapKey = ''; |
|
| 9 | +} |
|
| 8 | 10 | // Compressed GeoJson is used if true |
| 9 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 10 | -else $compress = $globalJsonCompress; |
|
| 11 | +if (!isset($globalJsonCompress)) { |
|
| 12 | + $compress = true; |
|
| 13 | +} else { |
|
| 14 | + $compress = $globalJsonCompress; |
|
| 15 | +} |
|
| 11 | 16 | if (isset($_GET['archive'])) { |
| 12 | 17 | $archive = true; |
| 13 | 18 | //$archiveupdatetime = 50; |
@@ -18,8 +23,11 @@ discard block |
||
| 18 | 23 | //$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10)); |
| 19 | 24 | //$lastupd = 20; |
| 20 | 25 | $lastupd = $_GET['archivespeed']*$archiveupdatetime; |
| 21 | - if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate']; |
|
| 22 | - else $enddate = time(); |
|
| 26 | + if (isset($_GET['enddate']) && $_GET['enddate'] != '') { |
|
| 27 | + $enddate = $_GET['enddate']; |
|
| 28 | + } else { |
|
| 29 | + $enddate = time(); |
|
| 30 | + } |
|
| 23 | 31 | setcookie("archive_begin",$begindate); |
| 24 | 32 | setcookie("archive_end",$enddate); |
| 25 | 33 | setcookie("archive_update",$lastupd); |
@@ -107,7 +115,17 @@ discard block |
||
| 107 | 115 | } |
| 108 | 116 | |
| 109 | 117 | //create the map |
| 110 | - map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom); |
|
| 118 | + map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) { |
|
| 119 | + print $latitude; |
|
| 120 | +} else { |
|
| 121 | + print $globalCenterLatitude; |
|
| 122 | +} |
|
| 123 | +?>,<?php if (isset($longitude)) { |
|
| 124 | + print $longitude; |
|
| 125 | +} else { |
|
| 126 | + print $globalCenterLongitude; |
|
| 127 | +} |
|
| 128 | +?>], zoom); |
|
| 111 | 129 | <?php |
| 112 | 130 | } else { |
| 113 | 131 | if ((isset($globalCenterLatitude) && $globalCenterLatitude != '' && isset($globalCenterLongitude) && $globalCenterLongitude != '') || isset($_COOKIE['lastcentercoord'])) { |
@@ -133,9 +151,21 @@ discard block |
||
| 133 | 151 | || navigator.userAgent.match(/BlackBerry/i) |
| 134 | 152 | || navigator.userAgent.match(/Windows Phone/i)) |
| 135 | 153 | { |
| 136 | - var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom-1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>; |
|
| 154 | + var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) { |
|
| 155 | + print $viewzoom-1; |
|
| 156 | +} elseif (isset($viewzoom)) { |
|
| 157 | + print $viewzoom; |
|
| 158 | +} else { |
|
| 159 | + print '8'; |
|
| 160 | +} |
|
| 161 | +?>; |
|
| 137 | 162 | } else { |
| 138 | - var zoom = <?php if (isset($viewzoom)) print $viewzoom; else print '9'; ?>; |
|
| 163 | + var zoom = <?php if (isset($viewzoom)) { |
|
| 164 | + print $viewzoom; |
|
| 165 | +} else { |
|
| 166 | + print '9'; |
|
| 167 | +} |
|
| 168 | +?>; |
|
| 139 | 169 | } |
| 140 | 170 | |
| 141 | 171 | //create the map |
@@ -161,16 +191,27 @@ discard block |
||
| 161 | 191 | bounds = L.latLngBounds(southWest,northEast); |
| 162 | 192 | //a few title layers |
| 163 | 193 | <?php |
| 164 | - if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType']; |
|
| 165 | - else $MapType = $globalMapProvider; |
|
| 194 | + if (isset($_COOKIE['MapType'])) { |
|
| 195 | + $MapType = $_COOKIE['MapType']; |
|
| 196 | + } else { |
|
| 197 | + $MapType = $globalMapProvider; |
|
| 198 | + } |
|
| 166 | 199 | |
| 167 | 200 | if ($MapType == 'Mapbox') { |
| 168 | - if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId; |
|
| 169 | - else $MapBoxId = $_COOKIE['MapTypeId']; |
|
| 170 | -?> |
|
| 201 | + if ($_COOKIE['MapTypeId'] == 'default') { |
|
| 202 | + $MapBoxId = $globalMapboxId; |
|
| 203 | + } else { |
|
| 204 | + $MapBoxId = $_COOKIE['MapTypeId']; |
|
| 205 | + } |
|
| 206 | + ?> |
|
| 171 | 207 | L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', { |
| 172 | 208 | maxZoom: 18, |
| 173 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
| 209 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
| 210 | + print 'false'; |
|
| 211 | +} else { |
|
| 212 | + print 'true'; |
|
| 213 | +} |
|
| 214 | +?>, |
|
| 174 | 215 | attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + |
| 175 | 216 | '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + |
| 176 | 217 | 'Imagery © <a href="http://mapbox.com">Mapbox</a>', |
@@ -193,7 +234,12 @@ discard block |
||
| 193 | 234 | ?> |
| 194 | 235 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
| 195 | 236 | maxZoom: 18, |
| 196 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
| 237 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
| 238 | + print 'false'; |
|
| 239 | +} else { |
|
| 240 | + print 'true'; |
|
| 241 | +} |
|
| 242 | +?>, |
|
| 197 | 243 | attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + |
| 198 | 244 | '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>' |
| 199 | 245 | }).addTo(map); |
@@ -239,20 +285,26 @@ discard block |
||
| 239 | 285 | map.addLayer(yandexLayer); |
| 240 | 286 | <?php |
| 241 | 287 | } elseif ($MapType == 'Bing-Aerial') { |
| 242 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
| 243 | -?> |
|
| 288 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') { |
|
| 289 | + setcookie('MapType','OpenStreetMap'); |
|
| 290 | + } |
|
| 291 | + ?> |
|
| 244 | 292 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'}); |
| 245 | 293 | map.addLayer(bingLayer); |
| 246 | 294 | <?php |
| 247 | 295 | } elseif ($MapType == 'Bing-Hybrid') { |
| 248 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
| 249 | -?> |
|
| 296 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') { |
|
| 297 | + setcookie('MapType','OpenStreetMap'); |
|
| 298 | + } |
|
| 299 | + ?> |
|
| 250 | 300 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'}); |
| 251 | 301 | map.addLayer(bingLayer); |
| 252 | 302 | <?php |
| 253 | 303 | } elseif ($MapType == 'Bing-Road') { |
| 254 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
| 255 | -?> |
|
| 304 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') { |
|
| 305 | + setcookie('MapType','OpenStreetMap'); |
|
| 306 | + } |
|
| 307 | + ?> |
|
| 256 | 308 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'}); |
| 257 | 309 | map.addLayer(bingLayer); |
| 258 | 310 | <?php |
@@ -281,7 +333,12 @@ discard block |
||
| 281 | 333 | maxZoom: 5, |
| 282 | 334 | tms : true, |
| 283 | 335 | zindex : 3, |
| 284 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
| 336 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
| 337 | + print 'false'; |
|
| 338 | +} else { |
|
| 339 | + print 'true'; |
|
| 340 | +} |
|
| 341 | +?>, |
|
| 285 | 342 | attribution: 'Natural Earth' |
| 286 | 343 | }).addTo(map); |
| 287 | 344 | <?php |
@@ -289,9 +346,24 @@ discard block |
||
| 289 | 346 | $customid = $MapType; |
| 290 | 347 | ?> |
| 291 | 348 | L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', { |
| 292 | - maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>, |
|
| 293 | - minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>, |
|
| 294 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
| 349 | + maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) { |
|
| 350 | + print $globalMapCustomLayer[$customid]['maxZoom']; |
|
| 351 | +} else { |
|
| 352 | + print '18'; |
|
| 353 | +} |
|
| 354 | +?>, |
|
| 355 | + minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) { |
|
| 356 | + print $globalMapCustomLayer[$customid]['minZoom']; |
|
| 357 | +} else { |
|
| 358 | + print '0'; |
|
| 359 | +} |
|
| 360 | +?>, |
|
| 361 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
| 362 | + print 'false'; |
|
| 363 | +} else { |
|
| 364 | + print 'true'; |
|
| 365 | +} |
|
| 366 | +?>, |
|
| 295 | 367 | attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>' |
| 296 | 368 | }).addTo(map); |
| 297 | 369 | |
@@ -331,7 +403,12 @@ discard block |
||
| 331 | 403 | } |
| 332 | 404 | } elseif ($globalBounding == 'circle') { |
| 333 | 405 | ?> |
| 334 | - var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{ |
|
| 406 | + var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) { |
|
| 407 | + print $globalBoundingCircleSize; |
|
| 408 | +} else { |
|
| 409 | + print '70000'; |
|
| 410 | +} |
|
| 411 | +?>,{ |
|
| 335 | 412 | color: '#92C7D1', |
| 336 | 413 | fillColor: '#92C7D1', |
| 337 | 414 | fillOpacity: 0.3, |
@@ -423,7 +500,12 @@ discard block |
||
| 423 | 500 | createCookie('lastcentercoord',map.getCenter().lat+','+map.getCenter().lng+','+map.getZoom(),2); |
| 424 | 501 | }); |
| 425 | 502 | update_locationsLayer(); |
| 426 | -setInterval(function(){if (noTimeout) update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
| 503 | +setInterval(function(){if (noTimeout) update_locationsLayer()},<?php if (isset($globalMapRefresh)) { |
|
| 504 | + print $globalMapRefresh*1000*2; |
|
| 505 | +} else { |
|
| 506 | + print '60000'; |
|
| 507 | +} |
|
| 508 | +?>); |
|
| 427 | 509 | |
| 428 | 510 | <?php |
| 429 | 511 | // Add support for custom json via $globalMapJson |
@@ -73,8 +73,11 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 75 | 75 | $sth->closeCursor(); |
| 76 | - if ($row['nb'] > 0) return false; |
|
| 77 | - else return true; |
|
| 76 | + if ($row['nb'] > 0) { |
|
| 77 | + return false; |
|
| 78 | + } else { |
|
| 79 | + return true; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | /* |
@@ -104,29 +107,48 @@ discard block |
||
| 104 | 107 | //$pieces = explode(' ',$data); |
| 105 | 108 | $pieces = preg_split('/\s/',$data); |
| 106 | 109 | $pos = 0; |
| 107 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 108 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
| 109 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 110 | + if ($pieces[0] == 'METAR') { |
|
| 111 | + $pos++; |
|
| 112 | + } elseif ($pieces[0] == 'SPECI') { |
|
| 113 | + $pos++; |
|
| 114 | + } |
|
| 115 | + if (strlen($pieces[$pos]) != 4) { |
|
| 116 | + $pos++; |
|
| 117 | + } |
|
| 110 | 118 | $result = array(); |
| 111 | - if (!isset($pieces[$pos])) return $result; |
|
| 119 | + if (!isset($pieces[$pos])) { |
|
| 120 | + return $result; |
|
| 121 | + } |
|
| 112 | 122 | $result['location'] = $pieces[$pos]; |
| 113 | 123 | $pos++; |
| 114 | - if (!isset($pieces[$pos])) return $result; |
|
| 124 | + if (!isset($pieces[$pos])) { |
|
| 125 | + return $result; |
|
| 126 | + } |
|
| 115 | 127 | $result['dayofmonth'] = substr($pieces[$pos],0,2); |
| 116 | 128 | $result['time'] = substr($pieces[$pos],2,4); |
| 117 | 129 | $c = count($pieces); |
| 118 | 130 | for($pos++; $pos < $c; $pos++) { |
| 119 | 131 | $piece = $pieces[$pos]; |
| 120 | - if ($piece == 'RMK') break; |
|
| 121 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
| 122 | - if ($piece == 'COR') $result['correction'] = true; |
|
| 132 | + if ($piece == 'RMK') { |
|
| 133 | + break; |
|
| 134 | + } |
|
| 135 | + if ($piece == 'AUTO') { |
|
| 136 | + $result['auto'] = true; |
|
| 137 | + } |
|
| 138 | + if ($piece == 'COR') { |
|
| 139 | + $result['correction'] = true; |
|
| 140 | + } |
|
| 123 | 141 | // Wind Speed |
| 124 | 142 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
| 125 | 143 | $result['wind']['direction'] = (float)$matches[1]; |
| 126 | 144 | $result['wind']['unit'] = $matches[4]; |
| 127 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 128 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 129 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 145 | + if ($result['wind']['unit'] == 'KT') { |
|
| 146 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 147 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
| 148 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 149 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
| 150 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 151 | + } |
|
| 130 | 152 | $result['wind']['gust'] = (float)$matches[3]; |
| 131 | 153 | $result['wind']['unit'] = $matches[4]; |
| 132 | 154 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -209,14 +231,23 @@ discard block |
||
| 209 | 231 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
| 210 | 232 | $type = $matches[1]; |
| 211 | 233 | $cloud = array(); |
| 212 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
| 213 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 214 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
| 215 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
| 216 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
| 217 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
| 218 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 219 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
| 234 | + if ($type == 'SKC') { |
|
| 235 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
| 236 | + } elseif ($type == 'CLR') { |
|
| 237 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 238 | + } elseif ($type == 'NSC') { |
|
| 239 | + $cloud['type'] = 'No significant cloud'; |
|
| 240 | + } elseif ($type == 'FEW') { |
|
| 241 | + $cloud['type'] = 'Few'; |
|
| 242 | + } elseif ($type == 'SCT') { |
|
| 243 | + $cloud['type'] = 'Scattered'; |
|
| 244 | + } elseif ($type == 'BKN') { |
|
| 245 | + $cloud['type'] = 'Broken'; |
|
| 246 | + } elseif ($type == 'OVC') { |
|
| 247 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 248 | + } elseif ($type == 'VV') { |
|
| 249 | + $cloud['type'] = 'Vertical visibility'; |
|
| 250 | + } |
|
| 220 | 251 | $cloud['type_code'] = $type; |
| 221 | 252 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
| 222 | 253 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
@@ -242,8 +273,11 @@ discard block |
||
| 242 | 273 | $result['RVR']['friction'] = $matches[5]; |
| 243 | 274 | } |
| 244 | 275 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
| 245 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 246 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 276 | + if (isset($matches[5])) { |
|
| 277 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 278 | + } else { |
|
| 279 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 280 | + } |
|
| 247 | 281 | if (isset($matches[3])) { |
| 248 | 282 | $range = Array( |
| 249 | 283 | 'from' => (float)$matches[2], |
@@ -276,8 +310,11 @@ discard block |
||
| 276 | 310 | if (isset($matches[3])) { |
| 277 | 311 | $text[] = $this->texts[$matches[3]]; |
| 278 | 312 | } |
| 279 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
| 280 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 313 | + if (!isset($result['weather'])) { |
|
| 314 | + $result['weather'] = implode(' ', $text); |
|
| 315 | + } else { |
|
| 316 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 317 | + } |
|
| 281 | 318 | } |
| 282 | 319 | } |
| 283 | 320 | return $result; |
@@ -293,8 +330,11 @@ discard block |
||
| 293 | 330 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
| 294 | 331 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
| 295 | 332 | } else { |
| 296 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 297 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 333 | + if ($globalDBdriver == 'mysql') { |
|
| 334 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 335 | + } else { |
|
| 336 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 337 | + } |
|
| 298 | 338 | } |
| 299 | 339 | $query_values = array(':icao' => $icao); |
| 300 | 340 | try { |
@@ -366,7 +406,9 @@ discard block |
||
| 366 | 406 | */ |
| 367 | 407 | public function addMETARCycle() { |
| 368 | 408 | global $globalDebug, $globalIVAO, $globalTransaction; |
| 369 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
| 409 | + if (isset($globalDebug) && $globalDebug) { |
|
| 410 | + echo "Downloading METAR cycle..."; |
|
| 411 | + } |
|
| 370 | 412 | date_default_timezone_set("UTC"); |
| 371 | 413 | $Common = new Common(); |
| 372 | 414 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -377,26 +419,40 @@ discard block |
||
| 377 | 419 | $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
| 378 | 420 | } |
| 379 | 421 | if ($handle) { |
| 380 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
| 422 | + if (isset($globalDebug) && $globalDebug) { |
|
| 423 | + echo "Done - Updating DB..."; |
|
| 424 | + } |
|
| 381 | 425 | $date = ''; |
| 382 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
| 426 | + if ($globalTransaction) { |
|
| 427 | + $this->db->beginTransaction(); |
|
| 428 | + } |
|
| 383 | 429 | while(($line = fgets($handle,4096)) !== false) { |
| 384 | 430 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
| 385 | 431 | $date = $line; |
| 386 | 432 | } elseif ($line != '') { |
| 387 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 433 | + if ($date == '') { |
|
| 434 | + $date = date('Y/m/d H:m'); |
|
| 435 | + } |
|
| 388 | 436 | $pos = 0; |
| 389 | 437 | $pieces = preg_split('/\s/',$line); |
| 390 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 391 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 438 | + if ($pieces[0] == 'METAR') { |
|
| 439 | + $pos++; |
|
| 440 | + } |
|
| 441 | + if (strlen($pieces[$pos]) != 4) { |
|
| 442 | + $pos++; |
|
| 443 | + } |
|
| 392 | 444 | $location = $pieces[$pos]; |
| 393 | 445 | echo $this->addMETAR($location,$line,$date); |
| 394 | 446 | } |
| 395 | 447 | } |
| 396 | 448 | fclose($handle); |
| 397 | - if ($globalTransaction) $this->db->commit(); |
|
| 449 | + if ($globalTransaction) { |
|
| 450 | + $this->db->commit(); |
|
| 451 | + } |
|
| 452 | + } |
|
| 453 | + if (isset($globalDebug) && $globalDebug) { |
|
| 454 | + echo "Done\n"; |
|
| 398 | 455 | } |
| 399 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
| 400 | 456 | } |
| 401 | 457 | |
| 402 | 458 | /* |
@@ -406,7 +462,9 @@ discard block |
||
| 406 | 462 | */ |
| 407 | 463 | public function downloadMETAR($icao) { |
| 408 | 464 | global $globalMETARurl; |
| 409 | - if ($globalMETARurl == '') return array(); |
|
| 465 | + if ($globalMETARurl == '') { |
|
| 466 | + return array(); |
|
| 467 | + } |
|
| 410 | 468 | date_default_timezone_set("UTC"); |
| 411 | 469 | $Common = new Common(); |
| 412 | 470 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -417,16 +475,24 @@ discard block |
||
| 417 | 475 | $date = $line; |
| 418 | 476 | } |
| 419 | 477 | if ($line != '') { |
| 420 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 478 | + if ($date == '') { |
|
| 479 | + $date = date('Y/m/d H:m'); |
|
| 480 | + } |
|
| 421 | 481 | $pos = 0; |
| 422 | 482 | $pieces = preg_split('/\s/',$line); |
| 423 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 424 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 483 | + if ($pieces[0] == 'METAR') { |
|
| 484 | + $pos++; |
|
| 485 | + } |
|
| 486 | + if (strlen($pieces[$pos]) != 4) { |
|
| 487 | + $pos++; |
|
| 488 | + } |
|
| 425 | 489 | $location = $pieces[$pos]; |
| 426 | 490 | if (strlen($location == 4)) { |
| 427 | 491 | $this->addMETAR($location,$line,$date); |
| 428 | 492 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 429 | - } else return array(); |
|
| 493 | + } else { |
|
| 494 | + return array(); |
|
| 495 | + } |
|
| 430 | 496 | } |
| 431 | 497 | } |
| 432 | 498 | return array(); |
@@ -42,7 +42,9 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function checkAll() { |
| 44 | 44 | global $globalDebug; |
| 45 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 45 | + if ($globalDebug) { |
|
| 46 | + echo "Update last seen tracked data...\n"; |
|
| 47 | + } |
|
| 46 | 48 | foreach ($this->all_tracked as $key => $flight) { |
| 47 | 49 | if (isset($this->all_tracked[$key]['id'])) { |
| 48 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -55,12 +57,16 @@ discard block |
||
| 55 | 57 | public function del() { |
| 56 | 58 | global $globalDebug; |
| 57 | 59 | // Delete old infos |
| 58 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 60 | + if ($globalDebug) { |
|
| 61 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 62 | + } |
|
| 59 | 63 | foreach ($this->all_tracked as $key => $flight) { |
| 60 | 64 | if (isset($flight['lastupdate'])) { |
| 61 | 65 | if ($flight['lastupdate'] < (time()-3000)) { |
| 62 | 66 | if (isset($this->all_tracked[$key]['id'])) { |
| 63 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 67 | + if ($globalDebug) { |
|
| 68 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 69 | + } |
|
| 64 | 70 | /* |
| 65 | 71 | $TrackerLive = new TrackerLive(); |
| 66 | 72 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
@@ -70,7 +76,9 @@ discard block |
||
| 70 | 76 | $Tracker = new Tracker($this->db); |
| 71 | 77 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 72 | 78 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
| 73 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 79 | + if ($globalDebug && $result != 'success') { |
|
| 80 | + echo '!!! ERROR : '.$result."\n"; |
|
| 81 | + } |
|
| 74 | 82 | } |
| 75 | 83 | // Put in archive |
| 76 | 84 | // $Tracker->db = null; |
@@ -83,7 +91,9 @@ discard block |
||
| 83 | 91 | |
| 84 | 92 | public function add($line) { |
| 85 | 93 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
| 86 | - if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015'; |
|
| 94 | + if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') { |
|
| 95 | + $globalCoordMinChangeTracker = '0.015'; |
|
| 96 | + } |
|
| 87 | 97 | date_default_timezone_set('UTC'); |
| 88 | 98 | $dataFound = false; |
| 89 | 99 | $send = false; |
@@ -97,19 +107,29 @@ discard block |
||
| 97 | 107 | // Increment message number |
| 98 | 108 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 99 | 109 | $current_date = date('Y-m-d'); |
| 100 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 101 | - else $source = ''; |
|
| 102 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 110 | + if (isset($line['source_name'])) { |
|
| 111 | + $source = $line['source_name']; |
|
| 112 | + } else { |
|
| 113 | + $source = ''; |
|
| 114 | + } |
|
| 115 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 116 | + $source = $line['format_source']; |
|
| 117 | + } |
|
| 103 | 118 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 104 | 119 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 105 | 120 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 106 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 121 | + } else { |
|
| 122 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 123 | + } |
|
| 107 | 124 | } |
| 108 | 125 | |
| 109 | 126 | |
| 110 | 127 | $Common = new Common(); |
| 111 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
| 112 | - else $id = trim($line['id']); |
|
| 128 | + if (!isset($line['id'])) { |
|
| 129 | + $id = trim($line['ident']); |
|
| 130 | + } else { |
|
| 131 | + $id = trim($line['id']); |
|
| 132 | + } |
|
| 113 | 133 | |
| 114 | 134 | if (!isset($this->all_tracked[$id])) { |
| 115 | 135 | $this->all_tracked[$id] = array(); |
@@ -117,31 +137,46 @@ discard block |
||
| 117 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
| 118 | 138 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 119 | 139 | if (!isset($line['id'])) { |
| 120 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 140 | + if (!isset($globalDaemon)) { |
|
| 141 | + $globalDaemon = TRUE; |
|
| 142 | + } |
|
| 121 | 143 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 122 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 123 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 144 | + } else { |
|
| 145 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 146 | + } |
|
| 147 | + if ($globalAllTracked !== FALSE) { |
|
| 148 | + $dataFound = true; |
|
| 149 | + } |
|
| 124 | 150 | } |
| 125 | 151 | |
| 126 | 152 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 127 | 153 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
| 128 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 129 | 155 | } else { |
| 130 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 131 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 156 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 157 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 158 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 159 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 160 | + } |
|
| 132 | 161 | return ''; |
| 133 | 162 | } |
| 134 | 163 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 135 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 164 | + if ($globalDebug) { |
|
| 165 | + echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 166 | + } |
|
| 136 | 167 | return ''; |
| 137 | 168 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 138 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 169 | + if ($globalDebug) { |
|
| 170 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 171 | + } |
|
| 139 | 172 | return ''; |
| 140 | 173 | } elseif (!isset($line['datetime'])) { |
| 141 | 174 | date_default_timezone_set('UTC'); |
| 142 | 175 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 143 | 176 | } else { |
| 144 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 177 | + if ($globalDebug) { |
|
| 178 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 179 | + } |
|
| 145 | 180 | return ''; |
| 146 | 181 | } |
| 147 | 182 | |
@@ -153,11 +188,17 @@ discard block |
||
| 153 | 188 | $Tracker = new Tracker($this->db); |
| 154 | 189 | $fromsource = NULL; |
| 155 | 190 | $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 156 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 191 | + if ($globalDebug && $result != 'success') { |
|
| 192 | + echo '!!! ERROR : '.$result."\n"; |
|
| 193 | + } |
|
| 157 | 194 | $Tracker->db = null; |
| 158 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 195 | + if ($globalDebugTimeElapsed) { |
|
| 196 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 159 | 201 | } |
| 160 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 161 | 202 | } |
| 162 | 203 | |
| 163 | 204 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -168,14 +209,21 @@ discard block |
||
| 168 | 209 | if ($distance > 100 && $distance < 10000) { |
| 169 | 210 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 170 | 211 | $speed = $speed*3.6; |
| 171 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 172 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
| 212 | + if ($speed < 1000) { |
|
| 213 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 214 | + } |
|
| 215 | + if ($globalDebug) { |
|
| 216 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
| 217 | + } |
|
| 173 | 218 | } |
| 174 | 219 | } |
| 175 | 220 | |
| 176 | 221 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 177 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 178 | - else unset($timediff); |
|
| 222 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 223 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 224 | + } else { |
|
| 225 | + unset($timediff); |
|
| 226 | + } |
|
| 179 | 227 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
| 180 | 228 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 181 | 229 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) { |
@@ -183,20 +231,30 @@ discard block |
||
| 183 | 231 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 184 | 232 | $this->all_tracked[$id]['putinarchive'] = true; |
| 185 | 233 | |
| 186 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 234 | + if ($globalDebug) { |
|
| 235 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 236 | + } |
|
| 187 | 237 | $timeelapsed = microtime(true); |
| 188 | 238 | $Tracker = new Tracker($this->db); |
| 189 | 239 | $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 190 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 240 | + if (!empty($all_country)) { |
|
| 241 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 242 | + } |
|
| 191 | 243 | $Tracker->db = null; |
| 192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 244 | + if ($globalDebugTimeElapsed) { |
|
| 245 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 246 | + } |
|
| 193 | 247 | $this->tmd = 0; |
| 194 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 248 | + if ($globalDebug) { |
|
| 249 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 250 | + } |
|
| 195 | 251 | } |
| 196 | 252 | } |
| 197 | 253 | |
| 198 | 254 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 199 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 255 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 256 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 257 | + } |
|
| 200 | 258 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 201 | 259 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 202 | 260 | $dataFound = true; |
@@ -205,8 +263,12 @@ discard block |
||
| 205 | 263 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 206 | 264 | } |
| 207 | 265 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 208 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 209 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 266 | + if ($line['longitude'] > 180) { |
|
| 267 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 268 | + } |
|
| 269 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 270 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 271 | + } |
|
| 210 | 272 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 211 | 273 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 212 | 274 | $dataFound = true; |
@@ -226,7 +288,9 @@ discard block |
||
| 226 | 288 | } |
| 227 | 289 | } |
| 228 | 290 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 229 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 291 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 292 | + $dataFound = true; |
|
| 293 | + } |
|
| 230 | 294 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 231 | 295 | } |
| 232 | 296 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -246,7 +310,9 @@ discard block |
||
| 246 | 310 | |
| 247 | 311 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 248 | 312 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 249 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 313 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) { |
|
| 314 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 315 | + } |
|
| 250 | 316 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
| 251 | 317 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
| 252 | 318 | //$dataFound = true; |
@@ -258,15 +324,21 @@ discard block |
||
| 258 | 324 | } |
| 259 | 325 | |
| 260 | 326 | if (isset($line['heading']) && $line['heading'] != '') { |
| 261 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 327 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 328 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 329 | + } |
|
| 262 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 263 | 331 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 264 | 332 | //$dataFound = true; |
| 265 | 333 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 266 | 334 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 267 | 335 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 268 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 269 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 336 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 337 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 338 | + } |
|
| 339 | + if ($globalDebug) { |
|
| 340 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 341 | + } |
|
| 270 | 342 | } |
| 271 | 343 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 272 | 344 | |
@@ -275,20 +347,31 @@ discard block |
||
| 275 | 347 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
| 276 | 348 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 277 | 349 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 278 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 350 | + if ($globalDebug) { |
|
| 351 | + echo "Check if aircraft is already in DB..."; |
|
| 352 | + } |
|
| 279 | 353 | $timeelapsed = microtime(true); |
| 280 | 354 | $TrackerLive = new TrackerLive($this->db); |
| 281 | 355 | if (isset($line['id'])) { |
| 282 | 356 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
| 283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 357 | + if ($globalDebugTimeElapsed) { |
|
| 358 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 359 | + } |
|
| 284 | 360 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 285 | 361 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 287 | - } else $recent_ident = ''; |
|
| 362 | + if ($globalDebugTimeElapsed) { |
|
| 363 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 364 | + } |
|
| 365 | + } else { |
|
| 366 | + $recent_ident = ''; |
|
| 367 | + } |
|
| 288 | 368 | $TrackerLive->db=null; |
| 289 | 369 | |
| 290 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 291 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 370 | + if ($globalDebug && $recent_ident == '') { |
|
| 371 | + echo " Not in DB.\n"; |
|
| 372 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 373 | + echo " Already in DB.\n"; |
|
| 374 | + } |
|
| 292 | 375 | } else { |
| 293 | 376 | $recent_ident = ''; |
| 294 | 377 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -296,27 +379,41 @@ discard block |
||
| 296 | 379 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 297 | 380 | if($recent_ident == "") |
| 298 | 381 | { |
| 299 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 382 | + if ($globalDebug) { |
|
| 383 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 384 | + } |
|
| 300 | 385 | //adds the spotter data for the archive |
| 301 | 386 | $highlight = ''; |
| 302 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 387 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 388 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 389 | + } |
|
| 303 | 390 | $timeelapsed = microtime(true); |
| 304 | 391 | $Tracker = new Tracker($this->db); |
| 305 | 392 | $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
| 306 | 393 | $Tracker->db = null; |
| 307 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 394 | + if ($globalDebug && isset($result)) { |
|
| 395 | + echo $result."\n"; |
|
| 396 | + } |
|
| 397 | + if ($globalDebugTimeElapsed) { |
|
| 398 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 399 | + } |
|
| 309 | 400 | |
| 310 | 401 | |
| 311 | 402 | // Add source stat in DB |
| 312 | 403 | $Stats = new Stats($this->db); |
| 313 | 404 | if (!empty($this->stats)) { |
| 314 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 405 | + if ($globalDebug) { |
|
| 406 | + echo 'Add source stats : '; |
|
| 407 | + } |
|
| 315 | 408 | foreach($this->stats as $date => $data) { |
| 316 | 409 | foreach($data as $source => $sourced) { |
| 317 | 410 | //print_r($sourced); |
| 318 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
| 319 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
| 411 | + if (isset($sourced['polar'])) { |
|
| 412 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
| 413 | + } |
|
| 414 | + if (isset($sourced['hist'])) { |
|
| 415 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
| 416 | + } |
|
| 320 | 417 | if (isset($sourced['msg'])) { |
| 321 | 418 | if (time() - $sourced['msg']['date'] > 10) { |
| 322 | 419 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -329,7 +426,9 @@ discard block |
||
| 329 | 426 | unset($this->stats[$date]); |
| 330 | 427 | } |
| 331 | 428 | } |
| 332 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 429 | + if ($globalDebug) { |
|
| 430 | + echo 'Done'."\n"; |
|
| 431 | + } |
|
| 333 | 432 | |
| 334 | 433 | } |
| 335 | 434 | $Stats->db = null; |
@@ -339,12 +438,16 @@ discard block |
||
| 339 | 438 | $this->all_tracked[$id]['addedTracker'] = 1; |
| 340 | 439 | //print_r($this->all_tracked[$id]); |
| 341 | 440 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 342 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 441 | + if ($globalDebug) { |
|
| 442 | + echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 443 | + } |
|
| 343 | 444 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 344 | 445 | $TrackerLive = new TrackerLive($this->db); |
| 345 | 446 | $TrackerLive->deleteLiveTrackerData(); |
| 346 | 447 | $TrackerLive->db=null; |
| 347 | - if ($globalDebug) echo " Done\n"; |
|
| 448 | + if ($globalDebug) { |
|
| 449 | + echo " Done\n"; |
|
| 450 | + } |
|
| 348 | 451 | $this->last_delete = time(); |
| 349 | 452 | } |
| 350 | 453 | } else { |
@@ -367,19 +470,25 @@ discard block |
||
| 367 | 470 | |
| 368 | 471 | if (!$ignoreImport) { |
| 369 | 472 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 370 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 473 | + if ($globalDebug) { |
|
| 474 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 475 | + } |
|
| 371 | 476 | $timeelapsed = microtime(true); |
| 372 | 477 | $TrackerLive = new TrackerLive($this->db); |
| 373 | 478 | $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
| 374 | 479 | $TrackerLive->db = null; |
| 375 | 480 | $this->all_tracked[$id]['putinarchive'] = false; |
| 376 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 481 | + if ($globalDebugTimeElapsed) { |
|
| 482 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 483 | + } |
|
| 377 | 484 | |
| 378 | 485 | // Put statistics in $this->stats variable |
| 379 | 486 | |
| 380 | 487 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 381 | 488 | $source = $this->all_tracked[$id]['source_name']; |
| 382 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
| 489 | + if ($source == '') { |
|
| 490 | + $source = $this->all_tracked[$id]['format_source']; |
|
| 491 | + } |
|
| 383 | 492 | if (!isset($this->source_location[$source])) { |
| 384 | 493 | $Location = new Source($this->db); |
| 385 | 494 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -400,7 +509,9 @@ discard block |
||
| 400 | 509 | $stats_heading = round($stats_heading/22.5); |
| 401 | 510 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 402 | 511 | $current_date = date('Y-m-d'); |
| 403 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 512 | + if ($stats_heading == 16) { |
|
| 513 | + $stats_heading = 0; |
|
| 514 | + } |
|
| 404 | 515 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 405 | 516 | for ($i=0;$i<=15;$i++) { |
| 406 | 517 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -418,7 +529,9 @@ discard block |
||
| 418 | 529 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 419 | 530 | end($this->stats[$current_date][$source]['hist']); |
| 420 | 531 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 421 | - } else $mini = 0; |
|
| 532 | + } else { |
|
| 533 | + $mini = 0; |
|
| 534 | + } |
|
| 422 | 535 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 423 | 536 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 424 | 537 | } |
@@ -429,19 +542,29 @@ discard block |
||
| 429 | 542 | } |
| 430 | 543 | |
| 431 | 544 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 432 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 433 | - if ($globalDebug) echo $result."\n"; |
|
| 434 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 545 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 546 | + $send = true; |
|
| 547 | + } |
|
| 548 | + if ($globalDebug) { |
|
| 549 | + echo $result."\n"; |
|
| 550 | + } |
|
| 551 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 552 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 553 | + } |
|
| 435 | 554 | //$this->del(); |
| 436 | 555 | |
| 437 | 556 | |
| 438 | 557 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 558 | + if ($globalDebug) { |
|
| 559 | + echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 560 | + } |
|
| 440 | 561 | $TrackerLive = new TrackerLive($this->db); |
| 441 | 562 | $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 442 | 563 | $TrackerLive->db = null; |
| 443 | 564 | //TrackerLive->deleteLiveTrackerData(); |
| 444 | - if ($globalDebug) echo " Done\n"; |
|
| 565 | + if ($globalDebug) { |
|
| 566 | + echo " Done\n"; |
|
| 567 | + } |
|
| 445 | 568 | $this->last_delete_hourly = time(); |
| 446 | 569 | } |
| 447 | 570 | |
@@ -449,7 +572,9 @@ discard block |
||
| 449 | 572 | //$ignoreImport = false; |
| 450 | 573 | } |
| 451 | 574 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 452 | - if ($send) return $this->all_tracked[$id]; |
|
| 575 | + if ($send) { |
|
| 576 | + return $this->all_tracked[$id]; |
|
| 577 | + } |
|
| 453 | 578 | } |
| 454 | 579 | } |
| 455 | 580 | } |
@@ -196,16 +196,22 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | /* Check that end was found and body has at least one byte. */ |
| 198 | 198 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
| 199 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
| 199 | + if ($globalDebug) { |
|
| 200 | + echo '!!! APRS invalid : '.$input."\n"; |
|
| 201 | + } |
|
| 200 | 202 | return false; |
| 201 | 203 | } |
| 202 | 204 | |
| 203 | - if ($debug) echo 'input : '.$input."\n"; |
|
| 205 | + if ($debug) { |
|
| 206 | + echo 'input : '.$input."\n"; |
|
| 207 | + } |
|
| 204 | 208 | /* Save header and body. */ |
| 205 | 209 | $body = substr($input,$splitpos+1,$input_len); |
| 206 | 210 | $body_len = strlen($body); |
| 207 | 211 | $header = substr($input,0,$splitpos); |
| 208 | - if ($debug) echo 'header : '.$header."\n"; |
|
| 212 | + if ($debug) { |
|
| 213 | + echo 'header : '.$header."\n"; |
|
| 214 | + } |
|
| 209 | 215 | |
| 210 | 216 | /* Parse source, target and path. */ |
| 211 | 217 | //FLRDF0A52>APRS,qAS,LSTB |
@@ -219,11 +225,15 @@ discard block |
||
| 219 | 225 | $result['format_source'] = 'famaprs'; |
| 220 | 226 | $result['source_type'] = 'ais'; |
| 221 | 227 | } else { |
| 222 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
| 228 | + if ($debug) { |
|
| 229 | + echo 'ident : '.$ident."\n"; |
|
| 230 | + } |
|
| 223 | 231 | $result['ident'] = $ident; |
| 224 | 232 | } |
| 225 | 233 | } else { |
| 226 | - if ($debug) 'No ident'."\n"; |
|
| 234 | + if ($debug) { |
|
| 235 | + 'No ident'."\n"; |
|
| 236 | + } |
|
| 227 | 237 | return false; |
| 228 | 238 | } |
| 229 | 239 | $elements = explode(',',$all_elements); |
@@ -233,7 +243,9 @@ discard block |
||
| 233 | 243 | if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
| 234 | 244 | //if ($element == 'TCPIP*') return false; |
| 235 | 245 | } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
| 236 | - if ($debug) echo 'element : '.$element."\n"; |
|
| 246 | + if ($debug) { |
|
| 247 | + echo 'element : '.$element."\n"; |
|
| 248 | + } |
|
| 237 | 249 | return false; |
| 238 | 250 | } |
| 239 | 251 | /* |
@@ -246,13 +258,17 @@ discard block |
||
| 246 | 258 | } |
| 247 | 259 | |
| 248 | 260 | $type = substr($body,0,1); |
| 249 | - if ($debug) echo 'type : '.$type."\n"; |
|
| 261 | + if ($debug) { |
|
| 262 | + echo 'type : '.$type."\n"; |
|
| 263 | + } |
|
| 250 | 264 | if ($type == ';') { |
| 251 | 265 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
| 252 | 266 | $result['address'] = trim(substr($body,1,9)); |
| 253 | 267 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
| 254 | 268 | $result['mmsi'] = trim(substr($body,1,9)); |
| 255 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
| 269 | + } else { |
|
| 270 | + $result['ident'] = trim(substr($body,1,9)); |
|
| 271 | + } |
|
| 256 | 272 | } elseif ($type == ',') { |
| 257 | 273 | // Invalid data or test data |
| 258 | 274 | return false; |
@@ -309,7 +325,9 @@ discard block |
||
| 309 | 325 | //$symbol_table = $matches[4]; |
| 310 | 326 | $lat = intval($lat_deg); |
| 311 | 327 | $lon = intval($lon_deg); |
| 312 | - if ($lat > 89 || $lon > 179) return false; |
|
| 328 | + if ($lat > 89 || $lon > 179) { |
|
| 329 | + return false; |
|
| 330 | + } |
|
| 313 | 331 | /* |
| 314 | 332 | $tmp_5b = str_replace('.','',$lat_min); |
| 315 | 333 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
@@ -318,8 +336,12 @@ discard block |
||
| 318 | 336 | */ |
| 319 | 337 | $latitude = $lat + floatval($lat_min)/60; |
| 320 | 338 | $longitude = $lon + floatval($lon_min)/60; |
| 321 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
| 322 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
| 339 | + if ($sind == 'S') { |
|
| 340 | + $latitude = 0-$latitude; |
|
| 341 | + } |
|
| 342 | + if ($wind == 'W') { |
|
| 343 | + $longitude = 0-$longitude; |
|
| 344 | + } |
|
| 323 | 345 | $result['latitude'] = $latitude; |
| 324 | 346 | $result['longitude'] = $longitude; |
| 325 | 347 | $body_parse = substr($body_parse,18); |
@@ -344,22 +366,29 @@ discard block |
||
| 344 | 366 | if ($find) { |
| 345 | 367 | $body_split = str_split($body_parse); |
| 346 | 368 | $symbol_code = $body_split[0]; |
| 347 | - if (!isset($symbolll) || $symbolll == '/') $symbol_code = '/'.$symbol_code; |
|
| 348 | - else $symbol_code = '\\'.$symbol_code; |
|
| 369 | + if (!isset($symbolll) || $symbolll == '/') { |
|
| 370 | + $symbol_code = '/'.$symbol_code; |
|
| 371 | + } else { |
|
| 372 | + $symbol_code = '\\'.$symbol_code; |
|
| 373 | + } |
|
| 349 | 374 | //' |
| 350 | 375 | //if ($type != ';' && $type != '>') { |
| 351 | 376 | if ($type != '') { |
| 352 | 377 | $body_parse = substr($body_parse,1); |
| 353 | 378 | $body_parse_len = strlen($body_parse); |
| 354 | 379 | $result['symbol_code'] = $symbol_code; |
| 355 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
|
| 380 | + if (isset($this->symbols[$symbol_code])) { |
|
| 381 | + $result['symbol'] = $this->symbols[$symbol_code]; |
|
| 382 | + } |
|
| 356 | 383 | if ($symbol_code != '_') { |
| 357 | 384 | } |
| 358 | 385 | if ($body_parse_len >= 7) { |
| 359 | 386 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
| 360 | 387 | $course = substr($body_parse,0,3); |
| 361 | 388 | $tmp_s = intval($course); |
| 362 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
| 389 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
| 390 | + $result['heading'] = intval($course); |
|
| 391 | + } |
|
| 363 | 392 | $speed = substr($body_parse,4,3); |
| 364 | 393 | if ($speed != '...') { |
| 365 | 394 | $result['speed'] = intval($speed); |
@@ -394,10 +423,16 @@ discard block |
||
| 394 | 423 | $dao_split = str_split($dao); |
| 395 | 424 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
| 396 | 425 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
| 397 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
| 398 | - else $result['latitude'] += $lat_off; |
|
| 399 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
| 400 | - else $result['longitude'] += $lon_off; |
|
| 426 | + if ($result['latitude'] < 0) { |
|
| 427 | + $result['latitude'] -= $lat_off; |
|
| 428 | + } else { |
|
| 429 | + $result['latitude'] += $lat_off; |
|
| 430 | + } |
|
| 431 | + if ($result['longitude'] < 0) { |
|
| 432 | + $result['longitude'] -= $lon_off; |
|
| 433 | + } else { |
|
| 434 | + $result['longitude'] += $lon_off; |
|
| 435 | + } |
|
| 401 | 436 | } |
| 402 | 437 | $body_parse = substr($body_parse,6); |
| 403 | 438 | } |
@@ -435,27 +470,48 @@ discard block |
||
| 435 | 470 | //$mode = substr($id,0,2); |
| 436 | 471 | $address = substr($id,2); |
| 437 | 472 | $addressType = (intval(substr($id,0,2),16))&3; |
| 438 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
| 439 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
| 440 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
| 441 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
| 473 | + if ($addressType == 0) { |
|
| 474 | + $result['addresstype'] = "RANDOM"; |
|
| 475 | + } elseif ($addressType == 1) { |
|
| 476 | + $result['addresstype'] = "ICAO"; |
|
| 477 | + } elseif ($addressType == 2) { |
|
| 478 | + $result['addresstype'] = "FLARM"; |
|
| 479 | + } elseif ($addressType == 3) { |
|
| 480 | + $result['addresstype'] = "OGN"; |
|
| 481 | + } |
|
| 442 | 482 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
| 443 | 483 | $result['aircrafttype_code'] = $aircraftType; |
| 444 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
| 445 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
| 446 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
| 447 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
| 448 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
| 449 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
| 450 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
| 451 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
| 452 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
| 453 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
| 454 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
| 455 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
| 456 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
| 457 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
| 458 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
| 484 | + if ($aircraftType == 0) { |
|
| 485 | + $result['aircrafttype'] = "UNKNOWN"; |
|
| 486 | + } elseif ($aircraftType == 1) { |
|
| 487 | + $result['aircrafttype'] = "GLIDER"; |
|
| 488 | + } elseif ($aircraftType == 2) { |
|
| 489 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
| 490 | + } elseif ($aircraftType == 3) { |
|
| 491 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
| 492 | + } elseif ($aircraftType == 4) { |
|
| 493 | + $result['aircrafttype'] = "PARACHUTE"; |
|
| 494 | + } elseif ($aircraftType == 5) { |
|
| 495 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
| 496 | + } elseif ($aircraftType == 6) { |
|
| 497 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
| 498 | + } elseif ($aircraftType == 7) { |
|
| 499 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
| 500 | + } elseif ($aircraftType == 8) { |
|
| 501 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
| 502 | + } elseif ($aircraftType == 9) { |
|
| 503 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
| 504 | + } elseif ($aircraftType == 10) { |
|
| 505 | + $result['aircrafttype'] = "UFO"; |
|
| 506 | + } elseif ($aircraftType == 11) { |
|
| 507 | + $result['aircrafttype'] = "BALLOON"; |
|
| 508 | + } elseif ($aircraftType == 12) { |
|
| 509 | + $result['aircrafttype'] = "AIRSHIP"; |
|
| 510 | + } elseif ($aircraftType == 13) { |
|
| 511 | + $result['aircrafttype'] = "UAV"; |
|
| 512 | + } elseif ($aircraftType == 15) { |
|
| 513 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
| 514 | + } |
|
| 459 | 515 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
| 460 | 516 | $result['stealth'] = $stealth; |
| 461 | 517 | $result['address'] = $address; |
@@ -490,77 +546,181 @@ discard block |
||
| 490 | 546 | //g012t088r000p000P000h38b10110 |
| 491 | 547 | //g011t086r000p000P000h29b10198 |
| 492 | 548 | if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 493 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 494 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 495 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 496 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 497 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 498 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 499 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 549 | + if ($matches[1] != '...') { |
|
| 550 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 551 | + } |
|
| 552 | + if ($matches[2] != '...') { |
|
| 553 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 554 | + } |
|
| 555 | + if ($matches[3] != '...') { |
|
| 556 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 557 | + } |
|
| 558 | + if ($matches[4] != '...') { |
|
| 559 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 560 | + } |
|
| 561 | + if ($matches[5] != '...') { |
|
| 562 | + $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 563 | + } |
|
| 564 | + if ($matches[6] != '...') { |
|
| 565 | + $result['humidity'] = intval($matches[6]); |
|
| 566 | + } |
|
| 567 | + if ($matches[7] != '...') { |
|
| 568 | + $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 569 | + } |
|
| 500 | 570 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 501 | 571 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 502 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 503 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 504 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 505 | - if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
| 506 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 507 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 508 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 572 | + if ($matches[1] != '...') { |
|
| 573 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 574 | + } |
|
| 575 | + if ($matches[2] != '...') { |
|
| 576 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 577 | + } |
|
| 578 | + if ($matches[3] != '...') { |
|
| 579 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 580 | + } |
|
| 581 | + if ($matches[5] != '...') { |
|
| 582 | + $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
| 583 | + } |
|
| 584 | + if ($matches[4] != '...') { |
|
| 585 | + $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 586 | + } |
|
| 587 | + if ($matches[6] != '...') { |
|
| 588 | + $result['humidity'] = intval($matches[6]); |
|
| 589 | + } |
|
| 590 | + if ($matches[7] != '...') { |
|
| 591 | + $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 592 | + } |
|
| 509 | 593 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 510 | 594 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
| 511 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 512 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 513 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 514 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 515 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 516 | - if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
|
| 517 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 595 | + if ($matches[1] != '...') { |
|
| 596 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 597 | + } |
|
| 598 | + if ($matches[2] != '...') { |
|
| 599 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 600 | + } |
|
| 601 | + if ($matches[3] != '...') { |
|
| 602 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 603 | + } |
|
| 604 | + if ($matches[4] != '...') { |
|
| 605 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 606 | + } |
|
| 607 | + if ($matches[5] != '...') { |
|
| 608 | + $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 609 | + } |
|
| 610 | + if ($matches[7] != '...') { |
|
| 611 | + $result['humidity'] = intval($matches[7]); |
|
| 612 | + } |
|
| 613 | + if ($matches[6] != '...') { |
|
| 614 | + $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 615 | + } |
|
| 518 | 616 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 519 | 617 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
| 520 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 521 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 522 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 523 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 524 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 525 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 618 | + if ($matches[1] != '...') { |
|
| 619 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 620 | + } |
|
| 621 | + if ($matches[2] != '...') { |
|
| 622 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 623 | + } |
|
| 624 | + if ($matches[3] != '...') { |
|
| 625 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 626 | + } |
|
| 627 | + if ($matches[4] != '...') { |
|
| 628 | + $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 629 | + } |
|
| 630 | + if ($matches[6] != '...') { |
|
| 631 | + $result['humidity'] = intval($matches[6]); |
|
| 632 | + } |
|
| 633 | + if ($matches[5] != '...') { |
|
| 634 | + $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 635 | + } |
|
| 526 | 636 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 527 | 637 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
| 528 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 529 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 530 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 531 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 532 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 533 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 638 | + if ($matches[1] != '...') { |
|
| 639 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 640 | + } |
|
| 641 | + if ($matches[2] != '...') { |
|
| 642 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 643 | + } |
|
| 644 | + if ($matches[3] != '...') { |
|
| 645 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 646 | + } |
|
| 647 | + if ($matches[4] != '...') { |
|
| 648 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 649 | + } |
|
| 650 | + if ($matches[6] != '...') { |
|
| 651 | + $result['humidity'] = intval($matches[6]); |
|
| 652 | + } |
|
| 653 | + if ($matches[5] != '...') { |
|
| 654 | + $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 655 | + } |
|
| 534 | 656 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 535 | 657 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 536 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 537 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 538 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 539 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 540 | - if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
|
| 541 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 658 | + if ($matches[1] != '...') { |
|
| 659 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 660 | + } |
|
| 661 | + if ($matches[2] != '...') { |
|
| 662 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 663 | + } |
|
| 664 | + if ($matches[3] != '...') { |
|
| 665 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 666 | + } |
|
| 667 | + if ($matches[4] != '...') { |
|
| 668 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 669 | + } |
|
| 670 | + if ($matches[5] != '...') { |
|
| 671 | + $result['humidity'] = intval($matches[5]); |
|
| 672 | + } |
|
| 673 | + if ($matches[6] != '...') { |
|
| 674 | + $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 675 | + } |
|
| 542 | 676 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 543 | 677 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 544 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 545 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 546 | - if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
|
| 547 | - if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); |
|
| 678 | + if ($matches[1] != '...') { |
|
| 679 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 680 | + } |
|
| 681 | + if ($matches[2] != '...') { |
|
| 682 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 683 | + } |
|
| 684 | + if ($matches[2] != '...') { |
|
| 685 | + $result['humidity'] = intval($matches[3]); |
|
| 686 | + } |
|
| 687 | + if ($matches[4] != '...') { |
|
| 688 | + $result['pressure'] = round((intval($matches[4])/10),1); |
|
| 689 | + } |
|
| 548 | 690 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 549 | 691 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 550 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 551 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 552 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 553 | - if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
|
| 554 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 692 | + if ($matches[1] != '...') { |
|
| 693 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 694 | + } |
|
| 695 | + if ($matches[2] != '...') { |
|
| 696 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 697 | + } |
|
| 698 | + if ($matches[3] != '...') { |
|
| 699 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 700 | + } |
|
| 701 | + if ($matches[4] != '...') { |
|
| 702 | + $result['humidity'] = intval($matches[4]); |
|
| 703 | + } |
|
| 704 | + if ($matches[5] != '...') { |
|
| 705 | + $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 706 | + } |
|
| 555 | 707 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 556 | 708 | } |
| 557 | 709 | $result['comment'] = trim($body_parse); |
| 558 | 710 | } |
| 559 | - } else $result['comment'] = trim($body_parse); |
|
| 711 | + } else { |
|
| 712 | + $result['comment'] = trim($body_parse); |
|
| 713 | + } |
|
| 714 | + } |
|
| 715 | + if (isset($result['latitude'])) { |
|
| 716 | + $result['latitude'] = round($result['latitude'],4); |
|
| 717 | + } |
|
| 718 | + if (isset($result['longitude'])) { |
|
| 719 | + $result['longitude'] = round($result['longitude'],4); |
|
| 720 | + } |
|
| 721 | + if ($debug) { |
|
| 722 | + print_r($result); |
|
| 560 | 723 | } |
| 561 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
| 562 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
| 563 | - if ($debug) print_r($result); |
|
| 564 | 724 | return $result; |
| 565 | 725 | } |
| 566 | 726 | |
@@ -572,12 +732,21 @@ discard block |
||
| 572 | 732 | $aprs_connect = 0; |
| 573 | 733 | $aprs_keep = 120; |
| 574 | 734 | $aprs_last_tx = time(); |
| 575 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 576 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 577 | - if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
|
| 578 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 579 | - if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
|
| 580 | - else $aprs_pass = '-1'; |
|
| 735 | + if (isset($globalAPRSversion)) { |
|
| 736 | + $aprs_version = $globalAPRSversion; |
|
| 737 | + } else { |
|
| 738 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 739 | + } |
|
| 740 | + if (isset($globalServerAPRSssid)) { |
|
| 741 | + $aprs_ssid = $globalServerAPRSssid; |
|
| 742 | + } else { |
|
| 743 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 744 | + } |
|
| 745 | + if (isset($globalServerAPRSpass)) { |
|
| 746 | + $aprs_pass = $globalServerAPRSpass; |
|
| 747 | + } else { |
|
| 748 | + $aprs_pass = '-1'; |
|
| 749 | + } |
|
| 581 | 750 | $aprs_filter = ''; |
| 582 | 751 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
| 583 | 752 | $Common = new Common(); |
@@ -616,10 +785,14 @@ discard block |
||
| 616 | 785 | */ |
| 617 | 786 | public function send($data) { |
| 618 | 787 | global $globalDebug; |
| 619 | - if ($this->connected === false) $this->connect(); |
|
| 788 | + if ($this->connected === false) { |
|
| 789 | + $this->connect(); |
|
| 790 | + } |
|
| 620 | 791 | $send = socket_send( $this->socket , $data , strlen($data),0); |
| 621 | 792 | if ($send === FALSE) { |
| 622 | - if ($globalDebug) echo 'Reconnect...'; |
|
| 793 | + if ($globalDebug) { |
|
| 794 | + echo 'Reconnect...'; |
|
| 795 | + } |
|
| 623 | 796 | socket_close($this->socket); |
| 624 | 797 | $this->connect(); |
| 625 | 798 | } |
@@ -642,22 +815,32 @@ discard block |
||
| 642 | 815 | //$w = '00'; |
| 643 | 816 | $custom = ''; |
| 644 | 817 | if ($ident != '') { |
| 645 | - if ($custom != '') $custom .= '/'; |
|
| 818 | + if ($custom != '') { |
|
| 819 | + $custom .= '/'; |
|
| 820 | + } |
|
| 646 | 821 | $custom .= 'CS='.$ident; |
| 647 | 822 | } |
| 648 | 823 | if ($squawk != '') { |
| 649 | - if ($custom != '') $custom .= '/'; |
|
| 824 | + if ($custom != '') { |
|
| 825 | + $custom .= '/'; |
|
| 826 | + } |
|
| 650 | 827 | $custom .= 'SQ='.$squawk; |
| 651 | 828 | } |
| 652 | 829 | if ($verticalrate != '') { |
| 653 | - if ($custom != '') $custom .= '/'; |
|
| 830 | + if ($custom != '') { |
|
| 831 | + $custom .= '/'; |
|
| 832 | + } |
|
| 654 | 833 | $custom .= 'VR='.$verticalrate; |
| 655 | 834 | } |
| 656 | 835 | if ($aircraft_icao != '' && $aircraft_icao != 'NA') { |
| 657 | - if ($custom != '') $custom .= '/'; |
|
| 836 | + if ($custom != '') { |
|
| 837 | + $custom .= '/'; |
|
| 838 | + } |
|
| 658 | 839 | $custom .= 'AI='.$aircraft_icao; |
| 659 | 840 | } |
| 660 | - if ($custom != '') $custom = ' '.$custom; |
|
| 841 | + if ($custom != '') { |
|
| 842 | + $custom = ' '.$custom; |
|
| 843 | + } |
|
| 661 | 844 | /* |
| 662 | 845 | // Use AMSL altitude |
| 663 | 846 | $GeoidClass = new GeoidHeight(); |
@@ -682,30 +865,44 @@ discard block |
||
| 682 | 865 | //$w = '00'; |
| 683 | 866 | $custom = ''; |
| 684 | 867 | if ($ident != '') { |
| 685 | - if ($custom != '') $custom .= '/'; |
|
| 868 | + if ($custom != '') { |
|
| 869 | + $custom .= '/'; |
|
| 870 | + } |
|
| 686 | 871 | $custom .= 'CS='.str_replace(' ','_',$ident); |
| 687 | 872 | } |
| 688 | 873 | if ($typeid != '') { |
| 689 | - if ($custom != '') $custom .= '/'; |
|
| 874 | + if ($custom != '') { |
|
| 875 | + $custom .= '/'; |
|
| 876 | + } |
|
| 690 | 877 | $custom .= 'TI='.$typeid; |
| 691 | 878 | } |
| 692 | 879 | if ($statusid != '') { |
| 693 | - if ($custom != '') $custom .= '/'; |
|
| 880 | + if ($custom != '') { |
|
| 881 | + $custom .= '/'; |
|
| 882 | + } |
|
| 694 | 883 | $custom .= 'SI='.$statusid; |
| 695 | 884 | } |
| 696 | 885 | if ($imo != '') { |
| 697 | - if ($custom != '') $custom .= '/'; |
|
| 886 | + if ($custom != '') { |
|
| 887 | + $custom .= '/'; |
|
| 888 | + } |
|
| 698 | 889 | $custom .= 'IMO='.$imo; |
| 699 | 890 | } |
| 700 | 891 | if ($arrival_date != '') { |
| 701 | - if ($custom != '') $custom .= '/'; |
|
| 892 | + if ($custom != '') { |
|
| 893 | + $custom .= '/'; |
|
| 894 | + } |
|
| 702 | 895 | $custom .= 'AD='.strtotime($arrival_date); |
| 703 | 896 | } |
| 704 | 897 | if ($arrival_code != '') { |
| 705 | - if ($custom != '') $custom .= '/'; |
|
| 898 | + if ($custom != '') { |
|
| 899 | + $custom .= '/'; |
|
| 900 | + } |
|
| 706 | 901 | $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
| 707 | 902 | } |
| 708 | - if ($custom != '') $custom = ' '.$custom; |
|
| 903 | + if ($custom != '') { |
|
| 904 | + $custom = ' '.$custom; |
|
| 905 | + } |
|
| 709 | 906 | $altitude = 0; |
| 710 | 907 | $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
| 711 | 908 | } |
@@ -1036,8 +1036,11 @@ discard block |
||
| 1036 | 1036 | public function parseNOTAMtextFile($filename) { |
| 1037 | 1037 | $data = file_get_contents($filename); |
| 1038 | 1038 | preg_match_all("/%%(.+?)%%/is", $data, $matches); |
| 1039 | - if (isset($matches[1])) return $matches[1]; |
|
| 1040 | - else return array(); |
|
| 1039 | + if (isset($matches[1])) { |
|
| 1040 | + return $matches[1]; |
|
| 1041 | + } else { |
|
| 1042 | + return array(); |
|
| 1043 | + } |
|
| 1041 | 1044 | } |
| 1042 | 1045 | public function getAllNOTAMbyScope($scope) { |
| 1043 | 1046 | global $globalDBdriver; |
@@ -1073,7 +1076,9 @@ discard block |
||
| 1073 | 1076 | $minlong = $maxlong; |
| 1074 | 1077 | $maxlong = $tmplong; |
| 1075 | 1078 | } |
| 1076 | - } else return array(); |
|
| 1079 | + } else { |
|
| 1080 | + return array(); |
|
| 1081 | + } |
|
| 1077 | 1082 | if ($globalDBdriver == 'mysql') { |
| 1078 | 1083 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()'; |
| 1079 | 1084 | } else { |
@@ -1096,7 +1101,9 @@ discard block |
||
| 1096 | 1101 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1097 | 1102 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1098 | 1103 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1099 | - } else return array(); |
|
| 1104 | + } else { |
|
| 1105 | + return array(); |
|
| 1106 | + } |
|
| 1100 | 1107 | if ($globalDBdriver == 'mysql') { |
| 1101 | 1108 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; |
| 1102 | 1109 | } else { |
@@ -1122,8 +1129,11 @@ discard block |
||
| 1122 | 1129 | return "error : ".$e->getMessage(); |
| 1123 | 1130 | } |
| 1124 | 1131 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1125 | - if (isset($all[0])) return $all[0]; |
|
| 1126 | - else return array(); |
|
| 1132 | + if (isset($all[0])) { |
|
| 1133 | + return $all[0]; |
|
| 1134 | + } else { |
|
| 1135 | + return array(); |
|
| 1136 | + } |
|
| 1127 | 1137 | } |
| 1128 | 1138 | |
| 1129 | 1139 | public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { |
@@ -1201,7 +1211,9 @@ discard block |
||
| 1201 | 1211 | foreach ($alldata as $initial_data) { |
| 1202 | 1212 | $data = $this->parse($initial_data); |
| 1203 | 1213 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1204 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1214 | + if (count($notamref) == 0) { |
|
| 1215 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1216 | + } |
|
| 1205 | 1217 | } |
| 1206 | 1218 | } |
| 1207 | 1219 | } |
@@ -1214,7 +1226,9 @@ discard block |
||
| 1214 | 1226 | foreach ($alldata as $initial_data) { |
| 1215 | 1227 | $data = $this->parse($initial_data); |
| 1216 | 1228 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1217 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1229 | + if (!isset($notamref['notam_id'])) { |
|
| 1230 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1231 | + } |
|
| 1218 | 1232 | } |
| 1219 | 1233 | } |
| 1220 | 1234 | } |
@@ -1226,11 +1240,15 @@ discard block |
||
| 1226 | 1240 | foreach (array_chunk($allairports,20) as $airport) { |
| 1227 | 1241 | $airports_icao = array(); |
| 1228 | 1242 | foreach($airport as $icao) { |
| 1229 | - if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
|
| 1243 | + if (isset($icao['icao'])) { |
|
| 1244 | + $airports_icao[] = $icao['icao']; |
|
| 1245 | + } |
|
| 1230 | 1246 | } |
| 1231 | 1247 | $airport_icao = implode(',',$airports_icao); |
| 1232 | 1248 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1233 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
| 1249 | + if ($globalTransaction) { |
|
| 1250 | + $this->db->beginTransaction(); |
|
| 1251 | + } |
|
| 1234 | 1252 | if (count($alldata) > 0) { |
| 1235 | 1253 | foreach ($alldata as $initial_data) { |
| 1236 | 1254 | //print_r($initial_data); |
@@ -1239,14 +1257,23 @@ discard block |
||
| 1239 | 1257 | if (isset($data['ref'])) { |
| 1240 | 1258 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1241 | 1259 | if (count($notamref) == 0) { |
| 1242 | - if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
| 1243 | - if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
| 1244 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1260 | + if (isset($data['ref_replaced'])) { |
|
| 1261 | + $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
| 1262 | + } |
|
| 1263 | + if (isset($data['ref_cancelled'])) { |
|
| 1264 | + $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
| 1265 | + } elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) { |
|
| 1266 | + echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1267 | + } |
|
| 1245 | 1268 | } |
| 1246 | 1269 | } |
| 1247 | 1270 | } |
| 1248 | - } else echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
| 1249 | - if ($globalTransaction) $this->db->commit(); |
|
| 1271 | + } else { |
|
| 1272 | + echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
| 1273 | + } |
|
| 1274 | + if ($globalTransaction) { |
|
| 1275 | + $this->db->commit(); |
|
| 1276 | + } |
|
| 1250 | 1277 | sleep(5); |
| 1251 | 1278 | } |
| 1252 | 1279 | } |
@@ -1259,8 +1286,11 @@ discard block |
||
| 1259 | 1286 | $data = $Common->getData($url); |
| 1260 | 1287 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
| 1261 | 1288 | //print_r($matches); |
| 1262 | - if (isset($matches[1])) return $matches[1]; |
|
| 1263 | - else return array(); |
|
| 1289 | + if (isset($matches[1])) { |
|
| 1290 | + return $matches[1]; |
|
| 1291 | + } else { |
|
| 1292 | + return array(); |
|
| 1293 | + } |
|
| 1264 | 1294 | } |
| 1265 | 1295 | |
| 1266 | 1296 | public function parse($data) { |
@@ -1291,99 +1321,156 @@ discard block |
||
| 1291 | 1321 | $rules = str_split($matches[3]); |
| 1292 | 1322 | foreach ($rules as $rule) { |
| 1293 | 1323 | if ($rule == 'I') { |
| 1294 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR'; |
|
| 1295 | - else $result['rules'] = 'IFR'; |
|
| 1324 | + if (isset($result['rules'])) { |
|
| 1325 | + $result['rules'] = $result['rules'].'/IFR'; |
|
| 1326 | + } else { |
|
| 1327 | + $result['rules'] = 'IFR'; |
|
| 1328 | + } |
|
| 1296 | 1329 | } elseif ($rule == 'V') { |
| 1297 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR'; |
|
| 1298 | - else $result['rules'] = 'VFR'; |
|
| 1330 | + if (isset($result['rules'])) { |
|
| 1331 | + $result['rules'] = $result['rules'].'/VFR'; |
|
| 1332 | + } else { |
|
| 1333 | + $result['rules'] = 'VFR'; |
|
| 1334 | + } |
|
| 1299 | 1335 | } elseif ($rule == 'K') { |
| 1300 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist'; |
|
| 1301 | - else $result['rules'] = 'Checklist'; |
|
| 1336 | + if (isset($result['rules'])) { |
|
| 1337 | + $result['rules'] = $result['rules'].'/Checklist'; |
|
| 1338 | + } else { |
|
| 1339 | + $result['rules'] = 'Checklist'; |
|
| 1340 | + } |
|
| 1302 | 1341 | } |
| 1303 | 1342 | } |
| 1304 | 1343 | $attentions = str_split($matches[4]); |
| 1305 | 1344 | foreach ($attentions as $attention) { |
| 1306 | 1345 | if ($attention == 'N') { |
| 1307 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention'; |
|
| 1308 | - else $result['rules'] = 'Immediate attention'; |
|
| 1346 | + if (isset($result['attention'])) { |
|
| 1347 | + $result['attention'] = $result['attention'].' / Immediate attention'; |
|
| 1348 | + } else { |
|
| 1349 | + $result['rules'] = 'Immediate attention'; |
|
| 1350 | + } |
|
| 1309 | 1351 | } elseif ($attention == 'B') { |
| 1310 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance'; |
|
| 1311 | - else $result['rules'] = 'Operational significance'; |
|
| 1352 | + if (isset($result['attention'])) { |
|
| 1353 | + $result['attention'] = $result['attention'].' / Operational significance'; |
|
| 1354 | + } else { |
|
| 1355 | + $result['rules'] = 'Operational significance'; |
|
| 1356 | + } |
|
| 1312 | 1357 | } elseif ($attention == 'O') { |
| 1313 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations'; |
|
| 1314 | - else $result['rules'] = 'Flight operations'; |
|
| 1358 | + if (isset($result['attention'])) { |
|
| 1359 | + $result['attention'] = $result['attention'].' / Flight operations'; |
|
| 1360 | + } else { |
|
| 1361 | + $result['rules'] = 'Flight operations'; |
|
| 1362 | + } |
|
| 1315 | 1363 | } elseif ($attention == 'M') { |
| 1316 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc'; |
|
| 1317 | - else $result['rules'] = 'Misc'; |
|
| 1364 | + if (isset($result['attention'])) { |
|
| 1365 | + $result['attention'] = $result['attention'].' / Misc'; |
|
| 1366 | + } else { |
|
| 1367 | + $result['rules'] = 'Misc'; |
|
| 1368 | + } |
|
| 1318 | 1369 | } elseif ($attention == 'K') { |
| 1319 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist'; |
|
| 1320 | - else $result['rules'] = 'Checklist'; |
|
| 1370 | + if (isset($result['attention'])) { |
|
| 1371 | + $result['attention'] = $result['attention'].' / Checklist'; |
|
| 1372 | + } else { |
|
| 1373 | + $result['rules'] = 'Checklist'; |
|
| 1374 | + } |
|
| 1321 | 1375 | } |
| 1322 | 1376 | } |
| 1323 | - if ($matches[5] == 'A') $result['scope'] = 'Airport warning'; |
|
| 1324 | - elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning'; |
|
| 1325 | - elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning'; |
|
| 1326 | - elseif ($matches[5] == 'K') $result['scope'] = 'Checklist'; |
|
| 1327 | - elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning'; |
|
| 1328 | - elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
|
| 1377 | + if ($matches[5] == 'A') { |
|
| 1378 | + $result['scope'] = 'Airport warning'; |
|
| 1379 | + } elseif ($matches[5] == 'E') { |
|
| 1380 | + $result['scope'] = 'Enroute warning'; |
|
| 1381 | + } elseif ($matches[5] == 'W') { |
|
| 1382 | + $result['scope'] = 'Navigation warning'; |
|
| 1383 | + } elseif ($matches[5] == 'K') { |
|
| 1384 | + $result['scope'] = 'Checklist'; |
|
| 1385 | + } elseif ($matches[5] == 'AE') { |
|
| 1386 | + $result['scope'] = 'Airport/Enroute warning'; |
|
| 1387 | + } elseif ($matches[5] == 'AW') { |
|
| 1388 | + $result['scope'] = 'Airport/Navigation warning'; |
|
| 1389 | + } |
|
| 1329 | 1390 | $result['lower_limit'] = $matches[6]; |
| 1330 | 1391 | $result['upper_limit'] = $matches[7]; |
| 1331 | 1392 | $latitude = $Common->convertDec($matches[8],'latitude'); |
| 1332 | - if ($matches[9] == 'S') $latitude = -$latitude; |
|
| 1393 | + if ($matches[9] == 'S') { |
|
| 1394 | + $latitude = -$latitude; |
|
| 1395 | + } |
|
| 1333 | 1396 | $longitude = $Common->convertDec($matches[10],'longitude'); |
| 1334 | - if ($matches[11] == 'W') $longitude = -$longitude; |
|
| 1397 | + if ($matches[11] == 'W') { |
|
| 1398 | + $longitude = -$longitude; |
|
| 1399 | + } |
|
| 1335 | 1400 | $result['latitude'] = $latitude; |
| 1336 | 1401 | $result['longitude'] = $longitude; |
| 1337 | - if ($matches[12] != '') $result['radius'] = intval($matches[12]); |
|
| 1338 | - else $result['radius'] = 0; |
|
| 1402 | + if ($matches[12] != '') { |
|
| 1403 | + $result['radius'] = intval($matches[12]); |
|
| 1404 | + } else { |
|
| 1405 | + $result['radius'] = 0; |
|
| 1406 | + } |
|
| 1339 | 1407 | $q = true; |
| 1340 | 1408 | } elseif ($globalDebug) { |
| 1341 | 1409 | echo 'NOTAM error : '.$result['full_notam']."\n"; |
| 1342 | 1410 | echo "Can't parse : ".$line."\n"; |
| 1343 | 1411 | } |
| 1344 | - } |
|
| 1345 | - elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) { |
|
| 1412 | + } elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) { |
|
| 1346 | 1413 | $result['icao'] = $matches[2]; |
| 1347 | 1414 | $a = true; |
| 1348 | - } |
|
| 1349 | - elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) { |
|
| 1350 | - if ($matches[1] > 50) $year = '19'.$matches[2]; |
|
| 1351 | - else $year = '20'.$matches[2]; |
|
| 1415 | + } elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) { |
|
| 1416 | + if ($matches[1] > 50) { |
|
| 1417 | + $year = '19'.$matches[2]; |
|
| 1418 | + } else { |
|
| 1419 | + $year = '20'.$matches[2]; |
|
| 1420 | + } |
|
| 1352 | 1421 | $result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1353 | 1422 | $b = true; |
| 1354 | - } |
|
| 1355 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) { |
|
| 1356 | - if ($matches[2] > 50) $year = '19'.$matches[2]; |
|
| 1357 | - else $year = '20'.$matches[2]; |
|
| 1423 | + } elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) { |
|
| 1424 | + if ($matches[2] > 50) { |
|
| 1425 | + $year = '19'.$matches[2]; |
|
| 1426 | + } else { |
|
| 1427 | + $year = '20'.$matches[2]; |
|
| 1428 | + } |
|
| 1358 | 1429 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1359 | 1430 | $result['permanent'] = 0; |
| 1360 | 1431 | $c = true; |
| 1361 | - } |
|
| 1362 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1363 | - if ($matches[2] > 50) $year = '19'.$matches[2]; |
|
| 1364 | - else $year = '20'.$matches[2]; |
|
| 1432 | + } elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1433 | + if ($matches[2] > 50) { |
|
| 1434 | + $year = '19'.$matches[2]; |
|
| 1435 | + } else { |
|
| 1436 | + $year = '20'.$matches[2]; |
|
| 1437 | + } |
|
| 1365 | 1438 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1366 | - if ($matches[7] == 'EST') $result['estimated'] = 1; |
|
| 1367 | - else $result['estimated'] = 0; |
|
| 1368 | - if ($matches[7] == 'PERM') $result['permanent'] = 1; |
|
| 1369 | - else $result['permanent'] = 0; |
|
| 1439 | + if ($matches[7] == 'EST') { |
|
| 1440 | + $result['estimated'] = 1; |
|
| 1441 | + } else { |
|
| 1442 | + $result['estimated'] = 0; |
|
| 1443 | + } |
|
| 1444 | + if ($matches[7] == 'PERM') { |
|
| 1445 | + $result['permanent'] = 1; |
|
| 1446 | + } else { |
|
| 1447 | + $result['permanent'] = 0; |
|
| 1448 | + } |
|
| 1370 | 1449 | $c = true; |
| 1371 | - } |
|
| 1372 | - elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1450 | + } elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1373 | 1451 | $result['date_end'] = '2030/12/20 12:00'; |
| 1374 | - if ($matches[2] == 'EST') $result['estimated'] = 1; |
|
| 1375 | - else $result['estimated'] = 0; |
|
| 1376 | - if ($matches[2] == 'PERM') $result['permanent'] = 1; |
|
| 1377 | - else $result['permanent'] = 0; |
|
| 1452 | + if ($matches[2] == 'EST') { |
|
| 1453 | + $result['estimated'] = 1; |
|
| 1454 | + } else { |
|
| 1455 | + $result['estimated'] = 0; |
|
| 1456 | + } |
|
| 1457 | + if ($matches[2] == 'PERM') { |
|
| 1458 | + $result['permanent'] = 1; |
|
| 1459 | + } else { |
|
| 1460 | + $result['permanent'] = 0; |
|
| 1461 | + } |
|
| 1378 | 1462 | $c = true; |
| 1379 | - } |
|
| 1380 | - elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) { |
|
| 1463 | + } elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) { |
|
| 1381 | 1464 | $rtext = array(); |
| 1382 | 1465 | $text = explode(' ',$matches[2]); |
| 1383 | 1466 | foreach ($text as $word) { |
| 1384 | - if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
|
| 1385 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
| 1386 | - else $rtext[] = $word; |
|
| 1467 | + if (isset($this->abbr[$word])) { |
|
| 1468 | + $rtext[] = strtoupper($this->abbr[$word]); |
|
| 1469 | + } elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) { |
|
| 1470 | + $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
| 1471 | + } else { |
|
| 1472 | + $rtext[] = $word; |
|
| 1473 | + } |
|
| 1387 | 1474 | } |
| 1388 | 1475 | $result['text'] = implode(' ',$rtext); |
| 1389 | 1476 | $e = true; |
@@ -1392,7 +1479,9 @@ discard block |
||
| 1392 | 1479 | } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
| 1393 | 1480 | $text = explode(' ',$line); |
| 1394 | 1481 | $result['ref'] = $text[0]; |
| 1395 | - if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
|
| 1482 | + if ($matches[1] == 'NOTAMN') { |
|
| 1483 | + $result['type'] = 'new'; |
|
| 1484 | + } |
|
| 1396 | 1485 | if ($matches[1] == 'NOTAMC') { |
| 1397 | 1486 | $result['type'] = 'cancel'; |
| 1398 | 1487 | $result['ref_cancelled'] = $text[2]; |
@@ -1414,69 +1503,101 @@ discard block |
||
| 1414 | 1503 | switch ($code[1]) { |
| 1415 | 1504 | case 'A': |
| 1416 | 1505 | $result = 'Airspace organization '; |
| 1417 | - if (isset($this->code_airspace[$code_fp])) $result .= $this->code_airspace[$code_fp]; |
|
| 1506 | + if (isset($this->code_airspace[$code_fp])) { |
|
| 1507 | + $result .= $this->code_airspace[$code_fp]; |
|
| 1508 | + } |
|
| 1418 | 1509 | break; |
| 1419 | 1510 | case 'C': |
| 1420 | 1511 | $result = 'Communications and radar facilities '; |
| 1421 | - if (isset($this->code_comradar[$code_fp])) $result .= $this->code_comradar[$code_fp]; |
|
| 1512 | + if (isset($this->code_comradar[$code_fp])) { |
|
| 1513 | + $result .= $this->code_comradar[$code_fp]; |
|
| 1514 | + } |
|
| 1422 | 1515 | break; |
| 1423 | 1516 | case 'F': |
| 1424 | 1517 | $result = 'Facilities and services '; |
| 1425 | - if (isset($this->code_facilities[$code_fp])) $result .= $this->code_facilities[$code_fp]; |
|
| 1518 | + if (isset($this->code_facilities[$code_fp])) { |
|
| 1519 | + $result .= $this->code_facilities[$code_fp]; |
|
| 1520 | + } |
|
| 1426 | 1521 | break; |
| 1427 | 1522 | case 'I': |
| 1428 | 1523 | $result = 'Instrument and Microwave Landing System '; |
| 1429 | - if (isset($this->code_instrumentlanding[$code_fp])) $result .= $this->code_instrumentlanding[$code_fp]; |
|
| 1524 | + if (isset($this->code_instrumentlanding[$code_fp])) { |
|
| 1525 | + $result .= $this->code_instrumentlanding[$code_fp]; |
|
| 1526 | + } |
|
| 1430 | 1527 | break; |
| 1431 | 1528 | case 'L': |
| 1432 | 1529 | $result = 'Lighting facilities '; |
| 1433 | - if (isset($this->code_lightingfacilities[$code_fp])) $result .= $this->code_lightingfacilities[$code_fp]; |
|
| 1530 | + if (isset($this->code_lightingfacilities[$code_fp])) { |
|
| 1531 | + $result .= $this->code_lightingfacilities[$code_fp]; |
|
| 1532 | + } |
|
| 1434 | 1533 | break; |
| 1435 | 1534 | case 'M': |
| 1436 | 1535 | $result = 'Movement and landing areas '; |
| 1437 | - if (isset($this->code_movementareas[$code_fp])) $result .= $this->code_movementareas[$code_fp]; |
|
| 1536 | + if (isset($this->code_movementareas[$code_fp])) { |
|
| 1537 | + $result .= $this->code_movementareas[$code_fp]; |
|
| 1538 | + } |
|
| 1438 | 1539 | break; |
| 1439 | 1540 | case 'N': |
| 1440 | 1541 | $result = 'Terminal and En Route Navigation Facilities '; |
| 1441 | - if (isset($this->code_terminalfacilities[$code_fp])) $result .= $this->code_terminalfacilities[$code_fp]; |
|
| 1542 | + if (isset($this->code_terminalfacilities[$code_fp])) { |
|
| 1543 | + $result .= $this->code_terminalfacilities[$code_fp]; |
|
| 1544 | + } |
|
| 1442 | 1545 | break; |
| 1443 | 1546 | case 'O': |
| 1444 | 1547 | $result = 'Other information '; |
| 1445 | - if (isset($this->code_information[$code_fp])) $result .= $this->code_information[$code_fp]; |
|
| 1548 | + if (isset($this->code_information[$code_fp])) { |
|
| 1549 | + $result .= $this->code_information[$code_fp]; |
|
| 1550 | + } |
|
| 1446 | 1551 | break; |
| 1447 | 1552 | case 'P': |
| 1448 | 1553 | $result = 'Air Traffic procedures '; |
| 1449 | - if (isset($this->code_airtraffic[$code_fp])) $result .= $this->code_airtraffic[$code_fp]; |
|
| 1554 | + if (isset($this->code_airtraffic[$code_fp])) { |
|
| 1555 | + $result .= $this->code_airtraffic[$code_fp]; |
|
| 1556 | + } |
|
| 1450 | 1557 | break; |
| 1451 | 1558 | case 'R': |
| 1452 | 1559 | $result = 'Navigation Warnings: Airspace Restrictions '; |
| 1453 | - if (isset($this->code_navigationw[$code_fp])) $result .= $this->code_navigationw[$code_fp]; |
|
| 1560 | + if (isset($this->code_navigationw[$code_fp])) { |
|
| 1561 | + $result .= $this->code_navigationw[$code_fp]; |
|
| 1562 | + } |
|
| 1454 | 1563 | break; |
| 1455 | 1564 | case 'S': |
| 1456 | 1565 | $result = 'Air Traffic and VOLMET Services '; |
| 1457 | - if (isset($this->code_volmet[$code_fp])) $result .= $this->code_volmet[$code_fp]; |
|
| 1566 | + if (isset($this->code_volmet[$code_fp])) { |
|
| 1567 | + $result .= $this->code_volmet[$code_fp]; |
|
| 1568 | + } |
|
| 1458 | 1569 | break; |
| 1459 | 1570 | case 'W': |
| 1460 | 1571 | $result = 'Navigation Warnings: Warnings '; |
| 1461 | - if (isset($this->code_warnings[$code_fp])) $result .= $this->code_warnings[$code_fp]; |
|
| 1572 | + if (isset($this->code_warnings[$code_fp])) { |
|
| 1573 | + $result .= $this->code_warnings[$code_fp]; |
|
| 1574 | + } |
|
| 1462 | 1575 | break; |
| 1463 | 1576 | } |
| 1464 | 1577 | switch ($code[3]) { |
| 1465 | 1578 | case 'A': |
| 1466 | 1579 | // Availability |
| 1467 | - if (isset($this->code_sp_availabity[$code_sp])) $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
| 1580 | + if (isset($this->code_sp_availabity[$code_sp])) { |
|
| 1581 | + $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
| 1582 | + } |
|
| 1468 | 1583 | break; |
| 1469 | 1584 | case 'C': |
| 1470 | 1585 | // Changes |
| 1471 | - if (isset($this->code_sp_changes[$code_sp])) $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
| 1586 | + if (isset($this->code_sp_changes[$code_sp])) { |
|
| 1587 | + $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
| 1588 | + } |
|
| 1472 | 1589 | break; |
| 1473 | 1590 | case 'H': |
| 1474 | 1591 | // Hazardous conditions |
| 1475 | - if (isset($this->code_sp_hazardous[$code_sp])) $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
| 1592 | + if (isset($this->code_sp_hazardous[$code_sp])) { |
|
| 1593 | + $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
| 1594 | + } |
|
| 1476 | 1595 | break; |
| 1477 | 1596 | case 'L': |
| 1478 | 1597 | // Limitations |
| 1479 | - if (isset($this->code_sp_limitations[$code_sp])) $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
| 1598 | + if (isset($this->code_sp_limitations[$code_sp])) { |
|
| 1599 | + $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
| 1600 | + } |
|
| 1480 | 1601 | break; |
| 1481 | 1602 | case 'X': |
| 1482 | 1603 | // Other Information |
@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | public function __construct($dbc = null) { |
| 21 | 21 | $Connection = new Connection($dbc); |
| 22 | 22 | $this->db = $Connection->db(); |
| 23 | - if ($this->db === null) die('Error: No DB connection. (Accident)'); |
|
| 23 | + if ($this->db === null) { |
|
| 24 | + die('Error: No DB connection. (Accident)'); |
|
| 25 | + } |
|
| 24 | 26 | } |
| 25 | 27 | |
| 26 | 28 | /* |
@@ -123,8 +125,11 @@ discard block |
||
| 123 | 125 | $data = array(); |
| 124 | 126 | if ($row['registration'] != '') { |
| 125 | 127 | $image_array = $Image->getSpotterImage($row['registration']); |
| 126 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 127 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 128 | + if (count($image_array) > 0) { |
|
| 129 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 130 | + } else { |
|
| 131 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 132 | + } |
|
| 128 | 133 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
| 129 | 134 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
| 130 | 135 | if (!empty($aircraft_info)) { |
@@ -140,17 +145,30 @@ discard block |
||
| 140 | 145 | $data['aircraft_base'] = $owner_data['base']; |
| 141 | 146 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
| 142 | 147 | } |
| 143 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 144 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 145 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 148 | + } else { |
|
| 149 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 150 | + } |
|
| 151 | + if ($row['registration'] == '') { |
|
| 152 | + $row['registration'] = 'NA'; |
|
| 153 | + } |
|
| 154 | + if ($row['ident'] == '') { |
|
| 155 | + $row['ident'] = 'NA'; |
|
| 156 | + } |
|
| 146 | 157 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
| 147 | 158 | if (isset($identicao[0])) { |
| 148 | 159 | if (substr($row['ident'],0,2) == 'AF') { |
| 149 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 150 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 151 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 160 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 161 | + $icao = $row['ident']; |
|
| 162 | + } else { |
|
| 163 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 164 | + } |
|
| 165 | + } else { |
|
| 166 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 167 | + } |
|
| 152 | 168 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 153 | - } else $icao = $row['ident']; |
|
| 169 | + } else { |
|
| 170 | + $icao = $row['ident']; |
|
| 171 | + } |
|
| 154 | 172 | $icao = $Translation->checkTranslation($icao,false); |
| 155 | 173 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
| 156 | 174 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
@@ -165,10 +183,14 @@ discard block |
||
| 165 | 183 | //else echo 'No data...'."\n"; |
| 166 | 184 | } |
| 167 | 185 | $data = array_merge($row,$data); |
| 168 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
| 186 | + if ($data['ident'] == null) { |
|
| 187 | + $data['ident'] = $icao; |
|
| 188 | + } |
|
| 169 | 189 | if ($data['title'] == null) { |
| 170 | 190 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
| 171 | - } else $data['message'] = strtolower($data['title']); |
|
| 191 | + } else { |
|
| 192 | + $data['message'] = strtolower($data['title']); |
|
| 193 | + } |
|
| 172 | 194 | $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
| 173 | 195 | $date = $data['date']; |
| 174 | 196 | if (isset($ids[$date])) { |
@@ -187,8 +209,9 @@ discard block |
||
| 187 | 209 | if (isset($result)) { |
| 188 | 210 | $result[0]['query_number_rows'] = $i; |
| 189 | 211 | return $result; |
| 212 | + } else { |
|
| 213 | + return array(); |
|
| 190 | 214 | } |
| 191 | - else return array(); |
|
| 192 | 215 | } |
| 193 | 216 | |
| 194 | 217 | /* |
@@ -233,7 +256,9 @@ discard block |
||
| 233 | 256 | */ |
| 234 | 257 | public function import($file) { |
| 235 | 258 | global $globalTransaction, $globalDebug; |
| 236 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
| 259 | + if ($globalDebug) { |
|
| 260 | + echo 'Import '.$file."\n"; |
|
| 261 | + } |
|
| 237 | 262 | $result = array(); |
| 238 | 263 | if (file_exists($file)) { |
| 239 | 264 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -244,8 +269,11 @@ discard block |
||
| 244 | 269 | } |
| 245 | 270 | fclose($handle); |
| 246 | 271 | } |
| 247 | - if (!empty($result)) $this->add($result,true); |
|
| 248 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
| 272 | + if (!empty($result)) { |
|
| 273 | + $this->add($result,true); |
|
| 274 | + } elseif ($globalDebug) { |
|
| 275 | + echo 'Nothing to import'; |
|
| 276 | + } |
|
| 249 | 277 | } |
| 250 | 278 | } |
| 251 | 279 | |
@@ -281,14 +309,23 @@ discard block |
||
| 281 | 309 | } |
| 282 | 310 | } |
| 283 | 311 | fclose($handle); |
| 284 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
| 285 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
| 312 | + } elseif ($globalDebug) { |
|
| 313 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
| 314 | + } |
|
| 315 | + } elseif ($globalDebug) { |
|
| 316 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
| 317 | + } |
|
| 286 | 318 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
| 287 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
| 319 | + if (empty($result) && $globalDebug) { |
|
| 320 | + echo 'Nothing to update'; |
|
| 321 | + } |
|
| 288 | 322 | foreach ($result as $file => $md5) { |
| 289 | 323 | $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
| 290 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 291 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
| 324 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
| 325 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 326 | + } elseif ($globalDebug) { |
|
| 327 | + echo 'Download '.$file.' failed'; |
|
| 328 | + } |
|
| 292 | 329 | } |
| 293 | 330 | } |
| 294 | 331 | |
@@ -305,13 +342,17 @@ discard block |
||
| 305 | 342 | $Image = new Image($this->db); |
| 306 | 343 | $Spotter = new Spotter($this->db); |
| 307 | 344 | |
| 308 | - if (empty($crash)) return false; |
|
| 345 | + if (empty($crash)) { |
|
| 346 | + return false; |
|
| 347 | + } |
|
| 309 | 348 | if (!$new) { |
| 310 | 349 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
| 311 | 350 | $sthd = $Connection->db->prepare($query_delete); |
| 312 | 351 | $sthd->execute(array(':source' => $crash[0]['source'])); |
| 313 | 352 | } |
| 314 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 353 | + if ($globalTransaction) { |
|
| 354 | + $Connection->db->beginTransaction(); |
|
| 355 | + } |
|
| 315 | 356 | $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
| 316 | 357 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
| 317 | 358 | $sth_check = $Connection->db->prepare($query_check); |
@@ -326,7 +367,9 @@ discard block |
||
| 326 | 367 | return $value === "" ? NULL : $value; |
| 327 | 368 | }, $cr); |
| 328 | 369 | if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
| 329 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 370 | + if (strpos($cr['registration'],'-') === FALSE) { |
|
| 371 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 372 | + } |
|
| 330 | 373 | $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
| 331 | 374 | $sth_check->execute($query_check_values); |
| 332 | 375 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
@@ -336,13 +379,19 @@ discard block |
||
| 336 | 379 | if ($cr['date'] > time()-(30*86400)) { |
| 337 | 380 | $imgchk = $Image->getSpotterImage($cr['registration']); |
| 338 | 381 | if (empty($imgchk)) { |
| 339 | - if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
|
| 382 | + if ($globalDebug) { |
|
| 383 | + echo "\t".'Get image for '.$cr['registration'].'...'; |
|
| 384 | + } |
|
| 340 | 385 | $Image->addSpotterImage($cr['registration']); |
| 341 | - if ($globalDebug) echo "\t".'Done'."\n"; |
|
| 386 | + if ($globalDebug) { |
|
| 387 | + echo "\t".'Done'."\n"; |
|
| 388 | + } |
|
| 342 | 389 | } |
| 343 | 390 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
| 344 | 391 | } |
| 345 | - if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
| 392 | + if ($cr['title'] == '') { |
|
| 393 | + $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
| 394 | + } |
|
| 346 | 395 | $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
| 347 | 396 | } |
| 348 | 397 | } |
@@ -351,9 +400,13 @@ discard block |
||
| 351 | 400 | $Connection->db->beginTransaction(); |
| 352 | 401 | } |
| 353 | 402 | } |
| 354 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 403 | + if ($globalTransaction) { |
|
| 404 | + $Connection->db->commit(); |
|
| 405 | + } |
|
| 355 | 406 | } catch(PDOException $e) { |
| 356 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 407 | + if ($globalTransaction) { |
|
| 408 | + $Connection->db->rollBack(); |
|
| 409 | + } |
|
| 357 | 410 | echo $e->getMessage(); |
| 358 | 411 | } |
| 359 | 412 | $sth_check->closeCursor(); |
@@ -392,8 +445,11 @@ discard block |
||
| 392 | 445 | return "error : ".$e->getMessage(); |
| 393 | 446 | } |
| 394 | 447 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 395 | - if ($row['nb'] > 0) return false; |
|
| 396 | - else return true; |
|
| 448 | + if ($row['nb'] > 0) { |
|
| 449 | + return false; |
|
| 450 | + } else { |
|
| 451 | + return true; |
|
| 452 | + } |
|
| 397 | 453 | } |
| 398 | 454 | |
| 399 | 455 | public static function insert_last_accidents_update() { |
@@ -79,9 +79,15 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public function TrackMatching($spotter_history_array) { |
| 81 | 81 | global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId; |
| 82 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
| 83 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 84 | - if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
| 82 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 83 | + $globalMapMatchingMaxPts = 100; |
|
| 84 | + } |
|
| 85 | + if (count($spotter_history_array) < 2) { |
|
| 86 | + return $spotter_history_array; |
|
| 87 | + } |
|
| 88 | + if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
|
| 89 | + $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
| 90 | + } |
|
| 85 | 91 | $data = $this->create_gpx($spotter_history_array); |
| 86 | 92 | $url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true'; |
| 87 | 93 | $Common = new Common(); |
@@ -107,8 +113,12 @@ discard block |
||
| 107 | 113 | */ |
| 108 | 114 | public function GraphHopper($spotter_history_array) { |
| 109 | 115 | global $globalMapMatchingMaxPts, $globalGraphHopperKey; |
| 110 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
| 111 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 116 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 117 | + $globalMapMatchingMaxPts = 100; |
|
| 118 | + } |
|
| 119 | + if (count($spotter_history_array) < 2) { |
|
| 120 | + return $spotter_history_array; |
|
| 121 | + } |
|
| 112 | 122 | $spotter_history_initial_array = array(); |
| 113 | 123 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 114 | 124 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -137,8 +147,12 @@ discard block |
||
| 137 | 147 | */ |
| 138 | 148 | public function osmr($spotter_history_array) { |
| 139 | 149 | global $globalMapMatchingMaxPts; |
| 140 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 50; |
|
| 141 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 150 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 151 | + $globalMapMatchingMaxPts = 50; |
|
| 152 | + } |
|
| 153 | + if (count($spotter_history_array) < 2) { |
|
| 154 | + return $spotter_history_array; |
|
| 155 | + } |
|
| 142 | 156 | $spotter_history_initial_array = array(); |
| 143 | 157 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 144 | 158 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -148,11 +162,17 @@ discard block |
||
| 148 | 162 | $ts = ''; |
| 149 | 163 | $rd = ''; |
| 150 | 164 | foreach ($spotter_history_array as $spotter_data) { |
| 151 | - if ($coord != '') $coord .= ';'; |
|
| 165 | + if ($coord != '') { |
|
| 166 | + $coord .= ';'; |
|
| 167 | + } |
|
| 152 | 168 | $coord .= $spotter_data['longitude'].','.$spotter_data['latitude']; |
| 153 | - if ($ts != '') $ts .= ';'; |
|
| 169 | + if ($ts != '') { |
|
| 170 | + $ts .= ';'; |
|
| 171 | + } |
|
| 154 | 172 | $ts .= strtotime($spotter_data['date']); |
| 155 | - if ($rd != '') $rd .= ';'; |
|
| 173 | + if ($rd != '') { |
|
| 174 | + $rd .= ';'; |
|
| 175 | + } |
|
| 156 | 176 | $rd .= '20'; |
| 157 | 177 | } |
| 158 | 178 | $url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore'; |
@@ -177,8 +197,12 @@ discard block |
||
| 177 | 197 | */ |
| 178 | 198 | public function mapbox($spotter_history_array) { |
| 179 | 199 | global $globalMapMatchingMaxPts, $globalMapboxToken; |
| 180 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 60; |
|
| 181 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 200 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 201 | + $globalMapMatchingMaxPts = 60; |
|
| 202 | + } |
|
| 203 | + if (count($spotter_history_array) < 2) { |
|
| 204 | + return $spotter_history_array; |
|
| 205 | + } |
|
| 182 | 206 | $spotter_history_initial_array = array(); |
| 183 | 207 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 184 | 208 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -188,11 +212,17 @@ discard block |
||
| 188 | 212 | $ts = ''; |
| 189 | 213 | $rd = ''; |
| 190 | 214 | foreach ($spotter_history_array as $spotter_data) { |
| 191 | - if ($coord != '') $coord .= ';'; |
|
| 215 | + if ($coord != '') { |
|
| 216 | + $coord .= ';'; |
|
| 217 | + } |
|
| 192 | 218 | $coord .= $spotter_data['longitude'].','.$spotter_data['latitude']; |
| 193 | - if ($ts != '') $ts .= ';'; |
|
| 219 | + if ($ts != '') { |
|
| 220 | + $ts .= ';'; |
|
| 221 | + } |
|
| 194 | 222 | $ts .= strtotime($spotter_data['date']); |
| 195 | - if ($rd != '') $rd .= ';'; |
|
| 223 | + if ($rd != '') { |
|
| 224 | + $rd .= ';'; |
|
| 225 | + } |
|
| 196 | 226 | $rd .= '20'; |
| 197 | 227 | } |
| 198 | 228 | //$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'×tamps='.$ts.'&overview=full&tidy=true&geometries=geojson&radiuses='.$rd; |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | public function __construct($dbc = null) { |
| 24 | 24 | $Connection = new Connection($dbc); |
| 25 | 25 | $this->db = $Connection->db(); |
| 26 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 26 | + if ($this->db === null) { |
|
| 27 | + die('Error: No DB connection.'); |
|
| 28 | + } |
|
| 27 | 29 | } |
| 28 | 30 | |
| 29 | 31 | /** |
@@ -138,7 +140,9 @@ discard block |
||
| 138 | 140 | $sth->closeCursor(); |
| 139 | 141 | if (count($row) > 0) { |
| 140 | 142 | return $row; |
| 141 | - } else return array(); |
|
| 143 | + } else { |
|
| 144 | + return array(); |
|
| 145 | + } |
|
| 142 | 146 | } |
| 143 | 147 | |
| 144 | 148 | /* |
@@ -179,7 +183,9 @@ discard block |
||
| 179 | 183 | $Common = new Common(); |
| 180 | 184 | $check_date = new Datetime($date); |
| 181 | 185 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 182 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 186 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 187 | + return array(); |
|
| 188 | + } |
|
| 183 | 189 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
| 184 | 190 | $json = $Common->getData($url); |
| 185 | 191 | |
@@ -206,7 +212,9 @@ discard block |
||
| 206 | 212 | */ |
| 207 | 213 | |
| 208 | 214 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
| 209 | - } else return array(); |
|
| 215 | + } else { |
|
| 216 | + return array(); |
|
| 217 | + } |
|
| 210 | 218 | } |
| 211 | 219 | |
| 212 | 220 | /** |
@@ -221,7 +229,9 @@ discard block |
||
| 221 | 229 | date_default_timezone_set($globalTimezone); |
| 222 | 230 | $check_date = new Datetime($date); |
| 223 | 231 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 224 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 232 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 233 | + return array(); |
|
| 234 | + } |
|
| 225 | 235 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
| 226 | 236 | $json = $Common->getData($url); |
| 227 | 237 | $parsed_json = json_decode($json); |
@@ -234,7 +244,9 @@ discard block |
||
| 234 | 244 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
| 235 | 245 | |
| 236 | 246 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
| 237 | - } else return array(); |
|
| 247 | + } else { |
|
| 248 | + return array(); |
|
| 249 | + } |
|
| 238 | 250 | } |
| 239 | 251 | |
| 240 | 252 | /** |
@@ -245,7 +257,9 @@ discard block |
||
| 245 | 257 | private function getRyanair($callsign) { |
| 246 | 258 | $Common = new Common(); |
| 247 | 259 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 248 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 260 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 261 | + return array(); |
|
| 262 | + } |
|
| 249 | 263 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
| 250 | 264 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
| 251 | 265 | $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
@@ -259,8 +273,12 @@ discard block |
||
| 259 | 273 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
| 260 | 274 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
| 261 | 275 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
| 262 | - } else return array(); |
|
| 263 | - } else return array(); |
|
| 276 | + } else { |
|
| 277 | + return array(); |
|
| 278 | + } |
|
| 279 | + } else { |
|
| 280 | + return array(); |
|
| 281 | + } |
|
| 264 | 282 | } |
| 265 | 283 | |
| 266 | 284 | /** |
@@ -271,7 +289,9 @@ discard block |
||
| 271 | 289 | private function getSwiss($callsign) { |
| 272 | 290 | $Common = new Common(); |
| 273 | 291 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 274 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 292 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 293 | + return array(); |
|
| 294 | + } |
|
| 275 | 295 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
| 276 | 296 | $json = $Common->getData($url); |
| 277 | 297 | $parsed_json = json_decode($json); |
@@ -291,8 +311,12 @@ discard block |
||
| 291 | 311 | } |
| 292 | 312 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
| 293 | 313 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
| 294 | - } else return array(); |
|
| 295 | - } else return array(); |
|
| 314 | + } else { |
|
| 315 | + return array(); |
|
| 316 | + } |
|
| 317 | + } else { |
|
| 318 | + return array(); |
|
| 319 | + } |
|
| 296 | 320 | } |
| 297 | 321 | |
| 298 | 322 | /** |
@@ -306,12 +330,18 @@ discard block |
||
| 306 | 330 | $Common = new Common(); |
| 307 | 331 | $check_date = new Datetime($date); |
| 308 | 332 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 309 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 310 | - if ($globalBritishAirwaysKey == '') return array(); |
|
| 333 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 334 | + return array(); |
|
| 335 | + } |
|
| 336 | + if ($globalBritishAirwaysKey == '') { |
|
| 337 | + return array(); |
|
| 338 | + } |
|
| 311 | 339 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
| 312 | 340 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
| 313 | 341 | $json = $Common->getData($url,'get','',$headers); |
| 314 | - if ($json == '') return array(); |
|
| 342 | + if ($json == '') { |
|
| 343 | + return array(); |
|
| 344 | + } |
|
| 315 | 345 | $parsed_json = json_decode($json); |
| 316 | 346 | $flights = $parsed_json->{'FlightsResponse'}; |
| 317 | 347 | if (count($flights) > 0) { |
@@ -320,7 +350,9 @@ discard block |
||
| 320 | 350 | $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
| 321 | 351 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
| 322 | 352 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
| 323 | - } else return array(); |
|
| 353 | + } else { |
|
| 354 | + return array(); |
|
| 355 | + } |
|
| 324 | 356 | } |
| 325 | 357 | |
| 326 | 358 | /** |
@@ -334,19 +366,27 @@ discard block |
||
| 334 | 366 | $Common = new Common(); |
| 335 | 367 | $check_date = new Datetime($date); |
| 336 | 368 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 337 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 338 | - if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
|
| 369 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 370 | + return array(); |
|
| 371 | + } |
|
| 372 | + if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') { |
|
| 373 | + return array(); |
|
| 374 | + } |
|
| 339 | 375 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
| 340 | 376 | $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
| 341 | 377 | $data = $Common->getData($url,'post',$post); |
| 342 | 378 | $parsed_data = json_decode($data); |
| 343 | - if (!isset($parsed_data->{'access_token'})) return array(); |
|
| 379 | + if (!isset($parsed_data->{'access_token'})) { |
|
| 380 | + return array(); |
|
| 381 | + } |
|
| 344 | 382 | $token = $parsed_data->{'access_token'}; |
| 345 | 383 | |
| 346 | 384 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
| 347 | 385 | $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
| 348 | 386 | $json = $Common->getData($url,'get','',$headers); |
| 349 | - if ($json == '') return array(); |
|
| 387 | + if ($json == '') { |
|
| 388 | + return array(); |
|
| 389 | + } |
|
| 350 | 390 | $parsed_json = json_decode($json); |
| 351 | 391 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
| 352 | 392 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
@@ -354,7 +394,9 @@ discard block |
||
| 354 | 394 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
| 355 | 395 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
| 356 | 396 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
| 357 | - } else return array(); |
|
| 397 | + } else { |
|
| 398 | + return array(); |
|
| 399 | + } |
|
| 358 | 400 | } |
| 359 | 401 | |
| 360 | 402 | /** |
@@ -368,14 +410,20 @@ discard block |
||
| 368 | 410 | $Common = new Common(); |
| 369 | 411 | $check_date = new Datetime($date); |
| 370 | 412 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 371 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 372 | - if ($globalTransaviaKey == '') return array(); |
|
| 413 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 414 | + return array(); |
|
| 415 | + } |
|
| 416 | + if ($globalTransaviaKey == '') { |
|
| 417 | + return array(); |
|
| 418 | + } |
|
| 373 | 419 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 374 | 420 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 375 | 421 | $headers = array('apikey: '.$globalTransaviaKey); |
| 376 | 422 | $json = $Common->getData($url,'get','',$headers); |
| 377 | 423 | //echo 'result : '.$json; |
| 378 | - if ($json == '') return array(); |
|
| 424 | + if ($json == '') { |
|
| 425 | + return array(); |
|
| 426 | + } |
|
| 379 | 427 | $parsed_json = json_decode($json); |
| 380 | 428 | |
| 381 | 429 | if (isset($parsed_json->{'data'}[0])) { |
@@ -384,7 +432,9 @@ discard block |
||
| 384 | 432 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
| 385 | 433 | $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
| 386 | 434 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
| 387 | - } else return array(); |
|
| 435 | + } else { |
|
| 436 | + return array(); |
|
| 437 | + } |
|
| 388 | 438 | } |
| 389 | 439 | |
| 390 | 440 | /** |
@@ -395,7 +445,9 @@ discard block |
||
| 395 | 445 | public function getTunisair($callsign) { |
| 396 | 446 | $Common = new Common(); |
| 397 | 447 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 398 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 448 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 449 | + return array(); |
|
| 450 | + } |
|
| 399 | 451 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
| 400 | 452 | $data = $Common->getData($url); |
| 401 | 453 | $table = $Common->table2array($data); |
@@ -416,7 +468,9 @@ discard block |
||
| 416 | 468 | $Common = new Common(); |
| 417 | 469 | $check_date = new Datetime($date); |
| 418 | 470 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 419 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 471 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 472 | + return array(); |
|
| 473 | + } |
|
| 420 | 474 | $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
| 421 | 475 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
| 422 | 476 | $data = $Common->getData($url); |
@@ -426,8 +480,11 @@ discard block |
||
| 426 | 480 | $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
| 427 | 481 | preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
| 428 | 482 | $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
| 429 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 430 | - else return array(); |
|
| 483 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') { |
|
| 484 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 485 | + } else { |
|
| 486 | + return array(); |
|
| 487 | + } |
|
| 431 | 488 | } |
| 432 | 489 | return array(); |
| 433 | 490 | } |
@@ -442,7 +499,9 @@ discard block |
||
| 442 | 499 | $Common = new Common(); |
| 443 | 500 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 444 | 501 | $check_date = new Datetime($date); |
| 445 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 502 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 503 | + return array(); |
|
| 504 | + } |
|
| 446 | 505 | $url = "https://www.iberia.com/web/flightDetail.do"; |
| 447 | 506 | $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
| 448 | 507 | $data = $Common->getData($url,'post',$post); |
@@ -459,7 +518,9 @@ discard block |
||
| 459 | 518 | $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
| 460 | 519 | if ($arrivalTime == 'Hora estimada de llegada') { |
| 461 | 520 | $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
| 462 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
| 521 | + } else { |
|
| 522 | + $arrivalTime = substr($arrivalTime,0,5); |
|
| 523 | + } |
|
| 463 | 524 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
| 464 | 525 | } |
| 465 | 526 | } |
@@ -477,7 +538,9 @@ discard block |
||
| 477 | 538 | $Common = new Common(); |
| 478 | 539 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 479 | 540 | $check_date = new Datetime($date); |
| 480 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 541 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 542 | + return array(); |
|
| 543 | + } |
|
| 481 | 544 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
| 482 | 545 | $data = $Common->getData($url); |
| 483 | 546 | if ($data != '') { |
@@ -493,7 +556,9 @@ discard block |
||
| 493 | 556 | $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
| 494 | 557 | $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
| 495 | 558 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
| 496 | - } else return array(); |
|
| 559 | + } else { |
|
| 560 | + return array(); |
|
| 561 | + } |
|
| 497 | 562 | } |
| 498 | 563 | |
| 499 | 564 | |
@@ -513,7 +578,9 @@ discard block |
||
| 513 | 578 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 514 | 579 | $check_date = new Datetime($date); |
| 515 | 580 | $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
| 516 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 581 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 582 | + return array(); |
|
| 583 | + } |
|
| 517 | 584 | $data = $Common->getData($url); |
| 518 | 585 | if ($data != '') { |
| 519 | 586 | $table = $Common->text2array($data); |
@@ -537,7 +604,9 @@ discard block |
||
| 537 | 604 | $check_date = new Datetime($date); |
| 538 | 605 | $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
| 539 | 606 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
| 540 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 607 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 608 | + return array(); |
|
| 609 | + } |
|
| 541 | 610 | $data = $Common->getData($url); |
| 542 | 611 | if ($data != '') { |
| 543 | 612 | //echo $data; |
@@ -627,7 +696,9 @@ discard block |
||
| 627 | 696 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 628 | 697 | $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
| 629 | 698 | //$check_date = new Datetime($date); |
| 630 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 699 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 700 | + return array(); |
|
| 701 | + } |
|
| 631 | 702 | $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
| 632 | 703 | $data = $Common->getData($url,'post',$post); |
| 633 | 704 | if ($data != '') { |
@@ -659,11 +730,15 @@ discard block |
||
| 659 | 730 | $airline_icao = substr($callsign, 0, 3); |
| 660 | 731 | } |
| 661 | 732 | } |
| 662 | - if ($airline_icao == '') return array(); |
|
| 733 | + if ($airline_icao == '') { |
|
| 734 | + return array(); |
|
| 735 | + } |
|
| 663 | 736 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 664 | 737 | $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
| 665 | 738 | //$check_date = new Datetime($date); |
| 666 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 739 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 740 | + return array(); |
|
| 741 | + } |
|
| 667 | 742 | $data = $Common->getData($url); |
| 668 | 743 | if ($data != '') { |
| 669 | 744 | $table = $Common->table2array($data); |
@@ -756,10 +831,16 @@ discard block |
||
| 756 | 831 | if ($data != '') { |
| 757 | 832 | $table = $Common->table2array($data); |
| 758 | 833 | if (isset($table[11][1])) { |
| 759 | - if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5); |
|
| 760 | - else $departureTime = ''; |
|
| 761 | - if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5); |
|
| 762 | - else $arrivalTime = ''; |
|
| 834 | + if (is_numeric(substr($table[11][1],0,1))) { |
|
| 835 | + $departureTime = substr($table[11][1],0,5); |
|
| 836 | + } else { |
|
| 837 | + $departureTime = ''; |
|
| 838 | + } |
|
| 839 | + if (is_numeric(substr($table[17][1],0,1))) { |
|
| 840 | + $arrivalTime = substr($table[17][1],0,5); |
|
| 841 | + } else { |
|
| 842 | + $arrivalTime = ''; |
|
| 843 | + } |
|
| 763 | 844 | $DepartureAirportIata = substr($table[13][1],0,3); |
| 764 | 845 | $ArrivalAirportIata = substr($table[15][1],0,3); |
| 765 | 846 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
@@ -776,16 +857,22 @@ discard block |
||
| 776 | 857 | */ |
| 777 | 858 | private function getAirCanada($callsign,$date = 'NOW') { |
| 778 | 859 | $Common = new Common(); |
| 779 | - if (class_exists("DomDocument") === FALSE) return array(); |
|
| 860 | + if (class_exists("DomDocument") === FALSE) { |
|
| 861 | + return array(); |
|
| 862 | + } |
|
| 780 | 863 | date_default_timezone_set('UTC'); |
| 781 | 864 | $check_date = new Datetime($date); |
| 782 | 865 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 783 | 866 | $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
| 784 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 867 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 868 | + return array(); |
|
| 869 | + } |
|
| 785 | 870 | $data = $Common->getData($url); |
| 786 | 871 | $dom = new DomDocument(); |
| 787 | 872 | $dom->loadXML($data); |
| 788 | - if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array(); |
|
| 873 | + if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) { |
|
| 874 | + return array(); |
|
| 875 | + } |
|
| 789 | 876 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
| 790 | 877 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
| 791 | 878 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
@@ -794,7 +881,9 @@ discard block |
||
| 794 | 881 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 795 | 882 | $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
| 796 | 883 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
| 797 | - } else return array(); |
|
| 884 | + } else { |
|
| 885 | + return array(); |
|
| 886 | + } |
|
| 798 | 887 | } |
| 799 | 888 | |
| 800 | 889 | /** |
@@ -808,7 +897,9 @@ discard block |
||
| 808 | 897 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 809 | 898 | $check_date = new Datetime($date); |
| 810 | 899 | $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
| 811 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 900 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 901 | + return array(); |
|
| 902 | + } |
|
| 812 | 903 | $data = $Common->getData($url); |
| 813 | 904 | if ($data != '') { |
| 814 | 905 | $table = $Common->table2array($data); |
@@ -837,7 +928,9 @@ discard block |
||
| 837 | 928 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 838 | 929 | $check_date = new Datetime($date); |
| 839 | 930 | $url= "http://www.airberlin.com/en-US/site/aims.php"; |
| 840 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 931 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 932 | + return array(); |
|
| 933 | + } |
|
| 841 | 934 | $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
| 842 | 935 | $data = $Common->getData($url,'post',$post); |
| 843 | 936 | //echo $data; |
@@ -847,11 +940,19 @@ discard block |
||
| 847 | 940 | if ($data != '') { |
| 848 | 941 | $table = $Common->table2array($data); |
| 849 | 942 | $flight = $table; |
| 850 | - if (isset($flight[5][4])) $departureTime = $flight[5][4]; |
|
| 851 | - else $departureTime = ''; |
|
| 852 | - if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
|
| 853 | - else $departureAirport = ''; |
|
| 854 | - } else return array(); |
|
| 943 | + if (isset($flight[5][4])) { |
|
| 944 | + $departureTime = $flight[5][4]; |
|
| 945 | + } else { |
|
| 946 | + $departureTime = ''; |
|
| 947 | + } |
|
| 948 | + if (isset($flight[5][2])) { |
|
| 949 | + $departureAirport = $flight[5][2]; |
|
| 950 | + } else { |
|
| 951 | + $departureAirport = ''; |
|
| 952 | + } |
|
| 953 | + } else { |
|
| 954 | + return array(); |
|
| 955 | + } |
|
| 855 | 956 | $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
| 856 | 957 | $data = $Common->getData($url,'post',$post); |
| 857 | 958 | if ($data != '') { |
@@ -864,10 +965,14 @@ discard block |
||
| 864 | 965 | $arrivalTime = ''; |
| 865 | 966 | $arrivalAirport = ''; |
| 866 | 967 | } |
| 867 | - } else return array(); |
|
| 968 | + } else { |
|
| 969 | + return array(); |
|
| 970 | + } |
|
| 868 | 971 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
| 869 | 972 | $json = $Common->getData($url); |
| 870 | - if ($json == '') return array(); |
|
| 973 | + if ($json == '') { |
|
| 974 | + return array(); |
|
| 975 | + } |
|
| 871 | 976 | $parsed_json = json_decode($json); |
| 872 | 977 | $airports = $parsed_json->{'suggestList'}; |
| 873 | 978 | if (count($airports) > 0) { |
@@ -882,7 +987,9 @@ discard block |
||
| 882 | 987 | } |
| 883 | 988 | if (isset($DepartureAirportIata)) { |
| 884 | 989 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
| 885 | - } else return array(); |
|
| 990 | + } else { |
|
| 991 | + return array(); |
|
| 992 | + } |
|
| 886 | 993 | } |
| 887 | 994 | |
| 888 | 995 | /* |
@@ -894,7 +1001,9 @@ discard block |
||
| 894 | 1001 | public function fetchSchedule($ident,$date = 'NOW') { |
| 895 | 1002 | global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline; |
| 896 | 1003 | //$Common = new Common(); |
| 897 | - if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array(); |
|
| 1004 | + if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) { |
|
| 1005 | + return array(); |
|
| 1006 | + } |
|
| 898 | 1007 | $airline_icao = ''; |
| 899 | 1008 | if (!is_numeric(substr($ident, 0, 3))) |
| 900 | 1009 | { |
@@ -1122,14 +1231,21 @@ discard block |
||
| 1122 | 1231 | default: |
| 1123 | 1232 | // Randomly use a generic function to get hours |
| 1124 | 1233 | if (strlen($airline_icao) == 2) { |
| 1125 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1234 | + if (!isset($globalSchedulesSources)) { |
|
| 1235 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1236 | + } |
|
| 1126 | 1237 | if (count($globalSchedulesSources) > 0) { |
| 1127 | 1238 | $rand = mt_rand(0,count($globalSchedulesSources)-1); |
| 1128 | 1239 | $source = $globalSchedulesSources[$rand]; |
| 1129 | - if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
|
| 1130 | - elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
|
| 1240 | + if ($source == 'flightmapper') { |
|
| 1241 | + return $this->getFlightMapper($ident); |
|
| 1242 | + } elseif ($source == 'costtotravel') { |
|
| 1243 | + return $this->getCostToTravel($ident); |
|
| 1244 | + } |
|
| 1131 | 1245 | //elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date); |
| 1132 | - elseif ($source == 'flightaware') return $this->getFlightAware($ident); |
|
| 1246 | + elseif ($source == 'flightaware') { |
|
| 1247 | + return $this->getFlightAware($ident); |
|
| 1248 | + } |
|
| 1133 | 1249 | } |
| 1134 | 1250 | } |
| 1135 | 1251 | } |
@@ -22,10 +22,14 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function __construct($dbc = null) { |
| 24 | 24 | global $globalFilterName; |
| 25 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
| 25 | + if (isset($globalFilterName)) { |
|
| 26 | + $this->filter_name = $globalFilterName; |
|
| 27 | + } |
|
| 26 | 28 | $Connection = new Connection($dbc); |
| 27 | 29 | $this->db = $Connection->db(); |
| 28 | - if ($this->db === null) die('Error: No DB connection. (Stats)'); |
|
| 30 | + if ($this->db === null) { |
|
| 31 | + die('Error: No DB connection. (Stats)'); |
|
| 32 | + } |
|
| 29 | 33 | } |
| 30 | 34 | |
| 31 | 35 | public function addLastStatsUpdate($type,$stats_date) { |
@@ -93,7 +97,9 @@ discard block |
||
| 93 | 97 | |
| 94 | 98 | public function getAllAirlineNames($filter_name = '') { |
| 95 | 99 | global $globalStatsFilters; |
| 96 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 100 | + if ($filter_name == '') { |
|
| 101 | + $filter_name = $this->filter_name; |
|
| 102 | + } |
|
| 97 | 103 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
| 98 | 104 | try { |
| 99 | 105 | $sth = $this->db->prepare($query); |
@@ -113,7 +119,9 @@ discard block |
||
| 113 | 119 | return $all; |
| 114 | 120 | } |
| 115 | 121 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
| 116 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 122 | + if ($filter_name == '') { |
|
| 123 | + $filter_name = $this->filter_name; |
|
| 124 | + } |
|
| 117 | 125 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 118 | 126 | try { |
| 119 | 127 | $sth = $this->db->prepare($query); |
@@ -125,7 +133,9 @@ discard block |
||
| 125 | 133 | return $all; |
| 126 | 134 | } |
| 127 | 135 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
| 128 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 136 | + if ($filter_name == '') { |
|
| 137 | + $filter_name = $this->filter_name; |
|
| 138 | + } |
|
| 129 | 139 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
| 130 | 140 | try { |
| 131 | 141 | $sth = $this->db->prepare($query); |
@@ -137,7 +147,9 @@ discard block |
||
| 137 | 147 | return $all; |
| 138 | 148 | } |
| 139 | 149 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
| 140 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 150 | + if ($filter_name == '') { |
|
| 151 | + $filter_name = $this->filter_name; |
|
| 152 | + } |
|
| 141 | 153 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
| 142 | 154 | try { |
| 143 | 155 | $sth = $this->db->prepare($query); |
@@ -150,7 +162,9 @@ discard block |
||
| 150 | 162 | } |
| 151 | 163 | |
| 152 | 164 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
| 153 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 165 | + if ($filter_name == '') { |
|
| 166 | + $filter_name = $this->filter_name; |
|
| 167 | + } |
|
| 154 | 168 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 155 | 169 | try { |
| 156 | 170 | $sth = $this->db->prepare($query); |
@@ -163,7 +177,9 @@ discard block |
||
| 163 | 177 | } |
| 164 | 178 | |
| 165 | 179 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
| 166 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 180 | + if ($filter_name == '') { |
|
| 181 | + $filter_name = $this->filter_name; |
|
| 182 | + } |
|
| 167 | 183 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 168 | 184 | try { |
| 169 | 185 | $sth = $this->db->prepare($query); |
@@ -178,7 +194,9 @@ discard block |
||
| 178 | 194 | |
| 179 | 195 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 180 | 196 | global $globalStatsFilters; |
| 181 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 197 | + if ($filter_name == '') { |
|
| 198 | + $filter_name = $this->filter_name; |
|
| 199 | + } |
|
| 182 | 200 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 183 | 201 | $Spotter = new Spotter($this->db); |
| 184 | 202 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -187,8 +205,11 @@ discard block |
||
| 187 | 205 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 188 | 206 | } |
| 189 | 207 | if ($year == '' && $month == '') { |
| 190 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 191 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 208 | + if ($limit) { |
|
| 209 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 210 | + } else { |
|
| 211 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 212 | + } |
|
| 192 | 213 | try { |
| 193 | 214 | $sth = $this->db->prepare($query); |
| 194 | 215 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -196,11 +217,16 @@ discard block |
||
| 196 | 217 | echo "error : ".$e->getMessage(); |
| 197 | 218 | } |
| 198 | 219 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 199 | - } else $all = array(); |
|
| 220 | + } else { |
|
| 221 | + $all = array(); |
|
| 222 | + } |
|
| 200 | 223 | } else { |
| 201 | 224 | if ($year == '' && $month == '') { |
| 202 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 203 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 225 | + if ($limit) { |
|
| 226 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 227 | + } else { |
|
| 228 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 229 | + } |
|
| 204 | 230 | try { |
| 205 | 231 | $sth = $this->db->prepare($query); |
| 206 | 232 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -208,7 +234,9 @@ discard block |
||
| 208 | 234 | echo "error : ".$e->getMessage(); |
| 209 | 235 | } |
| 210 | 236 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 211 | - } else $all = array(); |
|
| 237 | + } else { |
|
| 238 | + $all = array(); |
|
| 239 | + } |
|
| 212 | 240 | } |
| 213 | 241 | if (empty($all)) { |
| 214 | 242 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -227,10 +255,15 @@ discard block |
||
| 227 | 255 | } |
| 228 | 256 | public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') { |
| 229 | 257 | global $globalStatsFilters; |
| 230 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 258 | + if ($filter_name == '') { |
|
| 259 | + $filter_name = $this->filter_name; |
|
| 260 | + } |
|
| 231 | 261 | if ($year == '' && $month == '') { |
| 232 | - if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0"; |
|
| 233 | - else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 262 | + if ($limit) { |
|
| 263 | + $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0"; |
|
| 264 | + } else { |
|
| 265 | + $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 266 | + } |
|
| 234 | 267 | try { |
| 235 | 268 | $sth = $this->db->prepare($query); |
| 236 | 269 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -238,7 +271,9 @@ discard block |
||
| 238 | 271 | echo "error : ".$e->getMessage(); |
| 239 | 272 | } |
| 240 | 273 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 241 | - } else $all = array(); |
|
| 274 | + } else { |
|
| 275 | + $all = array(); |
|
| 276 | + } |
|
| 242 | 277 | if (empty($all)) { |
| 243 | 278 | $filters = array('year' => $year,'month' => $month); |
| 244 | 279 | if ($filter_name != '') { |
@@ -252,10 +287,15 @@ discard block |
||
| 252 | 287 | } |
| 253 | 288 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
| 254 | 289 | global $globalStatsFilters; |
| 255 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 290 | + if ($filter_name == '') { |
|
| 291 | + $filter_name = $this->filter_name; |
|
| 292 | + } |
|
| 256 | 293 | if ($year == '' && $month == '') { |
| 257 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 258 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
| 294 | + if ($limit) { |
|
| 295 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 296 | + } else { |
|
| 297 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
| 298 | + } |
|
| 259 | 299 | try { |
| 260 | 300 | $sth = $this->db->prepare($query); |
| 261 | 301 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -263,7 +303,9 @@ discard block |
||
| 263 | 303 | echo "error : ".$e->getMessage(); |
| 264 | 304 | } |
| 265 | 305 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 266 | - } else $all = array(); |
|
| 306 | + } else { |
|
| 307 | + $all = array(); |
|
| 308 | + } |
|
| 267 | 309 | if (empty($all)) { |
| 268 | 310 | $Spotter = new Spotter($this->db); |
| 269 | 311 | $filters = array(); |
@@ -278,7 +320,9 @@ discard block |
||
| 278 | 320 | } |
| 279 | 321 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 280 | 322 | global $globalStatsFilters; |
| 281 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 323 | + if ($filter_name == '') { |
|
| 324 | + $filter_name = $this->filter_name; |
|
| 325 | + } |
|
| 282 | 326 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 283 | 327 | $Spotter = new Spotter($this->db); |
| 284 | 328 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -287,8 +331,11 @@ discard block |
||
| 287 | 331 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 288 | 332 | } |
| 289 | 333 | if ($year == '' && $month == '') { |
| 290 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 291 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 334 | + if ($limit) { |
|
| 335 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 336 | + } else { |
|
| 337 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 338 | + } |
|
| 292 | 339 | try { |
| 293 | 340 | $sth = $this->db->prepare($query); |
| 294 | 341 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -296,11 +343,16 @@ discard block |
||
| 296 | 343 | echo "error : ".$e->getMessage(); |
| 297 | 344 | } |
| 298 | 345 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 299 | - } else $all = array(); |
|
| 346 | + } else { |
|
| 347 | + $all = array(); |
|
| 348 | + } |
|
| 300 | 349 | } else { |
| 301 | 350 | if ($year == '' && $month == '') { |
| 302 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 303 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 351 | + if ($limit) { |
|
| 352 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 353 | + } else { |
|
| 354 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 355 | + } |
|
| 304 | 356 | try { |
| 305 | 357 | $sth = $this->db->prepare($query); |
| 306 | 358 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -308,7 +360,9 @@ discard block |
||
| 308 | 360 | echo "error : ".$e->getMessage(); |
| 309 | 361 | } |
| 310 | 362 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 311 | - } else $all = array(); |
|
| 363 | + } else { |
|
| 364 | + $all = array(); |
|
| 365 | + } |
|
| 312 | 366 | } |
| 313 | 367 | if (empty($all)) { |
| 314 | 368 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -328,7 +382,9 @@ discard block |
||
| 328 | 382 | |
| 329 | 383 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 330 | 384 | global $globalStatsFilters; |
| 331 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 385 | + if ($filter_name == '') { |
|
| 386 | + $filter_name = $this->filter_name; |
|
| 387 | + } |
|
| 332 | 388 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 333 | 389 | $Spotter = new Spotter($this->db); |
| 334 | 390 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -337,8 +393,11 @@ discard block |
||
| 337 | 393 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 338 | 394 | } |
| 339 | 395 | if ($year == '' && $month == '') { |
| 340 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 341 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 396 | + if ($limit) { |
|
| 397 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 398 | + } else { |
|
| 399 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 400 | + } |
|
| 342 | 401 | try { |
| 343 | 402 | $sth = $this->db->prepare($query); |
| 344 | 403 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -346,11 +405,16 @@ discard block |
||
| 346 | 405 | echo "error : ".$e->getMessage(); |
| 347 | 406 | } |
| 348 | 407 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 349 | - } else $all = array(); |
|
| 408 | + } else { |
|
| 409 | + $all = array(); |
|
| 410 | + } |
|
| 350 | 411 | } else { |
| 351 | 412 | if ($year == '' && $month == '') { |
| 352 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 353 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 413 | + if ($limit) { |
|
| 414 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 415 | + } else { |
|
| 416 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 417 | + } |
|
| 354 | 418 | try { |
| 355 | 419 | $sth = $this->db->prepare($query); |
| 356 | 420 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -358,7 +422,9 @@ discard block |
||
| 358 | 422 | echo "error : ".$e->getMessage(); |
| 359 | 423 | } |
| 360 | 424 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 361 | - } else $all = array(); |
|
| 425 | + } else { |
|
| 426 | + $all = array(); |
|
| 427 | + } |
|
| 362 | 428 | } |
| 363 | 429 | if (empty($all)) { |
| 364 | 430 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -377,7 +443,9 @@ discard block |
||
| 377 | 443 | } |
| 378 | 444 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 379 | 445 | global $globalStatsFilters; |
| 380 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 446 | + if ($filter_name == '') { |
|
| 447 | + $filter_name = $this->filter_name; |
|
| 448 | + } |
|
| 381 | 449 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 382 | 450 | $Spotter = new Spotter($this->db); |
| 383 | 451 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -385,12 +453,18 @@ discard block |
||
| 385 | 453 | foreach ($airlines as $airline) { |
| 386 | 454 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 387 | 455 | } |
| 388 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 389 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 456 | + if ($limit) { |
|
| 457 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 458 | + } else { |
|
| 459 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 460 | + } |
|
| 390 | 461 | $query_values = array(':filter_name' => $filter_name); |
| 391 | 462 | } else { |
| 392 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 393 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 463 | + if ($limit) { |
|
| 464 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 465 | + } else { |
|
| 466 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 467 | + } |
|
| 394 | 468 | $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 395 | 469 | } |
| 396 | 470 | try { |
@@ -418,17 +492,29 @@ discard block |
||
| 418 | 492 | |
| 419 | 493 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
| 420 | 494 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
| 421 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 495 | + if ($filter_name == '') { |
|
| 496 | + $filter_name = $this->filter_name; |
|
| 497 | + } |
|
| 422 | 498 | if ($year == '' && $month == '') { |
| 423 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
| 424 | - if ($globalIVAO) $forsource = 'ivao'; |
|
| 499 | + if ($globalVATSIM) { |
|
| 500 | + $forsource = 'vatsim'; |
|
| 501 | + } |
|
| 502 | + if ($globalIVAO) { |
|
| 503 | + $forsource = 'ivao'; |
|
| 504 | + } |
|
| 425 | 505 | if (isset($forsource)) { |
| 426 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 427 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
| 506 | + if ($limit) { |
|
| 507 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 508 | + } else { |
|
| 509 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
| 510 | + } |
|
| 428 | 511 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
| 429 | 512 | } else { |
| 430 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 431 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
| 513 | + if ($limit) { |
|
| 514 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 515 | + } else { |
|
| 516 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
| 517 | + } |
|
| 432 | 518 | $query_values = array(':filter_name' => $filter_name); |
| 433 | 519 | } |
| 434 | 520 | try { |
@@ -438,7 +524,9 @@ discard block |
||
| 438 | 524 | echo "error : ".$e->getMessage(); |
| 439 | 525 | } |
| 440 | 526 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 441 | - } else $all = array(); |
|
| 527 | + } else { |
|
| 528 | + $all = array(); |
|
| 529 | + } |
|
| 442 | 530 | if (empty($all)) { |
| 443 | 531 | $Spotter = new Spotter($this->db); |
| 444 | 532 | $filters = array(); |
@@ -453,7 +541,9 @@ discard block |
||
| 453 | 541 | } |
| 454 | 542 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 455 | 543 | global $globalStatsFilters; |
| 456 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 544 | + if ($filter_name == '') { |
|
| 545 | + $filter_name = $this->filter_name; |
|
| 546 | + } |
|
| 457 | 547 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 458 | 548 | $Spotter = new Spotter($this->db); |
| 459 | 549 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -462,8 +552,11 @@ discard block |
||
| 462 | 552 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 463 | 553 | } |
| 464 | 554 | if ($year == '' && $month == '') { |
| 465 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 466 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
| 555 | + if ($limit) { |
|
| 556 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 557 | + } else { |
|
| 558 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
| 559 | + } |
|
| 467 | 560 | try { |
| 468 | 561 | $sth = $this->db->prepare($query); |
| 469 | 562 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -471,11 +564,16 @@ discard block |
||
| 471 | 564 | echo "error : ".$e->getMessage(); |
| 472 | 565 | } |
| 473 | 566 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 474 | - } else $all = array(); |
|
| 567 | + } else { |
|
| 568 | + $all = array(); |
|
| 569 | + } |
|
| 475 | 570 | } else { |
| 476 | 571 | if ($year == '' && $month == '') { |
| 477 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 478 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
| 572 | + if ($limit) { |
|
| 573 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 574 | + } else { |
|
| 575 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
| 576 | + } |
|
| 479 | 577 | try { |
| 480 | 578 | $sth = $this->db->prepare($query); |
| 481 | 579 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -483,7 +581,9 @@ discard block |
||
| 483 | 581 | echo "error : ".$e->getMessage(); |
| 484 | 582 | } |
| 485 | 583 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 486 | - } else $all = array(); |
|
| 584 | + } else { |
|
| 585 | + $all = array(); |
|
| 586 | + } |
|
| 487 | 587 | } |
| 488 | 588 | if (empty($all)) { |
| 489 | 589 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -502,7 +602,9 @@ discard block |
||
| 502 | 602 | } |
| 503 | 603 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 504 | 604 | global $globalStatsFilters; |
| 505 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 605 | + if ($filter_name == '') { |
|
| 606 | + $filter_name = $this->filter_name; |
|
| 607 | + } |
|
| 506 | 608 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 507 | 609 | $Spotter = new Spotter($this->db); |
| 508 | 610 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -511,8 +613,11 @@ discard block |
||
| 511 | 613 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 512 | 614 | } |
| 513 | 615 | if ($year == '' && $month == '') { |
| 514 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 515 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 616 | + if ($limit) { |
|
| 617 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 618 | + } else { |
|
| 619 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 620 | + } |
|
| 516 | 621 | try { |
| 517 | 622 | $sth = $this->db->prepare($query); |
| 518 | 623 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -520,11 +625,16 @@ discard block |
||
| 520 | 625 | echo "error : ".$e->getMessage(); |
| 521 | 626 | } |
| 522 | 627 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 523 | - } else $all = array(); |
|
| 628 | + } else { |
|
| 629 | + $all = array(); |
|
| 630 | + } |
|
| 524 | 631 | } else { |
| 525 | 632 | if ($year == '' && $month == '') { |
| 526 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 527 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 633 | + if ($limit) { |
|
| 634 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 635 | + } else { |
|
| 636 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 637 | + } |
|
| 528 | 638 | try { |
| 529 | 639 | $sth = $this->db->prepare($query); |
| 530 | 640 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -532,7 +642,9 @@ discard block |
||
| 532 | 642 | echo "error : ".$e->getMessage(); |
| 533 | 643 | } |
| 534 | 644 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 535 | - } else $all = array(); |
|
| 645 | + } else { |
|
| 646 | + $all = array(); |
|
| 647 | + } |
|
| 536 | 648 | } |
| 537 | 649 | if (empty($all)) { |
| 538 | 650 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -551,7 +663,9 @@ discard block |
||
| 551 | 663 | } |
| 552 | 664 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 553 | 665 | $Connection = new Connection($this->db); |
| 554 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 666 | + if ($filter_name == '') { |
|
| 667 | + $filter_name = $this->filter_name; |
|
| 668 | + } |
|
| 555 | 669 | if ($Connection->tableExists('countries')) { |
| 556 | 670 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 557 | 671 | $Spotter = new Spotter($this->db); |
@@ -561,8 +675,11 @@ discard block |
||
| 561 | 675 | foreach ($airlines as $airline) { |
| 562 | 676 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 563 | 677 | } |
| 564 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 565 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 678 | + if ($limit) { |
|
| 679 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 680 | + } else { |
|
| 681 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 682 | + } |
|
| 566 | 683 | try { |
| 567 | 684 | $sth = $this->db->prepare($query); |
| 568 | 685 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -571,11 +688,16 @@ discard block |
||
| 571 | 688 | } |
| 572 | 689 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 573 | 690 | return $all; |
| 574 | - } else return array(); |
|
| 691 | + } else { |
|
| 692 | + return array(); |
|
| 693 | + } |
|
| 575 | 694 | } else { |
| 576 | 695 | if ($year == '' && $month == '') { |
| 577 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 578 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 696 | + if ($limit) { |
|
| 697 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 698 | + } else { |
|
| 699 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 700 | + } |
|
| 579 | 701 | try { |
| 580 | 702 | $sth = $this->db->prepare($query); |
| 581 | 703 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -584,20 +706,29 @@ discard block |
||
| 584 | 706 | } |
| 585 | 707 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 586 | 708 | return $all; |
| 587 | - } else return array(); |
|
| 709 | + } else { |
|
| 710 | + return array(); |
|
| 711 | + } |
|
| 588 | 712 | } |
| 589 | 713 | $Spotter = new Spotter($this->db); |
| 590 | 714 | return $Spotter->countAllFlightOverCountries($limit); |
| 591 | - } else return array(); |
|
| 715 | + } else { |
|
| 716 | + return array(); |
|
| 717 | + } |
|
| 592 | 718 | } |
| 593 | 719 | public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
| 594 | 720 | $Connection = new Connection($this->db); |
| 595 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 721 | + if ($filter_name == '') { |
|
| 722 | + $filter_name = $this->filter_name; |
|
| 723 | + } |
|
| 596 | 724 | if ($Connection->tableExists('countries')) { |
| 597 | 725 | $all = array(); |
| 598 | 726 | if ($year == '' && $month == '') { |
| 599 | - if ($limit) $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0"; |
|
| 600 | - else $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC"; |
|
| 727 | + if ($limit) { |
|
| 728 | + $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0"; |
|
| 729 | + } else { |
|
| 730 | + $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC"; |
|
| 731 | + } |
|
| 601 | 732 | try { |
| 602 | 733 | $sth = $this->db->prepare($query); |
| 603 | 734 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -615,17 +746,24 @@ discard block |
||
| 615 | 746 | $all = $Marine->countAllMarineOverCountries($limit,0,'',$filters); |
| 616 | 747 | } |
| 617 | 748 | return $all; |
| 618 | - } else return array(); |
|
| 749 | + } else { |
|
| 750 | + return array(); |
|
| 751 | + } |
|
| 619 | 752 | } |
| 620 | 753 | public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
| 621 | 754 | global $globalStatsFilters; |
| 622 | 755 | $Connection = new Connection($this->db); |
| 623 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 756 | + if ($filter_name == '') { |
|
| 757 | + $filter_name = $this->filter_name; |
|
| 758 | + } |
|
| 624 | 759 | if ($Connection->tableExists('countries')) { |
| 625 | 760 | $all = array(); |
| 626 | 761 | if ($year == '' && $month == '') { |
| 627 | - if ($limit) $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0"; |
|
| 628 | - else $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC"; |
|
| 762 | + if ($limit) { |
|
| 763 | + $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0"; |
|
| 764 | + } else { |
|
| 765 | + $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC"; |
|
| 766 | + } |
|
| 629 | 767 | try { |
| 630 | 768 | $sth = $this->db->prepare($query); |
| 631 | 769 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -644,14 +782,21 @@ discard block |
||
| 644 | 782 | $all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters); |
| 645 | 783 | } |
| 646 | 784 | return $all; |
| 647 | - } else return array(); |
|
| 785 | + } else { |
|
| 786 | + return array(); |
|
| 787 | + } |
|
| 648 | 788 | } |
| 649 | 789 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
| 650 | 790 | global $globalStatsFilters; |
| 651 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 791 | + if ($filter_name == '') { |
|
| 792 | + $filter_name = $this->filter_name; |
|
| 793 | + } |
|
| 652 | 794 | if ($year == '' && $month == '') { |
| 653 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
| 654 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
| 795 | + if ($limit) { |
|
| 796 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
| 797 | + } else { |
|
| 798 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
| 799 | + } |
|
| 655 | 800 | try { |
| 656 | 801 | $sth = $this->db->prepare($query); |
| 657 | 802 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -659,7 +804,9 @@ discard block |
||
| 659 | 804 | echo "error : ".$e->getMessage(); |
| 660 | 805 | } |
| 661 | 806 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 662 | - } else $all = array(); |
|
| 807 | + } else { |
|
| 808 | + $all = array(); |
|
| 809 | + } |
|
| 663 | 810 | if (empty($all)) { |
| 664 | 811 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 665 | 812 | if ($filter_name != '') { |
@@ -674,7 +821,9 @@ discard block |
||
| 674 | 821 | |
| 675 | 822 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 676 | 823 | global $globalStatsFilters; |
| 677 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 824 | + if ($filter_name == '') { |
|
| 825 | + $filter_name = $this->filter_name; |
|
| 826 | + } |
|
| 678 | 827 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 679 | 828 | $Spotter = new Spotter($this->db); |
| 680 | 829 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -683,8 +832,11 @@ discard block |
||
| 683 | 832 | foreach ($airlines as $airline) { |
| 684 | 833 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 685 | 834 | } |
| 686 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 687 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 835 | + if ($limit) { |
|
| 836 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 837 | + } else { |
|
| 838 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 839 | + } |
|
| 688 | 840 | try { |
| 689 | 841 | $sth = $this->db->prepare($query); |
| 690 | 842 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -692,11 +844,16 @@ discard block |
||
| 692 | 844 | echo "error : ".$e->getMessage(); |
| 693 | 845 | } |
| 694 | 846 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 695 | - } else $all = array(); |
|
| 847 | + } else { |
|
| 848 | + $all = array(); |
|
| 849 | + } |
|
| 696 | 850 | } else { |
| 697 | 851 | if ($year == '' && $month == '') { |
| 698 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 699 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 852 | + if ($limit) { |
|
| 853 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 854 | + } else { |
|
| 855 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 856 | + } |
|
| 700 | 857 | try { |
| 701 | 858 | $sth = $this->db->prepare($query); |
| 702 | 859 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -704,7 +861,9 @@ discard block |
||
| 704 | 861 | echo "error : ".$e->getMessage(); |
| 705 | 862 | } |
| 706 | 863 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 707 | - } else $all = array(); |
|
| 864 | + } else { |
|
| 865 | + $all = array(); |
|
| 866 | + } |
|
| 708 | 867 | } |
| 709 | 868 | if (empty($all)) { |
| 710 | 869 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -723,7 +882,9 @@ discard block |
||
| 723 | 882 | } |
| 724 | 883 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 725 | 884 | global $globalStatsFilters; |
| 726 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 885 | + if ($filter_name == '') { |
|
| 886 | + $filter_name = $this->filter_name; |
|
| 887 | + } |
|
| 727 | 888 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 728 | 889 | $Spotter = new Spotter($this->db); |
| 729 | 890 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -732,8 +893,11 @@ discard block |
||
| 732 | 893 | foreach ($airlines as $airline) { |
| 733 | 894 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 734 | 895 | } |
| 735 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 736 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 896 | + if ($limit) { |
|
| 897 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 898 | + } else { |
|
| 899 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 900 | + } |
|
| 737 | 901 | try { |
| 738 | 902 | $sth = $this->db->prepare($query); |
| 739 | 903 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -741,11 +905,16 @@ discard block |
||
| 741 | 905 | echo "error : ".$e->getMessage(); |
| 742 | 906 | } |
| 743 | 907 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 744 | - } else $all = array(); |
|
| 908 | + } else { |
|
| 909 | + $all = array(); |
|
| 910 | + } |
|
| 745 | 911 | } else { |
| 746 | 912 | if ($year == '' && $month == '') { |
| 747 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 748 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 913 | + if ($limit) { |
|
| 914 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 915 | + } else { |
|
| 916 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 917 | + } |
|
| 749 | 918 | try { |
| 750 | 919 | $sth = $this->db->prepare($query); |
| 751 | 920 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -753,7 +922,9 @@ discard block |
||
| 753 | 922 | echo "error : ".$e->getMessage(); |
| 754 | 923 | } |
| 755 | 924 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 756 | - } else $all = array(); |
|
| 925 | + } else { |
|
| 926 | + $all = array(); |
|
| 927 | + } |
|
| 757 | 928 | } |
| 758 | 929 | if (empty($all)) { |
| 759 | 930 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -778,7 +949,9 @@ discard block |
||
| 778 | 949 | $icao = $value['airport_departure_icao']; |
| 779 | 950 | if (isset($all[$icao])) { |
| 780 | 951 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 781 | - } else $all[$icao] = $value; |
|
| 952 | + } else { |
|
| 953 | + $all[$icao] = $value; |
|
| 954 | + } |
|
| 782 | 955 | } |
| 783 | 956 | $count = array(); |
| 784 | 957 | foreach ($all as $key => $row) { |
@@ -790,7 +963,9 @@ discard block |
||
| 790 | 963 | } |
| 791 | 964 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 792 | 965 | global $globalStatsFilters; |
| 793 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 966 | + if ($filter_name == '') { |
|
| 967 | + $filter_name = $this->filter_name; |
|
| 968 | + } |
|
| 794 | 969 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 795 | 970 | $Spotter = new Spotter($this->db); |
| 796 | 971 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -799,8 +974,11 @@ discard block |
||
| 799 | 974 | foreach ($airlines as $airline) { |
| 800 | 975 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 801 | 976 | } |
| 802 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 803 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 977 | + if ($limit) { |
|
| 978 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 979 | + } else { |
|
| 980 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 981 | + } |
|
| 804 | 982 | try { |
| 805 | 983 | $sth = $this->db->prepare($query); |
| 806 | 984 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -808,11 +986,16 @@ discard block |
||
| 808 | 986 | echo "error : ".$e->getMessage(); |
| 809 | 987 | } |
| 810 | 988 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 811 | - } else $all = array(); |
|
| 989 | + } else { |
|
| 990 | + $all = array(); |
|
| 991 | + } |
|
| 812 | 992 | } else { |
| 813 | 993 | if ($year == '' && $month == '') { |
| 814 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 815 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 994 | + if ($limit) { |
|
| 995 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 996 | + } else { |
|
| 997 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 998 | + } |
|
| 816 | 999 | try { |
| 817 | 1000 | $sth = $this->db->prepare($query); |
| 818 | 1001 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -820,7 +1003,9 @@ discard block |
||
| 820 | 1003 | echo "error : ".$e->getMessage(); |
| 821 | 1004 | } |
| 822 | 1005 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 823 | - } else $all = array(); |
|
| 1006 | + } else { |
|
| 1007 | + $all = array(); |
|
| 1008 | + } |
|
| 824 | 1009 | } |
| 825 | 1010 | if (empty($all)) { |
| 826 | 1011 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -845,7 +1030,9 @@ discard block |
||
| 845 | 1030 | $icao = $value['airport_arrival_icao']; |
| 846 | 1031 | if (isset($all[$icao])) { |
| 847 | 1032 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 848 | - } else $all[$icao] = $value; |
|
| 1033 | + } else { |
|
| 1034 | + $all[$icao] = $value; |
|
| 1035 | + } |
|
| 849 | 1036 | } |
| 850 | 1037 | $count = array(); |
| 851 | 1038 | foreach ($all as $key => $row) { |
@@ -857,7 +1044,9 @@ discard block |
||
| 857 | 1044 | } |
| 858 | 1045 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
| 859 | 1046 | global $globalDBdriver, $globalStatsFilters; |
| 860 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1047 | + if ($filter_name == '') { |
|
| 1048 | + $filter_name = $this->filter_name; |
|
| 1049 | + } |
|
| 861 | 1050 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 862 | 1051 | $Spotter = new Spotter($this->db); |
| 863 | 1052 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -866,20 +1055,32 @@ discard block |
||
| 866 | 1055 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 867 | 1056 | } |
| 868 | 1057 | if ($globalDBdriver == 'mysql') { |
| 869 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 870 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 1058 | + if ($limit) { |
|
| 1059 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 1060 | + } else { |
|
| 1061 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 1062 | + } |
|
| 871 | 1063 | } else { |
| 872 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 873 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 1064 | + if ($limit) { |
|
| 1065 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 1066 | + } else { |
|
| 1067 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 1068 | + } |
|
| 874 | 1069 | } |
| 875 | 1070 | $query_data = array(':filter_name' => $filter_name); |
| 876 | 1071 | } else { |
| 877 | 1072 | if ($globalDBdriver == 'mysql') { |
| 878 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 879 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1073 | + if ($limit) { |
|
| 1074 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1075 | + } else { |
|
| 1076 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1077 | + } |
|
| 880 | 1078 | } else { |
| 881 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 882 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1079 | + if ($limit) { |
|
| 1080 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1081 | + } else { |
|
| 1082 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1083 | + } |
|
| 883 | 1084 | } |
| 884 | 1085 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 885 | 1086 | } |
@@ -907,13 +1108,21 @@ discard block |
||
| 907 | 1108 | |
| 908 | 1109 | public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') { |
| 909 | 1110 | global $globalDBdriver, $globalStatsFilters; |
| 910 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1111 | + if ($filter_name == '') { |
|
| 1112 | + $filter_name = $this->filter_name; |
|
| 1113 | + } |
|
| 911 | 1114 | if ($globalDBdriver == 'mysql') { |
| 912 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
| 913 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
| 1115 | + if ($limit) { |
|
| 1116 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
| 1117 | + } else { |
|
| 1118 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
| 1119 | + } |
|
| 914 | 1120 | } else { |
| 915 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
| 916 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
| 1121 | + if ($limit) { |
|
| 1122 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
| 1123 | + } else { |
|
| 1124 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
| 1125 | + } |
|
| 917 | 1126 | } |
| 918 | 1127 | $query_data = array(':filter_name' => $filter_name); |
| 919 | 1128 | try { |
@@ -936,13 +1145,21 @@ discard block |
||
| 936 | 1145 | |
| 937 | 1146 | public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') { |
| 938 | 1147 | global $globalDBdriver, $globalStatsFilters; |
| 939 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1148 | + if ($filter_name == '') { |
|
| 1149 | + $filter_name = $this->filter_name; |
|
| 1150 | + } |
|
| 940 | 1151 | if ($globalDBdriver == 'mysql') { |
| 941 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
| 942 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name"; |
|
| 1152 | + if ($limit) { |
|
| 1153 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
| 1154 | + } else { |
|
| 1155 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name"; |
|
| 1156 | + } |
|
| 943 | 1157 | } else { |
| 944 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
| 945 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name"; |
|
| 1158 | + if ($limit) { |
|
| 1159 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
| 1160 | + } else { |
|
| 1161 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name"; |
|
| 1162 | + } |
|
| 946 | 1163 | } |
| 947 | 1164 | $query_data = array(':filter_name' => $filter_name); |
| 948 | 1165 | try { |
@@ -965,7 +1182,9 @@ discard block |
||
| 965 | 1182 | |
| 966 | 1183 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
| 967 | 1184 | global $globalStatsFilters; |
| 968 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1185 | + if ($filter_name == '') { |
|
| 1186 | + $filter_name = $this->filter_name; |
|
| 1187 | + } |
|
| 969 | 1188 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 970 | 1189 | $Spotter = new Spotter($this->db); |
| 971 | 1190 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1002,7 +1221,9 @@ discard block |
||
| 1002 | 1221 | } |
| 1003 | 1222 | public function countAllMarineDatesLastMonth($filter_name = '') { |
| 1004 | 1223 | global $globalStatsFilters; |
| 1005 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1224 | + if ($filter_name == '') { |
|
| 1225 | + $filter_name = $this->filter_name; |
|
| 1226 | + } |
|
| 1006 | 1227 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND filter_name = :filter_name"; |
| 1007 | 1228 | $query_data = array(':filter_name' => $filter_name); |
| 1008 | 1229 | try { |
@@ -1024,7 +1245,9 @@ discard block |
||
| 1024 | 1245 | } |
| 1025 | 1246 | public function countAllTrackerDatesLastMonth($filter_name = '') { |
| 1026 | 1247 | global $globalStatsFilters; |
| 1027 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1248 | + if ($filter_name == '') { |
|
| 1249 | + $filter_name = $this->filter_name; |
|
| 1250 | + } |
|
| 1028 | 1251 | $query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND filter_name = :filter_name"; |
| 1029 | 1252 | $query_data = array(':filter_name' => $filter_name); |
| 1030 | 1253 | try { |
@@ -1046,7 +1269,9 @@ discard block |
||
| 1046 | 1269 | } |
| 1047 | 1270 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
| 1048 | 1271 | global $globalDBdriver, $globalStatsFilters; |
| 1049 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1272 | + if ($filter_name == '') { |
|
| 1273 | + $filter_name = $this->filter_name; |
|
| 1274 | + } |
|
| 1050 | 1275 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1051 | 1276 | $Spotter = new Spotter($this->db); |
| 1052 | 1277 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1091,7 +1316,9 @@ discard block |
||
| 1091 | 1316 | } |
| 1092 | 1317 | public function countAllMarineDatesLast7Days($filter_name = '') { |
| 1093 | 1318 | global $globalDBdriver, $globalStatsFilters; |
| 1094 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1319 | + if ($filter_name == '') { |
|
| 1320 | + $filter_name = $this->filter_name; |
|
| 1321 | + } |
|
| 1095 | 1322 | if ($globalDBdriver == 'mysql') { |
| 1096 | 1323 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND marine_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name"; |
| 1097 | 1324 | } else { |
@@ -1117,7 +1344,9 @@ discard block |
||
| 1117 | 1344 | } |
| 1118 | 1345 | public function countAllTrackerDatesLast7Days($filter_name = '') { |
| 1119 | 1346 | global $globalDBdriver, $globalStatsFilters; |
| 1120 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1347 | + if ($filter_name == '') { |
|
| 1348 | + $filter_name = $this->filter_name; |
|
| 1349 | + } |
|
| 1121 | 1350 | if ($globalDBdriver == 'mysql') { |
| 1122 | 1351 | $query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND tracker_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name"; |
| 1123 | 1352 | } else { |
@@ -1143,7 +1372,9 @@ discard block |
||
| 1143 | 1372 | } |
| 1144 | 1373 | public function countAllDates($stats_airline = '',$filter_name = '') { |
| 1145 | 1374 | global $globalStatsFilters; |
| 1146 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1375 | + if ($filter_name == '') { |
|
| 1376 | + $filter_name = $this->filter_name; |
|
| 1377 | + } |
|
| 1147 | 1378 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1148 | 1379 | $Spotter = new Spotter($this->db); |
| 1149 | 1380 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1180,7 +1411,9 @@ discard block |
||
| 1180 | 1411 | } |
| 1181 | 1412 | public function countAllDatesMarine($filter_name = '') { |
| 1182 | 1413 | global $globalStatsFilters; |
| 1183 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1414 | + if ($filter_name == '') { |
|
| 1415 | + $filter_name = $this->filter_name; |
|
| 1416 | + } |
|
| 1184 | 1417 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC"; |
| 1185 | 1418 | $query_data = array(':filter_name' => $filter_name); |
| 1186 | 1419 | try { |
@@ -1202,7 +1435,9 @@ discard block |
||
| 1202 | 1435 | } |
| 1203 | 1436 | public function countAllDatesTracker($filter_name = '') { |
| 1204 | 1437 | global $globalStatsFilters; |
| 1205 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1438 | + if ($filter_name == '') { |
|
| 1439 | + $filter_name = $this->filter_name; |
|
| 1440 | + } |
|
| 1206 | 1441 | $query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC"; |
| 1207 | 1442 | $query_data = array(':filter_name' => $filter_name); |
| 1208 | 1443 | try { |
@@ -1224,7 +1459,9 @@ discard block |
||
| 1224 | 1459 | } |
| 1225 | 1460 | public function countAllDatesByAirlines($filter_name = '') { |
| 1226 | 1461 | global $globalStatsFilters; |
| 1227 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1462 | + if ($filter_name == '') { |
|
| 1463 | + $filter_name = $this->filter_name; |
|
| 1464 | + } |
|
| 1228 | 1465 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
| 1229 | 1466 | $query_data = array('filter_name' => $filter_name); |
| 1230 | 1467 | try { |
@@ -1246,7 +1483,9 @@ discard block |
||
| 1246 | 1483 | } |
| 1247 | 1484 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
| 1248 | 1485 | global $globalStatsFilters, $globalDBdriver; |
| 1249 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1486 | + if ($filter_name == '') { |
|
| 1487 | + $filter_name = $this->filter_name; |
|
| 1488 | + } |
|
| 1250 | 1489 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1251 | 1490 | $Spotter = new Spotter($this->db); |
| 1252 | 1491 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1331,7 +1570,9 @@ discard block |
||
| 1331 | 1570 | } |
| 1332 | 1571 | public function countAllMilitaryMonths($filter_name = '') { |
| 1333 | 1572 | global $globalStatsFilters; |
| 1334 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1573 | + if ($filter_name == '') { |
|
| 1574 | + $filter_name = $this->filter_name; |
|
| 1575 | + } |
|
| 1335 | 1576 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
| 1336 | 1577 | try { |
| 1337 | 1578 | $sth = $this->db->prepare($query); |
@@ -1352,7 +1593,9 @@ discard block |
||
| 1352 | 1593 | } |
| 1353 | 1594 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
| 1354 | 1595 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1355 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1596 | + if ($filter_name == '') { |
|
| 1597 | + $filter_name = $this->filter_name; |
|
| 1598 | + } |
|
| 1356 | 1599 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1357 | 1600 | $Spotter = new Spotter($this->db); |
| 1358 | 1601 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1360,12 +1603,18 @@ discard block |
||
| 1360 | 1603 | foreach ($airlines as $airline) { |
| 1361 | 1604 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 1362 | 1605 | } |
| 1363 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1364 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1606 | + if ($limit) { |
|
| 1607 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1608 | + } else { |
|
| 1609 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1610 | + } |
|
| 1365 | 1611 | $query_data = array(':filter_name' => $filter_name); |
| 1366 | 1612 | } else { |
| 1367 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1368 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1613 | + if ($limit) { |
|
| 1614 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1615 | + } else { |
|
| 1616 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1617 | + } |
|
| 1369 | 1618 | $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
| 1370 | 1619 | } |
| 1371 | 1620 | if ($orderby == 'hour') { |
@@ -1375,7 +1624,9 @@ discard block |
||
| 1375 | 1624 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
| 1376 | 1625 | } |
| 1377 | 1626 | } |
| 1378 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
| 1627 | + if ($orderby == 'count') { |
|
| 1628 | + $query .= " ORDER BY hour_count DESC"; |
|
| 1629 | + } |
|
| 1379 | 1630 | try { |
| 1380 | 1631 | $sth = $this->db->prepare($query); |
| 1381 | 1632 | $sth->execute($query_data); |
@@ -1399,9 +1650,14 @@ discard block |
||
| 1399 | 1650 | } |
| 1400 | 1651 | public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') { |
| 1401 | 1652 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1402 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1403 | - if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
| 1404 | - else $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
| 1653 | + if ($filter_name == '') { |
|
| 1654 | + $filter_name = $this->filter_name; |
|
| 1655 | + } |
|
| 1656 | + if ($limit) { |
|
| 1657 | + $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
| 1658 | + } else { |
|
| 1659 | + $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
| 1660 | + } |
|
| 1405 | 1661 | $query_data = array(':filter_name' => $filter_name); |
| 1406 | 1662 | if ($orderby == 'hour') { |
| 1407 | 1663 | if ($globalDBdriver == 'mysql') { |
@@ -1410,7 +1666,9 @@ discard block |
||
| 1410 | 1666 | $query .= " ORDER BY CAST(marine_date AS integer) ASC"; |
| 1411 | 1667 | } |
| 1412 | 1668 | } |
| 1413 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
| 1669 | + if ($orderby == 'count') { |
|
| 1670 | + $query .= " ORDER BY hour_count DESC"; |
|
| 1671 | + } |
|
| 1414 | 1672 | try { |
| 1415 | 1673 | $sth = $this->db->prepare($query); |
| 1416 | 1674 | $sth->execute($query_data); |
@@ -1430,9 +1688,14 @@ discard block |
||
| 1430 | 1688 | } |
| 1431 | 1689 | public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') { |
| 1432 | 1690 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1433 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1434 | - if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
| 1435 | - else $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
| 1691 | + if ($filter_name == '') { |
|
| 1692 | + $filter_name = $this->filter_name; |
|
| 1693 | + } |
|
| 1694 | + if ($limit) { |
|
| 1695 | + $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
| 1696 | + } else { |
|
| 1697 | + $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
| 1698 | + } |
|
| 1436 | 1699 | $query_data = array(':filter_name' => $filter_name); |
| 1437 | 1700 | if ($orderby == 'hour') { |
| 1438 | 1701 | if ($globalDBdriver == 'mysql') { |
@@ -1441,7 +1704,9 @@ discard block |
||
| 1441 | 1704 | $query .= " ORDER BY CAST(tracker_date AS integer) ASC"; |
| 1442 | 1705 | } |
| 1443 | 1706 | } |
| 1444 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
| 1707 | + if ($orderby == 'count') { |
|
| 1708 | + $query .= " ORDER BY hour_count DESC"; |
|
| 1709 | + } |
|
| 1445 | 1710 | try { |
| 1446 | 1711 | $sth = $this->db->prepare($query); |
| 1447 | 1712 | $sth->execute($query_data); |
@@ -1461,8 +1726,12 @@ discard block |
||
| 1461 | 1726 | } |
| 1462 | 1727 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 1463 | 1728 | global $globalStatsFilters; |
| 1464 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1465 | - if ($year == '') $year = date('Y'); |
|
| 1729 | + if ($filter_name == '') { |
|
| 1730 | + $filter_name = $this->filter_name; |
|
| 1731 | + } |
|
| 1732 | + if ($year == '') { |
|
| 1733 | + $year = date('Y'); |
|
| 1734 | + } |
|
| 1466 | 1735 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
| 1467 | 1736 | if (empty($all)) { |
| 1468 | 1737 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1481,8 +1750,12 @@ discard block |
||
| 1481 | 1750 | } |
| 1482 | 1751 | public function countOverallMarine($filter_name = '',$year = '',$month = '') { |
| 1483 | 1752 | global $globalStatsFilters; |
| 1484 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1485 | - if ($year == '') $year = date('Y'); |
|
| 1753 | + if ($filter_name == '') { |
|
| 1754 | + $filter_name = $this->filter_name; |
|
| 1755 | + } |
|
| 1756 | + if ($year == '') { |
|
| 1757 | + $year = date('Y'); |
|
| 1758 | + } |
|
| 1486 | 1759 | $all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month); |
| 1487 | 1760 | if (empty($all)) { |
| 1488 | 1761 | $filters = array('year' => $year,'month' => $month); |
@@ -1497,8 +1770,12 @@ discard block |
||
| 1497 | 1770 | } |
| 1498 | 1771 | public function countOverallTracker($filter_name = '',$year = '',$month = '') { |
| 1499 | 1772 | global $globalStatsFilters; |
| 1500 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1501 | - if ($year == '') $year = date('Y'); |
|
| 1773 | + if ($filter_name == '') { |
|
| 1774 | + $filter_name = $this->filter_name; |
|
| 1775 | + } |
|
| 1776 | + if ($year == '') { |
|
| 1777 | + $year = date('Y'); |
|
| 1778 | + } |
|
| 1502 | 1779 | $all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month); |
| 1503 | 1780 | if (empty($all)) { |
| 1504 | 1781 | $filters = array('year' => $year,'month' => $month); |
@@ -1513,8 +1790,12 @@ discard block |
||
| 1513 | 1790 | } |
| 1514 | 1791 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
| 1515 | 1792 | global $globalStatsFilters; |
| 1516 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1517 | - if ($year == '') $year = date('Y'); |
|
| 1793 | + if ($filter_name == '') { |
|
| 1794 | + $filter_name = $this->filter_name; |
|
| 1795 | + } |
|
| 1796 | + if ($year == '') { |
|
| 1797 | + $year = date('Y'); |
|
| 1798 | + } |
|
| 1518 | 1799 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
| 1519 | 1800 | if (empty($all)) { |
| 1520 | 1801 | $filters = array(); |
@@ -1530,8 +1811,12 @@ discard block |
||
| 1530 | 1811 | } |
| 1531 | 1812 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
| 1532 | 1813 | global $globalStatsFilters; |
| 1533 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1534 | - if ($year == '') $year = date('Y'); |
|
| 1814 | + if ($filter_name == '') { |
|
| 1815 | + $filter_name = $this->filter_name; |
|
| 1816 | + } |
|
| 1817 | + if ($year == '') { |
|
| 1818 | + $year = date('Y'); |
|
| 1819 | + } |
|
| 1535 | 1820 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
| 1536 | 1821 | if (empty($all)) { |
| 1537 | 1822 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1550,7 +1835,9 @@ discard block |
||
| 1550 | 1835 | } |
| 1551 | 1836 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 1552 | 1837 | global $globalStatsFilters; |
| 1553 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1838 | + if ($filter_name == '') { |
|
| 1839 | + $filter_name = $this->filter_name; |
|
| 1840 | + } |
|
| 1554 | 1841 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1555 | 1842 | $Spotter = new Spotter($this->db); |
| 1556 | 1843 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1568,7 +1855,9 @@ discard block |
||
| 1568 | 1855 | } |
| 1569 | 1856 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1570 | 1857 | $all = $result[0]['nb']; |
| 1571 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1858 | + } else { |
|
| 1859 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1860 | + } |
|
| 1572 | 1861 | } else { |
| 1573 | 1862 | if ($year == '' && $month == '') { |
| 1574 | 1863 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1580,7 +1869,9 @@ discard block |
||
| 1580 | 1869 | } |
| 1581 | 1870 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1582 | 1871 | $all = $result[0]['nb']; |
| 1583 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1872 | + } else { |
|
| 1873 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1874 | + } |
|
| 1584 | 1875 | } |
| 1585 | 1876 | if (empty($all)) { |
| 1586 | 1877 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1599,7 +1890,9 @@ discard block |
||
| 1599 | 1890 | } |
| 1600 | 1891 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
| 1601 | 1892 | global $globalStatsFilters; |
| 1602 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1893 | + if ($filter_name == '') { |
|
| 1894 | + $filter_name = $this->filter_name; |
|
| 1895 | + } |
|
| 1603 | 1896 | if ($year == '' && $month == '') { |
| 1604 | 1897 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
| 1605 | 1898 | try { |
@@ -1610,7 +1903,9 @@ discard block |
||
| 1610 | 1903 | } |
| 1611 | 1904 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1612 | 1905 | $all = $result[0]['nb_airline']; |
| 1613 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1906 | + } else { |
|
| 1907 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1908 | + } |
|
| 1614 | 1909 | if (empty($all)) { |
| 1615 | 1910 | $filters = array(); |
| 1616 | 1911 | $filters = array('year' => $year,'month' => $month); |
@@ -1625,7 +1920,9 @@ discard block |
||
| 1625 | 1920 | } |
| 1626 | 1921 | public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') { |
| 1627 | 1922 | global $globalStatsFilters; |
| 1628 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1923 | + if ($filter_name == '') { |
|
| 1924 | + $filter_name = $this->filter_name; |
|
| 1925 | + } |
|
| 1629 | 1926 | $all = array(); |
| 1630 | 1927 | if ($year == '' && $month == '') { |
| 1631 | 1928 | $query = "SELECT COUNT(*) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name"; |
@@ -1652,7 +1949,9 @@ discard block |
||
| 1652 | 1949 | } |
| 1653 | 1950 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 1654 | 1951 | global $globalStatsFilters; |
| 1655 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1952 | + if ($filter_name == '') { |
|
| 1953 | + $filter_name = $this->filter_name; |
|
| 1954 | + } |
|
| 1656 | 1955 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1657 | 1956 | $Spotter = new Spotter($this->db); |
| 1658 | 1957 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1707,7 +2006,9 @@ discard block |
||
| 1707 | 2006 | } |
| 1708 | 2007 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 1709 | 2008 | global $globalStatsFilters; |
| 1710 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2009 | + if ($filter_name == '') { |
|
| 2010 | + $filter_name = $this->filter_name; |
|
| 2011 | + } |
|
| 1711 | 2012 | //if ($year == '') $year = date('Y'); |
| 1712 | 2013 | if ($year == '' && $month == '') { |
| 1713 | 2014 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1736,7 +2037,9 @@ discard block |
||
| 1736 | 2037 | } |
| 1737 | 2038 | |
| 1738 | 2039 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
| 1739 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2040 | + if ($filter_name == '') { |
|
| 2041 | + $filter_name = $this->filter_name; |
|
| 2042 | + } |
|
| 1740 | 2043 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1741 | 2044 | $Spotter = new Spotter($this->db); |
| 1742 | 2045 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1760,7 +2063,9 @@ discard block |
||
| 1760 | 2063 | return $all; |
| 1761 | 2064 | } |
| 1762 | 2065 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
| 1763 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2066 | + if ($filter_name == '') { |
|
| 2067 | + $filter_name = $this->filter_name; |
|
| 2068 | + } |
|
| 1764 | 2069 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 1765 | 2070 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 1766 | 2071 | try { |
@@ -1773,7 +2078,9 @@ discard block |
||
| 1773 | 2078 | return $all; |
| 1774 | 2079 | } |
| 1775 | 2080 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
| 1776 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2081 | + if ($filter_name == '') { |
|
| 2082 | + $filter_name = $this->filter_name; |
|
| 2083 | + } |
|
| 1777 | 2084 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1778 | 2085 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 1779 | 2086 | try { |
@@ -1784,7 +2091,9 @@ discard block |
||
| 1784 | 2091 | } |
| 1785 | 2092 | } |
| 1786 | 2093 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
| 1787 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2094 | + if ($filter_name == '') { |
|
| 2095 | + $filter_name = $this->filter_name; |
|
| 2096 | + } |
|
| 1788 | 2097 | global $globalArchiveMonths, $globalDBdriver; |
| 1789 | 2098 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1790 | 2099 | $Spotter = new Spotter($this->db); |
@@ -1840,7 +2149,9 @@ discard block |
||
| 1840 | 2149 | } |
| 1841 | 2150 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 1842 | 2151 | global $globalArchiveMonths, $globalDBdriver; |
| 1843 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2152 | + if ($filter_name == '') { |
|
| 2153 | + $filter_name = $this->filter_name; |
|
| 2154 | + } |
|
| 1844 | 2155 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1845 | 2156 | $Spotter = new Spotter($this->db); |
| 1846 | 2157 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1873,7 +2184,9 @@ discard block |
||
| 1873 | 2184 | } |
| 1874 | 2185 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 1875 | 2186 | global $globalArchiveMonths, $globalDBdriver; |
| 1876 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2187 | + if ($filter_name == '') { |
|
| 2188 | + $filter_name = $this->filter_name; |
|
| 2189 | + } |
|
| 1877 | 2190 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1878 | 2191 | $Spotter = new Spotter($this->db); |
| 1879 | 2192 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1904,7 +2217,9 @@ discard block |
||
| 1904 | 2217 | } |
| 1905 | 2218 | public function getStatsAirlineTotal($filter_name = '') { |
| 1906 | 2219 | global $globalArchiveMonths, $globalDBdriver; |
| 1907 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2220 | + if ($filter_name == '') { |
|
| 2221 | + $filter_name = $this->filter_name; |
|
| 2222 | + } |
|
| 1908 | 2223 | if ($globalDBdriver == 'mysql') { |
| 1909 | 2224 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
| 1910 | 2225 | } else { |
@@ -1921,7 +2236,9 @@ discard block |
||
| 1921 | 2236 | } |
| 1922 | 2237 | public function getStatsOwnerTotal($filter_name = '') { |
| 1923 | 2238 | global $globalArchiveMonths, $globalDBdriver; |
| 1924 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2239 | + if ($filter_name == '') { |
|
| 2240 | + $filter_name = $this->filter_name; |
|
| 2241 | + } |
|
| 1925 | 2242 | if ($globalDBdriver == 'mysql') { |
| 1926 | 2243 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
| 1927 | 2244 | } else { |
@@ -1938,7 +2255,9 @@ discard block |
||
| 1938 | 2255 | } |
| 1939 | 2256 | public function getStatsOwner($owner_name,$filter_name = '') { |
| 1940 | 2257 | global $globalArchiveMonths, $globalDBdriver; |
| 1941 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2258 | + if ($filter_name == '') { |
|
| 2259 | + $filter_name = $this->filter_name; |
|
| 2260 | + } |
|
| 1942 | 2261 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 1943 | 2262 | try { |
| 1944 | 2263 | $sth = $this->db->prepare($query); |
@@ -1947,12 +2266,17 @@ discard block |
||
| 1947 | 2266 | echo "error : ".$e->getMessage(); |
| 1948 | 2267 | } |
| 1949 | 2268 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1950 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1951 | - else return 0; |
|
| 2269 | + if (isset($all[0]['cnt'])) { |
|
| 2270 | + return $all[0]['cnt']; |
|
| 2271 | + } else { |
|
| 2272 | + return 0; |
|
| 2273 | + } |
|
| 1952 | 2274 | } |
| 1953 | 2275 | public function getStatsPilotTotal($filter_name = '') { |
| 1954 | 2276 | global $globalArchiveMonths, $globalDBdriver; |
| 1955 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2277 | + if ($filter_name == '') { |
|
| 2278 | + $filter_name = $this->filter_name; |
|
| 2279 | + } |
|
| 1956 | 2280 | if ($globalDBdriver == 'mysql') { |
| 1957 | 2281 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
| 1958 | 2282 | } else { |
@@ -1969,7 +2293,9 @@ discard block |
||
| 1969 | 2293 | } |
| 1970 | 2294 | public function getStatsPilot($pilot,$filter_name = '') { |
| 1971 | 2295 | global $globalArchiveMonths, $globalDBdriver; |
| 1972 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2296 | + if ($filter_name == '') { |
|
| 2297 | + $filter_name = $this->filter_name; |
|
| 2298 | + } |
|
| 1973 | 2299 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1974 | 2300 | try { |
| 1975 | 2301 | $sth = $this->db->prepare($query); |
@@ -1978,13 +2304,18 @@ discard block |
||
| 1978 | 2304 | echo "error : ".$e->getMessage(); |
| 1979 | 2305 | } |
| 1980 | 2306 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1981 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1982 | - else return 0; |
|
| 2307 | + if (isset($all[0]['cnt'])) { |
|
| 2308 | + return $all[0]['cnt']; |
|
| 2309 | + } else { |
|
| 2310 | + return 0; |
|
| 2311 | + } |
|
| 1983 | 2312 | } |
| 1984 | 2313 | |
| 1985 | 2314 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1986 | 2315 | global $globalDBdriver; |
| 1987 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2316 | + if ($filter_name == '') { |
|
| 2317 | + $filter_name = $this->filter_name; |
|
| 2318 | + } |
|
| 1988 | 2319 | if ($globalDBdriver == 'mysql') { |
| 1989 | 2320 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
| 1990 | 2321 | } else { |
@@ -2000,7 +2331,9 @@ discard block |
||
| 2000 | 2331 | } |
| 2001 | 2332 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 2002 | 2333 | global $globalDBdriver; |
| 2003 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2334 | + if ($filter_name == '') { |
|
| 2335 | + $filter_name = $this->filter_name; |
|
| 2336 | + } |
|
| 2004 | 2337 | if ($globalDBdriver == 'mysql') { |
| 2005 | 2338 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
| 2006 | 2339 | } else { |
@@ -2519,27 +2852,37 @@ discard block |
||
| 2519 | 2852 | date_default_timezone_set('UTC'); |
| 2520 | 2853 | if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) { |
| 2521 | 2854 | $last_update = $this->getLastStatsUpdate('last_update_stats_marine'); |
| 2522 | - if ($globalDebug) echo '!!! Update Marine stats !!!'."\n"; |
|
| 2855 | + if ($globalDebug) { |
|
| 2856 | + echo '!!! Update Marine stats !!!'."\n"; |
|
| 2857 | + } |
|
| 2523 | 2858 | if (isset($last_update[0]['value'])) { |
| 2524 | 2859 | $last_update_day = $last_update[0]['value']; |
| 2525 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 2860 | + } else { |
|
| 2861 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 2862 | + } |
|
| 2526 | 2863 | $reset = false; |
| 2527 | 2864 | $Marine = new Marine($this->db); |
| 2528 | 2865 | $filtername = 'marine'; |
| 2529 | 2866 | if ($Connection->tableExists('countries')) { |
| 2530 | - if ($globalDebug) echo 'Count all vessels by countries...'."\n"; |
|
| 2867 | + if ($globalDebug) { |
|
| 2868 | + echo 'Count all vessels by countries...'."\n"; |
|
| 2869 | + } |
|
| 2531 | 2870 | $alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day); |
| 2532 | 2871 | foreach ($alldata as $number) { |
| 2533 | 2872 | echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset); |
| 2534 | 2873 | } |
| 2535 | 2874 | } |
| 2536 | - if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
|
| 2875 | + if ($globalDebug) { |
|
| 2876 | + echo 'Count all vessels by months...'."\n"; |
|
| 2877 | + } |
|
| 2537 | 2878 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
| 2538 | 2879 | $filter_last_month = array('since_date' => $last_month); |
| 2539 | 2880 | $alldata = $Marine->countAllMonths($filter_last_month); |
| 2540 | 2881 | $lastyear = false; |
| 2541 | 2882 | foreach ($alldata as $number) { |
| 2542 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2883 | + if ($number['year_name'] != date('Y')) { |
|
| 2884 | + $lastyear = true; |
|
| 2885 | + } |
|
| 2543 | 2886 | $this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2544 | 2887 | } |
| 2545 | 2888 | echo 'Marine data...'."\n"; |
@@ -2569,7 +2912,9 @@ discard block |
||
| 2569 | 2912 | foreach ($alldata as $number) { |
| 2570 | 2913 | $this->addStatMarine('hour',$number['hour_name'],$number['hour_count']); |
| 2571 | 2914 | } |
| 2572 | - if ($globalDebug) echo 'Count all types...'."\n"; |
|
| 2915 | + if ($globalDebug) { |
|
| 2916 | + echo 'Count all types...'."\n"; |
|
| 2917 | + } |
|
| 2573 | 2918 | $alldata = $Marine->countAllMarineTypes(false,0,$last_update_day); |
| 2574 | 2919 | foreach ($alldata as $number) { |
| 2575 | 2920 | $this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset); |
@@ -2581,26 +2926,36 @@ discard block |
||
| 2581 | 2926 | } |
| 2582 | 2927 | if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) { |
| 2583 | 2928 | $last_update = $this->getLastStatsUpdate('last_update_stats_tracker'); |
| 2584 | - if ($globalDebug) echo '!!! Update tracker stats !!!'."\n"; |
|
| 2929 | + if ($globalDebug) { |
|
| 2930 | + echo '!!! Update tracker stats !!!'."\n"; |
|
| 2931 | + } |
|
| 2585 | 2932 | if (isset($last_update[0]['value'])) { |
| 2586 | 2933 | $last_update_day = $last_update[0]['value']; |
| 2587 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 2934 | + } else { |
|
| 2935 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 2936 | + } |
|
| 2588 | 2937 | $reset = false; |
| 2589 | 2938 | $Tracker = new Tracker($this->db); |
| 2590 | 2939 | if ($Connection->tableExists('countries')) { |
| 2591 | - if ($globalDebug) echo 'Count all trackers by countries...'."\n"; |
|
| 2940 | + if ($globalDebug) { |
|
| 2941 | + echo 'Count all trackers by countries...'."\n"; |
|
| 2942 | + } |
|
| 2592 | 2943 | $alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day); |
| 2593 | 2944 | foreach ($alldata as $number) { |
| 2594 | 2945 | $this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset); |
| 2595 | 2946 | } |
| 2596 | 2947 | } |
| 2597 | - if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
|
| 2948 | + if ($globalDebug) { |
|
| 2949 | + echo 'Count all vessels by months...'."\n"; |
|
| 2950 | + } |
|
| 2598 | 2951 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
| 2599 | 2952 | $filter_last_month = array('since_date' => $last_month); |
| 2600 | 2953 | $alldata = $Tracker->countAllMonths($filter_last_month); |
| 2601 | 2954 | $lastyear = false; |
| 2602 | 2955 | foreach ($alldata as $number) { |
| 2603 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2956 | + if ($number['year_name'] != date('Y')) { |
|
| 2957 | + $lastyear = true; |
|
| 2958 | + } |
|
| 2604 | 2959 | $this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2605 | 2960 | } |
| 2606 | 2961 | echo 'Tracker data...'."\n"; |
@@ -2630,7 +2985,9 @@ discard block |
||
| 2630 | 2985 | foreach ($alldata as $number) { |
| 2631 | 2986 | $this->addStatTracker('hour',$number['hour_name'],$number['hour_count']); |
| 2632 | 2987 | } |
| 2633 | - if ($globalDebug) echo 'Count all types...'."\n"; |
|
| 2988 | + if ($globalDebug) { |
|
| 2989 | + echo 'Count all types...'."\n"; |
|
| 2990 | + } |
|
| 2634 | 2991 | $alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day); |
| 2635 | 2992 | foreach ($alldata as $number) { |
| 2636 | 2993 | $this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset); |
@@ -2642,10 +2999,14 @@ discard block |
||
| 2642 | 2999 | |
| 2643 | 3000 | if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) { |
| 2644 | 3001 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 2645 | - if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n"; |
|
| 3002 | + if ($globalDebug) { |
|
| 3003 | + echo '!!! Update aicraft stats !!!'."\n"; |
|
| 3004 | + } |
|
| 2646 | 3005 | if (isset($last_update[0]['value'])) { |
| 2647 | 3006 | $last_update_day = $last_update[0]['value']; |
| 2648 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 3007 | + } else { |
|
| 3008 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 3009 | + } |
|
| 2649 | 3010 | $reset = false; |
| 2650 | 3011 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
| 2651 | 3012 | if ($globalStatsResetYear) { |
@@ -2654,43 +3015,63 @@ discard block |
||
| 2654 | 3015 | } |
| 2655 | 3016 | $Spotter = new Spotter($this->db); |
| 2656 | 3017 | |
| 2657 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 3018 | + if ($globalDebug) { |
|
| 3019 | + echo 'Count all aircraft types...'."\n"; |
|
| 3020 | + } |
|
| 2658 | 3021 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
| 2659 | 3022 | foreach ($alldata as $number) { |
| 2660 | 3023 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
| 2661 | 3024 | } |
| 2662 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 3025 | + if ($globalDebug) { |
|
| 3026 | + echo 'Count all airlines...'."\n"; |
|
| 3027 | + } |
|
| 2663 | 3028 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
| 2664 | 3029 | foreach ($alldata as $number) { |
| 2665 | 3030 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
| 2666 | 3031 | } |
| 2667 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
| 3032 | + if ($globalDebug) { |
|
| 3033 | + echo 'Count all registrations...'."\n"; |
|
| 3034 | + } |
|
| 2668 | 3035 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
| 2669 | 3036 | foreach ($alldata as $number) { |
| 2670 | 3037 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
| 2671 | 3038 | } |
| 2672 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 3039 | + if ($globalDebug) { |
|
| 3040 | + echo 'Count all callsigns...'."\n"; |
|
| 3041 | + } |
|
| 2673 | 3042 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
| 2674 | 3043 | foreach ($alldata as $number) { |
| 2675 | 3044 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 2676 | 3045 | } |
| 2677 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 3046 | + if ($globalDebug) { |
|
| 3047 | + echo 'Count all owners...'."\n"; |
|
| 3048 | + } |
|
| 2678 | 3049 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
| 2679 | 3050 | foreach ($alldata as $number) { |
| 2680 | 3051 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
| 2681 | 3052 | } |
| 2682 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 3053 | + if ($globalDebug) { |
|
| 3054 | + echo 'Count all pilots...'."\n"; |
|
| 3055 | + } |
|
| 2683 | 3056 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
| 2684 | 3057 | foreach ($alldata as $number) { |
| 2685 | - if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
|
| 3058 | + if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') { |
|
| 3059 | + $number['pilot_id'] = $number['pilot_name']; |
|
| 3060 | + } |
|
| 2686 | 3061 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
| 2687 | 3062 | } |
| 2688 | 3063 | |
| 2689 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
| 3064 | + if ($globalDebug) { |
|
| 3065 | + echo 'Count all departure airports...'."\n"; |
|
| 3066 | + } |
|
| 2690 | 3067 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
| 2691 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
| 3068 | + if ($globalDebug) { |
|
| 3069 | + echo 'Count all detected departure airports...'."\n"; |
|
| 3070 | + } |
|
| 2692 | 3071 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
| 2693 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
| 3072 | + if ($globalDebug) { |
|
| 3073 | + echo 'Order departure airports...'."\n"; |
|
| 3074 | + } |
|
| 2694 | 3075 | $alldata = array(); |
| 2695 | 3076 | foreach ($pall as $value) { |
| 2696 | 3077 | $icao = $value['airport_departure_icao']; |
@@ -2700,7 +3081,9 @@ discard block |
||
| 2700 | 3081 | $icao = $value['airport_departure_icao']; |
| 2701 | 3082 | if (isset($alldata[$icao])) { |
| 2702 | 3083 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 2703 | - } else $alldata[$icao] = $value; |
|
| 3084 | + } else { |
|
| 3085 | + $alldata[$icao] = $value; |
|
| 3086 | + } |
|
| 2704 | 3087 | } |
| 2705 | 3088 | $count = array(); |
| 2706 | 3089 | foreach ($alldata as $key => $row) { |
@@ -2710,11 +3093,17 @@ discard block |
||
| 2710 | 3093 | foreach ($alldata as $number) { |
| 2711 | 3094 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
| 2712 | 3095 | } |
| 2713 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 3096 | + if ($globalDebug) { |
|
| 3097 | + echo 'Count all arrival airports...'."\n"; |
|
| 3098 | + } |
|
| 2714 | 3099 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
| 2715 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
| 3100 | + if ($globalDebug) { |
|
| 3101 | + echo 'Count all detected arrival airports...'."\n"; |
|
| 3102 | + } |
|
| 2716 | 3103 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
| 2717 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
| 3104 | + if ($globalDebug) { |
|
| 3105 | + echo 'Order arrival airports...'."\n"; |
|
| 3106 | + } |
|
| 2718 | 3107 | $alldata = array(); |
| 2719 | 3108 | foreach ($pall as $value) { |
| 2720 | 3109 | $icao = $value['airport_arrival_icao']; |
@@ -2724,7 +3113,9 @@ discard block |
||
| 2724 | 3113 | $icao = $value['airport_arrival_icao']; |
| 2725 | 3114 | if (isset($alldata[$icao])) { |
| 2726 | 3115 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 2727 | - } else $alldata[$icao] = $value; |
|
| 3116 | + } else { |
|
| 3117 | + $alldata[$icao] = $value; |
|
| 3118 | + } |
|
| 2728 | 3119 | } |
| 2729 | 3120 | $count = array(); |
| 2730 | 3121 | foreach ($alldata as $key => $row) { |
@@ -2735,7 +3126,9 @@ discard block |
||
| 2735 | 3126 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
| 2736 | 3127 | } |
| 2737 | 3128 | if ($Connection->tableExists('countries')) { |
| 2738 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
| 3129 | + if ($globalDebug) { |
|
| 3130 | + echo 'Count all flights by countries...'."\n"; |
|
| 3131 | + } |
|
| 2739 | 3132 | //$SpotterArchive = new SpotterArchive(); |
| 2740 | 3133 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 2741 | 3134 | $Spotter = new Spotter($this->db); |
@@ -2746,7 +3139,9 @@ discard block |
||
| 2746 | 3139 | } |
| 2747 | 3140 | |
| 2748 | 3141 | if (isset($globalAccidents) && $globalAccidents) { |
| 2749 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
| 3142 | + if ($globalDebug) { |
|
| 3143 | + echo 'Count fatalities stats...'."\n"; |
|
| 3144 | + } |
|
| 2750 | 3145 | $Accident = new Accident($this->db); |
| 2751 | 3146 | $this->deleteStatsByType('fatalities_byyear'); |
| 2752 | 3147 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -2762,48 +3157,68 @@ discard block |
||
| 2762 | 3157 | |
| 2763 | 3158 | // Add by month using getstat if month finish... |
| 2764 | 3159 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
| 2765 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
| 3160 | + if ($globalDebug) { |
|
| 3161 | + echo 'Count all flights by months...'."\n"; |
|
| 3162 | + } |
|
| 2766 | 3163 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
| 2767 | 3164 | $filter_last_month = array('since_date' => $last_month); |
| 2768 | 3165 | $Spotter = new Spotter($this->db); |
| 2769 | 3166 | $alldata = $Spotter->countAllMonths($filter_last_month); |
| 2770 | 3167 | $lastyear = false; |
| 2771 | 3168 | foreach ($alldata as $number) { |
| 2772 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 3169 | + if ($number['year_name'] != date('Y')) { |
|
| 3170 | + $lastyear = true; |
|
| 3171 | + } |
|
| 2773 | 3172 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2774 | 3173 | } |
| 2775 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
| 3174 | + if ($globalDebug) { |
|
| 3175 | + echo 'Count all military flights by months...'."\n"; |
|
| 3176 | + } |
|
| 2776 | 3177 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
| 2777 | 3178 | foreach ($alldata as $number) { |
| 2778 | 3179 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2779 | 3180 | } |
| 2780 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 3181 | + if ($globalDebug) { |
|
| 3182 | + echo 'Count all owners by months...'."\n"; |
|
| 3183 | + } |
|
| 2781 | 3184 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
| 2782 | 3185 | foreach ($alldata as $number) { |
| 2783 | 3186 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2784 | 3187 | } |
| 2785 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 3188 | + if ($globalDebug) { |
|
| 3189 | + echo 'Count all pilots by months...'."\n"; |
|
| 3190 | + } |
|
| 2786 | 3191 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
| 2787 | 3192 | foreach ($alldata as $number) { |
| 2788 | 3193 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2789 | 3194 | } |
| 2790 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
| 3195 | + if ($globalDebug) { |
|
| 3196 | + echo 'Count all airlines by months...'."\n"; |
|
| 3197 | + } |
|
| 2791 | 3198 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
| 2792 | 3199 | foreach ($alldata as $number) { |
| 2793 | 3200 | $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2794 | 3201 | } |
| 2795 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 3202 | + if ($globalDebug) { |
|
| 3203 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 3204 | + } |
|
| 2796 | 3205 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
| 2797 | 3206 | foreach ($alldata as $number) { |
| 2798 | 3207 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2799 | 3208 | } |
| 2800 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 3209 | + if ($globalDebug) { |
|
| 3210 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 3211 | + } |
|
| 2801 | 3212 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
| 2802 | 3213 | foreach ($alldata as $number) { |
| 2803 | 3214 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2804 | 3215 | } |
| 2805 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
| 2806 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 3216 | + if ($globalDebug) { |
|
| 3217 | + echo 'Airports data...'."\n"; |
|
| 3218 | + } |
|
| 3219 | + if ($globalDebug) { |
|
| 3220 | + echo '...Departure'."\n"; |
|
| 3221 | + } |
|
| 2807 | 3222 | $this->deleteStatAirport('daily'); |
| 2808 | 3223 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
| 2809 | 3224 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -2921,7 +3336,9 @@ discard block |
||
| 2921 | 3336 | // Count by airlines |
| 2922 | 3337 | echo '--- Stats by airlines ---'."\n"; |
| 2923 | 3338 | if ($Connection->tableExists('countries')) { |
| 2924 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
| 3339 | + if ($globalDebug) { |
|
| 3340 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
| 3341 | + } |
|
| 2925 | 3342 | $SpotterArchive = new SpotterArchive($this->db); |
| 2926 | 3343 | //$Spotter = new Spotter($this->db); |
| 2927 | 3344 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
@@ -2930,37 +3347,53 @@ discard block |
||
| 2930 | 3347 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
| 2931 | 3348 | } |
| 2932 | 3349 | } |
| 2933 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
| 3350 | + if ($globalDebug) { |
|
| 3351 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
| 3352 | + } |
|
| 2934 | 3353 | $Spotter = new Spotter($this->db); |
| 2935 | 3354 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
| 2936 | 3355 | foreach ($alldata as $number) { |
| 2937 | 3356 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
| 2938 | 3357 | } |
| 2939 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 3358 | + if ($globalDebug) { |
|
| 3359 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 3360 | + } |
|
| 2940 | 3361 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
| 2941 | 3362 | foreach ($alldata as $number) { |
| 2942 | 3363 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
| 2943 | 3364 | } |
| 2944 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
| 3365 | + if ($globalDebug) { |
|
| 3366 | + echo 'Count all callsigns by airlines...'."\n"; |
|
| 3367 | + } |
|
| 2945 | 3368 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
| 2946 | 3369 | foreach ($alldata as $number) { |
| 2947 | 3370 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 2948 | 3371 | } |
| 2949 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
| 3372 | + if ($globalDebug) { |
|
| 3373 | + echo 'Count all owners by airlines...'."\n"; |
|
| 3374 | + } |
|
| 2950 | 3375 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
| 2951 | 3376 | foreach ($alldata as $number) { |
| 2952 | 3377 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
| 2953 | 3378 | } |
| 2954 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
| 3379 | + if ($globalDebug) { |
|
| 3380 | + echo 'Count all pilots by airlines...'."\n"; |
|
| 3381 | + } |
|
| 2955 | 3382 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
| 2956 | 3383 | foreach ($alldata as $number) { |
| 2957 | 3384 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
| 2958 | 3385 | } |
| 2959 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
| 3386 | + if ($globalDebug) { |
|
| 3387 | + echo 'Count all departure airports by airlines...'."\n"; |
|
| 3388 | + } |
|
| 2960 | 3389 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
| 2961 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 3390 | + if ($globalDebug) { |
|
| 3391 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 3392 | + } |
|
| 2962 | 3393 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
| 2963 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
| 3394 | + if ($globalDebug) { |
|
| 3395 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
| 3396 | + } |
|
| 2964 | 3397 | //$alldata = array(); |
| 2965 | 3398 | foreach ($dall as $value) { |
| 2966 | 3399 | $icao = $value['airport_departure_icao']; |
@@ -2981,11 +3414,17 @@ discard block |
||
| 2981 | 3414 | foreach ($alldata as $number) { |
| 2982 | 3415 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
| 2983 | 3416 | } |
| 2984 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
| 3417 | + if ($globalDebug) { |
|
| 3418 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
| 3419 | + } |
|
| 2985 | 3420 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
| 2986 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 3421 | + if ($globalDebug) { |
|
| 3422 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 3423 | + } |
|
| 2987 | 3424 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
| 2988 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
| 3425 | + if ($globalDebug) { |
|
| 3426 | + echo 'Order arrival airports by airlines...'."\n"; |
|
| 3427 | + } |
|
| 2989 | 3428 | //$alldata = array(); |
| 2990 | 3429 | foreach ($dall as $value) { |
| 2991 | 3430 | $icao = $value['airport_arrival_icao']; |
@@ -3004,37 +3443,53 @@ discard block |
||
| 3004 | 3443 | } |
| 3005 | 3444 | $alldata = $pall; |
| 3006 | 3445 | foreach ($alldata as $number) { |
| 3007 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
| 3446 | + if ($number['airline_icao'] != '') { |
|
| 3447 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
| 3448 | + } |
|
| 3449 | + } |
|
| 3450 | + if ($globalDebug) { |
|
| 3451 | + echo 'Count all flights by months by airlines...'."\n"; |
|
| 3008 | 3452 | } |
| 3009 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
| 3010 | 3453 | $Spotter = new Spotter($this->db); |
| 3011 | 3454 | $alldata = $Spotter->countAllMonthsByAirlines($filter_last_month); |
| 3012 | 3455 | $lastyear = false; |
| 3013 | 3456 | foreach ($alldata as $number) { |
| 3014 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 3457 | + if ($number['year_name'] != date('Y')) { |
|
| 3458 | + $lastyear = true; |
|
| 3459 | + } |
|
| 3015 | 3460 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 3016 | 3461 | } |
| 3017 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
| 3462 | + if ($globalDebug) { |
|
| 3463 | + echo 'Count all owners by months by airlines...'."\n"; |
|
| 3464 | + } |
|
| 3018 | 3465 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
| 3019 | 3466 | foreach ($alldata as $number) { |
| 3020 | 3467 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 3021 | 3468 | } |
| 3022 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
| 3469 | + if ($globalDebug) { |
|
| 3470 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
| 3471 | + } |
|
| 3023 | 3472 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
| 3024 | 3473 | foreach ($alldata as $number) { |
| 3025 | 3474 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 3026 | 3475 | } |
| 3027 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 3476 | + if ($globalDebug) { |
|
| 3477 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 3478 | + } |
|
| 3028 | 3479 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
| 3029 | 3480 | foreach ($alldata as $number) { |
| 3030 | 3481 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 3031 | 3482 | } |
| 3032 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 3483 | + if ($globalDebug) { |
|
| 3484 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 3485 | + } |
|
| 3033 | 3486 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
| 3034 | 3487 | foreach ($alldata as $number) { |
| 3035 | 3488 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 3036 | 3489 | } |
| 3037 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 3490 | + if ($globalDebug) { |
|
| 3491 | + echo '...Departure'."\n"; |
|
| 3492 | + } |
|
| 3038 | 3493 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
| 3039 | 3494 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
| 3040 | 3495 | foreach ($dall as $value) { |
@@ -3057,7 +3512,9 @@ discard block |
||
| 3057 | 3512 | foreach ($alldata as $number) { |
| 3058 | 3513 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
| 3059 | 3514 | } |
| 3060 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
| 3515 | + if ($globalDebug) { |
|
| 3516 | + echo '...Arrival'."\n"; |
|
| 3517 | + } |
|
| 3061 | 3518 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
| 3062 | 3519 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
| 3063 | 3520 | foreach ($dall as $value) { |
@@ -3081,13 +3538,19 @@ discard block |
||
| 3081 | 3538 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
| 3082 | 3539 | } |
| 3083 | 3540 | |
| 3084 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
| 3085 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
| 3541 | + if ($globalDebug) { |
|
| 3542 | + echo 'Flights data...'."\n"; |
|
| 3543 | + } |
|
| 3544 | + if ($globalDebug) { |
|
| 3545 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
| 3546 | + } |
|
| 3086 | 3547 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
| 3087 | 3548 | foreach ($alldata as $number) { |
| 3088 | 3549 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
| 3089 | 3550 | } |
| 3090 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
| 3551 | + if ($globalDebug) { |
|
| 3552 | + echo '-> countAllDates...'."\n"; |
|
| 3553 | + } |
|
| 3091 | 3554 | //$previousdata = $this->countAllDatesByAirlines(); |
| 3092 | 3555 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
| 3093 | 3556 | $values = array(); |
@@ -3100,14 +3563,18 @@ discard block |
||
| 3100 | 3563 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
| 3101 | 3564 | } |
| 3102 | 3565 | |
| 3103 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
| 3566 | + if ($globalDebug) { |
|
| 3567 | + echo '-> countAllHours...'."\n"; |
|
| 3568 | + } |
|
| 3104 | 3569 | $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
| 3105 | 3570 | foreach ($alldata as $number) { |
| 3106 | 3571 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
| 3107 | 3572 | } |
| 3108 | 3573 | |
| 3109 | 3574 | // Stats by filters |
| 3110 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
| 3575 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
| 3576 | + $globalStatsFilters = array(); |
|
| 3577 | + } |
|
| 3111 | 3578 | foreach ($globalStatsFilters as $name => $filter) { |
| 3112 | 3579 | if (!empty($filter)) { |
| 3113 | 3580 | //$filter_name = $filter['name']; |
@@ -3115,7 +3582,9 @@ discard block |
||
| 3115 | 3582 | $reset = false; |
| 3116 | 3583 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
| 3117 | 3584 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
| 3118 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
| 3585 | + if ($globalDebug) { |
|
| 3586 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
| 3587 | + } |
|
| 3119 | 3588 | $this->deleteOldStats($filter_name); |
| 3120 | 3589 | unset($last_update); |
| 3121 | 3590 | } |
@@ -3132,39 +3601,55 @@ discard block |
||
| 3132 | 3601 | $reset = true; |
| 3133 | 3602 | } |
| 3134 | 3603 | // Count by filter |
| 3135 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 3604 | + if ($globalDebug) { |
|
| 3605 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 3606 | + } |
|
| 3136 | 3607 | $Spotter = new Spotter($this->db); |
| 3137 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 3608 | + if ($globalDebug) { |
|
| 3609 | + echo 'Count all aircraft types...'."\n"; |
|
| 3610 | + } |
|
| 3138 | 3611 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
| 3139 | 3612 | foreach ($alldata as $number) { |
| 3140 | 3613 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
| 3141 | 3614 | } |
| 3142 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 3615 | + if ($globalDebug) { |
|
| 3616 | + echo 'Count all airlines...'."\n"; |
|
| 3617 | + } |
|
| 3143 | 3618 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
| 3144 | 3619 | foreach ($alldata as $number) { |
| 3145 | 3620 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
| 3146 | 3621 | } |
| 3147 | - if ($globalDebug) echo 'Count all aircraft registrations...'."\n"; |
|
| 3622 | + if ($globalDebug) { |
|
| 3623 | + echo 'Count all aircraft registrations...'."\n"; |
|
| 3624 | + } |
|
| 3148 | 3625 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
| 3149 | 3626 | foreach ($alldata as $number) { |
| 3150 | 3627 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
| 3151 | 3628 | } |
| 3152 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 3629 | + if ($globalDebug) { |
|
| 3630 | + echo 'Count all callsigns...'."\n"; |
|
| 3631 | + } |
|
| 3153 | 3632 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
| 3154 | 3633 | foreach ($alldata as $number) { |
| 3155 | 3634 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
| 3156 | 3635 | } |
| 3157 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 3636 | + if ($globalDebug) { |
|
| 3637 | + echo 'Count all owners...'."\n"; |
|
| 3638 | + } |
|
| 3158 | 3639 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
| 3159 | 3640 | foreach ($alldata as $number) { |
| 3160 | 3641 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
| 3161 | 3642 | } |
| 3162 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 3643 | + if ($globalDebug) { |
|
| 3644 | + echo 'Count all pilots...'."\n"; |
|
| 3645 | + } |
|
| 3163 | 3646 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
| 3164 | 3647 | foreach ($alldata as $number) { |
| 3165 | 3648 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
| 3166 | 3649 | } |
| 3167 | - if ($globalDebug) echo 'Count departure airports...'."\n"; |
|
| 3650 | + if ($globalDebug) { |
|
| 3651 | + echo 'Count departure airports...'."\n"; |
|
| 3652 | + } |
|
| 3168 | 3653 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
| 3169 | 3654 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
| 3170 | 3655 | $alldata = array(); |
@@ -3176,7 +3661,9 @@ discard block |
||
| 3176 | 3661 | $icao = $value['airport_departure_icao']; |
| 3177 | 3662 | if (isset($alldata[$icao])) { |
| 3178 | 3663 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 3179 | - } else $alldata[$icao] = $value; |
|
| 3664 | + } else { |
|
| 3665 | + $alldata[$icao] = $value; |
|
| 3666 | + } |
|
| 3180 | 3667 | } |
| 3181 | 3668 | $count = array(); |
| 3182 | 3669 | foreach ($alldata as $key => $row) { |
@@ -3186,7 +3673,9 @@ discard block |
||
| 3186 | 3673 | foreach ($alldata as $number) { |
| 3187 | 3674 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
| 3188 | 3675 | } |
| 3189 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 3676 | + if ($globalDebug) { |
|
| 3677 | + echo 'Count all arrival airports...'."\n"; |
|
| 3678 | + } |
|
| 3190 | 3679 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
| 3191 | 3680 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
| 3192 | 3681 | $alldata = array(); |
@@ -3198,7 +3687,9 @@ discard block |
||
| 3198 | 3687 | $icao = $value['airport_arrival_icao']; |
| 3199 | 3688 | if (isset($alldata[$icao])) { |
| 3200 | 3689 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 3201 | - } else $alldata[$icao] = $value; |
|
| 3690 | + } else { |
|
| 3691 | + $alldata[$icao] = $value; |
|
| 3692 | + } |
|
| 3202 | 3693 | } |
| 3203 | 3694 | $count = array(); |
| 3204 | 3695 | foreach ($alldata as $key => $row) { |
@@ -3208,35 +3699,49 @@ discard block |
||
| 3208 | 3699 | foreach ($alldata as $number) { |
| 3209 | 3700 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
| 3210 | 3701 | } |
| 3211 | - if ($globalDebug) echo 'Count all months...'."\n"; |
|
| 3702 | + if ($globalDebug) { |
|
| 3703 | + echo 'Count all months...'."\n"; |
|
| 3704 | + } |
|
| 3212 | 3705 | $Spotter = new Spotter($this->db); |
| 3213 | 3706 | $alldata = $Spotter->countAllMonths($filter); |
| 3214 | 3707 | $lastyear = false; |
| 3215 | 3708 | foreach ($alldata as $number) { |
| 3216 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 3709 | + if ($number['year_name'] != date('Y')) { |
|
| 3710 | + $lastyear = true; |
|
| 3711 | + } |
|
| 3217 | 3712 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 3218 | 3713 | } |
| 3219 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 3714 | + if ($globalDebug) { |
|
| 3715 | + echo 'Count all owners by months...'."\n"; |
|
| 3716 | + } |
|
| 3220 | 3717 | $alldata = $Spotter->countAllMonthsOwners($filter); |
| 3221 | 3718 | foreach ($alldata as $number) { |
| 3222 | 3719 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 3223 | 3720 | } |
| 3224 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 3721 | + if ($globalDebug) { |
|
| 3722 | + echo 'Count all pilots by months...'."\n"; |
|
| 3723 | + } |
|
| 3225 | 3724 | $alldata = $Spotter->countAllMonthsPilots($filter); |
| 3226 | 3725 | foreach ($alldata as $number) { |
| 3227 | 3726 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 3228 | 3727 | } |
| 3229 | - if ($globalDebug) echo 'Count all military by months...'."\n"; |
|
| 3728 | + if ($globalDebug) { |
|
| 3729 | + echo 'Count all military by months...'."\n"; |
|
| 3730 | + } |
|
| 3230 | 3731 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
| 3231 | 3732 | foreach ($alldata as $number) { |
| 3232 | 3733 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 3233 | 3734 | } |
| 3234 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 3735 | + if ($globalDebug) { |
|
| 3736 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 3737 | + } |
|
| 3235 | 3738 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
| 3236 | 3739 | foreach ($alldata as $number) { |
| 3237 | 3740 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 3238 | 3741 | } |
| 3239 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 3742 | + if ($globalDebug) { |
|
| 3743 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 3744 | + } |
|
| 3240 | 3745 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
| 3241 | 3746 | foreach ($alldata as $number) { |
| 3242 | 3747 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |