@@ -48,27 +48,52 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | header('Content-Type: text/javascript'); |
| 50 | 50 | |
| 51 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 52 | -else $compress = $globalJsonCompress; |
|
| 51 | +if (!isset($globalJsonCompress)) { |
|
| 52 | + $compress = true; |
|
| 53 | +} else { |
|
| 54 | + $compress = $globalJsonCompress; |
|
| 55 | +} |
|
| 53 | 56 | |
| 54 | 57 | $from_archive = false; |
| 55 | 58 | $min = true; |
| 56 | 59 | $allhistory = false; |
| 57 | 60 | $filter['source'] = array(); |
| 58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs')); |
|
| 62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 61 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
| 62 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 63 | +} |
|
| 64 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
| 65 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 66 | +} |
|
| 67 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
| 68 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 69 | +} |
|
| 70 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
| 71 | + $filter['source'] = array_merge($filter['source'],array('sbs')); |
|
| 72 | +} |
|
| 73 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
| 74 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 75 | +} |
|
| 76 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
| 77 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 78 | +} |
|
| 79 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
| 80 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 81 | +} |
|
| 82 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
| 83 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 84 | +} |
|
| 85 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
| 86 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 87 | +} |
|
| 88 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
| 89 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 90 | +} |
|
| 68 | 91 | |
| 69 | 92 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 70 | 93 | $min = true; |
| 71 | -} else $min = false; |
|
| 94 | +} else { |
|
| 95 | + $min = false; |
|
| 96 | +} |
|
| 72 | 97 | |
| 73 | 98 | if (isset($_GET['ident'])) { |
| 74 | 99 | $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
@@ -157,21 +182,33 @@ discard block |
||
| 157 | 182 | } else { |
| 158 | 183 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
| 159 | 184 | } |
| 160 | - } else $flightcnt = count($spotter_array); |
|
| 161 | - if ($flightcnt == '') $flightcnt = 0; |
|
| 162 | -} else $flightcnt = 0; |
|
| 185 | + } else { |
|
| 186 | + $flightcnt = count($spotter_array); |
|
| 187 | + } |
|
| 188 | + if ($flightcnt == '') { |
|
| 189 | + $flightcnt = 0; |
|
| 190 | + } |
|
| 191 | + } else { |
|
| 192 | + $flightcnt = 0; |
|
| 193 | +} |
|
| 163 | 194 | |
| 164 | 195 | $sqltime = round(microtime(true)-$begintime,2); |
| 165 | 196 | |
| 166 | -if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
|
| 167 | -else $usenextlatlon = true; |
|
| 197 | +if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) { |
|
| 198 | + $usenextlatlon = false; |
|
| 199 | +} else { |
|
| 200 | + $usenextlatlon = true; |
|
| 201 | +} |
|
| 168 | 202 | $j = 0; |
| 169 | 203 | $prev_flightaware_id = ''; |
| 170 | 204 | $aircrafts_shadow = array(); |
| 171 | 205 | $output = '{'; |
| 172 | 206 | $output .= '"type": "FeatureCollection",'; |
| 173 | - if ($min) $output .= '"minimal": "true",'; |
|
| 174 | - else $output .= '"minimal": "false",'; |
|
| 207 | + if ($min) { |
|
| 208 | + $output .= '"minimal": "true",'; |
|
| 209 | + } else { |
|
| 210 | + $output .= '"minimal": "false",'; |
|
| 211 | + } |
|
| 175 | 212 | $output .= '"fc": "'.$flightcnt.'",'; |
| 176 | 213 | $output .= '"sqt": "'.$sqltime.'",'; |
| 177 | 214 | |
@@ -215,18 +252,29 @@ discard block |
||
| 215 | 252 | } |
| 216 | 253 | $output .= '"properties": {'; |
| 217 | 254 | if (isset($spotter_item['flightaware_id'])) { |
| 218 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
| 219 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
| 255 | + if ($compress) { |
|
| 256 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
| 257 | + } else { |
|
| 258 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
| 259 | + } |
|
| 220 | 260 | } elseif (isset($spotter_item['famtrackid'])) { |
| 221 | - if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
| 222 | - else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
| 261 | + if ($compress) { |
|
| 262 | + $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
| 263 | + } else { |
|
| 264 | + $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
| 265 | + } |
|
| 223 | 266 | } elseif (isset($spotter_item['fammarine_id'])) { |
| 224 | - if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
| 225 | - else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
| 267 | + if ($compress) { |
|
| 268 | + $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
| 269 | + } else { |
|
| 270 | + $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
| 271 | + } |
|
| 226 | 272 | } |
| 227 | 273 | $output .= '"fc": "'.$flightcnt.'",'; |
| 228 | 274 | $output .= '"sqt": "'.$sqltime.'",'; |
| 229 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 275 | + if (isset($begindate)) { |
|
| 276 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 277 | + } |
|
| 230 | 278 | |
| 231 | 279 | /* |
| 232 | 280 | if ($min) $output .= '"minimal": "true",'; |
@@ -234,13 +282,21 @@ discard block |
||
| 234 | 282 | */ |
| 235 | 283 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
| 236 | 284 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
| 237 | - if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",'; |
|
| 238 | - else $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
|
| 285 | + if ($compress) { |
|
| 286 | + $output .= '"c": "'.$spotter_item['ident'].'",'; |
|
| 287 | + } else { |
|
| 288 | + $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
|
| 289 | + } |
|
| 239 | 290 | } else { |
| 240 | - if ($compress) $output .= '"c": "NA",'; |
|
| 241 | - else $output .= '"callsign": "NA",'; |
|
| 291 | + if ($compress) { |
|
| 292 | + $output .= '"c": "NA",'; |
|
| 293 | + } else { |
|
| 294 | + $output .= '"callsign": "NA",'; |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + if (isset($spotter_item['registration'])) { |
|
| 298 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 242 | 299 | } |
| 243 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 244 | 300 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
| 245 | 301 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
| 246 | 302 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
@@ -253,15 +309,21 @@ discard block |
||
| 253 | 309 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
| 254 | 310 | } |
| 255 | 311 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker) { |
| 256 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
| 257 | - else { |
|
| 312 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
| 313 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 314 | + } else { |
|
| 258 | 315 | $aircraft_icao = $spotter_item['aircraft_icao']; |
| 259 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
| 260 | - else { |
|
| 316 | + if (isset($aircrafts_shadow[$aircraft_icao])) { |
|
| 317 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
| 318 | + } else { |
|
| 261 | 319 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
| 262 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 263 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
| 264 | - else $spotter_item['aircraft_shadow'] = ''; |
|
| 320 | + if (count($aircraft_info) > 0) { |
|
| 321 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 322 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
| 323 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
| 324 | + } else { |
|
| 325 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 326 | + } |
|
| 265 | 327 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
| 266 | 328 | } |
| 267 | 329 | } |
@@ -269,73 +331,139 @@ discard block |
||
| 269 | 331 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
| 270 | 332 | if ($tracker) { |
| 271 | 333 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
| 272 | - if ($compress) $output .= '"as": "ambulance.png",'; |
|
| 273 | - else $output .= '"aircraft_shadow": "ambulance.png",'; |
|
| 334 | + if ($compress) { |
|
| 335 | + $output .= '"as": "ambulance.png",'; |
|
| 336 | + } else { |
|
| 337 | + $output .= '"aircraft_shadow": "ambulance.png",'; |
|
| 338 | + } |
|
| 274 | 339 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
| 275 | - if ($compress) $output .= '"as": "police.png",'; |
|
| 276 | - else $output .= '"aircraft_shadow": "police.png",'; |
|
| 340 | + if ($compress) { |
|
| 341 | + $output .= '"as": "police.png",'; |
|
| 342 | + } else { |
|
| 343 | + $output .= '"aircraft_shadow": "police.png",'; |
|
| 344 | + } |
|
| 277 | 345 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
| 278 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 279 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 346 | + if ($compress) { |
|
| 347 | + $output .= '"as": "ship.png",'; |
|
| 348 | + } else { |
|
| 349 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 350 | + } |
|
| 280 | 351 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
| 281 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 282 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 352 | + if ($compress) { |
|
| 353 | + $output .= '"as": "ship.png",'; |
|
| 354 | + } else { |
|
| 355 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 356 | + } |
|
| 283 | 357 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
| 284 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 285 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 358 | + if ($compress) { |
|
| 359 | + $output .= '"as": "ship.png",'; |
|
| 360 | + } else { |
|
| 361 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 362 | + } |
|
| 286 | 363 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
| 287 | - if ($compress) $output .= '"as": "truck.png",'; |
|
| 288 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
| 364 | + if ($compress) { |
|
| 365 | + $output .= '"as": "truck.png",'; |
|
| 366 | + } else { |
|
| 367 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
| 368 | + } |
|
| 289 | 369 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
| 290 | - if ($compress) $output .= '"as": "truck.png",'; |
|
| 291 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
| 370 | + if ($compress) { |
|
| 371 | + $output .= '"as": "truck.png",'; |
|
| 372 | + } else { |
|
| 373 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
| 374 | + } |
|
| 292 | 375 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
| 293 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
| 294 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 376 | + if ($compress) { |
|
| 377 | + $output .= '"as": "aircraft.png",'; |
|
| 378 | + } else { |
|
| 379 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 380 | + } |
|
| 295 | 381 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
| 296 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
| 297 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 382 | + if ($compress) { |
|
| 383 | + $output .= '"as": "aircraft.png",'; |
|
| 384 | + } else { |
|
| 385 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 386 | + } |
|
| 298 | 387 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
| 299 | - if ($compress) $output .= '"as": "helico.png",'; |
|
| 300 | - else $output .= '"aircraft_shadow": "helico.png",'; |
|
| 388 | + if ($compress) { |
|
| 389 | + $output .= '"as": "helico.png",'; |
|
| 390 | + } else { |
|
| 391 | + $output .= '"aircraft_shadow": "helico.png",'; |
|
| 392 | + } |
|
| 301 | 393 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
| 302 | - if ($compress) $output .= '"as": "rail.png",'; |
|
| 303 | - else $output .= '"aircraft_shadow": "rail.png",'; |
|
| 394 | + if ($compress) { |
|
| 395 | + $output .= '"as": "rail.png",'; |
|
| 396 | + } else { |
|
| 397 | + $output .= '"aircraft_shadow": "rail.png",'; |
|
| 398 | + } |
|
| 304 | 399 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
| 305 | - if ($compress) $output .= '"as": "firetruck.png",'; |
|
| 306 | - else $output .= '"aircraft_shadow": "firetruck.png",'; |
|
| 400 | + if ($compress) { |
|
| 401 | + $output .= '"as": "firetruck.png",'; |
|
| 402 | + } else { |
|
| 403 | + $output .= '"aircraft_shadow": "firetruck.png",'; |
|
| 404 | + } |
|
| 307 | 405 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
| 308 | - if ($compress) $output .= '"as": "bus.png",'; |
|
| 309 | - else $output .= '"aircraft_shadow": "bus.png",'; |
|
| 406 | + if ($compress) { |
|
| 407 | + $output .= '"as": "bus.png",'; |
|
| 408 | + } else { |
|
| 409 | + $output .= '"aircraft_shadow": "bus.png",'; |
|
| 410 | + } |
|
| 310 | 411 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
| 311 | - if ($compress) $output .= '"as": "phone.png",'; |
|
| 312 | - else $output .= '"aircraft_shadow": "phone.png",'; |
|
| 412 | + if ($compress) { |
|
| 413 | + $output .= '"as": "phone.png",'; |
|
| 414 | + } else { |
|
| 415 | + $output .= '"aircraft_shadow": "phone.png",'; |
|
| 416 | + } |
|
| 313 | 417 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
| 314 | - if ($compress) $output .= '"as": "jogger.png",'; |
|
| 315 | - else $output .= '"aircraft_shadow": "jogger.png",'; |
|
| 418 | + if ($compress) { |
|
| 419 | + $output .= '"as": "jogger.png",'; |
|
| 420 | + } else { |
|
| 421 | + $output .= '"aircraft_shadow": "jogger.png",'; |
|
| 422 | + } |
|
| 316 | 423 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
| 317 | - if ($compress) $output .= '"as": "bike.png",'; |
|
| 318 | - else $output .= '"aircraft_shadow": "bike.png",'; |
|
| 424 | + if ($compress) { |
|
| 425 | + $output .= '"as": "bike.png",'; |
|
| 426 | + } else { |
|
| 427 | + $output .= '"aircraft_shadow": "bike.png",'; |
|
| 428 | + } |
|
| 319 | 429 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
| 320 | - if ($compress) $output .= '"as": "motorcycle.png",'; |
|
| 321 | - else $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
| 430 | + if ($compress) { |
|
| 431 | + $output .= '"as": "motorcycle.png",'; |
|
| 432 | + } else { |
|
| 433 | + $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
| 434 | + } |
|
| 322 | 435 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
| 323 | - if ($compress) $output .= '"as": "balloon.png",'; |
|
| 324 | - else $output .= '"aircraft_shadow": "balloon.png",'; |
|
| 436 | + if ($compress) { |
|
| 437 | + $output .= '"as": "balloon.png",'; |
|
| 438 | + } else { |
|
| 439 | + $output .= '"aircraft_shadow": "balloon.png",'; |
|
| 440 | + } |
|
| 325 | 441 | } else { |
| 326 | - if ($compress) $output .= '"as": "car.png",'; |
|
| 327 | - else $output .= '"aircraft_shadow": "car.png",'; |
|
| 442 | + if ($compress) { |
|
| 443 | + $output .= '"as": "car.png",'; |
|
| 444 | + } else { |
|
| 445 | + $output .= '"aircraft_shadow": "car.png",'; |
|
| 446 | + } |
|
| 328 | 447 | } |
| 329 | 448 | } elseif ($marine) { |
| 330 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 331 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 449 | + if ($compress) { |
|
| 450 | + $output .= '"as": "ship.png",'; |
|
| 451 | + } else { |
|
| 452 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 453 | + } |
|
| 332 | 454 | } else { |
| 333 | - if ($compress) $output .= '"as": "default.png",'; |
|
| 334 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
| 455 | + if ($compress) { |
|
| 456 | + $output .= '"as": "default.png",'; |
|
| 457 | + } else { |
|
| 458 | + $output .= '"aircraft_shadow": "default.png",'; |
|
| 459 | + } |
|
| 335 | 460 | } |
| 336 | 461 | } else { |
| 337 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 338 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 462 | + if ($compress) { |
|
| 463 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 464 | + } else { |
|
| 465 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 466 | + } |
|
| 339 | 467 | } |
| 340 | 468 | if (isset($spotter_item['airline_name'])) { |
| 341 | 469 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -343,8 +471,11 @@ discard block |
||
| 343 | 471 | $output .= '"airline_name": "NA",'; |
| 344 | 472 | } |
| 345 | 473 | if (isset($spotter_item['departure_airport'])) { |
| 346 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 347 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 474 | + if ($compress) { |
|
| 475 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 476 | + } else { |
|
| 477 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 478 | + } |
|
| 348 | 479 | } |
| 349 | 480 | if (isset($spotter_item['departure_airport_city'])) { |
| 350 | 481 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -356,8 +487,11 @@ discard block |
||
| 356 | 487 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
| 357 | 488 | } |
| 358 | 489 | if (isset($spotter_item['arrival_airport'])) { |
| 359 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 360 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 490 | + if ($compress) { |
|
| 491 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 492 | + } else { |
|
| 493 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 494 | + } |
|
| 361 | 495 | } |
| 362 | 496 | if (isset($spotter_item['arrival_airport_city'])) { |
| 363 | 497 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -376,11 +510,17 @@ discard block |
||
| 376 | 510 | } |
| 377 | 511 | |
| 378 | 512 | if (isset($spotter_item['altitude'])) { |
| 379 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 380 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 513 | + if ($compress) { |
|
| 514 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 515 | + } else { |
|
| 516 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 517 | + } |
|
| 518 | + } |
|
| 519 | + if ($compress) { |
|
| 520 | + $output .= '"h": "'.$spotter_item['heading'].'",'; |
|
| 521 | + } else { |
|
| 522 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 381 | 523 | } |
| 382 | - if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",'; |
|
| 383 | - else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 384 | 524 | |
| 385 | 525 | if (isset($archivespeed)) { |
| 386 | 526 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
@@ -390,7 +530,9 @@ discard block |
||
| 390 | 530 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 391 | 531 | } |
| 392 | 532 | |
| 393 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
| 533 | + if (!$min) { |
|
| 534 | + $output .= '"image": "'.$image.'",'; |
|
| 535 | + } |
|
| 394 | 536 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
| 395 | 537 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
| 396 | 538 | } |
@@ -398,8 +540,11 @@ discard block |
||
| 398 | 540 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
| 399 | 541 | } |
| 400 | 542 | if (isset($spotter_item['squawk'])) { |
| 401 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 402 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 543 | + if ($compress) { |
|
| 544 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 545 | + } else { |
|
| 546 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 547 | + } |
|
| 403 | 548 | } |
| 404 | 549 | if (isset($spotter_item['squawk_usage'])) { |
| 405 | 550 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -418,14 +563,23 @@ discard block |
||
| 418 | 563 | } |
| 419 | 564 | // type when not aircraft ? |
| 420 | 565 | if (isset($spotter_item['type'])) { |
| 421 | - if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
|
| 422 | - else $output .= '"type": "'.$spotter_item['type'].'"'; |
|
| 566 | + if ($compress) { |
|
| 567 | + $output .= '"t": "'.$spotter_item['type'].'"'; |
|
| 568 | + } else { |
|
| 569 | + $output .= '"type": "'.$spotter_item['type'].'"'; |
|
| 570 | + } |
|
| 423 | 571 | } elseif ($marine) { |
| 424 | - if ($compress) $output .= '"t": "ship"'; |
|
| 425 | - else $output .= '"type": "ship"'; |
|
| 572 | + if ($compress) { |
|
| 573 | + $output .= '"t": "ship"'; |
|
| 574 | + } else { |
|
| 575 | + $output .= '"type": "ship"'; |
|
| 576 | + } |
|
| 426 | 577 | } else { |
| 427 | - if ($compress) $output .= '"t": "aircraft"'; |
|
| 428 | - else $output .= '"type": "aircraft"'; |
|
| 578 | + if ($compress) { |
|
| 579 | + $output .= '"t": "aircraft"'; |
|
| 580 | + } else { |
|
| 581 | + $output .= '"type": "aircraft"'; |
|
| 582 | + } |
|
| 429 | 583 | } |
| 430 | 584 | $output .= '},'; |
| 431 | 585 | $output .= '"geometry": {'; |
@@ -493,7 +647,9 @@ discard block |
||
| 493 | 647 | } |
| 494 | 648 | */ |
| 495 | 649 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
| 496 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
| 650 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
| 651 | + $history = $_COOKIE['history']; |
|
| 652 | + } |
|
| 497 | 653 | |
| 498 | 654 | if ( |
| 499 | 655 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
@@ -525,8 +681,11 @@ discard block |
||
| 525 | 681 | $output_history .= ']}},'; |
| 526 | 682 | $output .= $output_history; |
| 527 | 683 | } |
| 528 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 529 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 684 | + if ($compress) { |
|
| 685 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 686 | + } else { |
|
| 687 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 688 | + } |
|
| 530 | 689 | } |
| 531 | 690 | $output_history .= '['; |
| 532 | 691 | $output_history .= $spotter_history['longitude'].', '; |
@@ -536,9 +695,14 @@ discard block |
||
| 536 | 695 | $prev_alt = $alt; |
| 537 | 696 | } else { |
| 538 | 697 | if ($d == false) { |
| 539 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 540 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 541 | - } else $d = true; |
|
| 698 | + if ($compress) { |
|
| 699 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 700 | + } else { |
|
| 701 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 702 | + } |
|
| 703 | + } else { |
|
| 704 | + $d = true; |
|
| 705 | + } |
|
| 542 | 706 | $output_history .= '['; |
| 543 | 707 | $output_history .= $spotter_history['longitude'].', '; |
| 544 | 708 | $output_history .= $spotter_history['latitude']; |
@@ -581,7 +745,9 @@ discard block |
||
| 581 | 745 | $output .= ']'; |
| 582 | 746 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
| 583 | 747 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
| 584 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 748 | + if (isset($begindate)) { |
|
| 749 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 750 | + } |
|
| 585 | 751 | $output .= '"fc": "'.$j.'"'; |
| 586 | 752 | } else { |
| 587 | 753 | $output .= '"features": '; |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | 30 | $filters = array_merge($filters,$filter); |
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 33 | 35 | $filter_query_join = ''; |
| 34 | 36 | $filter_query_where = ''; |
| 35 | 37 | foreach($filters as $flt) { |
@@ -118,8 +120,11 @@ discard block |
||
| 118 | 120 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 119 | 121 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 120 | 122 | } |
| 121 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 122 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 123 | + if ($filter_query_where == '' && $where) { |
|
| 124 | + $filter_query_where = ' WHERE'; |
|
| 125 | + } elseif ($filter_query_where != '' && $and) { |
|
| 126 | + $filter_query_where .= ' AND'; |
|
| 127 | + } |
|
| 123 | 128 | if ($filter_query_where != '') { |
| 124 | 129 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 125 | 130 | } |
@@ -161,7 +166,9 @@ discard block |
||
| 161 | 166 | } |
| 162 | 167 | } |
| 163 | 168 | |
| 164 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 169 | + if (!isset($globalLiveInterval)) { |
|
| 170 | + $globalLiveInterval = '200'; |
|
| 171 | + } |
|
| 165 | 172 | if ($globalDBdriver == 'mysql') { |
| 166 | 173 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
| 167 | 174 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -186,7 +193,9 @@ discard block |
||
| 186 | 193 | |
| 187 | 194 | $filter_query = $this->getFilter($filter,true,true); |
| 188 | 195 | |
| 189 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 196 | + if (!isset($globalLiveInterval)) { |
|
| 197 | + $globalLiveInterval = '200'; |
|
| 198 | + } |
|
| 190 | 199 | if ($globalDBdriver == 'mysql') { |
| 191 | 200 | // $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query"; |
| 192 | 201 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao'; |
@@ -243,7 +252,9 @@ discard block |
||
| 243 | 252 | |
| 244 | 253 | $filter_query = $this->getFilter($filter,true,true); |
| 245 | 254 | |
| 246 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 255 | + if (!isset($globalLiveInterval)) { |
|
| 256 | + $globalLiveInterval = '200'; |
|
| 257 | + } |
|
| 247 | 258 | if ($globalDBdriver == 'mysql') { |
| 248 | 259 | /* |
| 249 | 260 | $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -287,7 +298,9 @@ discard block |
||
| 287 | 298 | global $globalDBdriver, $globalLiveInterval; |
| 288 | 299 | $filter_query = $this->getFilter($filter,true,true); |
| 289 | 300 | |
| 290 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 301 | + if (!isset($globalLiveInterval)) { |
|
| 302 | + $globalLiveInterval = '200'; |
|
| 303 | + } |
|
| 291 | 304 | if ($globalDBdriver == 'mysql') { |
| 292 | 305 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
| 293 | 306 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -317,7 +330,9 @@ discard block |
||
| 317 | 330 | { |
| 318 | 331 | global $globalDBdriver, $globalLiveInterval; |
| 319 | 332 | $Spotter = new Spotter($this->db); |
| 320 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 333 | + if (!isset($globalLiveInterval)) { |
|
| 334 | + $globalLiveInterval = '200'; |
|
| 335 | + } |
|
| 321 | 336 | $filter_query = $this->getFilter($filter); |
| 322 | 337 | |
| 323 | 338 | if (is_array($coord)) { |
@@ -325,7 +340,9 @@ discard block |
||
| 325 | 340 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 326 | 341 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 327 | 342 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 328 | - } else return array(); |
|
| 343 | + } else { |
|
| 344 | + return array(); |
|
| 345 | + } |
|
| 329 | 346 | if ($globalDBdriver == 'mysql') { |
| 330 | 347 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
| 331 | 348 | } else { |
@@ -346,7 +363,9 @@ discard block |
||
| 346 | 363 | { |
| 347 | 364 | global $globalDBdriver, $globalLiveInterval; |
| 348 | 365 | $Spotter = new Spotter($this->db); |
| 349 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 366 | + if (!isset($globalLiveInterval)) { |
|
| 367 | + $globalLiveInterval = '200'; |
|
| 368 | + } |
|
| 350 | 369 | $filter_query = $this->getFilter($filter,true,true); |
| 351 | 370 | |
| 352 | 371 | if (is_array($coord)) { |
@@ -354,7 +373,9 @@ discard block |
||
| 354 | 373 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 355 | 374 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 356 | 375 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 357 | - } else return array(); |
|
| 376 | + } else { |
|
| 377 | + return array(); |
|
| 378 | + } |
|
| 358 | 379 | if ($globalDBdriver == 'mysql') { |
| 359 | 380 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 360 | 381 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.' spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.''; |
@@ -561,11 +582,15 @@ discard block |
||
| 561 | 582 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 562 | 583 | if ($globalDBdriver == 'mysql') { |
| 563 | 584 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 564 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 585 | + if ($liveinterval) { |
|
| 586 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 587 | + } |
|
| 565 | 588 | $query .= ' ORDER BY date'; |
| 566 | 589 | } else { |
| 567 | 590 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 568 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 591 | + if ($liveinterval) { |
|
| 592 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 593 | + } |
|
| 569 | 594 | $query .= ' ORDER BY date'; |
| 570 | 595 | } |
| 571 | 596 | |
@@ -660,7 +685,9 @@ discard block |
||
| 660 | 685 | $i++; |
| 661 | 686 | $j++; |
| 662 | 687 | if ($j == 30) { |
| 663 | - if ($globalDebug) echo "."; |
|
| 688 | + if ($globalDebug) { |
|
| 689 | + echo "."; |
|
| 690 | + } |
|
| 664 | 691 | try { |
| 665 | 692 | |
| 666 | 693 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -967,7 +994,9 @@ discard block |
||
| 967 | 994 | { |
| 968 | 995 | return false; |
| 969 | 996 | } |
| 970 | - } else return ''; |
|
| 997 | + } else { |
|
| 998 | + return ''; |
|
| 999 | + } |
|
| 971 | 1000 | |
| 972 | 1001 | if ($longitude != '') |
| 973 | 1002 | { |
@@ -975,7 +1004,9 @@ discard block |
||
| 975 | 1004 | { |
| 976 | 1005 | return false; |
| 977 | 1006 | } |
| 978 | - } else return ''; |
|
| 1007 | + } else { |
|
| 1008 | + return ''; |
|
| 1009 | + } |
|
| 979 | 1010 | |
| 980 | 1011 | if ($waypoints != '') |
| 981 | 1012 | { |
@@ -991,7 +1022,9 @@ discard block |
||
| 991 | 1022 | { |
| 992 | 1023 | return false; |
| 993 | 1024 | } |
| 994 | - } else $altitude = 0; |
|
| 1025 | + } else { |
|
| 1026 | + $altitude = 0; |
|
| 1027 | + } |
|
| 995 | 1028 | |
| 996 | 1029 | if ($heading != '') |
| 997 | 1030 | { |
@@ -999,7 +1032,9 @@ discard block |
||
| 999 | 1032 | { |
| 1000 | 1033 | return false; |
| 1001 | 1034 | } |
| 1002 | - } else $heading = 0; |
|
| 1035 | + } else { |
|
| 1036 | + $heading = 0; |
|
| 1037 | + } |
|
| 1003 | 1038 | |
| 1004 | 1039 | if ($groundspeed != '') |
| 1005 | 1040 | { |
@@ -1007,9 +1042,13 @@ discard block |
||
| 1007 | 1042 | { |
| 1008 | 1043 | return false; |
| 1009 | 1044 | } |
| 1010 | - } else $groundspeed = 0; |
|
| 1045 | + } else { |
|
| 1046 | + $groundspeed = 0; |
|
| 1047 | + } |
|
| 1011 | 1048 | date_default_timezone_set('UTC'); |
| 1012 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1049 | + if ($date == '') { |
|
| 1050 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1051 | + } |
|
| 1013 | 1052 | |
| 1014 | 1053 | |
| 1015 | 1054 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1053,10 +1092,18 @@ discard block |
||
| 1053 | 1092 | $arrival_airport_country = ''; |
| 1054 | 1093 | |
| 1055 | 1094 | |
| 1056 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1057 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1058 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1059 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1095 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1096 | + $squawk = NULL; |
|
| 1097 | + } |
|
| 1098 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1099 | + $verticalrate = NULL; |
|
| 1100 | + } |
|
| 1101 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1102 | + $groundspeed = 0; |
|
| 1103 | + } |
|
| 1104 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1105 | + $heading = 0; |
|
| 1106 | + } |
|
| 1060 | 1107 | |
| 1061 | 1108 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
| 1062 | 1109 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -1070,10 +1117,14 @@ discard block |
||
| 1070 | 1117 | return "error : ".$e->getMessage(); |
| 1071 | 1118 | } |
| 1072 | 1119 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1073 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1120 | + if ($globalDebug) { |
|
| 1121 | + echo '(Add to SBS archive : '; |
|
| 1122 | + } |
|
| 1074 | 1123 | $SpotterArchive = new SpotterArchive($this->db); |
| 1075 | 1124 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
| 1076 | - if ($globalDebug) echo $result.')'; |
|
| 1125 | + if ($globalDebug) { |
|
| 1126 | + echo $result.')'; |
|
| 1127 | + } |
|
| 1077 | 1128 | } |
| 1078 | 1129 | return "success"; |
| 1079 | 1130 | |