@@ -57,7 +57,9 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function envelope() { |
| 60 | - if ($this->isEmpty()) return new Polygon(); |
|
| 60 | + if ($this->isEmpty()) { |
|
| 61 | + return new Polygon(); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | if ($this->geos()) { |
| 63 | 65 | return geoPHP::geosToGeometry($this->geos()->envelope()); |
@@ -148,8 +150,7 @@ discard block |
||
| 148 | 150 | if (geoPHP::geosInstalled()) { |
| 149 | 151 | $reader = new GEOSWKBReader(); |
| 150 | 152 | $this->geos = $reader->readHEX($this->out('wkb',TRUE)); |
| 151 | - } |
|
| 152 | - else { |
|
| 153 | + } else { |
|
| 153 | 154 | $this->geos = FALSE; |
| 154 | 155 | } |
| 155 | 156 | return $this->geos; |
@@ -175,8 +176,7 @@ discard block |
||
| 175 | 176 | if ($this->geos()) { |
| 176 | 177 | if ($pattern) { |
| 177 | 178 | return $this->geos()->relate($geometry->geos(), $pattern); |
| 178 | - } |
|
| 179 | - else { |
|
| 179 | + } else { |
|
| 180 | 180 | return $this->geos()->relate($geometry->geos()); |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -227,8 +227,7 @@ discard block |
||
| 227 | 227 | $geom = $geom->union($item->geos()); |
| 228 | 228 | } |
| 229 | 229 | return geoPHP::geosToGeometry($geom); |
| 230 | - } |
|
| 231 | - else { |
|
| 230 | + } else { |
|
| 232 | 231 | return geoPHP::geosToGeometry($this->geos()->union($geometry->geos())); |
| 233 | 232 | } |
| 234 | 233 | } |
@@ -52,7 +52,9 @@ discard block |
||
| 52 | 52 | if (!$type) {
|
| 53 | 53 | // If the user is trying to load a Geometry from a Geometry... Just pass it back |
| 54 | 54 | if (is_object($data)) {
|
| 55 | - if ($data instanceOf Geometry) return $data; |
|
| 55 | + if ($data instanceOf Geometry) { |
|
| 56 | + return $data; |
|
| 57 | + } |
|
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | $detected = geoPHP::detectFormat($data); |
@@ -120,7 +122,9 @@ discard block |
||
| 120 | 122 | |
| 121 | 123 | static function geosInstalled($force = NULL) {
|
| 122 | 124 | static $geos_installed = NULL; |
| 123 | - if ($force !== NULL) $geos_installed = $force; |
|
| 125 | + if ($force !== NULL) { |
|
| 126 | + $geos_installed = $force; |
|
| 127 | + } |
|
| 124 | 128 | if ($geos_installed !== NULL) {
|
| 125 | 129 | return $geos_installed; |
| 126 | 130 | } |
@@ -148,8 +152,12 @@ discard block |
||
| 148 | 152 | static function geometryReduce($geometry) {
|
| 149 | 153 | // If it's an array of one, then just parse the one |
| 150 | 154 | if (is_array($geometry)) {
|
| 151 | - if (empty($geometry)) return FALSE; |
|
| 152 | - if (count($geometry) == 1) return geoPHP::geometryReduce(array_shift($geometry)); |
|
| 155 | + if (empty($geometry)) { |
|
| 156 | + return FALSE; |
|
| 157 | + } |
|
| 158 | + if (count($geometry) == 1) { |
|
| 159 | + return geoPHP::geometryReduce(array_shift($geometry)); |
|
| 160 | + } |
|
| 153 | 161 | } |
| 154 | 162 | |
| 155 | 163 | // If the geometry cannot even theoretically be reduced more, then pass it back |
@@ -168,8 +176,7 @@ discard block |
||
| 168 | 176 | $components = $geometry->getComponents(); |
| 169 | 177 | if (count($components) == 1) {
|
| 170 | 178 | return $components[0]; |
| 171 | - } |
|
| 172 | - else {
|
|
| 179 | + } else {
|
|
| 173 | 180 | return $geometry; |
| 174 | 181 | } |
| 175 | 182 | } |
@@ -192,8 +199,7 @@ discard block |
||
| 192 | 199 | $geometries[] = $component; |
| 193 | 200 | $geom_types[] = $component->geometryType(); |
| 194 | 201 | } |
| 195 | - } |
|
| 196 | - else {
|
|
| 202 | + } else {
|
|
| 197 | 203 | $geometries[] = $item; |
| 198 | 204 | $geom_types[] = $item->geometryType(); |
| 199 | 205 | } |
@@ -209,13 +215,11 @@ discard block |
||
| 209 | 215 | if (count($geom_types) == 1) {
|
| 210 | 216 | if (count($geometries) == 1) {
|
| 211 | 217 | return $geometries[0]; |
| 212 | - } |
|
| 213 | - else {
|
|
| 218 | + } else {
|
|
| 214 | 219 | $class = 'Multi'.$geom_types[0]; |
| 215 | 220 | return new $class($geometries); |
| 216 | 221 | } |
| 217 | - } |
|
| 218 | - else {
|
|
| 222 | + } else {
|
|
| 219 | 223 | return new GeometryCollection($geometries); |
| 220 | 224 | } |
| 221 | 225 | } |
@@ -230,7 +234,9 @@ discard block |
||
| 230 | 234 | $bytes = unpack("c*", fread($mem, 11));
|
| 231 | 235 | |
| 232 | 236 | // If bytes is empty, then we were passed empty input |
| 233 | - if (empty($bytes)) return FALSE; |
|
| 237 | + if (empty($bytes)) { |
|
| 238 | + return FALSE; |
|
| 239 | + } |
|
| 234 | 240 | |
| 235 | 241 | // First char is a tab, space or carriage-return. trim it and try again |
| 236 | 242 | if ($bytes[1] == 9 || $bytes[1] == 10 || $bytes[1] == 32) {
|
@@ -240,8 +246,11 @@ discard block |
||
| 240 | 246 | // Detect WKB or EWKB -- first byte is 1 (little endian indicator) |
| 241 | 247 | if ($bytes[1] == 1) {
|
| 242 | 248 | // If SRID byte is TRUE (1), it's EWKB |
| 243 | - if ($bytes[5]) return 'ewkb'; |
|
| 244 | - else return 'wkb'; |
|
| 249 | + if ($bytes[5]) { |
|
| 250 | + return 'ewkb'; |
|
| 251 | + } else { |
|
| 252 | + return 'wkb'; |
|
| 253 | + } |
|
| 245 | 254 | } |
| 246 | 255 | |
| 247 | 256 | // Detect HEX encoded WKB or EWKB (PostGIS format) -- first byte is 48, second byte is 49 (hex '01' => first-byte = 1) |
@@ -274,12 +283,24 @@ discard block |
||
| 274 | 283 | if ($bytes[1] == 60) {
|
| 275 | 284 | // grab the first 256 characters |
| 276 | 285 | $string = substr($input, 0, 256); |
| 277 | - if (strpos($string, '<kml') !== FALSE) return 'kml'; |
|
| 278 | - if (strpos($string, '<coordinate') !== FALSE) return 'kml'; |
|
| 279 | - if (strpos($string, '<gpx') !== FALSE) return 'gpx'; |
|
| 280 | - if (strpos($string, '<georss') !== FALSE) return 'georss'; |
|
| 281 | - if (strpos($string, '<rss') !== FALSE) return 'georss'; |
|
| 282 | - if (strpos($string, '<feed') !== FALSE) return 'georss'; |
|
| 286 | + if (strpos($string, '<kml') !== FALSE) { |
|
| 287 | + return 'kml'; |
|
| 288 | + } |
|
| 289 | + if (strpos($string, '<coordinate') !== FALSE) { |
|
| 290 | + return 'kml'; |
|
| 291 | + } |
|
| 292 | + if (strpos($string, '<gpx') !== FALSE) { |
|
| 293 | + return 'gpx'; |
|
| 294 | + } |
|
| 295 | + if (strpos($string, '<georss') !== FALSE) { |
|
| 296 | + return 'georss'; |
|
| 297 | + } |
|
| 298 | + if (strpos($string, '<rss') !== FALSE) { |
|
| 299 | + return 'georss'; |
|
| 300 | + } |
|
| 301 | + if (strpos($string, '<feed') !== FALSE) { |
|
| 302 | + return 'georss'; |
|
| 303 | + } |
|
| 283 | 304 | } |
| 284 | 305 | |
| 285 | 306 | // We need an 8 byte string for geohash and unpacked WKB / WKT |
@@ -22,7 +22,9 @@ discard block |
||
| 22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
| 23 | 23 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
| 24 | 24 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
| 25 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
| 25 | + if ($registration == '' && $aircraft_icao != '') { |
|
| 26 | + $registration = $aircraft_icao.$airline_icao; |
|
| 27 | + } |
|
| 26 | 28 | |
| 27 | 29 | $registration = trim($registration); |
| 28 | 30 | |
@@ -64,8 +66,11 @@ discard block |
||
| 64 | 66 | public function getExifCopyright($url) { |
| 65 | 67 | $exif = exif_read_data($url); |
| 66 | 68 | $copyright = ''; |
| 67 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
| 68 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
| 69 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
| 70 | + $copyright = $exif['COMPUTED']['copyright']; |
|
| 71 | + } elseif (isset($exif['copyright'])) { |
|
| 72 | + $copyright = $exif['copyright']; |
|
| 73 | + } |
|
| 69 | 74 | if ($copyright != '') { |
| 70 | 75 | $copyright = str_replace('Copyright ','',$copyright); |
| 71 | 76 | $copyright = str_replace('© ','',$copyright); |
@@ -83,12 +88,16 @@ discard block |
||
| 83 | 88 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 84 | 89 | { |
| 85 | 90 | global $globalAircraftImageFetch; |
| 86 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
| 91 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
| 92 | + return ''; |
|
| 93 | + } |
|
| 87 | 94 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
| 88 | 95 | $registration = trim($registration); |
| 89 | 96 | //getting the aircraft image |
| 90 | 97 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
| 91 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
| 98 | + if ($registration == '' && $aircraft_icao != '') { |
|
| 99 | + $registration = $aircraft_icao.$airline_icao; |
|
| 100 | + } |
|
| 92 | 101 | if ($image_url['original'] != '') { |
| 93 | 102 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
| 94 | 103 | try { |
@@ -115,39 +124,78 @@ discard block |
||
| 115 | 124 | { |
| 116 | 125 | global $globalAircraftImageSources, $globalIVAO; |
| 117 | 126 | $Spotter = new Spotter($this->db); |
| 118 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
| 127 | + if (!isset($globalIVAO)) { |
|
| 128 | + $globalIVAO = FALSE; |
|
| 129 | + } |
|
| 119 | 130 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
| 120 | 131 | |
| 121 | 132 | if ($aircraft_registration != '') { |
| 122 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 133 | + if (strpos($aircraft_registration,'/') !== false) { |
|
| 134 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 135 | + } |
|
| 123 | 136 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 124 | 137 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 125 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 126 | - else $aircraft_name = ''; |
|
| 127 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 128 | - else $aircraft_icao = ''; |
|
| 129 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 130 | - else $airline_icao = ''; |
|
| 138 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
| 139 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 140 | + } else { |
|
| 141 | + $aircraft_name = ''; |
|
| 142 | + } |
|
| 143 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
| 144 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 145 | + } else { |
|
| 146 | + $aircraft_icao = ''; |
|
| 147 | + } |
|
| 148 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
| 149 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 150 | + } else { |
|
| 151 | + $airline_icao = ''; |
|
| 152 | + } |
|
| 131 | 153 | } elseif ($aircraft_icao != '') { |
| 132 | 154 | $aircraft_registration = $aircraft_icao; |
| 133 | 155 | $aircraft_name = ''; |
| 134 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 156 | + } else { |
|
| 157 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 158 | + } |
|
| 135 | 159 | |
| 136 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 160 | + if (!isset($globalAircraftImageSources)) { |
|
| 161 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 162 | + } |
|
| 137 | 163 | |
| 138 | 164 | foreach ($globalAircraftImageSources as $source) { |
| 139 | 165 | $source = strtolower($source); |
| 140 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
| 141 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
| 142 | - if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
| 143 | - if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
| 144 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
| 145 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
| 146 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
| 147 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
| 148 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
| 149 | - if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
| 150 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 166 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
| 167 | + $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
| 168 | + } |
|
| 169 | + if ($source == 'planespotters' && !$globalIVAO) { |
|
| 170 | + $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
| 171 | + } |
|
| 172 | + if ($source == 'flickr') { |
|
| 173 | + $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
| 174 | + } |
|
| 175 | + if ($source == 'bing') { |
|
| 176 | + $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
| 177 | + } |
|
| 178 | + if ($source == 'deviantart') { |
|
| 179 | + $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
| 180 | + } |
|
| 181 | + if ($source == 'wikimedia') { |
|
| 182 | + $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
| 183 | + } |
|
| 184 | + if ($source == 'jetphotos' && !$globalIVAO) { |
|
| 185 | + $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
| 186 | + } |
|
| 187 | + if ($source == 'planepictures' && !$globalIVAO) { |
|
| 188 | + $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
| 189 | + } |
|
| 190 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
| 191 | + $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
| 192 | + } |
|
| 193 | + if ($source == 'customsources') { |
|
| 194 | + $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
| 195 | + } |
|
| 196 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 197 | + return $images_array; |
|
| 198 | + } |
|
| 151 | 199 | } |
| 152 | 200 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 153 | 201 | } |
@@ -306,8 +354,11 @@ discard block |
||
| 306 | 354 | public function fromFlickr($aircraft_registration,$aircraft_name='') { |
| 307 | 355 | $Common = new Common(); |
| 308 | 356 | |
| 309 | - if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
|
| 310 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft'; |
|
| 357 | + if ($aircraft_name != '') { |
|
| 358 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
|
| 359 | + } else { |
|
| 360 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft'; |
|
| 361 | + } |
|
| 311 | 362 | |
| 312 | 363 | $data = $Common->getData($url); |
| 313 | 364 | |
@@ -355,9 +406,14 @@ discard block |
||
| 355 | 406 | public function fromBing($aircraft_registration,$aircraft_name='') { |
| 356 | 407 | global $globalImageBingKey; |
| 357 | 408 | $Common = new Common(); |
| 358 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
| 359 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 360 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 409 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
| 410 | + return false; |
|
| 411 | + } |
|
| 412 | + if ($aircraft_name != '') { |
|
| 413 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 414 | + } else { |
|
| 415 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 416 | + } |
|
| 361 | 417 | |
| 362 | 418 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
| 363 | 419 | |
@@ -414,14 +470,19 @@ discard block |
||
| 414 | 470 | */ |
| 415 | 471 | public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
| 416 | 472 | $Common = new Common(); |
| 417 | - if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
|
| 418 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
| 473 | + if ($aircraft_name != '') { |
|
| 474 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
|
| 475 | + } else { |
|
| 476 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
| 477 | + } |
|
| 419 | 478 | |
| 420 | 479 | $data = $Common->getData($url); |
| 421 | 480 | $result = json_decode($data); |
| 422 | 481 | if (isset($result->query->search[0]->title)) { |
| 423 | 482 | $fileo = $result->query->search[0]->title; |
| 424 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 483 | + if (substr($fileo,-3) == 'pdf') { |
|
| 484 | + return false; |
|
| 485 | + } |
|
| 425 | 486 | $file = urlencode($fileo); |
| 426 | 487 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
| 427 | 488 | |
@@ -476,7 +537,9 @@ discard block |
||
| 476 | 537 | global $globalAircraftCustomSources; |
| 477 | 538 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
| 478 | 539 | if (!empty($globalAircraftImageCustomSources)) { |
| 479 | - if (!isset($globalAircraftImageCustomSources[0])) $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources; |
|
| 540 | + if (!isset($globalAircraftImageCustomSources[0])) { |
|
| 541 | + $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources; |
|
| 542 | + } |
|
| 480 | 543 | foreach ($globalAircraftImageCustomSources as $source) { |
| 481 | 544 | $Common = new Common(); |
| 482 | 545 | $url = str_replace('{registration}',$aircraft_registration,$source['original']); |
@@ -484,17 +547,25 @@ discard block |
||
| 484 | 547 | if ($Common->urlexist($url)) { |
| 485 | 548 | $image_url['thumbnail'] = $url_thumbnail; |
| 486 | 549 | $image_url['original'] = $url; |
| 487 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 488 | - else $exifCopyright = ''; |
|
| 489 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 490 | - else $image_url['copyright'] = $source['copyright']; |
|
| 550 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 551 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 552 | + } else { |
|
| 553 | + $exifCopyright = ''; |
|
| 554 | + } |
|
| 555 | + if ($exifCopyright != '') { |
|
| 556 | + $image_url['copyright'] = $exifCopyright; |
|
| 557 | + } else { |
|
| 558 | + $image_url['copyright'] = $source['copyright']; |
|
| 559 | + } |
|
| 491 | 560 | $image_url['source_website'] = $source['source_website']; |
| 492 | 561 | $image_url['source'] = $source['source']; |
| 493 | 562 | return $image_url; |
| 494 | 563 | } |
| 495 | 564 | } |
| 496 | 565 | return false; |
| 497 | - } else return false; |
|
| 566 | + } else { |
|
| 567 | + return false; |
|
| 568 | + } |
|
| 498 | 569 | } |
| 499 | 570 | |
| 500 | 571 | |
@@ -26,9 +26,15 @@ discard block |
||
| 26 | 26 | $Image = new Image($this->db); |
| 27 | 27 | $Schedule = new Schedule($this->db); |
| 28 | 28 | $ACARS = new ACARS($this->db); |
| 29 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
| 30 | - if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
|
| 31 | - if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
|
| 29 | + if (!isset($globalIVAO)) { |
|
| 30 | + $globalIVAO = FALSE; |
|
| 31 | + } |
|
| 32 | + if (!isset($globalVATSIM)) { |
|
| 33 | + $globalVATSIM = FALSE; |
|
| 34 | + } |
|
| 35 | + if (!isset($globalphpVMS)) { |
|
| 36 | + $globalphpVMS = FALSE; |
|
| 37 | + } |
|
| 32 | 38 | date_default_timezone_set('UTC'); |
| 33 | 39 | |
| 34 | 40 | if (!is_string($query)) |
@@ -77,18 +83,24 @@ discard block |
||
| 77 | 83 | $temp_array['spotter_id'] = ''; |
| 78 | 84 | } |
| 79 | 85 | $temp_array['flightaware_id'] = $row['flightaware_id']; |
| 80 | - if (isset($row['modes'])) $temp_array['modes'] = $row['modes']; |
|
| 86 | + if (isset($row['modes'])) { |
|
| 87 | + $temp_array['modes'] = $row['modes']; |
|
| 88 | + } |
|
| 81 | 89 | $temp_array['ident'] = $row['ident']; |
| 82 | 90 | if (isset($row['registration']) && $row['registration'] != '') { |
| 83 | 91 | $temp_array['registration'] = $row['registration']; |
| 84 | 92 | } elseif (isset($temp_array['modes'])) { |
| 85 | 93 | $temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']); |
| 86 | - } else $temp_array['registration'] = ''; |
|
| 94 | + } else { |
|
| 95 | + $temp_array['registration'] = ''; |
|
| 96 | + } |
|
| 87 | 97 | $temp_array['aircraft_type'] = $row['aircraft_icao']; |
| 88 | 98 | |
| 89 | 99 | $temp_array['departure_airport'] = $row['departure_airport_icao']; |
| 90 | 100 | $temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
| 91 | - if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
|
| 101 | + if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) { |
|
| 102 | + $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
|
| 103 | + } |
|
| 92 | 104 | $temp_array['latitude'] = $row['latitude']; |
| 93 | 105 | $temp_array['longitude'] = $row['longitude']; |
| 94 | 106 | /* |
@@ -122,7 +134,9 @@ discard block |
||
| 122 | 134 | $temp_array['altitude'] = $row['altitude']; |
| 123 | 135 | $temp_array['heading'] = $row['heading']; |
| 124 | 136 | $heading_direction = $this->parseDirection($row['heading']); |
| 125 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 137 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 138 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 139 | + } |
|
| 126 | 140 | $temp_array['ground_speed'] = $row['ground_speed']; |
| 127 | 141 | $temp_array['image'] = ""; |
| 128 | 142 | $temp_array['image_thumbnail'] = ""; |
@@ -131,7 +145,9 @@ discard block |
||
| 131 | 145 | |
| 132 | 146 | if (isset($row['highlight'])) { |
| 133 | 147 | $temp_array['highlight'] = $row['highlight']; |
| 134 | - } else $temp_array['highlight'] = ''; |
|
| 148 | + } else { |
|
| 149 | + $temp_array['highlight'] = ''; |
|
| 150 | + } |
|
| 135 | 151 | |
| 136 | 152 | $dateArray = $this->parseDateString($row['date']); |
| 137 | 153 | if ($dateArray['seconds'] < 10) |
@@ -177,7 +193,9 @@ discard block |
||
| 177 | 193 | |
| 178 | 194 | if ($aircraft_array[0]['aircraft_shadow'] != NULL) { |
| 179 | 195 | $temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow']; |
| 180 | - } else $temp_array['aircraft_shadow'] = 'default.png'; |
|
| 196 | + } else { |
|
| 197 | + $temp_array['aircraft_shadow'] = 'default.png'; |
|
| 198 | + } |
|
| 181 | 199 | } else { |
| 182 | 200 | $temp_array['aircraft_shadow'] = 'default.png'; |
| 183 | 201 | $temp_array['aircraft_name'] = 'N/A'; |
@@ -207,12 +225,18 @@ discard block |
||
| 207 | 225 | } |
| 208 | 226 | } else { |
| 209 | 227 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 210 | - if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata']; |
|
| 211 | - else $temp_array['airline_iata'] = ''; |
|
| 228 | + if (isset($row['airline_iata'])) { |
|
| 229 | + $temp_array['airline_iata'] = $row['airline_iata']; |
|
| 230 | + } else { |
|
| 231 | + $temp_array['airline_iata'] = ''; |
|
| 232 | + } |
|
| 212 | 233 | $temp_array['airline_name'] = $row['airline_name']; |
| 213 | 234 | $temp_array['airline_country'] = $row['airline_country']; |
| 214 | - if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign']; |
|
| 215 | - else $temp_array['airline_callsign'] = 'N/A'; |
|
| 235 | + if (isset($row['airline_callsign'])) { |
|
| 236 | + $temp_array['airline_callsign'] = $row['airline_callsign']; |
|
| 237 | + } else { |
|
| 238 | + $temp_array['airline_callsign'] = 'N/A'; |
|
| 239 | + } |
|
| 216 | 240 | $temp_array['airline_type'] = $row['airline_type']; |
| 217 | 241 | } |
| 218 | 242 | if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') { |
@@ -228,7 +252,9 @@ discard block |
||
| 228 | 252 | } |
| 229 | 253 | if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !isset($temp_array['aircraft_owner'])) { |
| 230 | 254 | $owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']); |
| 231 | - if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
|
| 255 | + if ($owner_info['owner'] != '') { |
|
| 256 | + $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
|
| 257 | + } |
|
| 232 | 258 | $temp_array['aircraft_base'] = $owner_info['base']; |
| 233 | 259 | $temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg']; |
| 234 | 260 | } |
@@ -236,9 +262,14 @@ discard block |
||
| 236 | 262 | if($temp_array['registration'] != "" || ($globalIVAO && $temp_array['aircraft_type'] != '')) |
| 237 | 263 | { |
| 238 | 264 | if ($globalIVAO) { |
| 239 | - if (isset($temp_array['airline_icao'])) $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
|
| 240 | - else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
|
| 241 | - } else $image_array = $Image->getSpotterImage($temp_array['registration']); |
|
| 265 | + if (isset($temp_array['airline_icao'])) { |
|
| 266 | + $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
|
| 267 | + } else { |
|
| 268 | + $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
|
| 269 | + } |
|
| 270 | + } else { |
|
| 271 | + $image_array = $Image->getSpotterImage($temp_array['registration']); |
|
| 272 | + } |
|
| 242 | 273 | if (count($image_array) > 0) { |
| 243 | 274 | $temp_array['image'] = $image_array[0]['image']; |
| 244 | 275 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -288,7 +319,9 @@ discard block |
||
| 288 | 319 | //if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') { |
| 289 | 320 | if ($row['departure_airport_icao'] != '') { |
| 290 | 321 | $departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']); |
| 291 | - if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
| 322 | + if (!isset($departure_airport_array[0]['name'])) { |
|
| 323 | + $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
| 324 | + } |
|
| 292 | 325 | /* |
| 293 | 326 | } elseif ($row['departure_airport_name'] != '') { |
| 294 | 327 | $temp_array['departure_airport_name'] = $row['departure_airport_name']; |
@@ -296,7 +329,9 @@ discard block |
||
| 296 | 329 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
| 297 | 330 | $temp_array['departure_airport_icao'] = $row['departure_airport_icao']; |
| 298 | 331 | */ |
| 299 | - } else $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
| 332 | + } else { |
|
| 333 | + $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
| 334 | + } |
|
| 300 | 335 | if (isset($departure_airport_array[0]['name'])) { |
| 301 | 336 | $temp_array['departure_airport_name'] = $departure_airport_array[0]['name']; |
| 302 | 337 | $temp_array['departure_airport_city'] = $departure_airport_array[0]['city']; |
@@ -316,8 +351,12 @@ discard block |
||
| 316 | 351 | |
| 317 | 352 | if ($row['arrival_airport_icao'] != '') { |
| 318 | 353 | $arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']); |
| 319 | - if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
| 320 | - } else $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
| 354 | + if (count($arrival_airport_array) == 0) { |
|
| 355 | + $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
| 356 | + } |
|
| 357 | + } else { |
|
| 358 | + $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
| 359 | + } |
|
| 321 | 360 | if (isset($arrival_airport_array[0]['name'])) { |
| 322 | 361 | $temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name']; |
| 323 | 362 | $temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city']; |
@@ -333,27 +372,45 @@ discard block |
||
| 333 | 372 | $temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
| 334 | 373 | } |
| 335 | 374 | */ |
| 336 | - if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id']; |
|
| 337 | - if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name']; |
|
| 338 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 339 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 340 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 375 | + if (isset($row['pilot_id']) && $row['pilot_id'] != '') { |
|
| 376 | + $temp_array['pilot_id'] = $row['pilot_id']; |
|
| 377 | + } |
|
| 378 | + if (isset($row['pilot_name']) && $row['pilot_name'] != '') { |
|
| 379 | + $temp_array['pilot_name'] = $row['pilot_name']; |
|
| 380 | + } |
|
| 381 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 382 | + $temp_array['source_name'] = $row['source_name']; |
|
| 383 | + } |
|
| 384 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 385 | + $temp_array['over_country'] = $row['over_country']; |
|
| 386 | + } |
|
| 387 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 388 | + $temp_array['distance'] = $row['distance']; |
|
| 389 | + } |
|
| 341 | 390 | if (isset($row['squawk'])) { |
| 342 | 391 | $temp_array['squawk'] = $row['squawk']; |
| 343 | 392 | if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) { |
| 344 | 393 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']); |
| 345 | - if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
| 394 | + if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) { |
|
| 395 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
| 396 | + } |
|
| 346 | 397 | } elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) { |
| 347 | 398 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']); |
| 348 | - if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
| 349 | - } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
| 399 | + if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) { |
|
| 400 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
| 401 | + } |
|
| 402 | + } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) { |
|
| 403 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
| 404 | + } |
|
| 350 | 405 | } |
| 351 | 406 | |
| 352 | 407 | $temp_array['query_number_rows'] = $num_rows; |
| 353 | 408 | |
| 354 | 409 | $spotter_array[] = $temp_array; |
| 355 | 410 | } |
| 356 | - if ($num_rows == 0) return array(); |
|
| 411 | + if ($num_rows == 0) { |
|
| 412 | + return array(); |
|
| 413 | + } |
|
| 357 | 414 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 358 | 415 | return $spotter_array; |
| 359 | 416 | } |
@@ -385,7 +442,9 @@ discard block |
||
| 385 | 442 | foreach ($q_array as $q_item){ |
| 386 | 443 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
| 387 | 444 | $additional_query .= " AND ("; |
| 388 | - if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
|
| 445 | + if (is_int($q_item)) { |
|
| 446 | + $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
|
| 447 | + } |
|
| 389 | 448 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
| 390 | 449 | $additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
| 391 | 450 | $additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
@@ -406,7 +465,9 @@ discard block |
||
| 406 | 465 | $additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR "; |
| 407 | 466 | $additional_query .= "(spotter_output.ident like '%".$q_item."%') OR "; |
| 408 | 467 | $translate = $Translation->ident2icao($q_item); |
| 409 | - if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
|
| 468 | + if ($translate != $q_item) { |
|
| 469 | + $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
|
| 470 | + } |
|
| 410 | 471 | $additional_query .= "(spotter_output.highlight like '%".$q_item."%')"; |
| 411 | 472 | $additional_query .= ")"; |
| 412 | 473 | } |
@@ -633,7 +694,9 @@ discard block |
||
| 633 | 694 | date_default_timezone_set($globalTimezone); |
| 634 | 695 | $datetime = new DateTime(); |
| 635 | 696 | $offset = $datetime->format('P'); |
| 636 | - } else $offset = '+00:00'; |
|
| 697 | + } else { |
|
| 698 | + $offset = '+00:00'; |
|
| 699 | + } |
|
| 637 | 700 | |
| 638 | 701 | if ($date_array[1] != "") |
| 639 | 702 | { |
@@ -666,7 +729,9 @@ discard block |
||
| 666 | 729 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 667 | 730 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 668 | 731 | } |
| 669 | - } else $limit_query = ""; |
|
| 732 | + } else { |
|
| 733 | + $limit_query = ""; |
|
| 734 | + } |
|
| 670 | 735 | |
| 671 | 736 | |
| 672 | 737 | if ($sort != "") |
@@ -1366,7 +1431,9 @@ discard block |
||
| 1366 | 1431 | date_default_timezone_set($globalTimezone); |
| 1367 | 1432 | $datetime = new DateTime($date); |
| 1368 | 1433 | $offset = $datetime->format('P'); |
| 1369 | - } else $offset = '+00:00'; |
|
| 1434 | + } else { |
|
| 1435 | + $offset = '+00:00'; |
|
| 1436 | + } |
|
| 1370 | 1437 | if ($globalDBdriver == 'mysql') { |
| 1371 | 1438 | $additional_query = " AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date "; |
| 1372 | 1439 | $query_values = array(':date' => $datetime->format('Y-m-d'), ':offset' => $offset); |
@@ -1658,7 +1725,9 @@ discard block |
||
| 1658 | 1725 | { |
| 1659 | 1726 | $highlight = $row['highlight']; |
| 1660 | 1727 | } |
| 1661 | - if (isset($highlight)) return $highlight; |
|
| 1728 | + if (isset($highlight)) { |
|
| 1729 | + return $highlight; |
|
| 1730 | + } |
|
| 1662 | 1731 | } |
| 1663 | 1732 | |
| 1664 | 1733 | |
@@ -1689,7 +1758,9 @@ discard block |
||
| 1689 | 1758 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1690 | 1759 | if (count($row) > 0) { |
| 1691 | 1760 | return $row['usage']; |
| 1692 | - } else return ''; |
|
| 1761 | + } else { |
|
| 1762 | + return ''; |
|
| 1763 | + } |
|
| 1693 | 1764 | } |
| 1694 | 1765 | |
| 1695 | 1766 | /** |
@@ -1716,7 +1787,9 @@ discard block |
||
| 1716 | 1787 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1717 | 1788 | if (count($row) > 0) { |
| 1718 | 1789 | return $row['icao']; |
| 1719 | - } else return ''; |
|
| 1790 | + } else { |
|
| 1791 | + return ''; |
|
| 1792 | + } |
|
| 1720 | 1793 | } |
| 1721 | 1794 | |
| 1722 | 1795 | /** |
@@ -1745,7 +1818,9 @@ discard block |
||
| 1745 | 1818 | $airport_longitude = $row['longitude']; |
| 1746 | 1819 | $Common = new Common(); |
| 1747 | 1820 | return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude); |
| 1748 | - } else return ''; |
|
| 1821 | + } else { |
|
| 1822 | + return ''; |
|
| 1823 | + } |
|
| 1749 | 1824 | } |
| 1750 | 1825 | |
| 1751 | 1826 | /** |
@@ -2021,7 +2096,9 @@ discard block |
||
| 2021 | 2096 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2022 | 2097 | if (isset($row['icaotypecode'])) { |
| 2023 | 2098 | return $row['icaotypecode']; |
| 2024 | - } else return ''; |
|
| 2099 | + } else { |
|
| 2100 | + return ''; |
|
| 2101 | + } |
|
| 2025 | 2102 | } |
| 2026 | 2103 | |
| 2027 | 2104 | /** |
@@ -2042,7 +2119,9 @@ discard block |
||
| 2042 | 2119 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2043 | 2120 | if (isset($row['operator_correct'])) { |
| 2044 | 2121 | return $row['operator_correct']; |
| 2045 | - } else return $operator; |
|
| 2122 | + } else { |
|
| 2123 | + return $operator; |
|
| 2124 | + } |
|
| 2046 | 2125 | } |
| 2047 | 2126 | |
| 2048 | 2127 | /** |
@@ -2055,7 +2134,9 @@ discard block |
||
| 2055 | 2134 | public function getRouteInfo($callsign) |
| 2056 | 2135 | { |
| 2057 | 2136 | $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
| 2058 | - if ($callsign == '') return array(); |
|
| 2137 | + if ($callsign == '') { |
|
| 2138 | + return array(); |
|
| 2139 | + } |
|
| 2059 | 2140 | $query = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1"; |
| 2060 | 2141 | |
| 2061 | 2142 | $sth = $this->db->prepare($query); |
@@ -2064,7 +2145,9 @@ discard block |
||
| 2064 | 2145 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2065 | 2146 | if (count($row) > 0) { |
| 2066 | 2147 | return $row; |
| 2067 | - } else return array(); |
|
| 2148 | + } else { |
|
| 2149 | + return array(); |
|
| 2150 | + } |
|
| 2068 | 2151 | } |
| 2069 | 2152 | |
| 2070 | 2153 | /** |
@@ -2116,7 +2199,9 @@ discard block |
||
| 2116 | 2199 | $sth->execute(array(':registration' => $registration)); |
| 2117 | 2200 | |
| 2118 | 2201 | return $sth->fetch(PDO::FETCH_ASSOC); |
| 2119 | - } else return array(); |
|
| 2202 | + } else { |
|
| 2203 | + return array(); |
|
| 2204 | + } |
|
| 2120 | 2205 | } |
| 2121 | 2206 | |
| 2122 | 2207 | |
@@ -2272,8 +2357,11 @@ discard block |
||
| 2272 | 2357 | $query .= " ORDER BY spotter_output.source_name ASC"; |
| 2273 | 2358 | |
| 2274 | 2359 | $sth = $this->db->prepare($query); |
| 2275 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 2276 | - else $sth->execute(); |
|
| 2360 | + if (!empty($query_values)) { |
|
| 2361 | + $sth->execute($query_values); |
|
| 2362 | + } else { |
|
| 2363 | + $sth->execute(); |
|
| 2364 | + } |
|
| 2277 | 2365 | |
| 2278 | 2366 | $source_array = array(); |
| 2279 | 2367 | $temp_array = array(); |
@@ -2604,7 +2692,9 @@ discard block |
||
| 2604 | 2692 | date_default_timezone_set($globalTimezone); |
| 2605 | 2693 | $datetime = new DateTime(); |
| 2606 | 2694 | $offset = $datetime->format('P'); |
| 2607 | - } else $offset = '+00:00'; |
|
| 2695 | + } else { |
|
| 2696 | + $offset = '+00:00'; |
|
| 2697 | + } |
|
| 2608 | 2698 | if ($airport_icao == '') { |
| 2609 | 2699 | if ($globalDBdriver == 'mysql') { |
| 2610 | 2700 | $query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
@@ -2636,7 +2726,9 @@ discard block |
||
| 2636 | 2726 | date_default_timezone_set($globalTimezone); |
| 2637 | 2727 | $datetime = new DateTime(); |
| 2638 | 2728 | $offset = $datetime->format('P'); |
| 2639 | - } else $offset = '+00:00'; |
|
| 2729 | + } else { |
|
| 2730 | + $offset = '+00:00'; |
|
| 2731 | + } |
|
| 2640 | 2732 | if ($airport_icao == '') { |
| 2641 | 2733 | if ($globalDBdriver == 'mysql') { |
| 2642 | 2734 | $query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -2679,7 +2771,9 @@ discard block |
||
| 2679 | 2771 | date_default_timezone_set($globalTimezone); |
| 2680 | 2772 | $datetime = new DateTime(); |
| 2681 | 2773 | $offset = $datetime->format('P'); |
| 2682 | - } else $offset = '+00:00'; |
|
| 2774 | + } else { |
|
| 2775 | + $offset = '+00:00'; |
|
| 2776 | + } |
|
| 2683 | 2777 | if ($airport_icao == '') { |
| 2684 | 2778 | if ($globalDBdriver == 'mysql') { |
| 2685 | 2779 | $query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
@@ -2713,7 +2807,9 @@ discard block |
||
| 2713 | 2807 | date_default_timezone_set($globalTimezone); |
| 2714 | 2808 | $datetime = new DateTime(); |
| 2715 | 2809 | $offset = $datetime->format('P'); |
| 2716 | - } else $offset = '+00:00'; |
|
| 2810 | + } else { |
|
| 2811 | + $offset = '+00:00'; |
|
| 2812 | + } |
|
| 2717 | 2813 | if ($airport_icao == '') { |
| 2718 | 2814 | if ($globalDBdriver == 'mysql') { |
| 2719 | 2815 | $query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -2761,7 +2857,9 @@ discard block |
||
| 2761 | 2857 | date_default_timezone_set($globalTimezone); |
| 2762 | 2858 | $datetime = new DateTime(); |
| 2763 | 2859 | $offset = $datetime->format('P'); |
| 2764 | - } else $offset = '+00:00'; |
|
| 2860 | + } else { |
|
| 2861 | + $offset = '+00:00'; |
|
| 2862 | + } |
|
| 2765 | 2863 | |
| 2766 | 2864 | if ($globalDBdriver == 'mysql') { |
| 2767 | 2865 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date |
@@ -2883,7 +2981,9 @@ discard block |
||
| 2883 | 2981 | */ |
| 2884 | 2982 | public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '') |
| 2885 | 2983 | { |
| 2886 | - if ($groundspeed == '') $groundspeed = NULL; |
|
| 2984 | + if ($groundspeed == '') { |
|
| 2985 | + $groundspeed = NULL; |
|
| 2986 | + } |
|
| 2887 | 2987 | $query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id'; |
| 2888 | 2988 | $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident); |
| 2889 | 2989 | |
@@ -2917,9 +3017,15 @@ discard block |
||
| 2917 | 3017 | $Image = new Image($this->db); |
| 2918 | 3018 | $Common = new Common(); |
| 2919 | 3019 | |
| 2920 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
| 2921 | - if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
|
| 2922 | - if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
|
| 3020 | + if (!isset($globalIVAO)) { |
|
| 3021 | + $globalIVAO = FALSE; |
|
| 3022 | + } |
|
| 3023 | + if (!isset($globalVATSIM)) { |
|
| 3024 | + $globalVATSIM = FALSE; |
|
| 3025 | + } |
|
| 3026 | + if (!isset($globalphpVMS)) { |
|
| 3027 | + $globalphpVMS = FALSE; |
|
| 3028 | + } |
|
| 2923 | 3029 | date_default_timezone_set('UTC'); |
| 2924 | 3030 | |
| 2925 | 3031 | //getting the registration |
@@ -2932,13 +3038,17 @@ discard block |
||
| 2932 | 3038 | if ($ModeS != '') { |
| 2933 | 3039 | $timeelapsed = microtime(true); |
| 2934 | 3040 | $registration = $this->getAircraftRegistrationBymodeS($ModeS); |
| 2935 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3041 | + if ($globalDebugTimeElapsed) { |
|
| 3042 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3043 | + } |
|
| 2936 | 3044 | } else { |
| 2937 | 3045 | $myhex = explode('-',$flightaware_id); |
| 2938 | 3046 | if (count($myhex) > 0) { |
| 2939 | 3047 | $timeelapsed = microtime(true); |
| 2940 | 3048 | $registration = $this->getAircraftRegistrationBymodeS($myhex[0]); |
| 2941 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3049 | + if ($globalDebugTimeElapsed) { |
|
| 3050 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3051 | + } |
|
| 2942 | 3052 | } |
| 2943 | 3053 | } |
| 2944 | 3054 | } |
@@ -2967,15 +3077,21 @@ discard block |
||
| 2967 | 3077 | if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
| 2968 | 3078 | $airline_array = $this->getAllAirlineInfo("NA"); |
| 2969 | 3079 | } |
| 2970 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3080 | + if ($globalDebugTimeElapsed) { |
|
| 3081 | + echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3082 | + } |
|
| 2971 | 3083 | |
| 2972 | 3084 | } else { |
| 2973 | 3085 | $timeelapsed = microtime(true); |
| 2974 | 3086 | $airline_array = $this->getAllAirlineInfo("NA"); |
| 2975 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3087 | + if ($globalDebugTimeElapsed) { |
|
| 3088 | + echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3089 | + } |
|
| 2976 | 3090 | } |
| 2977 | 3091 | } |
| 2978 | - } else $airline_array = array(); |
|
| 3092 | + } else { |
|
| 3093 | + $airline_array = array(); |
|
| 3094 | + } |
|
| 2979 | 3095 | |
| 2980 | 3096 | //getting the aircraft information |
| 2981 | 3097 | if ($aircraft_icao != "") |
@@ -2988,27 +3104,37 @@ discard block |
||
| 2988 | 3104 | { |
| 2989 | 3105 | $timeelapsed = microtime(true); |
| 2990 | 3106 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
| 2991 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3107 | + if ($globalDebugTimeElapsed) { |
|
| 3108 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3109 | + } |
|
| 2992 | 3110 | } else { |
| 2993 | 3111 | $timeelapsed = microtime(true); |
| 2994 | 3112 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
| 2995 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3113 | + if ($globalDebugTimeElapsed) { |
|
| 3114 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3115 | + } |
|
| 2996 | 3116 | } |
| 2997 | 3117 | } |
| 2998 | 3118 | } else { |
| 2999 | 3119 | if ($ModeS != '') { |
| 3000 | 3120 | $timeelapsed = microtime(true); |
| 3001 | 3121 | $aircraft_icao = $this->getAllAircraftType($ModeS); |
| 3002 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3122 | + if ($globalDebugTimeElapsed) { |
|
| 3123 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3124 | + } |
|
| 3003 | 3125 | if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
| 3004 | 3126 | { |
| 3005 | 3127 | $timeelapsed = microtime(true); |
| 3006 | 3128 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
| 3007 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3129 | + if ($globalDebugTimeElapsed) { |
|
| 3130 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3131 | + } |
|
| 3008 | 3132 | } else { |
| 3009 | 3133 | $timeelapsed = microtime(true); |
| 3010 | 3134 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
| 3011 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3135 | + if ($globalDebugTimeElapsed) { |
|
| 3136 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3137 | + } |
|
| 3012 | 3138 | } |
| 3013 | 3139 | } |
| 3014 | 3140 | } |
@@ -3022,7 +3148,9 @@ discard block |
||
| 3022 | 3148 | } else { |
| 3023 | 3149 | $timeelapsed = microtime(true); |
| 3024 | 3150 | $departure_airport_array = $this->getAllAirportInfo($departure_airport_icao); |
| 3025 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3151 | + if ($globalDebugTimeElapsed) { |
|
| 3152 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3153 | + } |
|
| 3026 | 3154 | } |
| 3027 | 3155 | } |
| 3028 | 3156 | |
@@ -3035,7 +3163,9 @@ discard block |
||
| 3035 | 3163 | } else { |
| 3036 | 3164 | $timeelapsed = microtime(true); |
| 3037 | 3165 | $arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao); |
| 3038 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3166 | + if ($globalDebugTimeElapsed) { |
|
| 3167 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3168 | + } |
|
| 3039 | 3169 | } |
| 3040 | 3170 | } |
| 3041 | 3171 | |
@@ -3070,7 +3200,9 @@ discard block |
||
| 3070 | 3200 | { |
| 3071 | 3201 | return false; |
| 3072 | 3202 | } |
| 3073 | - } else $altitude = 0; |
|
| 3203 | + } else { |
|
| 3204 | + $altitude = 0; |
|
| 3205 | + } |
|
| 3074 | 3206 | |
| 3075 | 3207 | if ($heading != "") |
| 3076 | 3208 | { |
@@ -3099,7 +3231,9 @@ discard block |
||
| 3099 | 3231 | { |
| 3100 | 3232 | $timeelapsed = microtime(true); |
| 3101 | 3233 | $image_array = $Image->getSpotterImage($registration); |
| 3102 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3234 | + if ($globalDebugTimeElapsed) { |
|
| 3235 | + echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3236 | + } |
|
| 3103 | 3237 | if (!isset($image_array[0]['registration'])) |
| 3104 | 3238 | { |
| 3105 | 3239 | //echo "Add image !!!! \n"; |
@@ -3107,14 +3241,21 @@ discard block |
||
| 3107 | 3241 | } |
| 3108 | 3242 | $timeelapsed = microtime(true); |
| 3109 | 3243 | $owner_info = $this->getAircraftOwnerByRegistration($registration); |
| 3110 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3111 | - if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
|
| 3244 | + if ($globalDebugTimeElapsed) { |
|
| 3245 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3246 | + } |
|
| 3247 | + if ($owner_info['owner'] != '') { |
|
| 3248 | + $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
|
| 3249 | + } |
|
| 3112 | 3250 | } |
| 3113 | 3251 | |
| 3114 | 3252 | if ($globalIVAO && $aircraft_icao != '') |
| 3115 | 3253 | { |
| 3116 | - if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao']; |
|
| 3117 | - else $airline_icao = ''; |
|
| 3254 | + if (isset($airline_array[0]['icao'])) { |
|
| 3255 | + $airline_icao = $airline_array[0]['icao']; |
|
| 3256 | + } else { |
|
| 3257 | + $airline_icao = ''; |
|
| 3258 | + } |
|
| 3118 | 3259 | $image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao); |
| 3119 | 3260 | if (!isset($image_array[0]['registration'])) |
| 3120 | 3261 | { |
@@ -3159,12 +3300,24 @@ discard block |
||
| 3159 | 3300 | { |
| 3160 | 3301 | $arrival_airport_array = $this->getAllAirportInfo('NA'); |
| 3161 | 3302 | } |
| 3162 | - if ($registration == '') $registration = 'NA'; |
|
| 3163 | - if ($squawk == '' || $Common->isInteger($squawk) == false) $squawk = NULL; |
|
| 3164 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) == false) $verticalrate = NULL; |
|
| 3165 | - if ($heading == '' || $Common->isInteger($heading) == false) $heading = 0; |
|
| 3166 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) == false) $groundspeed = 0; |
|
| 3167 | - if (!isset($aircraft_owner)) $aircraft_owner = NULL; |
|
| 3303 | + if ($registration == '') { |
|
| 3304 | + $registration = 'NA'; |
|
| 3305 | + } |
|
| 3306 | + if ($squawk == '' || $Common->isInteger($squawk) == false) { |
|
| 3307 | + $squawk = NULL; |
|
| 3308 | + } |
|
| 3309 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) == false) { |
|
| 3310 | + $verticalrate = NULL; |
|
| 3311 | + } |
|
| 3312 | + if ($heading == '' || $Common->isInteger($heading) == false) { |
|
| 3313 | + $heading = 0; |
|
| 3314 | + } |
|
| 3315 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) == false) { |
|
| 3316 | + $groundspeed = 0; |
|
| 3317 | + } |
|
| 3318 | + if (!isset($aircraft_owner)) { |
|
| 3319 | + $aircraft_owner = NULL; |
|
| 3320 | + } |
|
| 3168 | 3321 | $query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, 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,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) |
| 3169 | 3322 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,: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, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)"; |
| 3170 | 3323 | |
@@ -3175,9 +3328,13 @@ discard block |
||
| 3175 | 3328 | if ($airline_type == '') { |
| 3176 | 3329 | $timeelapsed = microtime(true); |
| 3177 | 3330 | $airline_type = $this->getAircraftTypeBymodeS($ModeS); |
| 3178 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3331 | + if ($globalDebugTimeElapsed) { |
|
| 3332 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3333 | + } |
|
| 3334 | + } |
|
| 3335 | + if ($airline_type == null) { |
|
| 3336 | + $airline_type = ''; |
|
| 3179 | 3337 | } |
| 3180 | - if ($airline_type == null) $airline_type = ''; |
|
| 3181 | 3338 | $aircraft_type = $aircraft_array[0]['type']; |
| 3182 | 3339 | $aircraft_manufacturer = $aircraft_array[0]['manufacturer']; |
| 3183 | 3340 | $departure_airport_name = $departure_airport_array[0]['name']; |
@@ -3313,7 +3470,9 @@ discard block |
||
| 3313 | 3470 | } |
| 3314 | 3471 | } |
| 3315 | 3472 | $query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC"; |
| 3316 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 3473 | + if ($limit) { |
|
| 3474 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 3475 | + } |
|
| 3317 | 3476 | |
| 3318 | 3477 | |
| 3319 | 3478 | $sth = $this->db->prepare($query); |
@@ -3362,7 +3521,9 @@ discard block |
||
| 3362 | 3521 | } |
| 3363 | 3522 | } |
| 3364 | 3523 | $query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC"; |
| 3365 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 3524 | + if ($limit) { |
|
| 3525 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 3526 | + } |
|
| 3366 | 3527 | |
| 3367 | 3528 | |
| 3368 | 3529 | $sth = $this->db->prepare($query); |
@@ -3394,7 +3555,9 @@ discard block |
||
| 3394 | 3555 | FROM spotter_output |
| 3395 | 3556 | WHERE spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL "; |
| 3396 | 3557 | $query .= "GROUP BY spotter_output.owner_name ORDER BY owner_count DESC"; |
| 3397 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 3558 | + if ($limit) { |
|
| 3559 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 3560 | + } |
|
| 3398 | 3561 | |
| 3399 | 3562 | |
| 3400 | 3563 | $sth = $this->db->prepare($query); |
@@ -3643,7 +3806,9 @@ discard block |
||
| 3643 | 3806 | date_default_timezone_set($globalTimezone); |
| 3644 | 3807 | $datetime = new DateTime($date); |
| 3645 | 3808 | $offset = $datetime->format('P'); |
| 3646 | - } else $offset = '+00:00'; |
|
| 3809 | + } else { |
|
| 3810 | + $offset = '+00:00'; |
|
| 3811 | + } |
|
| 3647 | 3812 | |
| 3648 | 3813 | if ($globalDBdriver == 'mysql') { |
| 3649 | 3814 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
@@ -3692,7 +3857,9 @@ discard block |
||
| 3692 | 3857 | date_default_timezone_set($globalTimezone); |
| 3693 | 3858 | $datetime = new DateTime($date); |
| 3694 | 3859 | $offset = $datetime->format('P'); |
| 3695 | - } else $offset = '+00:00'; |
|
| 3860 | + } else { |
|
| 3861 | + $offset = '+00:00'; |
|
| 3862 | + } |
|
| 3696 | 3863 | |
| 3697 | 3864 | if ($globalDBdriver == 'mysql') { |
| 3698 | 3865 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
@@ -3915,7 +4082,9 @@ discard block |
||
| 3915 | 4082 | WHERE spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' |
| 3916 | 4083 | GROUP BY spotter_output.airline_country |
| 3917 | 4084 | ORDER BY airline_country_count DESC"; |
| 3918 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 4085 | + if ($limit) { |
|
| 4086 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 4087 | + } |
|
| 3919 | 4088 | |
| 3920 | 4089 | $sth = $this->db->prepare($query); |
| 3921 | 4090 | $sth->execute(); |
@@ -3956,9 +4125,13 @@ discard block |
||
| 3956 | 4125 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 3957 | 4126 | } |
| 3958 | 4127 | } |
| 3959 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 4128 | + if ($sincedate != '') { |
|
| 4129 | + $query .= "AND date > '".$sincedate."' "; |
|
| 4130 | + } |
|
| 3960 | 4131 | $query .= "GROUP BY c.name ORDER BY nb DESC"; |
| 3961 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 4132 | + if ($limit) { |
|
| 4133 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 4134 | + } |
|
| 3962 | 4135 | |
| 3963 | 4136 | |
| 3964 | 4137 | $sth = $this->db->prepare($query); |
@@ -4009,7 +4182,9 @@ discard block |
||
| 4009 | 4182 | //if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 4010 | 4183 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
| 4011 | 4184 | $query .= "GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name ORDER BY aircraft_icao_count DESC"; |
| 4012 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 4185 | + if ($limit) { |
|
| 4186 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 4187 | + } |
|
| 4013 | 4188 | |
| 4014 | 4189 | |
| 4015 | 4190 | $sth = $this->db->prepare($query); |
@@ -4063,7 +4238,9 @@ discard block |
||
| 4063 | 4238 | if($row['registration'] != "") |
| 4064 | 4239 | { |
| 4065 | 4240 | $image_array = $Image->getSpotterImage($row['registration']); |
| 4066 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 4241 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
| 4242 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 4243 | + } |
|
| 4067 | 4244 | } |
| 4068 | 4245 | $emp_array['registration_count'] = $row['registration_count']; |
| 4069 | 4246 | |
@@ -4139,7 +4316,9 @@ discard block |
||
| 4139 | 4316 | if($row['registration'] != "") |
| 4140 | 4317 | { |
| 4141 | 4318 | $image_array = $Image->getSpotterImage($row['registration']); |
| 4142 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 4319 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
| 4320 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 4321 | + } |
|
| 4143 | 4322 | } |
| 4144 | 4323 | $temp_array['registration_count'] = $row['registration_count']; |
| 4145 | 4324 | |
@@ -4392,7 +4571,9 @@ discard block |
||
| 4392 | 4571 | date_default_timezone_set($globalTimezone); |
| 4393 | 4572 | $datetime = new DateTime($date); |
| 4394 | 4573 | $offset = $datetime->format('P'); |
| 4395 | - } else $offset = '+00:00'; |
|
| 4574 | + } else { |
|
| 4575 | + $offset = '+00:00'; |
|
| 4576 | + } |
|
| 4396 | 4577 | |
| 4397 | 4578 | if ($globalDBdriver == 'mysql') { |
| 4398 | 4579 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
@@ -4440,7 +4621,9 @@ discard block |
||
| 4440 | 4621 | date_default_timezone_set($globalTimezone); |
| 4441 | 4622 | $datetime = new DateTime($date); |
| 4442 | 4623 | $offset = $datetime->format('P'); |
| 4443 | - } else $offset = '+00:00'; |
|
| 4624 | + } else { |
|
| 4625 | + $offset = '+00:00'; |
|
| 4626 | + } |
|
| 4444 | 4627 | |
| 4445 | 4628 | if ($globalDBdriver == 'mysql') { |
| 4446 | 4629 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
@@ -4495,7 +4678,9 @@ discard block |
||
| 4495 | 4678 | date_default_timezone_set($globalTimezone); |
| 4496 | 4679 | $datetime = new DateTime($date); |
| 4497 | 4680 | $offset = $datetime->format('P'); |
| 4498 | - } else $offset = '+00:00'; |
|
| 4681 | + } else { |
|
| 4682 | + $offset = '+00:00'; |
|
| 4683 | + } |
|
| 4499 | 4684 | |
| 4500 | 4685 | if ($globalDBdriver == 'mysql') { |
| 4501 | 4686 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
@@ -4596,8 +4781,11 @@ discard block |
||
| 4596 | 4781 | if($row['registration'] != "") |
| 4597 | 4782 | { |
| 4598 | 4783 | $image_array = $Image->getSpotterImage($row['registration']); |
| 4599 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 4600 | - else $temp_array['image_thumbnail'] = ''; |
|
| 4784 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
| 4785 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 4786 | + } else { |
|
| 4787 | + $temp_array['image_thumbnail'] = ''; |
|
| 4788 | + } |
|
| 4601 | 4789 | } |
| 4602 | 4790 | $temp_array['registration_count'] = $row['registration_count']; |
| 4603 | 4791 | $aircraft_array[] = $temp_array; |
@@ -4714,7 +4902,9 @@ discard block |
||
| 4714 | 4902 | if($row['registration'] != "") |
| 4715 | 4903 | { |
| 4716 | 4904 | $image_array = $Image->getSpotterImage($row['registration']); |
| 4717 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 4905 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
| 4906 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 4907 | + } |
|
| 4718 | 4908 | } |
| 4719 | 4909 | $temp_array['registration_count'] = $row['registration_count']; |
| 4720 | 4910 | |
@@ -4833,7 +5023,9 @@ discard block |
||
| 4833 | 5023 | if($row['registration'] != "") |
| 4834 | 5024 | { |
| 4835 | 5025 | $image_array = $Image->getSpotterImage($row['registration']); |
| 4836 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 5026 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
| 5027 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 5028 | + } |
|
| 4837 | 5029 | } |
| 4838 | 5030 | $temp_array['registration_count'] = $row['registration_count']; |
| 4839 | 5031 | |
@@ -4946,7 +5138,9 @@ discard block |
||
| 4946 | 5138 | // if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 4947 | 5139 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
| 4948 | 5140 | $query .= "GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
| 4949 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 5141 | + if ($limit) { |
|
| 5142 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 5143 | + } |
|
| 4950 | 5144 | |
| 4951 | 5145 | $sth = $this->db->prepare($query); |
| 4952 | 5146 | $sth->execute(); |
@@ -4965,7 +5159,9 @@ discard block |
||
| 4965 | 5159 | if($row['registration'] != "") |
| 4966 | 5160 | { |
| 4967 | 5161 | $image_array = $Image->getSpotterImage($row['registration']); |
| 4968 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 5162 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
| 5163 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 5164 | + } |
|
| 4969 | 5165 | } |
| 4970 | 5166 | |
| 4971 | 5167 | $aircraft_array[] = $temp_array; |
@@ -5008,7 +5204,9 @@ discard block |
||
| 5008 | 5204 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
| 5009 | 5205 | $query .= "GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 5010 | 5206 | ORDER BY airport_departure_icao_count DESC"; |
| 5011 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 5207 | + if ($limit) { |
|
| 5208 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 5209 | + } |
|
| 5012 | 5210 | |
| 5013 | 5211 | $sth = $this->db->prepare($query); |
| 5014 | 5212 | $sth->execute(); |
@@ -5060,7 +5258,9 @@ discard block |
||
| 5060 | 5258 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
| 5061 | 5259 | $query .= "GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
| 5062 | 5260 | ORDER BY airport_departure_icao_count DESC"; |
| 5063 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 5261 | + if ($limit) { |
|
| 5262 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 5263 | + } |
|
| 5064 | 5264 | |
| 5065 | 5265 | $sth = $this->db->prepare($query); |
| 5066 | 5266 | $sth->execute(); |
@@ -5466,7 +5666,9 @@ discard block |
||
| 5466 | 5666 | date_default_timezone_set($globalTimezone); |
| 5467 | 5667 | $datetime = new DateTime($date); |
| 5468 | 5668 | $offset = $datetime->format('P'); |
| 5469 | - } else $offset = '+00:00'; |
|
| 5669 | + } else { |
|
| 5670 | + $offset = '+00:00'; |
|
| 5671 | + } |
|
| 5470 | 5672 | |
| 5471 | 5673 | if ($globalDBdriver == 'mysql') { |
| 5472 | 5674 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
@@ -5517,7 +5719,9 @@ discard block |
||
| 5517 | 5719 | date_default_timezone_set($globalTimezone); |
| 5518 | 5720 | $datetime = new DateTime($date); |
| 5519 | 5721 | $offset = $datetime->format('P'); |
| 5520 | - } else $offset = '+00:00'; |
|
| 5722 | + } else { |
|
| 5723 | + $offset = '+00:00'; |
|
| 5724 | + } |
|
| 5521 | 5725 | |
| 5522 | 5726 | if ($globalDBdriver == 'mysql') { |
| 5523 | 5727 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
@@ -5735,7 +5939,9 @@ discard block |
||
| 5735 | 5939 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
| 5736 | 5940 | $query .= "GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 5737 | 5941 | ORDER BY airport_arrival_icao_count DESC"; |
| 5738 | - if ($limit) $query .= " LIMIT 10"; |
|
| 5942 | + if ($limit) { |
|
| 5943 | + $query .= " LIMIT 10"; |
|
| 5944 | + } |
|
| 5739 | 5945 | |
| 5740 | 5946 | |
| 5741 | 5947 | $sth = $this->db->prepare($query); |
@@ -5755,7 +5961,9 @@ discard block |
||
| 5755 | 5961 | if ($icaoaskey) { |
| 5756 | 5962 | $icao = $row['arrival_airport_icao']; |
| 5757 | 5963 | $airport_array[$icao] = $temp_array; |
| 5758 | - } else $airport_array[] = $temp_array; |
|
| 5964 | + } else { |
|
| 5965 | + $airport_array[] = $temp_array; |
|
| 5966 | + } |
|
| 5759 | 5967 | } |
| 5760 | 5968 | |
| 5761 | 5969 | return $airport_array; |
@@ -5797,7 +6005,9 @@ discard block |
||
| 5797 | 6005 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
| 5798 | 6006 | $query .= "GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country |
| 5799 | 6007 | ORDER BY airport_arrival_icao_count DESC"; |
| 5800 | - if ($limit) $query .= " LIMIT 10"; |
|
| 6008 | + if ($limit) { |
|
| 6009 | + $query .= " LIMIT 10"; |
|
| 6010 | + } |
|
| 5801 | 6011 | |
| 5802 | 6012 | |
| 5803 | 6013 | $sth = $this->db->prepare($query); |
@@ -5817,7 +6027,9 @@ discard block |
||
| 5817 | 6027 | if ($icaoaskey) { |
| 5818 | 6028 | $icao = $row['arrival_airport_icao']; |
| 5819 | 6029 | $airport_array[$icao] = $temp_array; |
| 5820 | - } else $airport_array[] = $temp_array; |
|
| 6030 | + } else { |
|
| 6031 | + $airport_array[] = $temp_array; |
|
| 6032 | + } |
|
| 5821 | 6033 | } |
| 5822 | 6034 | |
| 5823 | 6035 | return $airport_array; |
@@ -6208,7 +6420,9 @@ discard block |
||
| 6208 | 6420 | date_default_timezone_set($globalTimezone); |
| 6209 | 6421 | $datetime = new DateTime($date); |
| 6210 | 6422 | $offset = $datetime->format('P'); |
| 6211 | - } else $offset = '+00:00'; |
|
| 6423 | + } else { |
|
| 6424 | + $offset = '+00:00'; |
|
| 6425 | + } |
|
| 6212 | 6426 | |
| 6213 | 6427 | if ($globalDBdriver == 'mysql') { |
| 6214 | 6428 | $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
@@ -6259,7 +6473,9 @@ discard block |
||
| 6259 | 6473 | date_default_timezone_set($globalTimezone); |
| 6260 | 6474 | $datetime = new DateTime($date); |
| 6261 | 6475 | $offset = $datetime->format('P'); |
| 6262 | - } else $offset = '+00:00'; |
|
| 6476 | + } else { |
|
| 6477 | + $offset = '+00:00'; |
|
| 6478 | + } |
|
| 6263 | 6479 | |
| 6264 | 6480 | if ($globalDBdriver == 'mysql') { |
| 6265 | 6481 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
@@ -6488,7 +6704,9 @@ discard block |
||
| 6488 | 6704 | WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA' |
| 6489 | 6705 | GROUP BY spotter_output.arrival_airport_country |
| 6490 | 6706 | ORDER BY airport_arrival_country_count DESC"; |
| 6491 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 6707 | + if ($limit) { |
|
| 6708 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 6709 | + } |
|
| 6492 | 6710 | |
| 6493 | 6711 | |
| 6494 | 6712 | $sth = $this->db->prepare($query); |
@@ -6783,7 +7001,9 @@ discard block |
||
| 6783 | 7001 | date_default_timezone_set($globalTimezone); |
| 6784 | 7002 | $datetime = new DateTime($date); |
| 6785 | 7003 | $offset = $datetime->format('P'); |
| 6786 | - } else $offset = '+00:00'; |
|
| 7004 | + } else { |
|
| 7005 | + $offset = '+00:00'; |
|
| 7006 | + } |
|
| 6787 | 7007 | |
| 6788 | 7008 | if ($globalDBdriver == 'mysql') { |
| 6789 | 7009 | $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
@@ -6966,15 +7186,23 @@ discard block |
||
| 6966 | 7186 | FROM spotter_output |
| 6967 | 7187 | WHERE spotter_output.ident <> '' "; |
| 6968 | 7188 | if ($olderthanmonths > 0) { |
| 6969 | - if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
| 6970 | - else $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
| 7189 | + if ($globalDBdriver == 'mysql') { |
|
| 7190 | + $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
| 7191 | + } else { |
|
| 7192 | + $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
| 7193 | + } |
|
| 6971 | 7194 | } |
| 6972 | 7195 | if ($sincedate != '') { |
| 6973 | - if ($globalDBdriver == 'mysql') $query .= "AND date > '".$sincedate."' "; |
|
| 6974 | - else $query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP) "; |
|
| 7196 | + if ($globalDBdriver == 'mysql') { |
|
| 7197 | + $query .= "AND date > '".$sincedate."' "; |
|
| 7198 | + } else { |
|
| 7199 | + $query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP) "; |
|
| 7200 | + } |
|
| 6975 | 7201 | } |
| 6976 | 7202 | $query .= "GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; |
| 6977 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 7203 | + if ($limit) { |
|
| 7204 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 7205 | + } |
|
| 6978 | 7206 | |
| 6979 | 7207 | $sth = $this->db->prepare($query); |
| 6980 | 7208 | $sth->execute(); |
@@ -7011,7 +7239,9 @@ discard block |
||
| 7011 | 7239 | date_default_timezone_set($globalTimezone); |
| 7012 | 7240 | $datetime = new DateTime(); |
| 7013 | 7241 | $offset = $datetime->format('P'); |
| 7014 | - } else $offset = '+00:00'; |
|
| 7242 | + } else { |
|
| 7243 | + $offset = '+00:00'; |
|
| 7244 | + } |
|
| 7015 | 7245 | |
| 7016 | 7246 | if ($globalDBdriver == 'mysql') { |
| 7017 | 7247 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -7060,7 +7290,9 @@ discard block |
||
| 7060 | 7290 | date_default_timezone_set($globalTimezone); |
| 7061 | 7291 | $datetime = new DateTime(); |
| 7062 | 7292 | $offset = $datetime->format('P'); |
| 7063 | - } else $offset = '+00:00'; |
|
| 7293 | + } else { |
|
| 7294 | + $offset = '+00:00'; |
|
| 7295 | + } |
|
| 7064 | 7296 | |
| 7065 | 7297 | if ($globalDBdriver == 'mysql') { |
| 7066 | 7298 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -7108,7 +7340,9 @@ discard block |
||
| 7108 | 7340 | date_default_timezone_set($globalTimezone); |
| 7109 | 7341 | $datetime = new DateTime(); |
| 7110 | 7342 | $offset = $datetime->format('P'); |
| 7111 | - } else $offset = '+00:00'; |
|
| 7343 | + } else { |
|
| 7344 | + $offset = '+00:00'; |
|
| 7345 | + } |
|
| 7112 | 7346 | |
| 7113 | 7347 | if ($globalDBdriver == 'mysql') { |
| 7114 | 7348 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -7156,7 +7390,9 @@ discard block |
||
| 7156 | 7390 | date_default_timezone_set($globalTimezone); |
| 7157 | 7391 | $datetime = new DateTime(); |
| 7158 | 7392 | $offset = $datetime->format('P'); |
| 7159 | - } else $offset = '+00:00'; |
|
| 7393 | + } else { |
|
| 7394 | + $offset = '+00:00'; |
|
| 7395 | + } |
|
| 7160 | 7396 | |
| 7161 | 7397 | if ($globalDBdriver == 'mysql') { |
| 7162 | 7398 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -7202,7 +7438,9 @@ discard block |
||
| 7202 | 7438 | date_default_timezone_set($globalTimezone); |
| 7203 | 7439 | $datetime = new DateTime(); |
| 7204 | 7440 | $offset = $datetime->format('P'); |
| 7205 | - } else $offset = '+00:00'; |
|
| 7441 | + } else { |
|
| 7442 | + $offset = '+00:00'; |
|
| 7443 | + } |
|
| 7206 | 7444 | |
| 7207 | 7445 | if ($globalDBdriver == 'mysql') { |
| 7208 | 7446 | $query = "SELECT YEAR(CONVERT_TZ(s.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(s.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -7249,7 +7487,9 @@ discard block |
||
| 7249 | 7487 | date_default_timezone_set($globalTimezone); |
| 7250 | 7488 | $datetime = new DateTime(); |
| 7251 | 7489 | $offset = $datetime->format('P'); |
| 7252 | - } else $offset = '+00:00'; |
|
| 7490 | + } else { |
|
| 7491 | + $offset = '+00:00'; |
|
| 7492 | + } |
|
| 7253 | 7493 | |
| 7254 | 7494 | if ($globalDBdriver == 'mysql') { |
| 7255 | 7495 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count |
@@ -7296,7 +7536,9 @@ discard block |
||
| 7296 | 7536 | date_default_timezone_set($globalTimezone); |
| 7297 | 7537 | $datetime = new DateTime(); |
| 7298 | 7538 | $offset = $datetime->format('P'); |
| 7299 | - } else $offset = '+00:00'; |
|
| 7539 | + } else { |
|
| 7540 | + $offset = '+00:00'; |
|
| 7541 | + } |
|
| 7300 | 7542 | |
| 7301 | 7543 | if ($globalDBdriver == 'mysql') { |
| 7302 | 7544 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count |
@@ -7344,7 +7586,9 @@ discard block |
||
| 7344 | 7586 | date_default_timezone_set($globalTimezone); |
| 7345 | 7587 | $datetime = new DateTime(); |
| 7346 | 7588 | $offset = $datetime->format('P'); |
| 7347 | - } else $offset = '+00:00'; |
|
| 7589 | + } else { |
|
| 7590 | + $offset = '+00:00'; |
|
| 7591 | + } |
|
| 7348 | 7592 | |
| 7349 | 7593 | if ($globalDBdriver == 'mysql') { |
| 7350 | 7594 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count |
@@ -7391,7 +7635,9 @@ discard block |
||
| 7391 | 7635 | date_default_timezone_set($globalTimezone); |
| 7392 | 7636 | $datetime = new DateTime(); |
| 7393 | 7637 | $offset = $datetime->format('P'); |
| 7394 | - } else $offset = '+00:00'; |
|
| 7638 | + } else { |
|
| 7639 | + $offset = '+00:00'; |
|
| 7640 | + } |
|
| 7395 | 7641 | |
| 7396 | 7642 | if ($globalDBdriver == 'mysql') { |
| 7397 | 7643 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count |
@@ -7439,7 +7685,9 @@ discard block |
||
| 7439 | 7685 | date_default_timezone_set($globalTimezone); |
| 7440 | 7686 | $datetime = new DateTime(); |
| 7441 | 7687 | $offset = $datetime->format('P'); |
| 7442 | - } else $offset = '+00:00'; |
|
| 7688 | + } else { |
|
| 7689 | + $offset = '+00:00'; |
|
| 7690 | + } |
|
| 7443 | 7691 | |
| 7444 | 7692 | if ($globalDBdriver == 'mysql') { |
| 7445 | 7693 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count |
@@ -7488,7 +7736,9 @@ discard block |
||
| 7488 | 7736 | date_default_timezone_set($globalTimezone); |
| 7489 | 7737 | $datetime = new DateTime(); |
| 7490 | 7738 | $offset = $datetime->format('P'); |
| 7491 | - } else $offset = '+00:00'; |
|
| 7739 | + } else { |
|
| 7740 | + $offset = '+00:00'; |
|
| 7741 | + } |
|
| 7492 | 7742 | |
| 7493 | 7743 | if ($globalDBdriver == 'mysql') { |
| 7494 | 7744 | $query = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -7541,7 +7791,9 @@ discard block |
||
| 7541 | 7791 | date_default_timezone_set($globalTimezone); |
| 7542 | 7792 | $datetime = new DateTime(); |
| 7543 | 7793 | $offset = $datetime->format('P'); |
| 7544 | - } else $offset = '+00:00'; |
|
| 7794 | + } else { |
|
| 7795 | + $offset = '+00:00'; |
|
| 7796 | + } |
|
| 7545 | 7797 | |
| 7546 | 7798 | if ($orderby == "hour") |
| 7547 | 7799 | { |
@@ -7604,7 +7856,9 @@ discard block |
||
| 7604 | 7856 | date_default_timezone_set($globalTimezone); |
| 7605 | 7857 | $datetime = new DateTime(); |
| 7606 | 7858 | $offset = $datetime->format('P'); |
| 7607 | - } else $offset = '+00:00'; |
|
| 7859 | + } else { |
|
| 7860 | + $offset = '+00:00'; |
|
| 7861 | + } |
|
| 7608 | 7862 | |
| 7609 | 7863 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
| 7610 | 7864 | |
@@ -7656,7 +7910,9 @@ discard block |
||
| 7656 | 7910 | date_default_timezone_set($globalTimezone); |
| 7657 | 7911 | $datetime = new DateTime(); |
| 7658 | 7912 | $offset = $datetime->format('P'); |
| 7659 | - } else $offset = '+00:00'; |
|
| 7913 | + } else { |
|
| 7914 | + $offset = '+00:00'; |
|
| 7915 | + } |
|
| 7660 | 7916 | |
| 7661 | 7917 | if ($globalDBdriver == 'mysql') { |
| 7662 | 7918 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -7704,7 +7960,9 @@ discard block |
||
| 7704 | 7960 | date_default_timezone_set($globalTimezone); |
| 7705 | 7961 | $datetime = new DateTime(); |
| 7706 | 7962 | $offset = $datetime->format('P'); |
| 7707 | - } else $offset = '+00:00'; |
|
| 7963 | + } else { |
|
| 7964 | + $offset = '+00:00'; |
|
| 7965 | + } |
|
| 7708 | 7966 | |
| 7709 | 7967 | if ($globalDBdriver == 'mysql') { |
| 7710 | 7968 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -7752,7 +8010,9 @@ discard block |
||
| 7752 | 8010 | date_default_timezone_set($globalTimezone); |
| 7753 | 8011 | $datetime = new DateTime(); |
| 7754 | 8012 | $offset = $datetime->format('P'); |
| 7755 | - } else $offset = '+00:00'; |
|
| 8013 | + } else { |
|
| 8014 | + $offset = '+00:00'; |
|
| 8015 | + } |
|
| 7756 | 8016 | |
| 7757 | 8017 | if ($globalDBdriver == 'mysql') { |
| 7758 | 8018 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -7801,7 +8061,9 @@ discard block |
||
| 7801 | 8061 | date_default_timezone_set($globalTimezone); |
| 7802 | 8062 | $datetime = new DateTime(); |
| 7803 | 8063 | $offset = $datetime->format('P'); |
| 7804 | - } else $offset = '+00:00'; |
|
| 8064 | + } else { |
|
| 8065 | + $offset = '+00:00'; |
|
| 8066 | + } |
|
| 7805 | 8067 | |
| 7806 | 8068 | if ($globalDBdriver == 'mysql') { |
| 7807 | 8069 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -7850,7 +8112,9 @@ discard block |
||
| 7850 | 8112 | date_default_timezone_set($globalTimezone); |
| 7851 | 8113 | $datetime = new DateTime($date); |
| 7852 | 8114 | $offset = $datetime->format('P'); |
| 7853 | - } else $offset = '+00:00'; |
|
| 8115 | + } else { |
|
| 8116 | + $offset = '+00:00'; |
|
| 8117 | + } |
|
| 7854 | 8118 | |
| 7855 | 8119 | if ($globalDBdriver == 'mysql') { |
| 7856 | 8120 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -7899,7 +8163,9 @@ discard block |
||
| 7899 | 8163 | date_default_timezone_set($globalTimezone); |
| 7900 | 8164 | $datetime = new DateTime(); |
| 7901 | 8165 | $offset = $datetime->format('P'); |
| 7902 | - } else $offset = '+00:00'; |
|
| 8166 | + } else { |
|
| 8167 | + $offset = '+00:00'; |
|
| 8168 | + } |
|
| 7903 | 8169 | |
| 7904 | 8170 | if ($globalDBdriver == 'mysql') { |
| 7905 | 8171 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -7950,7 +8216,9 @@ discard block |
||
| 7950 | 8216 | date_default_timezone_set($globalTimezone); |
| 7951 | 8217 | $datetime = new DateTime(); |
| 7952 | 8218 | $offset = $datetime->format('P'); |
| 7953 | - } else $offset = '+00:00'; |
|
| 8219 | + } else { |
|
| 8220 | + $offset = '+00:00'; |
|
| 8221 | + } |
|
| 7954 | 8222 | |
| 7955 | 8223 | if ($globalDBdriver == 'mysql') { |
| 7956 | 8224 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -7998,7 +8266,9 @@ discard block |
||
| 7998 | 8266 | date_default_timezone_set($globalTimezone); |
| 7999 | 8267 | $datetime = new DateTime(); |
| 8000 | 8268 | $offset = $datetime->format('P'); |
| 8001 | - } else $offset = '+00:00'; |
|
| 8269 | + } else { |
|
| 8270 | + $offset = '+00:00'; |
|
| 8271 | + } |
|
| 8002 | 8272 | |
| 8003 | 8273 | if ($globalDBdriver == 'mysql') { |
| 8004 | 8274 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -8174,7 +8444,9 @@ discard block |
||
| 8174 | 8444 | date_default_timezone_set($globalTimezone); |
| 8175 | 8445 | $datetime = new DateTime(); |
| 8176 | 8446 | $offset = $datetime->format('P'); |
| 8177 | - } else $offset = '+00:00'; |
|
| 8447 | + } else { |
|
| 8448 | + $offset = '+00:00'; |
|
| 8449 | + } |
|
| 8178 | 8450 | |
| 8179 | 8451 | if ($globalDBdriver == 'mysql') { |
| 8180 | 8452 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -8349,7 +8621,9 @@ discard block |
||
| 8349 | 8621 | */ |
| 8350 | 8622 | public function parseDirection($direction = 0) |
| 8351 | 8623 | { |
| 8352 | - if ($direction == '') $direction = 0; |
|
| 8624 | + if ($direction == '') { |
|
| 8625 | + $direction = 0; |
|
| 8626 | + } |
|
| 8353 | 8627 | $direction_array = array(); |
| 8354 | 8628 | $temp_array = array(); |
| 8355 | 8629 | |
@@ -8479,7 +8753,9 @@ discard block |
||
| 8479 | 8753 | if (count($row) > 0) { |
| 8480 | 8754 | //return $row['Registration']; |
| 8481 | 8755 | return $row['registration']; |
| 8482 | - } else return ''; |
|
| 8756 | + } else { |
|
| 8757 | + return ''; |
|
| 8758 | + } |
|
| 8483 | 8759 | |
| 8484 | 8760 | } |
| 8485 | 8761 | |
@@ -8502,9 +8778,14 @@ discard block |
||
| 8502 | 8778 | |
| 8503 | 8779 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 8504 | 8780 | if (count($row) > 0) { |
| 8505 | - if ($row['type_flight'] == null) return ''; |
|
| 8506 | - else return $row['type_flight']; |
|
| 8507 | - } else return ''; |
|
| 8781 | + if ($row['type_flight'] == null) { |
|
| 8782 | + return ''; |
|
| 8783 | + } else { |
|
| 8784 | + return $row['type_flight']; |
|
| 8785 | + } |
|
| 8786 | + } else { |
|
| 8787 | + return ''; |
|
| 8788 | + } |
|
| 8508 | 8789 | |
| 8509 | 8790 | } |
| 8510 | 8791 | |
@@ -8539,9 +8820,13 @@ discard block |
||
| 8539 | 8820 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 8540 | 8821 | if (count($row) > 0) { |
| 8541 | 8822 | return $row; |
| 8542 | - } else return ''; |
|
| 8823 | + } else { |
|
| 8824 | + return ''; |
|
| 8825 | + } |
|
| 8543 | 8826 | } catch (PDOException $e) { |
| 8544 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 8827 | + if (isset($globalDebug) && $globalDebug) { |
|
| 8828 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 8829 | + } |
|
| 8545 | 8830 | return ''; |
| 8546 | 8831 | } |
| 8547 | 8832 | |
@@ -8693,7 +8978,9 @@ discard block |
||
| 8693 | 8978 | { |
| 8694 | 8979 | global $globalBitlyAccessToken; |
| 8695 | 8980 | |
| 8696 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 8981 | + if ($globalBitlyAccessToken == '') { |
|
| 8982 | + return $url; |
|
| 8983 | + } |
|
| 8697 | 8984 | |
| 8698 | 8985 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 8699 | 8986 | |
@@ -8857,7 +9144,9 @@ discard block |
||
| 8857 | 9144 | |
| 8858 | 9145 | |
| 8859 | 9146 | // routes |
| 8860 | - if ($globalDebug) print "Routes...\n"; |
|
| 9147 | + if ($globalDebug) { |
|
| 9148 | + print "Routes...\n"; |
|
| 9149 | + } |
|
| 8861 | 9150 | if ($globalDBdriver == 'mysql') { |
| 8862 | 9151 | $query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)"; |
| 8863 | 9152 | } elseif ($globalDBdriver == 'pgsql') { |
@@ -8876,7 +9165,9 @@ discard block |
||
| 8876 | 9165 | } |
| 8877 | 9166 | } |
| 8878 | 9167 | |
| 8879 | - if ($globalDebug) print "Airlines...\n"; |
|
| 9168 | + if ($globalDebug) { |
|
| 9169 | + print "Airlines...\n"; |
|
| 9170 | + } |
|
| 8880 | 9171 | //airlines |
| 8881 | 9172 | if ($globalDBdriver == 'mysql') { |
| 8882 | 9173 | $query = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)"; |
@@ -8898,13 +9189,17 @@ discard block |
||
| 8898 | 9189 | } |
| 8899 | 9190 | } |
| 8900 | 9191 | |
| 8901 | - if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n"; |
|
| 9192 | + if ($globalDebug) { |
|
| 9193 | + print "Remove Duplicate in aircraft_modes...\n"; |
|
| 9194 | + } |
|
| 8902 | 9195 | //duplicate modes |
| 8903 | 9196 | $query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL"; |
| 8904 | 9197 | $sth = $this->db->prepare($query); |
| 8905 | 9198 | $sth->execute(); |
| 8906 | 9199 | |
| 8907 | - if ($globalDebug) print "Aircraft...\n"; |
|
| 9200 | + if ($globalDebug) { |
|
| 9201 | + print "Aircraft...\n"; |
|
| 9202 | + } |
|
| 8908 | 9203 | //aircraft |
| 8909 | 9204 | if ($globalDBdriver == 'mysql') { |
| 8910 | 9205 | $query = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -8947,26 +9242,38 @@ discard block |
||
| 8947 | 9242 | if (isset($closestAirports[0])) { |
| 8948 | 9243 | if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) { |
| 8949 | 9244 | $airport_icao = $closestAirports[0]['icao']; |
| 8950 | - if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 9245 | + if ($globalDebug) { |
|
| 9246 | + echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 9247 | + } |
|
| 8951 | 9248 | } elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') { |
| 8952 | 9249 | foreach ($closestAirports as $airport) { |
| 8953 | 9250 | if ($row['arrival_airport_icao'] == $airport['icao']) { |
| 8954 | 9251 | $airport_icao = $airport['icao']; |
| 8955 | - if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 9252 | + if ($globalDebug) { |
|
| 9253 | + echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 9254 | + } |
|
| 8956 | 9255 | break; |
| 8957 | 9256 | } |
| 8958 | 9257 | } |
| 8959 | 9258 | } elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) { |
| 8960 | 9259 | $airport_icao = $closestAirports[0]['icao']; |
| 8961 | - if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." ! Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
| 9260 | + if ($globalDebug) { |
|
| 9261 | + echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." ! Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
| 9262 | + } |
|
| 8962 | 9263 | } else { |
| 8963 | - if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
| 9264 | + if ($globalDebug) { |
|
| 9265 | + echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
| 9266 | + } |
|
| 8964 | 9267 | } |
| 8965 | 9268 | } else { |
| 8966 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 9269 | + if ($globalDebug) { |
|
| 9270 | + echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 9271 | + } |
|
| 8967 | 9272 | } |
| 8968 | 9273 | if ($row['real_arrival_airport_icao'] != $airport_icao) { |
| 8969 | - if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n"; |
|
| 9274 | + if ($globalDebug) { |
|
| 9275 | + echo "Updating airport to ".$airport_icao."...\n"; |
|
| 9276 | + } |
|
| 8970 | 9277 | $update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id"; |
| 8971 | 9278 | $sthu = $this->db->prepare($update_query); |
| 8972 | 9279 | $sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id'])); |
@@ -27,7 +27,9 @@ |
||
| 27 | 27 | $info = str_replace('^','<br />',$info); |
| 28 | 28 | $info = str_replace('&sect;','',$info); |
| 29 | 29 | $info = str_replace('"','',$info); |
| 30 | - if ($type == '') $type = NULL; |
|
| 30 | + if ($type == '') { |
|
| 31 | + $type = NULL; |
|
| 32 | + } |
|
| 31 | 33 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name)"; |
| 32 | 34 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type); |
| 33 | 35 | try { |
@@ -62,7 +62,9 @@ discard block |
||
| 62 | 62 | if ($Schedule->checkSchedule($operator) == 0) { |
| 63 | 63 | $schedule = $Schedule->fetchSchedule($operator); |
| 64 | 64 | if (count($schedule) > 0) { |
| 65 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 65 | + if ($globalDebug) { |
|
| 66 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 67 | + } |
|
| 66 | 68 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
| 67 | 69 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
| 68 | 70 | // FIXME : Check if route schedule = route from DB |
@@ -71,7 +73,9 @@ discard block |
||
| 71 | 73 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
| 72 | 74 | if ($airport_icao != '') { |
| 73 | 75 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 74 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 76 | + if ($globalDebug) { |
|
| 77 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 78 | + } |
|
| 75 | 79 | } |
| 76 | 80 | } |
| 77 | 81 | } |
@@ -80,7 +84,9 @@ discard block |
||
| 80 | 84 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
| 81 | 85 | if ($airport_icao != '') { |
| 82 | 86 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 83 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 87 | + if ($globalDebug) { |
|
| 88 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 89 | + } |
|
| 84 | 90 | } |
| 85 | 91 | } |
| 86 | 92 | } |
@@ -108,7 +114,9 @@ discard block |
||
| 108 | 114 | |
| 109 | 115 | public function checkAll() { |
| 110 | 116 | global $globalDebug; |
| 111 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
| 117 | + if ($globalDebug) { |
|
| 118 | + echo "Update last seen flights data...\n"; |
|
| 119 | + } |
|
| 112 | 120 | foreach ($this->all_flights as $key => $flight) { |
| 113 | 121 | if (isset($this->all_flights[$key]['id'])) { |
| 114 | 122 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
@@ -124,20 +132,26 @@ discard block |
||
| 124 | 132 | $Spotter = new Spotter($this->db); |
| 125 | 133 | $airport_icao = ''; |
| 126 | 134 | $airport_time = ''; |
| 127 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 135 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
| 136 | + $globalClosestMinDist = 50; |
|
| 137 | + } |
|
| 128 | 138 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 129 | 139 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
| 130 | 140 | if (isset($closestAirports[0])) { |
| 131 | 141 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 132 | 142 | $airport_icao = $closestAirports[0]['icao']; |
| 133 | 143 | $airport_time = $this->all_flights[$key]['datetime']; |
| 134 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 144 | + if ($globalDebug) { |
|
| 145 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 146 | + } |
|
| 135 | 147 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
| 136 | 148 | foreach ($closestAirports as $airport) { |
| 137 | 149 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
| 138 | 150 | $airport_icao = $airport['icao']; |
| 139 | 151 | $airport_time = $this->all_flights[$key]['datetime']; |
| 140 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 152 | + if ($globalDebug) { |
|
| 153 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 154 | + } |
|
| 141 | 155 | break; |
| 142 | 156 | } |
| 143 | 157 | } |
@@ -145,14 +159,20 @@ discard block |
||
| 145 | 159 | $airport_icao = $closestAirports[0]['icao']; |
| 146 | 160 | $airport_time = $this->all_flights[$key]['datetime']; |
| 147 | 161 | } else { |
| 148 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 162 | + if ($globalDebug) { |
|
| 163 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 164 | + } |
|
| 149 | 165 | } |
| 150 | 166 | } else { |
| 151 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 167 | + if ($globalDebug) { |
|
| 168 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 169 | + } |
|
| 152 | 170 | } |
| 153 | 171 | |
| 154 | 172 | } else { |
| 155 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 173 | + if ($globalDebug) { |
|
| 174 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 175 | + } |
|
| 156 | 176 | } |
| 157 | 177 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
| 158 | 178 | } |
@@ -166,7 +186,9 @@ discard block |
||
| 166 | 186 | if (isset($flight['lastupdate'])) { |
| 167 | 187 | if ($flight['lastupdate'] < (time()-3000)) { |
| 168 | 188 | if (isset($this->all_flights[$key]['id'])) { |
| 169 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 189 | + if ($globalDebug) { |
|
| 190 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 191 | + } |
|
| 170 | 192 | /* |
| 171 | 193 | $SpotterLive = new SpotterLive(); |
| 172 | 194 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
@@ -177,7 +199,9 @@ discard block |
||
| 177 | 199 | $Spotter = new Spotter($this->db); |
| 178 | 200 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 179 | 201 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
| 180 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 202 | + if ($globalDebug && $result != 'success') { |
|
| 203 | + echo '!!! ERROR : '.$result."\n"; |
|
| 204 | + } |
|
| 181 | 205 | } |
| 182 | 206 | // Put in archive |
| 183 | 207 | // $Spotter->db = null; |
@@ -191,8 +215,10 @@ discard block |
||
| 191 | 215 | function add($line) { |
| 192 | 216 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBSupdate, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta; |
| 193 | 217 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 194 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 195 | -/* |
|
| 218 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 219 | + $globalCoordMinChange = '0.02'; |
|
| 220 | + } |
|
| 221 | + /* |
|
| 196 | 222 | $Spotter = new Spotter(); |
| 197 | 223 | $dbc = $Spotter->db; |
| 198 | 224 | $SpotterLive = new SpotterLive($dbc); |
@@ -220,11 +246,15 @@ discard block |
||
| 220 | 246 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 221 | 247 | $current_date = date('Y-m-d'); |
| 222 | 248 | $source = $line['source_name']; |
| 223 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 249 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 250 | + $source = $line['format_source']; |
|
| 251 | + } |
|
| 224 | 252 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 225 | 253 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 226 | 254 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 227 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 255 | + } else { |
|
| 256 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 257 | + } |
|
| 228 | 258 | } |
| 229 | 259 | |
| 230 | 260 | /* |
@@ -255,35 +285,55 @@ discard block |
||
| 255 | 285 | $Spotter = new Spotter($this->db); |
| 256 | 286 | $aircraft_icao = $Spotter->getAllAircraftType($hex); |
| 257 | 287 | $Spotter->db = null; |
| 258 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 288 | + if ($globalDebugTimeElapsed) { |
|
| 289 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 290 | + } |
|
| 259 | 291 | |
| 260 | 292 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
| 261 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
| 262 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
| 263 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
| 264 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
| 293 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
| 294 | + $aircraft_icao = 'GLID'; |
|
| 295 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
| 296 | + $aircraft_icao = 'UHEL'; |
|
| 297 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
| 298 | + $aircraft_icao = 'TOWPLANE'; |
|
| 299 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
| 300 | + $aircraft_icao = 'POWAIRC'; |
|
| 301 | + } |
|
| 265 | 302 | } |
| 266 | 303 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
| 267 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
| 304 | + } else { |
|
| 305 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
| 306 | + } |
|
| 268 | 307 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => false)); |
| 269 | 308 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
| 270 | 309 | if (!isset($line['id'])) { |
| 271 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 272 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
| 310 | + if (!isset($globalDaemon)) { |
|
| 311 | + $globalDaemon = TRUE; |
|
| 312 | + } |
|
| 313 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
| 273 | 314 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 274 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 315 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
|
| 316 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 317 | + } |
|
| 275 | 318 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 276 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 319 | + } else { |
|
| 320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 321 | + } |
|
| 277 | 322 | |
| 278 | - if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
| 323 | + if ($globalDebug) { |
|
| 324 | + echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
| 325 | + } |
|
| 279 | 326 | } |
| 280 | 327 | |
| 281 | 328 | if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 282 | 329 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 283 | 330 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 284 | 331 | } else { |
| 285 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 286 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 332 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 333 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 334 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 335 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 336 | + } |
|
| 287 | 337 | /* |
| 288 | 338 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
| 289 | 339 | print_r($this->all_flights[$id]); |
@@ -291,7 +341,9 @@ discard block |
||
| 291 | 341 | */ |
| 292 | 342 | return ''; |
| 293 | 343 | } |
| 294 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 344 | + } else { |
|
| 345 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 346 | + } |
|
| 295 | 347 | |
| 296 | 348 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
| 297 | 349 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
@@ -312,9 +364,13 @@ discard block |
||
| 312 | 364 | $timeelapsed = microtime(true); |
| 313 | 365 | $Spotter = new Spotter($this->db); |
| 314 | 366 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident']); |
| 315 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 367 | + if ($globalDebug && $result != 'success') { |
|
| 368 | + echo '!!! ERROR : '.$result."\n"; |
|
| 369 | + } |
|
| 316 | 370 | $Spotter->db = null; |
| 317 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 371 | + if ($globalDebugTimeElapsed) { |
|
| 372 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 373 | + } |
|
| 318 | 374 | } |
| 319 | 375 | |
| 320 | 376 | /* |
@@ -325,7 +381,9 @@ discard block |
||
| 325 | 381 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 326 | 382 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 327 | 383 | */ |
| 328 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 384 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 385 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 386 | + } |
|
| 329 | 387 | |
| 330 | 388 | //$putinarchive = true; |
| 331 | 389 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -342,7 +400,9 @@ discard block |
||
| 342 | 400 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 343 | 401 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 344 | 402 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
| 345 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 403 | + if ($globalDebugTimeElapsed) { |
|
| 404 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 405 | + } |
|
| 346 | 406 | |
| 347 | 407 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 348 | 408 | $timeelapsed = microtime(true); |
@@ -355,7 +415,9 @@ discard block |
||
| 355 | 415 | $Translation->db = null; |
| 356 | 416 | } |
| 357 | 417 | $Spotter->db = null; |
| 358 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 418 | + if ($globalDebugTimeElapsed) { |
|
| 419 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 420 | + } |
|
| 359 | 421 | |
| 360 | 422 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 361 | 423 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -364,7 +426,9 @@ discard block |
||
| 364 | 426 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
| 365 | 427 | } |
| 366 | 428 | } |
| 367 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
| 429 | + if (!isset($globalFork)) { |
|
| 430 | + $globalFork = TRUE; |
|
| 431 | + } |
|
| 368 | 432 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 369 | 433 | /* |
| 370 | 434 | if (function_exists('pcntl_fork') && $globalFork) { |
@@ -394,16 +458,23 @@ discard block |
||
| 394 | 458 | // use datetime |
| 395 | 459 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 396 | 460 | $speed = $speed*3.6; |
| 397 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 398 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 461 | + if ($speed < 1000) { |
|
| 462 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 463 | + } |
|
| 464 | + if ($globalDebug) { |
|
| 465 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 466 | + } |
|
| 399 | 467 | } |
| 400 | 468 | } |
| 401 | 469 | |
| 402 | 470 | |
| 403 | 471 | |
| 404 | 472 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') { |
| 405 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 406 | - else unset($timediff); |
|
| 473 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
| 474 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 475 | + } else { |
|
| 476 | + unset($timediff); |
|
| 477 | + } |
|
| 407 | 478 | if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
| 408 | 479 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
| 409 | 480 | if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -416,9 +487,13 @@ discard block |
||
| 416 | 487 | $timeelapsed = microtime(true); |
| 417 | 488 | $Spotter = new Spotter($this->db); |
| 418 | 489 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 419 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 490 | + if (!empty($all_country)) { |
|
| 491 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 492 | + } |
|
| 420 | 493 | $Spotter->db = null; |
| 421 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 494 | + if ($globalDebugTimeElapsed) { |
|
| 495 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 496 | + } |
|
| 422 | 497 | $this->tmd = 0; |
| 423 | 498 | //echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 424 | 499 | //$putinarchive = true; |
@@ -432,7 +507,9 @@ discard block |
||
| 432 | 507 | |
| 433 | 508 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 434 | 509 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
| 435 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
| 510 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
| 511 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
| 512 | + } |
|
| 436 | 513 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
| 437 | 514 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
| 438 | 515 | $dataFound = true; |
@@ -454,9 +531,13 @@ discard block |
||
| 454 | 531 | */ |
| 455 | 532 | } |
| 456 | 533 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 457 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 534 | + if ($line['longitude'] > 180) { |
|
| 535 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 536 | + } |
|
| 458 | 537 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
| 459 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
| 538 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
| 539 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
| 540 | + } |
|
| 460 | 541 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
| 461 | 542 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
| 462 | 543 | $dataFound = true; |
@@ -505,11 +586,17 @@ discard block |
||
| 505 | 586 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 506 | 587 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 507 | 588 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 508 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
| 509 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 510 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 589 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) { |
|
| 590 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
| 591 | + } elseif (isset($line['id'])) { |
|
| 592 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 593 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 594 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 595 | + } |
|
| 596 | + } |
|
| 597 | + if ($line['ground'] != 1) { |
|
| 598 | + $line['ground'] = 0; |
|
| 511 | 599 | } |
| 512 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 513 | 600 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
| 514 | 601 | //$dataFound = true; |
| 515 | 602 | } |
@@ -517,28 +604,40 @@ discard block |
||
| 517 | 604 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
| 518 | 605 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
| 519 | 606 | $highlight = ''; |
| 520 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 521 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 522 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 607 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 608 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 609 | + } |
|
| 610 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 611 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 612 | + } |
|
| 613 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 614 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 615 | + } |
|
| 523 | 616 | if ($highlight != '') { |
| 524 | 617 | $timeelapsed = microtime(true); |
| 525 | 618 | $Spotter = new Spotter($this->db); |
| 526 | 619 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
| 527 | 620 | $Spotter->db = null; |
| 528 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 621 | + if ($globalDebugTimeElapsed) { |
|
| 622 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 623 | + } |
|
| 529 | 624 | |
| 530 | 625 | $this->all_flights[$id]['putinarchive'] = true; |
| 531 | 626 | //$putinarchive = true; |
| 532 | 627 | $highlight = ''; |
| 533 | 628 | } |
| 534 | 629 | |
| 535 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 630 | + } else { |
|
| 631 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 632 | + } |
|
| 536 | 633 | //$dataFound = true; |
| 537 | 634 | } |
| 538 | 635 | |
| 539 | 636 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 540 | 637 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 541 | - if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
| 638 | + if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) { |
|
| 639 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 640 | + } |
|
| 542 | 641 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 543 | 642 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 544 | 643 | //$dataFound = true; |
@@ -550,21 +649,30 @@ discard block |
||
| 550 | 649 | } |
| 551 | 650 | |
| 552 | 651 | if (isset($line['heading']) && $line['heading'] != '') { |
| 553 | - if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
| 652 | + if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) { |
|
| 653 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 654 | + } |
|
| 554 | 655 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
| 555 | 656 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
| 556 | 657 | //$dataFound = true; |
| 557 | 658 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 558 | 659 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 559 | 660 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
| 560 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
| 561 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 661 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) { |
|
| 662 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 663 | + } |
|
| 664 | + if ($globalDebug) { |
|
| 665 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 666 | + } |
|
| 562 | 667 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 563 | 668 | // If not enough messages and ACARS set heading to 0 |
| 564 | 669 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
| 565 | 670 | } |
| 566 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 567 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 671 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
| 672 | + $dataFound = false; |
|
| 673 | + } elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
| 674 | + $dataFound = false; |
|
| 675 | + } |
|
| 568 | 676 | |
| 569 | 677 | // print_r($this->all_flights[$id]); |
| 570 | 678 | //gets the callsign from the last hour |
@@ -578,22 +686,33 @@ discard block |
||
| 578 | 686 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
| 579 | 687 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
| 580 | 688 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
| 581 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 689 | + if ($globalDebug) { |
|
| 690 | + echo "Check if aircraft is already in DB..."; |
|
| 691 | + } |
|
| 582 | 692 | $timeelapsed = microtime(true); |
| 583 | 693 | $SpotterLive = new SpotterLive($this->db); |
| 584 | 694 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
| 585 | 695 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 586 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 696 | + if ($globalDebugTimeElapsed) { |
|
| 697 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 698 | + } |
|
| 587 | 699 | |
| 588 | 700 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 589 | 701 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 590 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 702 | + if ($globalDebugTimeElapsed) { |
|
| 703 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 704 | + } |
|
| 591 | 705 | |
| 592 | - } else $recent_ident = ''; |
|
| 706 | + } else { |
|
| 707 | + $recent_ident = ''; |
|
| 708 | + } |
|
| 593 | 709 | $SpotterLive->db=null; |
| 594 | 710 | |
| 595 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 596 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 711 | + if ($globalDebug && $recent_ident == '') { |
|
| 712 | + echo " Not in DB.\n"; |
|
| 713 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 714 | + echo " Already in DB.\n"; |
|
| 715 | + } |
|
| 597 | 716 | } else { |
| 598 | 717 | $recent_ident = ''; |
| 599 | 718 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -601,7 +720,9 @@ discard block |
||
| 601 | 720 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 602 | 721 | if($recent_ident == "") |
| 603 | 722 | { |
| 604 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 723 | + if ($globalDebug) { |
|
| 724 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 725 | + } |
|
| 605 | 726 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 606 | 727 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 607 | 728 | //adds the spotter data for the archive |
@@ -645,26 +766,44 @@ discard block |
||
| 645 | 766 | |
| 646 | 767 | if (!$ignoreImport) { |
| 647 | 768 | $highlight = ''; |
| 648 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 649 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 650 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 651 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 769 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 770 | + $highlight = 'Squawk 7500 : Hijack'; |
|
| 771 | + } |
|
| 772 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 773 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 774 | + } |
|
| 775 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 776 | + $highlight = 'Squawk 7700 : Emergency'; |
|
| 777 | + } |
|
| 778 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 779 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 780 | + } |
|
| 652 | 781 | $timeelapsed = microtime(true); |
| 653 | 782 | $Spotter = new Spotter($this->db); |
| 654 | 783 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
| 655 | 784 | $Spotter->db = null; |
| 656 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 657 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 785 | + if ($globalDebug && isset($result)) { |
|
| 786 | + echo $result."\n"; |
|
| 787 | + } |
|
| 788 | + if ($globalDebugTimeElapsed) { |
|
| 789 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 790 | + } |
|
| 658 | 791 | |
| 659 | 792 | // Add source stat in DB |
| 660 | 793 | $Stats = new Stats($this->db); |
| 661 | 794 | if (!empty($this->stats)) { |
| 662 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 795 | + if ($globalDebug) { |
|
| 796 | + echo 'Add source stats : '; |
|
| 797 | + } |
|
| 663 | 798 | foreach($this->stats as $date => $data) { |
| 664 | 799 | foreach($data as $source => $sourced) { |
| 665 | 800 | //print_r($sourced); |
| 666 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 667 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 801 | + if (isset($sourced['polar'])) { |
|
| 802 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 803 | + } |
|
| 804 | + if (isset($sourced['hist'])) { |
|
| 805 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 806 | + } |
|
| 668 | 807 | if (isset($sourced['msg'])) { |
| 669 | 808 | if (time() - $sourced['msg']['date'] > 10) { |
| 670 | 809 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -677,13 +816,17 @@ discard block |
||
| 677 | 816 | unset($this->stats[$date]); |
| 678 | 817 | } |
| 679 | 818 | } |
| 680 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 819 | + if ($globalDebug) { |
|
| 820 | + echo 'Done'."\n"; |
|
| 821 | + } |
|
| 681 | 822 | |
| 682 | 823 | } |
| 683 | 824 | $Stats->db = null; |
| 684 | 825 | |
| 685 | 826 | $this->del(); |
| 686 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
| 827 | + } elseif ($globalDebug) { |
|
| 828 | + echo 'Ignore data'."\n"; |
|
| 829 | + } |
|
| 687 | 830 | $ignoreImport = false; |
| 688 | 831 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 689 | 832 | //print_r($this->all_flights[$id]); |
@@ -700,12 +843,16 @@ discard block |
||
| 700 | 843 | */ |
| 701 | 844 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 702 | 845 | if ($this->last_delete == '' || time() - $this->last_delete > 1800) { |
| 703 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 846 | + if ($globalDebug) { |
|
| 847 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 848 | + } |
|
| 704 | 849 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 705 | 850 | $SpotterLive = new SpotterLive($this->db); |
| 706 | 851 | $SpotterLive->deleteLiveSpotterData(); |
| 707 | 852 | $SpotterLive->db=null; |
| 708 | - if ($globalDebug) echo " Done\n"; |
|
| 853 | + if ($globalDebug) { |
|
| 854 | + echo " Done\n"; |
|
| 855 | + } |
|
| 709 | 856 | $this->last_delete = time(); |
| 710 | 857 | } |
| 711 | 858 | } else { |
@@ -728,11 +875,17 @@ discard block |
||
| 728 | 875 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
| 729 | 876 | if ($globalDebug) { |
| 730 | 877 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
| 731 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 732 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 878 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 879 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 880 | + } else { |
|
| 881 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 882 | + } |
|
| 733 | 883 | } else { |
| 734 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 735 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 884 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 885 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 886 | + } else { |
|
| 887 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 888 | + } |
|
| 736 | 889 | } |
| 737 | 890 | } |
| 738 | 891 | $ignoreImport = false; |
@@ -778,19 +931,25 @@ discard block |
||
| 778 | 931 | |
| 779 | 932 | if (!$ignoreImport) { |
| 780 | 933 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 781 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 934 | + if ($globalDebug) { |
|
| 935 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 936 | + } |
|
| 782 | 937 | $timeelapsed = microtime(true); |
| 783 | 938 | $SpotterLive = new SpotterLive($this->db); |
| 784 | 939 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 785 | 940 | $SpotterLive->db = null; |
| 786 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 941 | + if ($globalDebugTimeElapsed) { |
|
| 942 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 943 | + } |
|
| 787 | 944 | |
| 788 | 945 | // Put statistics in $this->stats variable |
| 789 | 946 | //if ($line['format_source'] != 'aprs') { |
| 790 | 947 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
| 791 | 948 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs') { |
| 792 | 949 | $source = $this->all_flights[$id]['source_name']; |
| 793 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
| 950 | + if ($source == '') { |
|
| 951 | + $source = $this->all_flights[$id]['format_source']; |
|
| 952 | + } |
|
| 794 | 953 | if (!isset($source_location[$source])) { |
| 795 | 954 | $Location = new Source(); |
| 796 | 955 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -811,7 +970,9 @@ discard block |
||
| 811 | 970 | $stats_heading = round($stats_heading/22.5); |
| 812 | 971 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 813 | 972 | $current_date = date('Y-m-d'); |
| 814 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 973 | + if ($stats_heading == 16) { |
|
| 974 | + $stats_heading = 0; |
|
| 975 | + } |
|
| 815 | 976 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 816 | 977 | for ($i=0;$i<=15;$i++) { |
| 817 | 978 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -829,7 +990,9 @@ discard block |
||
| 829 | 990 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 830 | 991 | end($this->stats[$current_date][$source]['hist']); |
| 831 | 992 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 832 | - } else $mini = 0; |
|
| 993 | + } else { |
|
| 994 | + $mini = 0; |
|
| 995 | + } |
|
| 833 | 996 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 834 | 997 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 835 | 998 | } |
@@ -840,20 +1003,30 @@ discard block |
||
| 840 | 1003 | } |
| 841 | 1004 | |
| 842 | 1005 | $this->all_flights[$id]['lastupdate'] = time(); |
| 843 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
| 1006 | + if ($this->all_flights[$id]['putinarchive']) { |
|
| 1007 | + $send = true; |
|
| 1008 | + } |
|
| 844 | 1009 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 845 | - if ($globalDebug) echo $result."\n"; |
|
| 846 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1010 | + if ($globalDebug) { |
|
| 1011 | + echo $result."\n"; |
|
| 1012 | + } |
|
| 1013 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 1014 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1015 | + } |
|
| 847 | 1016 | //$this->del(); |
| 848 | 1017 | |
| 849 | 1018 | |
| 850 | 1019 | if ($this->last_delete_hourly == '' || time() - $this->last_delete_hourly > 900) { |
| 851 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1020 | + if ($globalDebug) { |
|
| 1021 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1022 | + } |
|
| 852 | 1023 | $SpotterLive = new SpotterLive($this->db); |
| 853 | 1024 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 854 | 1025 | $SpotterLive->db = null; |
| 855 | 1026 | //SpotterLive->deleteLiveSpotterData(); |
| 856 | - if ($globalDebug) echo " Done\n"; |
|
| 1027 | + if ($globalDebug) { |
|
| 1028 | + echo " Done\n"; |
|
| 1029 | + } |
|
| 857 | 1030 | $this->last_delete_hourly = time(); |
| 858 | 1031 | } |
| 859 | 1032 | |
@@ -861,7 +1034,9 @@ discard block |
||
| 861 | 1034 | $ignoreImport = false; |
| 862 | 1035 | } |
| 863 | 1036 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 864 | - if ($send) return $this->all_flights[$id]; |
|
| 1037 | + if ($send) { |
|
| 1038 | + return $this->all_flights[$id]; |
|
| 1039 | + } |
|
| 865 | 1040 | } |
| 866 | 1041 | } |
| 867 | 1042 | } |
@@ -36,81 +36,128 @@ |
||
| 36 | 36 | $data['hex'] = trim($line['hex']); |
| 37 | 37 | if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 38 | 38 | $data['datetime'] = $line['datetime']; |
| 39 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 39 | + } else { |
|
| 40 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 41 | + } |
|
| 40 | 42 | if (!isset($line['aircraft_icao'])) { |
| 41 | 43 | $Spotter = new Spotter(); |
| 42 | 44 | $aircraft_icao = $Spotter->getAllAircraftType($data['hex']); |
| 43 | 45 | $Spotter->db = null; |
| 44 | 46 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
| 45 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
| 46 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
| 47 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
| 48 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
| 47 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
| 48 | + $aircraft_icao = 'GLID'; |
|
| 49 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
| 50 | + $aircraft_icao = 'UHEL'; |
|
| 51 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
| 52 | + $aircraft_icao = 'TOWPLANE'; |
|
| 53 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
| 54 | + $aircraft_icao = 'POWAIRC'; |
|
| 55 | + } |
|
| 49 | 56 | } |
| 50 | 57 | $data['aircraft_icao'] = $aircraft_icao; |
| 51 | - } else $data['aircraft_icao'] = $line['aircraft_icao']; |
|
| 58 | + } else { |
|
| 59 | + $data['aircraft_icao'] = $line['aircraft_icao']; |
|
| 60 | + } |
|
| 52 | 61 | //if ($globalDebug) echo "*********** New aircraft hex : ".$data['hex']." ***********\n"; |
| 53 | 62 | } |
| 54 | 63 | if (isset($line['registration']) && $line['registration'] != '') { |
| 55 | 64 | $data['registration'] = $line['registration']; |
| 56 | - } else $data['registration'] = null; |
|
| 65 | + } else { |
|
| 66 | + $data['registration'] = null; |
|
| 67 | + } |
|
| 57 | 68 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 58 | 69 | $data['waypoints'] = $line['waypoints']; |
| 59 | - } else $data['waypoints'] = null; |
|
| 70 | + } else { |
|
| 71 | + $data['waypoints'] = null; |
|
| 72 | + } |
|
| 60 | 73 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
| 61 | 74 | $data['ident'] = trim($line['ident']); |
| 62 | - } else $data['ident'] = null; |
|
| 75 | + } else { |
|
| 76 | + $data['ident'] = null; |
|
| 77 | + } |
|
| 63 | 78 | |
| 64 | 79 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') { |
| 65 | 80 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 66 | 81 | $data['latitude'] = $line['latitude']; |
| 67 | - } else $data['latitude'] = null; |
|
| 82 | + } else { |
|
| 83 | + $data['latitude'] = null; |
|
| 84 | + } |
|
| 68 | 85 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 69 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 86 | + if ($line['longitude'] > 180) { |
|
| 87 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 88 | + } |
|
| 70 | 89 | $data['longitude'] = $line['longitude']; |
| 71 | - } else $data['longitude'] = null; |
|
| 90 | + } else { |
|
| 91 | + $data['longitude'] = null; |
|
| 92 | + } |
|
| 72 | 93 | } else { |
| 73 | 94 | $data['latitude'] = null; |
| 74 | 95 | $data['longitude'] = null; |
| 75 | 96 | } |
| 76 | 97 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 77 | 98 | $data['verticalrate'] = $line['verticalrate']; |
| 78 | - } else $data['verticalrate'] = null; |
|
| 99 | + } else { |
|
| 100 | + $data['verticalrate'] = null; |
|
| 101 | + } |
|
| 79 | 102 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 80 | 103 | $data['emergency'] = $line['emergency']; |
| 81 | - } else $data['emergency'] = null; |
|
| 104 | + } else { |
|
| 105 | + $data['emergency'] = null; |
|
| 106 | + } |
|
| 82 | 107 | if (isset($line['ground']) && $line['ground'] != '') { |
| 83 | 108 | $data['ground'] = $line['ground']; |
| 84 | - } else $data['ground'] = null; |
|
| 109 | + } else { |
|
| 110 | + $data['ground'] = null; |
|
| 111 | + } |
|
| 85 | 112 | if (isset($line['speed']) && $line['speed'] != '') { |
| 86 | 113 | $data['speed'] = round($line['speed']); |
| 87 | - } else $data['speed'] = null; |
|
| 114 | + } else { |
|
| 115 | + $data['speed'] = null; |
|
| 116 | + } |
|
| 88 | 117 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 89 | 118 | $data['squawk'] = $line['squawk']; |
| 90 | - } else $data['squawk'] = null; |
|
| 119 | + } else { |
|
| 120 | + $data['squawk'] = null; |
|
| 121 | + } |
|
| 91 | 122 | |
| 92 | 123 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 93 | 124 | $data['altitude'] = round($line['altitude']); |
| 94 | - } else $data['altitude'] = null; |
|
| 125 | + } else { |
|
| 126 | + $data['altitude'] = null; |
|
| 127 | + } |
|
| 95 | 128 | if (isset($line['heading']) && $line['heading'] != '') { |
| 96 | 129 | $data['heading'] = round($line['heading']); |
| 97 | - } else $data['heading'] = null; |
|
| 130 | + } else { |
|
| 131 | + $data['heading'] = null; |
|
| 132 | + } |
|
| 98 | 133 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 99 | 134 | $data['source_name'] = $line['source_name']; |
| 100 | - } else $data['source_name'] = null; |
|
| 135 | + } else { |
|
| 136 | + $data['source_name'] = null; |
|
| 137 | + } |
|
| 101 | 138 | if (isset($line['over_country']) && $line['over_country'] != '') { |
| 102 | 139 | $data['over_country'] = $line['over_country']; |
| 103 | - } else $data['over_country'] = null; |
|
| 140 | + } else { |
|
| 141 | + $data['over_country'] = null; |
|
| 142 | + } |
|
| 104 | 143 | if (isset($line['noarchive']) && $line['noarchive']) { |
| 105 | 144 | $data['noarchive'] = true; |
| 106 | - } else $data['noarchive'] = false; |
|
| 145 | + } else { |
|
| 146 | + $data['noarchive'] = false; |
|
| 147 | + } |
|
| 107 | 148 | $data['format_source'] = $line['format_source']; |
| 108 | - if (isset($line['id_source'])) $id_source = $line['id_source']; |
|
| 149 | + if (isset($line['id_source'])) { |
|
| 150 | + $id_source = $line['id_source']; |
|
| 151 | + } |
|
| 109 | 152 | if (isset($data['hex'])) { |
| 110 | 153 | echo '.'; |
| 111 | 154 | $id_user = $globalServerUserID; |
| 112 | - if ($id_user == NULL) $id_user = 1; |
|
| 113 | - if (!isset($id_source)) $id_source = 1; |
|
| 155 | + if ($id_user == NULL) { |
|
| 156 | + $id_user = 1; |
|
| 157 | + } |
|
| 158 | + if (!isset($id_source)) { |
|
| 159 | + $id_source = 1; |
|
| 160 | + } |
|
| 114 | 161 | $query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)'; |
| 115 | 162 | $query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']); |
| 116 | 163 | try { |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | $limit_start = 0; |
| 14 | 14 | $limit_end = 25; |
| 15 | 15 | $absolute_difference = 25; |
| 16 | - } else { |
|
| 16 | + } else { |
|
| 17 | 17 | $limit_explode = explode(",", $_GET['limit']); |
| 18 | 18 | $limit_start = $limit_explode[0]; |
| 19 | 19 | $limit_end = $limit_explode[1]; |
@@ -37,7 +37,9 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | if (isset($spotter_array[0]['airline_name']) && isset($spotter_array[0]['airline_icao'])) { |
| 39 | 39 | $title = sprintf(_("Detailed View for %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']); |
| 40 | - } else $title = ''; |
|
| 40 | + } else { |
|
| 41 | + $title = ''; |
|
| 42 | + } |
|
| 41 | 43 | require_once('header.php'); |
| 42 | 44 | |
| 43 | 45 | print '<div class="select-item">'; |
@@ -73,8 +75,12 @@ discard block |
||
| 73 | 75 | print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['airline_name'].'</div>'; |
| 74 | 76 | print '<div><span class="label">'._("Country").'</span>'.$spotter_array[0]['airline_country'].'</div>'; |
| 75 | 77 | print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['airline_icao'].'</div>'; |
| 76 | - if (isset($spotter_array[0]['airline_iata'])) print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>'; |
|
| 77 | - if (isset($spotter_array[0]['airline_callsign'])) print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>'; |
|
| 78 | + if (isset($spotter_array[0]['airline_iata'])) { |
|
| 79 | + print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>'; |
|
| 80 | + } |
|
| 81 | + if (isset($spotter_array[0]['airline_callsign'])) { |
|
| 82 | + print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>'; |
|
| 83 | + } |
|
| 78 | 84 | print '<div><span class="label">'._("Type").'</span>'.ucwords($spotter_array[0]['airline_type']).'</div>'; |
| 79 | 85 | print '</div>'; |
| 80 | 86 | } else { |
@@ -54,7 +54,9 @@ |
||
| 54 | 54 | $radius = $spotter_item['radius']*1852; |
| 55 | 55 | $output .= '"radiusm": "'.$radius.'",'; |
| 56 | 56 | $output .= '"radiusnm": "'.$spotter_item['radius'].'",'; |
| 57 | - if ($radius > 25000) $radius = 25000; |
|
| 57 | + if ($radius > 25000) { |
|
| 58 | + $radius = 25000; |
|
| 59 | + } |
|
| 58 | 60 | $output .= '"radius": "'.$radius.'"'; |
| 59 | 61 | $output .= '},'; |
| 60 | 62 | $output .= '"geometry": {'; |