@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | date_default_timezone_set('UTC'); |
| 22 | 22 | //waypoint plotting |
| 23 | 23 | $id = $spotter_item['Waypoint']['@attributes']['id']; |
| 24 | - if ($id == 0 || !is_numeric($id)) $id = $j; |
|
| 24 | + if ($id == 0 || !is_numeric($id)) { |
|
| 25 | + $id = $j; |
|
| 26 | + } |
|
| 25 | 27 | $output .= '{"type": "Feature",'; |
| 26 | 28 | $output .= '"id": '.$id.','; |
| 27 | 29 | $output .= '"properties": {'; |
@@ -34,7 +36,9 @@ discard block |
||
| 34 | 36 | $output .= '"icon": "/images/tsk/tsk-start.png"'; |
| 35 | 37 | } elseif ($spotter_item['@attributes']['type'] == 'Finish') { |
| 36 | 38 | $output .= '"icon": "/images/tsk/tsk-finish.png"'; |
| 37 | - } else $output .= '"icon": "/images/tsk/number_'.$id.'.png"'; |
|
| 39 | + } else { |
|
| 40 | + $output .= '"icon": "/images/tsk/number_'.$id.'.png"'; |
|
| 41 | + } |
|
| 38 | 42 | $output .= '},'; |
| 39 | 43 | $output .= '"geometry": {'; |
| 40 | 44 | $output .= '"type": "Point",'; |
@@ -9,7 +9,9 @@ discard block |
||
| 9 | 9 | public function __construct($dbc = null) { |
| 10 | 10 | $Connection = new Connection($dbc); |
| 11 | 11 | $this->db = $Connection->db(); |
| 12 | - if ($this->db === null) die('Error: No DB connection. (Image)'); |
|
| 12 | + if ($this->db === null) { |
|
| 13 | + die('Error: No DB connection. (Image)'); |
|
| 14 | + } |
|
| 13 | 15 | } |
| 14 | 16 | |
| 15 | 17 | /** |
@@ -24,7 +26,9 @@ discard block |
||
| 24 | 26 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
| 25 | 27 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
| 26 | 28 | $reg = $registration; |
| 27 | - if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
|
| 29 | + if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') { |
|
| 30 | + $reg = $aircraft_icao.$airline_icao; |
|
| 31 | + } |
|
| 28 | 32 | $reg = trim($reg); |
| 29 | 33 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
| 30 | 34 | FROM spotter_image |
@@ -32,9 +36,13 @@ discard block |
||
| 32 | 36 | $sth = $this->db->prepare($query); |
| 33 | 37 | $sth->execute(array(':registration' => $reg)); |
| 34 | 38 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 35 | - if (!empty($result)) return $result; |
|
| 36 | - elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 37 | - else return array(); |
|
| 39 | + if (!empty($result)) { |
|
| 40 | + return $result; |
|
| 41 | + } elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) { |
|
| 42 | + return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 43 | + } else { |
|
| 44 | + return array(); |
|
| 45 | + } |
|
| 38 | 46 | } |
| 39 | 47 | |
| 40 | 48 | /** |
@@ -77,8 +85,11 @@ discard block |
||
| 77 | 85 | public function getExifCopyright($url) { |
| 78 | 86 | $exif = exif_read_data($url); |
| 79 | 87 | $copyright = ''; |
| 80 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
| 81 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
| 88 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
| 89 | + $copyright = $exif['COMPUTED']['copyright']; |
|
| 90 | + } elseif (isset($exif['copyright'])) { |
|
| 91 | + $copyright = $exif['copyright']; |
|
| 92 | + } |
|
| 82 | 93 | if ($copyright != '') { |
| 83 | 94 | $copyright = str_replace('Copyright ','',$copyright); |
| 84 | 95 | $copyright = str_replace('© ','',$copyright); |
@@ -96,17 +107,27 @@ discard block |
||
| 96 | 107 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 97 | 108 | { |
| 98 | 109 | global $globalDebug,$globalAircraftImageFetch, $globalOffline; |
| 99 | - if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) return ''; |
|
| 110 | + if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) { |
|
| 111 | + return ''; |
|
| 112 | + } |
|
| 100 | 113 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
| 101 | 114 | $registration = trim($registration); |
| 102 | 115 | //getting the aircraft image |
| 103 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 104 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 105 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 116 | + if ($globalDebug && $registration != '') { |
|
| 117 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 118 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
| 119 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 120 | + } elseif ($globalDebug && $airline_icao != '') { |
|
| 121 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 122 | + } |
|
| 106 | 123 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
| 107 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
| 124 | + if ($registration == '' && $aircraft_icao != '') { |
|
| 125 | + $registration = $aircraft_icao.$airline_icao; |
|
| 126 | + } |
|
| 108 | 127 | if ($image_url['original'] != '') { |
| 109 | - if ($globalDebug) echo 'Found !'."\n"; |
|
| 128 | + if ($globalDebug) { |
|
| 129 | + echo 'Found !'."\n"; |
|
| 130 | + } |
|
| 110 | 131 | $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)"; |
| 111 | 132 | try { |
| 112 | 133 | $sth = $this->db->prepare($query); |
@@ -115,7 +136,9 @@ discard block |
||
| 115 | 136 | echo $e->getMessage()."\n"; |
| 116 | 137 | return "error"; |
| 117 | 138 | } |
| 118 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
| 139 | + } elseif ($globalDebug) { |
|
| 140 | + echo "Not found :'(\n"; |
|
| 141 | + } |
|
| 119 | 142 | return "success"; |
| 120 | 143 | } |
| 121 | 144 | |
@@ -128,7 +151,9 @@ discard block |
||
| 128 | 151 | public function addMarineImage($mmsi,$imo = '',$name = '') |
| 129 | 152 | { |
| 130 | 153 | global $globalDebug,$globalMarineImageFetch, $globalOffline; |
| 131 | - if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) return ''; |
|
| 154 | + if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) { |
|
| 155 | + return ''; |
|
| 156 | + } |
|
| 132 | 157 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
| 133 | 158 | $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 134 | 159 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
@@ -138,16 +163,22 @@ discard block |
||
| 138 | 163 | $identity = $Marine->getIdentity($mmsi); |
| 139 | 164 | if (isset($identity[0]['mmsi'])) { |
| 140 | 165 | $imo = $identity[0]['imo']; |
| 141 | - if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name']; |
|
| 166 | + if ($identity[0]['ship_name'] != '') { |
|
| 167 | + $name = $identity[0]['ship_name']; |
|
| 168 | + } |
|
| 142 | 169 | } |
| 143 | 170 | } |
| 144 | 171 | unset($Marine); |
| 145 | 172 | |
| 146 | 173 | //getting the aircraft image |
| 147 | - if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
|
| 174 | + if ($globalDebug && $name != '') { |
|
| 175 | + echo 'Try to find an vessel image for '.$name.'...'; |
|
| 176 | + } |
|
| 148 | 177 | $image_url = $this->findMarineImage($mmsi,$imo,$name); |
| 149 | 178 | if ($image_url['original'] != '') { |
| 150 | - if ($globalDebug) echo 'Found !'."\n"; |
|
| 179 | + if ($globalDebug) { |
|
| 180 | + echo 'Found !'."\n"; |
|
| 181 | + } |
|
| 151 | 182 | $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
| 152 | 183 | try { |
| 153 | 184 | $sth = $this->db->prepare($query); |
@@ -156,7 +187,9 @@ discard block |
||
| 156 | 187 | echo $e->getMessage()."\n"; |
| 157 | 188 | return "error"; |
| 158 | 189 | } |
| 159 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
| 190 | + } elseif ($globalDebug) { |
|
| 191 | + echo "Not found :'(\n"; |
|
| 192 | + } |
|
| 160 | 193 | return "success"; |
| 161 | 194 | } |
| 162 | 195 | |
@@ -171,41 +204,85 @@ discard block |
||
| 171 | 204 | { |
| 172 | 205 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
| 173 | 206 | $Spotter = new Spotter($this->db); |
| 174 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
| 207 | + if (!isset($globalIVAO)) { |
|
| 208 | + $globalIVAO = FALSE; |
|
| 209 | + } |
|
| 175 | 210 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
| 176 | 211 | if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) { |
| 177 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 212 | + if (strpos($aircraft_registration,'/') !== false) { |
|
| 213 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 214 | + } |
|
| 178 | 215 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 179 | 216 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 180 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 181 | - else $aircraft_name = ''; |
|
| 182 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 183 | - else $aircraft_icao = ''; |
|
| 184 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 185 | - else $airline_icao = ''; |
|
| 217 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
| 218 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 219 | + } else { |
|
| 220 | + $aircraft_name = ''; |
|
| 221 | + } |
|
| 222 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
| 223 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 224 | + } else { |
|
| 225 | + $aircraft_icao = ''; |
|
| 226 | + } |
|
| 227 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
| 228 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 229 | + } else { |
|
| 230 | + $airline_icao = ''; |
|
| 231 | + } |
|
| 186 | 232 | } elseif ($aircraft_icao != '') { |
| 187 | 233 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
| 188 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
| 189 | - else $aircraft_name = ''; |
|
| 234 | + if (isset($aircraft_info[0]['type'])) { |
|
| 235 | + $aircraft_name = $aircraft_info[0]['type']; |
|
| 236 | + } else { |
|
| 237 | + $aircraft_name = ''; |
|
| 238 | + } |
|
| 190 | 239 | $aircraft_registration = $aircraft_icao; |
| 191 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 240 | + } else { |
|
| 241 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 242 | + } |
|
| 192 | 243 | unset($Spotter); |
| 193 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 244 | + if (!isset($globalAircraftImageSources)) { |
|
| 245 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 246 | + } |
|
| 194 | 247 | foreach ($globalAircraftImageSources as $source) { |
| 195 | 248 | $source = strtolower($source); |
| 196 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 197 | - if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 198 | - if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 199 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 200 | - if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 201 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 202 | - if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 203 | - if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 204 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 205 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 206 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 207 | - } |
|
| 208 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
| 249 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
| 250 | + $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 251 | + } |
|
| 252 | + if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) { |
|
| 253 | + $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 254 | + } |
|
| 255 | + if ($source == 'flickr' && extension_loaded('simplexml')) { |
|
| 256 | + $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 257 | + } |
|
| 258 | + if ($source == 'bing') { |
|
| 259 | + $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 260 | + } |
|
| 261 | + if ($source == 'deviantart' && extension_loaded('simplexml')) { |
|
| 262 | + $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 263 | + } |
|
| 264 | + if ($source == 'wikimedia') { |
|
| 265 | + $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 266 | + } |
|
| 267 | + if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) { |
|
| 268 | + $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 269 | + } |
|
| 270 | + if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) { |
|
| 271 | + $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 272 | + } |
|
| 273 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
| 274 | + $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 275 | + } |
|
| 276 | + if ($source == 'customsources') { |
|
| 277 | + $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 278 | + } |
|
| 279 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 280 | + return $images_array; |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
| 284 | + return $this->findAircraftImage($aircraft_icao); |
|
| 285 | + } |
|
| 209 | 286 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 210 | 287 | } |
| 211 | 288 | |
@@ -225,7 +302,9 @@ discard block |
||
| 225 | 302 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 226 | 303 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
| 227 | 304 | $name = trim($name); |
| 228 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 305 | + if (strlen($name) < 4) { |
|
| 306 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 307 | + } |
|
| 229 | 308 | /* |
| 230 | 309 | $Marine = new Marine($this->db); |
| 231 | 310 | if ($imo == '' || $name == '') { |
@@ -237,15 +316,29 @@ discard block |
||
| 237 | 316 | } |
| 238 | 317 | unset($Marine); |
| 239 | 318 | */ |
| 240 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 319 | + if (!isset($globalMarineImageSources)) { |
|
| 320 | + $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 321 | + } |
|
| 241 | 322 | foreach ($globalMarineImageSources as $source) { |
| 242 | 323 | $source = strtolower($source); |
| 243 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 244 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 245 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 246 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 247 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 248 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 324 | + if ($source == 'flickr') { |
|
| 325 | + $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 326 | + } |
|
| 327 | + if ($source == 'bing') { |
|
| 328 | + $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 329 | + } |
|
| 330 | + if ($source == 'deviantart') { |
|
| 331 | + $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 332 | + } |
|
| 333 | + if ($source == 'wikimedia') { |
|
| 334 | + $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 335 | + } |
|
| 336 | + if ($source == 'customsources') { |
|
| 337 | + $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 338 | + } |
|
| 339 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 340 | + return $images_array; |
|
| 341 | + } |
|
| 249 | 342 | } |
| 250 | 343 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 251 | 344 | } |
@@ -268,7 +361,9 @@ discard block |
||
| 268 | 361 | $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
| 269 | 362 | } |
| 270 | 363 | $data = $Common->getData($url); |
| 271 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
| 364 | + if (substr($data, 0, 5) != "<?xml") { |
|
| 365 | + return false; |
|
| 366 | + } |
|
| 272 | 367 | if ($xml = simplexml_load_string($data)) { |
| 273 | 368 | if (isset($xml->channel->item)) { |
| 274 | 369 | $image_url = array(); |
@@ -307,7 +402,9 @@ discard block |
||
| 307 | 402 | $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
| 308 | 403 | } |
| 309 | 404 | $data = $Common->getData($url); |
| 310 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
| 405 | + if (substr($data, 0, 5) != "<?xml") { |
|
| 406 | + return false; |
|
| 407 | + } |
|
| 311 | 408 | if ($xml = simplexml_load_string($data)) { |
| 312 | 409 | if (isset($xml->channel->item->link)) { |
| 313 | 410 | $image_url = array(); |
@@ -411,14 +508,22 @@ discard block |
||
| 411 | 508 | public function fromFlickr($type,$registration,$name='') { |
| 412 | 509 | $Common = new Common(); |
| 413 | 510 | if ($type == 'aircraft') { |
| 414 | - if ($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='.$registration.','.urlencode($name); |
|
| 415 | - 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='.$registration.',aircraft'; |
|
| 511 | + if ($name != '') { |
|
| 512 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
| 513 | + } else { |
|
| 514 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
| 515 | + } |
|
| 416 | 516 | } elseif ($type == 'marine') { |
| 417 | - if ($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=ship,'.urlencode($name); |
|
| 418 | - 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='.$registration.',ship'; |
|
| 517 | + if ($name != '') { |
|
| 518 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
| 519 | + } else { |
|
| 520 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
| 521 | + } |
|
| 419 | 522 | } |
| 420 | 523 | $data = $Common->getData($url); |
| 421 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
| 524 | + if (substr($data, 0, 5) != "<?xml") { |
|
| 525 | + return false; |
|
| 526 | + } |
|
| 422 | 527 | if ($xml = simplexml_load_string($data)) { |
| 423 | 528 | if (isset($xml->channel->item)) { |
| 424 | 529 | $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
@@ -461,13 +566,21 @@ discard block |
||
| 461 | 566 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
| 462 | 567 | global $globalImageBingKey; |
| 463 | 568 | $Common = new Common(); |
| 464 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
| 569 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
| 570 | + return false; |
|
| 571 | + } |
|
| 465 | 572 | if ($type == 'aircraft') { |
| 466 | - 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'; |
|
| 467 | - 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'; |
|
| 573 | + if ($aircraft_name != '') { |
|
| 574 | + $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'; |
|
| 575 | + } else { |
|
| 576 | + $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'; |
|
| 577 | + } |
|
| 468 | 578 | } elseif ($type == 'marine') { |
| 469 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
| 470 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
| 579 | + if ($aircraft_name != '') { |
|
| 580 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
| 581 | + } else { |
|
| 582 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
| 583 | + } |
|
| 471 | 584 | } |
| 472 | 585 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
| 473 | 586 | $data = $Common->getData($url,'get','',$headers); |
@@ -523,17 +636,25 @@ discard block |
||
| 523 | 636 | public function fromWikimedia($type,$registration,$name='') { |
| 524 | 637 | $Common = new Common(); |
| 525 | 638 | if ($type == 'aircraft') { |
| 526 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
| 527 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
| 639 | + if ($name != '') { |
|
| 640 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
| 641 | + } else { |
|
| 642 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
| 643 | + } |
|
| 528 | 644 | } elseif ($type == 'marine') { |
| 529 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
| 530 | - else return false; |
|
| 645 | + if ($name != '') { |
|
| 646 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
| 647 | + } else { |
|
| 648 | + return false; |
|
| 649 | + } |
|
| 531 | 650 | } |
| 532 | 651 | $data = $Common->getData($url); |
| 533 | 652 | $result = json_decode($data); |
| 534 | 653 | if (isset($result->query->search[0]->title)) { |
| 535 | 654 | $fileo = $result->query->search[0]->title; |
| 536 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 655 | + if (substr($fileo,-3) == 'pdf') { |
|
| 656 | + return false; |
|
| 657 | + } |
|
| 537 | 658 | $file = urlencode($fileo); |
| 538 | 659 | $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; |
| 539 | 660 | $data2 = $Common->getData($url2); |
@@ -604,18 +725,27 @@ discard block |
||
| 604 | 725 | $image_url = array(); |
| 605 | 726 | $image_url['thumbnail'] = $url_thumbnail; |
| 606 | 727 | $image_url['original'] = $url; |
| 607 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 608 | - else $exifCopyright = ''; |
|
| 609 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 610 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
| 611 | - else $image_url['copyright'] = $source['source_website']; |
|
| 728 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 729 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 730 | + } else { |
|
| 731 | + $exifCopyright = ''; |
|
| 732 | + } |
|
| 733 | + if ($exifCopyright != '') { |
|
| 734 | + $image_url['copyright'] = $exifCopyright; |
|
| 735 | + } elseif (isset($source['copyright'])) { |
|
| 736 | + $image_url['copyright'] = $source['copyright']; |
|
| 737 | + } else { |
|
| 738 | + $image_url['copyright'] = $source['source_website']; |
|
| 739 | + } |
|
| 612 | 740 | $image_url['source_website'] = $source['source_website']; |
| 613 | 741 | $image_url['source'] = $source['source']; |
| 614 | 742 | return $image_url; |
| 615 | 743 | } |
| 616 | 744 | } |
| 617 | 745 | return false; |
| 618 | - } else return false; |
|
| 746 | + } else { |
|
| 747 | + return false; |
|
| 748 | + } |
|
| 619 | 749 | if (!empty($globalMarineImageCustomSources) && $type == 'marine') { |
| 620 | 750 | $customsources = array(); |
| 621 | 751 | if (!isset($globalMarineImageCustomSources[0])) { |
@@ -640,18 +770,27 @@ discard block |
||
| 640 | 770 | $image_url = array(); |
| 641 | 771 | $image_url['thumbnail'] = $url_thumbnail; |
| 642 | 772 | $image_url['original'] = $url; |
| 643 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 644 | - else $exifCopyright = ''; |
|
| 645 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 646 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
| 647 | - else $image_url['copyright'] = $source['source_website']; |
|
| 773 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 774 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 775 | + } else { |
|
| 776 | + $exifCopyright = ''; |
|
| 777 | + } |
|
| 778 | + if ($exifCopyright != '') { |
|
| 779 | + $image_url['copyright'] = $exifCopyright; |
|
| 780 | + } elseif (isset($source['copyright'])) { |
|
| 781 | + $image_url['copyright'] = $source['copyright']; |
|
| 782 | + } else { |
|
| 783 | + $image_url['copyright'] = $source['source_website']; |
|
| 784 | + } |
|
| 648 | 785 | $image_url['source_website'] = $source['source_website']; |
| 649 | 786 | $image_url['source'] = $source['source']; |
| 650 | 787 | return $image_url; |
| 651 | 788 | } |
| 652 | 789 | } |
| 653 | 790 | return false; |
| 654 | - } else return false; |
|
| 791 | + } else { |
|
| 792 | + return false; |
|
| 793 | + } |
|
| 655 | 794 | } |
| 656 | 795 | } |
| 657 | 796 | |
@@ -196,16 +196,22 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | /* Check that end was found and body has at least one byte. */ |
| 198 | 198 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
| 199 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
| 199 | + if ($globalDebug) { |
|
| 200 | + echo '!!! APRS invalid : '.$input."\n"; |
|
| 201 | + } |
|
| 200 | 202 | return false; |
| 201 | 203 | } |
| 202 | 204 | |
| 203 | - if ($debug) echo 'input : '.$input."\n"; |
|
| 205 | + if ($debug) { |
|
| 206 | + echo 'input : '.$input."\n"; |
|
| 207 | + } |
|
| 204 | 208 | /* Save header and body. */ |
| 205 | 209 | $body = substr($input,$splitpos+1,$input_len); |
| 206 | 210 | $body_len = strlen($body); |
| 207 | 211 | $header = substr($input,0,$splitpos); |
| 208 | - if ($debug) echo 'header : '.$header."\n"; |
|
| 212 | + if ($debug) { |
|
| 213 | + echo 'header : '.$header."\n"; |
|
| 214 | + } |
|
| 209 | 215 | |
| 210 | 216 | /* Parse source, target and path. */ |
| 211 | 217 | //FLRDF0A52>APRS,qAS,LSTB |
@@ -219,11 +225,15 @@ discard block |
||
| 219 | 225 | $result['format_source'] = 'famaprs'; |
| 220 | 226 | $result['source_type'] = 'ais'; |
| 221 | 227 | } else { |
| 222 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
| 228 | + if ($debug) { |
|
| 229 | + echo 'ident : '.$ident."\n"; |
|
| 230 | + } |
|
| 223 | 231 | $result['ident'] = $ident; |
| 224 | 232 | } |
| 225 | 233 | } else { |
| 226 | - if ($debug) 'No ident'."\n"; |
|
| 234 | + if ($debug) { |
|
| 235 | + 'No ident'."\n"; |
|
| 236 | + } |
|
| 227 | 237 | return false; |
| 228 | 238 | } |
| 229 | 239 | $elements = explode(',',$all_elements); |
@@ -233,7 +243,9 @@ discard block |
||
| 233 | 243 | if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
| 234 | 244 | //if ($element == 'TCPIP*') return false; |
| 235 | 245 | } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
| 236 | - if ($debug) echo 'element : '.$element."\n"; |
|
| 246 | + if ($debug) { |
|
| 247 | + echo 'element : '.$element."\n"; |
|
| 248 | + } |
|
| 237 | 249 | return false; |
| 238 | 250 | } |
| 239 | 251 | /* |
@@ -246,13 +258,17 @@ discard block |
||
| 246 | 258 | } |
| 247 | 259 | |
| 248 | 260 | $type = substr($body,0,1); |
| 249 | - if ($debug) echo 'type : '.$type."\n"; |
|
| 261 | + if ($debug) { |
|
| 262 | + echo 'type : '.$type."\n"; |
|
| 263 | + } |
|
| 250 | 264 | if ($type == ';') { |
| 251 | 265 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
| 252 | 266 | $result['address'] = trim(substr($body,1,9)); |
| 253 | 267 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
| 254 | 268 | $result['mmsi'] = trim(substr($body,1,9)); |
| 255 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
| 269 | + } else { |
|
| 270 | + $result['ident'] = trim(substr($body,1,9)); |
|
| 271 | + } |
|
| 256 | 272 | } elseif ($type == ',') { |
| 257 | 273 | // Invalid data or test data |
| 258 | 274 | return false; |
@@ -309,7 +325,9 @@ discard block |
||
| 309 | 325 | //$symbol_table = $matches[4]; |
| 310 | 326 | $lat = intval($lat_deg); |
| 311 | 327 | $lon = intval($lon_deg); |
| 312 | - if ($lat > 89 || $lon > 179) return false; |
|
| 328 | + if ($lat > 89 || $lon > 179) { |
|
| 329 | + return false; |
|
| 330 | + } |
|
| 313 | 331 | /* |
| 314 | 332 | $tmp_5b = str_replace('.','',$lat_min); |
| 315 | 333 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
@@ -318,8 +336,12 @@ discard block |
||
| 318 | 336 | */ |
| 319 | 337 | $latitude = $lat + floatval($lat_min)/60; |
| 320 | 338 | $longitude = $lon + floatval($lon_min)/60; |
| 321 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
| 322 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
| 339 | + if ($sind == 'S') { |
|
| 340 | + $latitude = 0-$latitude; |
|
| 341 | + } |
|
| 342 | + if ($wind == 'W') { |
|
| 343 | + $longitude = 0-$longitude; |
|
| 344 | + } |
|
| 323 | 345 | $result['latitude'] = $latitude; |
| 324 | 346 | $result['longitude'] = $longitude; |
| 325 | 347 | $body_parse = substr($body_parse,18); |
@@ -344,22 +366,29 @@ discard block |
||
| 344 | 366 | if ($find) { |
| 345 | 367 | $body_split = str_split($body_parse); |
| 346 | 368 | $symbol_code = $body_split[0]; |
| 347 | - if (!isset($symbolll) || $symbolll == '/') $symbol_code = '/'.$symbol_code; |
|
| 348 | - else $symbol_code = '\\'.$symbol_code; |
|
| 369 | + if (!isset($symbolll) || $symbolll == '/') { |
|
| 370 | + $symbol_code = '/'.$symbol_code; |
|
| 371 | + } else { |
|
| 372 | + $symbol_code = '\\'.$symbol_code; |
|
| 373 | + } |
|
| 349 | 374 | //' |
| 350 | 375 | //if ($type != ';' && $type != '>') { |
| 351 | 376 | if ($type != '') { |
| 352 | 377 | $body_parse = substr($body_parse,1); |
| 353 | 378 | $body_parse_len = strlen($body_parse); |
| 354 | 379 | $result['symbol_code'] = $symbol_code; |
| 355 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
|
| 380 | + if (isset($this->symbols[$symbol_code])) { |
|
| 381 | + $result['symbol'] = $this->symbols[$symbol_code]; |
|
| 382 | + } |
|
| 356 | 383 | if ($symbol_code != '_') { |
| 357 | 384 | } |
| 358 | 385 | if ($body_parse_len >= 7) { |
| 359 | 386 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
| 360 | 387 | $course = substr($body_parse,0,3); |
| 361 | 388 | $tmp_s = intval($course); |
| 362 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
| 389 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
| 390 | + $result['heading'] = intval($course); |
|
| 391 | + } |
|
| 363 | 392 | $speed = substr($body_parse,4,3); |
| 364 | 393 | if ($speed != '...') { |
| 365 | 394 | $result['speed'] = intval($speed); |
@@ -394,10 +423,16 @@ discard block |
||
| 394 | 423 | $dao_split = str_split($dao); |
| 395 | 424 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
| 396 | 425 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
| 397 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
| 398 | - else $result['latitude'] += $lat_off; |
|
| 399 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
| 400 | - else $result['longitude'] += $lon_off; |
|
| 426 | + if ($result['latitude'] < 0) { |
|
| 427 | + $result['latitude'] -= $lat_off; |
|
| 428 | + } else { |
|
| 429 | + $result['latitude'] += $lat_off; |
|
| 430 | + } |
|
| 431 | + if ($result['longitude'] < 0) { |
|
| 432 | + $result['longitude'] -= $lon_off; |
|
| 433 | + } else { |
|
| 434 | + $result['longitude'] += $lon_off; |
|
| 435 | + } |
|
| 401 | 436 | } |
| 402 | 437 | $body_parse = substr($body_parse,6); |
| 403 | 438 | } |
@@ -435,27 +470,48 @@ discard block |
||
| 435 | 470 | //$mode = substr($id,0,2); |
| 436 | 471 | $address = substr($id,2); |
| 437 | 472 | $addressType = (intval(substr($id,0,2),16))&3; |
| 438 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
| 439 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
| 440 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
| 441 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
| 473 | + if ($addressType == 0) { |
|
| 474 | + $result['addresstype'] = "RANDOM"; |
|
| 475 | + } elseif ($addressType == 1) { |
|
| 476 | + $result['addresstype'] = "ICAO"; |
|
| 477 | + } elseif ($addressType == 2) { |
|
| 478 | + $result['addresstype'] = "FLARM"; |
|
| 479 | + } elseif ($addressType == 3) { |
|
| 480 | + $result['addresstype'] = "OGN"; |
|
| 481 | + } |
|
| 442 | 482 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
| 443 | 483 | $result['aircrafttype_code'] = $aircraftType; |
| 444 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
| 445 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
| 446 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
| 447 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
| 448 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
| 449 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
| 450 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
| 451 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
| 452 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
| 453 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
| 454 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
| 455 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
| 456 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
| 457 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
| 458 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
| 484 | + if ($aircraftType == 0) { |
|
| 485 | + $result['aircrafttype'] = "UNKNOWN"; |
|
| 486 | + } elseif ($aircraftType == 1) { |
|
| 487 | + $result['aircrafttype'] = "GLIDER"; |
|
| 488 | + } elseif ($aircraftType == 2) { |
|
| 489 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
| 490 | + } elseif ($aircraftType == 3) { |
|
| 491 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
| 492 | + } elseif ($aircraftType == 4) { |
|
| 493 | + $result['aircrafttype'] = "PARACHUTE"; |
|
| 494 | + } elseif ($aircraftType == 5) { |
|
| 495 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
| 496 | + } elseif ($aircraftType == 6) { |
|
| 497 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
| 498 | + } elseif ($aircraftType == 7) { |
|
| 499 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
| 500 | + } elseif ($aircraftType == 8) { |
|
| 501 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
| 502 | + } elseif ($aircraftType == 9) { |
|
| 503 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
| 504 | + } elseif ($aircraftType == 10) { |
|
| 505 | + $result['aircrafttype'] = "UFO"; |
|
| 506 | + } elseif ($aircraftType == 11) { |
|
| 507 | + $result['aircrafttype'] = "BALLOON"; |
|
| 508 | + } elseif ($aircraftType == 12) { |
|
| 509 | + $result['aircrafttype'] = "AIRSHIP"; |
|
| 510 | + } elseif ($aircraftType == 13) { |
|
| 511 | + $result['aircrafttype'] = "UAV"; |
|
| 512 | + } elseif ($aircraftType == 15) { |
|
| 513 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
| 514 | + } |
|
| 459 | 515 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
| 460 | 516 | $result['stealth'] = $stealth; |
| 461 | 517 | $result['address'] = $address; |
@@ -490,77 +546,181 @@ discard block |
||
| 490 | 546 | //g012t088r000p000P000h38b10110 |
| 491 | 547 | //g011t086r000p000P000h29b10198 |
| 492 | 548 | if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 493 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 494 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 495 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 496 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 497 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 498 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 499 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 549 | + if ($matches[1] != '...') { |
|
| 550 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 551 | + } |
|
| 552 | + if ($matches[2] != '...') { |
|
| 553 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 554 | + } |
|
| 555 | + if ($matches[3] != '...') { |
|
| 556 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 557 | + } |
|
| 558 | + if ($matches[4] != '...') { |
|
| 559 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 560 | + } |
|
| 561 | + if ($matches[5] != '...') { |
|
| 562 | + $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 563 | + } |
|
| 564 | + if ($matches[6] != '...') { |
|
| 565 | + $result['humidity'] = intval($matches[6]); |
|
| 566 | + } |
|
| 567 | + if ($matches[7] != '...') { |
|
| 568 | + $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 569 | + } |
|
| 500 | 570 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 501 | 571 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 502 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 503 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 504 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 505 | - if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
| 506 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 507 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 508 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 572 | + if ($matches[1] != '...') { |
|
| 573 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 574 | + } |
|
| 575 | + if ($matches[2] != '...') { |
|
| 576 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 577 | + } |
|
| 578 | + if ($matches[3] != '...') { |
|
| 579 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 580 | + } |
|
| 581 | + if ($matches[5] != '...') { |
|
| 582 | + $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
| 583 | + } |
|
| 584 | + if ($matches[4] != '...') { |
|
| 585 | + $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 586 | + } |
|
| 587 | + if ($matches[6] != '...') { |
|
| 588 | + $result['humidity'] = intval($matches[6]); |
|
| 589 | + } |
|
| 590 | + if ($matches[7] != '...') { |
|
| 591 | + $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 592 | + } |
|
| 509 | 593 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 510 | 594 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
| 511 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 512 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 513 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 514 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 515 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 516 | - if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
|
| 517 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 595 | + if ($matches[1] != '...') { |
|
| 596 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 597 | + } |
|
| 598 | + if ($matches[2] != '...') { |
|
| 599 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 600 | + } |
|
| 601 | + if ($matches[3] != '...') { |
|
| 602 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 603 | + } |
|
| 604 | + if ($matches[4] != '...') { |
|
| 605 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 606 | + } |
|
| 607 | + if ($matches[5] != '...') { |
|
| 608 | + $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 609 | + } |
|
| 610 | + if ($matches[7] != '...') { |
|
| 611 | + $result['humidity'] = intval($matches[7]); |
|
| 612 | + } |
|
| 613 | + if ($matches[6] != '...') { |
|
| 614 | + $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 615 | + } |
|
| 518 | 616 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 519 | 617 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
| 520 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 521 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 522 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 523 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 524 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 525 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 618 | + if ($matches[1] != '...') { |
|
| 619 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 620 | + } |
|
| 621 | + if ($matches[2] != '...') { |
|
| 622 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 623 | + } |
|
| 624 | + if ($matches[3] != '...') { |
|
| 625 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 626 | + } |
|
| 627 | + if ($matches[4] != '...') { |
|
| 628 | + $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 629 | + } |
|
| 630 | + if ($matches[6] != '...') { |
|
| 631 | + $result['humidity'] = intval($matches[6]); |
|
| 632 | + } |
|
| 633 | + if ($matches[5] != '...') { |
|
| 634 | + $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 635 | + } |
|
| 526 | 636 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 527 | 637 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
| 528 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 529 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 530 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 531 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 532 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 533 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 638 | + if ($matches[1] != '...') { |
|
| 639 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 640 | + } |
|
| 641 | + if ($matches[2] != '...') { |
|
| 642 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 643 | + } |
|
| 644 | + if ($matches[3] != '...') { |
|
| 645 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 646 | + } |
|
| 647 | + if ($matches[4] != '...') { |
|
| 648 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 649 | + } |
|
| 650 | + if ($matches[6] != '...') { |
|
| 651 | + $result['humidity'] = intval($matches[6]); |
|
| 652 | + } |
|
| 653 | + if ($matches[5] != '...') { |
|
| 654 | + $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 655 | + } |
|
| 534 | 656 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 535 | 657 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 536 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 537 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 538 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 539 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 540 | - if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
|
| 541 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 658 | + if ($matches[1] != '...') { |
|
| 659 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 660 | + } |
|
| 661 | + if ($matches[2] != '...') { |
|
| 662 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 663 | + } |
|
| 664 | + if ($matches[3] != '...') { |
|
| 665 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 666 | + } |
|
| 667 | + if ($matches[4] != '...') { |
|
| 668 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 669 | + } |
|
| 670 | + if ($matches[5] != '...') { |
|
| 671 | + $result['humidity'] = intval($matches[5]); |
|
| 672 | + } |
|
| 673 | + if ($matches[6] != '...') { |
|
| 674 | + $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 675 | + } |
|
| 542 | 676 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 543 | 677 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 544 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 545 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 546 | - if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
|
| 547 | - if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); |
|
| 678 | + if ($matches[1] != '...') { |
|
| 679 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 680 | + } |
|
| 681 | + if ($matches[2] != '...') { |
|
| 682 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 683 | + } |
|
| 684 | + if ($matches[2] != '...') { |
|
| 685 | + $result['humidity'] = intval($matches[3]); |
|
| 686 | + } |
|
| 687 | + if ($matches[4] != '...') { |
|
| 688 | + $result['pressure'] = round((intval($matches[4])/10),1); |
|
| 689 | + } |
|
| 548 | 690 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 549 | 691 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 550 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 551 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 552 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 553 | - if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
|
| 554 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 692 | + if ($matches[1] != '...') { |
|
| 693 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 694 | + } |
|
| 695 | + if ($matches[2] != '...') { |
|
| 696 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 697 | + } |
|
| 698 | + if ($matches[3] != '...') { |
|
| 699 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 700 | + } |
|
| 701 | + if ($matches[4] != '...') { |
|
| 702 | + $result['humidity'] = intval($matches[4]); |
|
| 703 | + } |
|
| 704 | + if ($matches[5] != '...') { |
|
| 705 | + $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 706 | + } |
|
| 555 | 707 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 556 | 708 | } |
| 557 | 709 | $result['comment'] = trim($body_parse); |
| 558 | 710 | } |
| 559 | - } else $result['comment'] = trim($body_parse); |
|
| 711 | + } else { |
|
| 712 | + $result['comment'] = trim($body_parse); |
|
| 713 | + } |
|
| 714 | + } |
|
| 715 | + if (isset($result['latitude'])) { |
|
| 716 | + $result['latitude'] = round($result['latitude'],4); |
|
| 717 | + } |
|
| 718 | + if (isset($result['longitude'])) { |
|
| 719 | + $result['longitude'] = round($result['longitude'],4); |
|
| 720 | + } |
|
| 721 | + if ($debug) { |
|
| 722 | + print_r($result); |
|
| 560 | 723 | } |
| 561 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
| 562 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
| 563 | - if ($debug) print_r($result); |
|
| 564 | 724 | return $result; |
| 565 | 725 | } |
| 566 | 726 | |
@@ -572,12 +732,21 @@ discard block |
||
| 572 | 732 | $aprs_connect = 0; |
| 573 | 733 | $aprs_keep = 120; |
| 574 | 734 | $aprs_last_tx = time(); |
| 575 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 576 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 577 | - if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
|
| 578 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 579 | - if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
|
| 580 | - else $aprs_pass = '-1'; |
|
| 735 | + if (isset($globalAPRSversion)) { |
|
| 736 | + $aprs_version = $globalAPRSversion; |
|
| 737 | + } else { |
|
| 738 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 739 | + } |
|
| 740 | + if (isset($globalServerAPRSssid)) { |
|
| 741 | + $aprs_ssid = $globalServerAPRSssid; |
|
| 742 | + } else { |
|
| 743 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 744 | + } |
|
| 745 | + if (isset($globalServerAPRSpass)) { |
|
| 746 | + $aprs_pass = $globalServerAPRSpass; |
|
| 747 | + } else { |
|
| 748 | + $aprs_pass = '-1'; |
|
| 749 | + } |
|
| 581 | 750 | $aprs_filter = ''; |
| 582 | 751 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
| 583 | 752 | $Common = new Common(); |
@@ -616,10 +785,14 @@ discard block |
||
| 616 | 785 | */ |
| 617 | 786 | public function send($data) { |
| 618 | 787 | global $globalDebug; |
| 619 | - if ($this->connected === false) $this->connect(); |
|
| 788 | + if ($this->connected === false) { |
|
| 789 | + $this->connect(); |
|
| 790 | + } |
|
| 620 | 791 | $send = socket_send( $this->socket , $data , strlen($data),0); |
| 621 | 792 | if ($send === FALSE) { |
| 622 | - if ($globalDebug) echo 'Reconnect...'; |
|
| 793 | + if ($globalDebug) { |
|
| 794 | + echo 'Reconnect...'; |
|
| 795 | + } |
|
| 623 | 796 | socket_close($this->socket); |
| 624 | 797 | $this->connect(); |
| 625 | 798 | } |
@@ -642,22 +815,32 @@ discard block |
||
| 642 | 815 | //$w = '00'; |
| 643 | 816 | $custom = ''; |
| 644 | 817 | if ($ident != '') { |
| 645 | - if ($custom != '') $custom .= '/'; |
|
| 818 | + if ($custom != '') { |
|
| 819 | + $custom .= '/'; |
|
| 820 | + } |
|
| 646 | 821 | $custom .= 'CS='.$ident; |
| 647 | 822 | } |
| 648 | 823 | if ($squawk != '') { |
| 649 | - if ($custom != '') $custom .= '/'; |
|
| 824 | + if ($custom != '') { |
|
| 825 | + $custom .= '/'; |
|
| 826 | + } |
|
| 650 | 827 | $custom .= 'SQ='.$squawk; |
| 651 | 828 | } |
| 652 | 829 | if ($verticalrate != '') { |
| 653 | - if ($custom != '') $custom .= '/'; |
|
| 830 | + if ($custom != '') { |
|
| 831 | + $custom .= '/'; |
|
| 832 | + } |
|
| 654 | 833 | $custom .= 'VR='.$verticalrate; |
| 655 | 834 | } |
| 656 | 835 | if ($aircraft_icao != '' && $aircraft_icao != 'NA') { |
| 657 | - if ($custom != '') $custom .= '/'; |
|
| 836 | + if ($custom != '') { |
|
| 837 | + $custom .= '/'; |
|
| 838 | + } |
|
| 658 | 839 | $custom .= 'AI='.$aircraft_icao; |
| 659 | 840 | } |
| 660 | - if ($custom != '') $custom = ' '.$custom; |
|
| 841 | + if ($custom != '') { |
|
| 842 | + $custom = ' '.$custom; |
|
| 843 | + } |
|
| 661 | 844 | /* |
| 662 | 845 | // Use AMSL altitude |
| 663 | 846 | $GeoidClass = new GeoidHeight(); |
@@ -682,30 +865,44 @@ discard block |
||
| 682 | 865 | //$w = '00'; |
| 683 | 866 | $custom = ''; |
| 684 | 867 | if ($ident != '') { |
| 685 | - if ($custom != '') $custom .= '/'; |
|
| 868 | + if ($custom != '') { |
|
| 869 | + $custom .= '/'; |
|
| 870 | + } |
|
| 686 | 871 | $custom .= 'CS='.str_replace(' ','_',$ident); |
| 687 | 872 | } |
| 688 | 873 | if ($typeid != '') { |
| 689 | - if ($custom != '') $custom .= '/'; |
|
| 874 | + if ($custom != '') { |
|
| 875 | + $custom .= '/'; |
|
| 876 | + } |
|
| 690 | 877 | $custom .= 'TI='.$typeid; |
| 691 | 878 | } |
| 692 | 879 | if ($statusid != '') { |
| 693 | - if ($custom != '') $custom .= '/'; |
|
| 880 | + if ($custom != '') { |
|
| 881 | + $custom .= '/'; |
|
| 882 | + } |
|
| 694 | 883 | $custom .= 'SI='.$statusid; |
| 695 | 884 | } |
| 696 | 885 | if ($imo != '') { |
| 697 | - if ($custom != '') $custom .= '/'; |
|
| 886 | + if ($custom != '') { |
|
| 887 | + $custom .= '/'; |
|
| 888 | + } |
|
| 698 | 889 | $custom .= 'IMO='.$imo; |
| 699 | 890 | } |
| 700 | 891 | if ($arrival_date != '') { |
| 701 | - if ($custom != '') $custom .= '/'; |
|
| 892 | + if ($custom != '') { |
|
| 893 | + $custom .= '/'; |
|
| 894 | + } |
|
| 702 | 895 | $custom .= 'AD='.strtotime($arrival_date); |
| 703 | 896 | } |
| 704 | 897 | if ($arrival_code != '') { |
| 705 | - if ($custom != '') $custom .= '/'; |
|
| 898 | + if ($custom != '') { |
|
| 899 | + $custom .= '/'; |
|
| 900 | + } |
|
| 706 | 901 | $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
| 707 | 902 | } |
| 708 | - if ($custom != '') $custom = ' '.$custom; |
|
| 903 | + if ($custom != '') { |
|
| 904 | + $custom = ' '.$custom; |
|
| 905 | + } |
|
| 709 | 906 | $altitude = 0; |
| 710 | 907 | $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
| 711 | 908 | } |
@@ -19,9 +19,13 @@ discard block |
||
| 19 | 19 | // Not yet finished, no CRC checks |
| 20 | 20 | $data = array(); |
| 21 | 21 | $typehex = substr($buffer,0,1); |
| 22 | - if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1); |
|
| 23 | - elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13); |
|
| 24 | - else $hex = substr($buffer,1,-1); |
|
| 22 | + if ($typehex == '*' || $typehex == ':') { |
|
| 23 | + $hex = substr($buffer,1,-1); |
|
| 24 | + } elseif ($typehex == '@' || $typehex == '%') { |
|
| 25 | + $hex = substr($buffer,13,-13); |
|
| 26 | + } else { |
|
| 27 | + $hex = substr($buffer,1,-1); |
|
| 28 | + } |
|
| 25 | 29 | $bin = gmp_strval( gmp_init($hex,16), 2); |
| 26 | 30 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
| 27 | 31 | if (strlen($hex) == 28) { |
@@ -64,8 +68,9 @@ discard block |
||
| 64 | 68 | // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
| 65 | 69 | $cprlat = intval(substr($bin,54,17),2)/131072.0; |
| 66 | 70 | $cprlon = intval(substr($bin,71,17),2)/131072.0; |
| 67 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
| 68 | - elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
| 71 | + if ($oe == 0) { |
|
| 72 | + $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
| 73 | + } elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
| 69 | 74 | $cprlat_odd = $cprlat; |
| 70 | 75 | $cprlon_odd = $cprlon; |
| 71 | 76 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
@@ -73,8 +78,12 @@ discard block |
||
| 73 | 78 | $j = 59*$cprlat_even-60*$cprlat_odd+0.5; |
| 74 | 79 | $lat_even = (360.0/60)*($j%60+$cprlat_even); |
| 75 | 80 | $lat_odd = (360.0/59)*($j%59+$cprlat_odd); |
| 76 | - if ($lat_even >= 270) $lat_even = $lat_even - 360; |
|
| 77 | - if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
|
| 81 | + if ($lat_even >= 270) { |
|
| 82 | + $lat_even = $lat_even - 360; |
|
| 83 | + } |
|
| 84 | + if ($lat_odd >= 270) { |
|
| 85 | + $lat_odd = $lat_odd - 360; |
|
| 86 | + } |
|
| 78 | 87 | // check latitude zone |
| 79 | 88 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
| 80 | 89 | if ($this::$latlon[$icao]['created'] > time()) { |
@@ -82,7 +91,9 @@ discard block |
||
| 82 | 91 | $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
| 83 | 92 | $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
| 84 | 93 | $lat = $lat_even; |
| 85 | - if ($lon > 180) $lon = $lon -360; |
|
| 94 | + if ($lon > 180) { |
|
| 95 | + $lon = $lon -360; |
|
| 96 | + } |
|
| 86 | 97 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
| 87 | 98 | //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
| 88 | 99 | $data['latitude'] = $lat; |
@@ -93,14 +104,18 @@ discard block |
||
| 93 | 104 | $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
| 94 | 105 | $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
| 95 | 106 | $lat = $lat_odd; |
| 96 | - if ($lon > 180) $lon = $lon -360; |
|
| 107 | + if ($lon > 180) { |
|
| 108 | + $lon = $lon -360; |
|
| 109 | + } |
|
| 97 | 110 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
| 98 | 111 | //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
| 99 | 112 | $data['latitude'] = $lat; |
| 100 | 113 | $data['longitude'] = $lon; |
| 101 | 114 | } |
| 102 | 115 | } |
| 103 | - } else echo "Not cprNL"; |
|
| 116 | + } else { |
|
| 117 | + echo "Not cprNL"; |
|
| 118 | + } |
|
| 104 | 119 | unset($this::$latlon[$icao]); |
| 105 | 120 | } |
| 106 | 121 | } elseif ($tc == 19) { |
@@ -109,11 +124,17 @@ discard block |
||
| 109 | 124 | $v_ew = intval(substr($bin,46,10),2); |
| 110 | 125 | $v_ns_dir = intval(substr($bin,56,1)); |
| 111 | 126 | $v_ns = intval(substr($bin,57,10),2); |
| 112 | - if ($v_ew_dir) $v_ew = -1*$v_ew; |
|
| 113 | - if ($v_ns_dir) $v_ns = -1*$v_ns; |
|
| 127 | + if ($v_ew_dir) { |
|
| 128 | + $v_ew = -1*$v_ew; |
|
| 129 | + } |
|
| 130 | + if ($v_ns_dir) { |
|
| 131 | + $v_ns = -1*$v_ns; |
|
| 132 | + } |
|
| 114 | 133 | $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
| 115 | 134 | $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
| 116 | - if ($heading <0) $heading = $heading+360; |
|
| 135 | + if ($heading <0) { |
|
| 136 | + $heading = $heading+360; |
|
| 137 | + } |
|
| 117 | 138 | $data['speed'] = $speed; |
| 118 | 139 | $data['heading'] = $heading; |
| 119 | 140 | } |
@@ -128,72 +149,194 @@ discard block |
||
| 128 | 149 | * Lookup table to convert the latitude to index. |
| 129 | 150 | */ |
| 130 | 151 | private function cprNL($lat) { |
| 131 | - if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
| 132 | - if ($lat < 10.47047130) return 59; |
|
| 133 | - if ($lat < 14.82817437) return 58; |
|
| 134 | - if ($lat < 18.18626357) return 57; |
|
| 135 | - if ($lat < 21.02939493) return 56; |
|
| 136 | - if ($lat < 23.54504487) return 55; |
|
| 137 | - if ($lat < 25.82924707) return 54; |
|
| 138 | - if ($lat < 27.93898710) return 53; |
|
| 139 | - if ($lat < 29.91135686) return 52; |
|
| 140 | - if ($lat < 31.77209708) return 51; |
|
| 141 | - if ($lat < 33.53993436) return 50; |
|
| 142 | - if ($lat < 35.22899598) return 49; |
|
| 143 | - if ($lat < 36.85025108) return 48; |
|
| 144 | - if ($lat < 38.41241892) return 47; |
|
| 145 | - if ($lat < 39.92256684) return 46; |
|
| 146 | - if ($lat < 41.38651832) return 45; |
|
| 147 | - if ($lat < 42.80914012) return 44; |
|
| 148 | - if ($lat < 44.19454951) return 43; |
|
| 149 | - if ($lat < 45.54626723) return 42; |
|
| 150 | - if ($lat < 46.86733252) return 41; |
|
| 151 | - if ($lat < 48.16039128) return 40; |
|
| 152 | - if ($lat < 49.42776439) return 39; |
|
| 153 | - if ($lat < 50.67150166) return 38; |
|
| 154 | - if ($lat < 51.89342469) return 37; |
|
| 155 | - if ($lat < 53.09516153) return 36; |
|
| 156 | - if ($lat < 54.27817472) return 35; |
|
| 157 | - if ($lat < 55.44378444) return 34; |
|
| 158 | - if ($lat < 56.59318756) return 33; |
|
| 159 | - if ($lat < 57.72747354) return 32; |
|
| 160 | - if ($lat < 58.84763776) return 31; |
|
| 161 | - if ($lat < 59.95459277) return 30; |
|
| 162 | - if ($lat < 61.04917774) return 29; |
|
| 163 | - if ($lat < 62.13216659) return 28; |
|
| 164 | - if ($lat < 63.20427479) return 27; |
|
| 165 | - if ($lat < 64.26616523) return 26; |
|
| 166 | - if ($lat < 65.31845310) return 25; |
|
| 167 | - if ($lat < 66.36171008) return 24; |
|
| 168 | - if ($lat < 67.39646774) return 23; |
|
| 169 | - if ($lat < 68.42322022) return 22; |
|
| 170 | - if ($lat < 69.44242631) return 21; |
|
| 171 | - if ($lat < 70.45451075) return 20; |
|
| 172 | - if ($lat < 71.45986473) return 19; |
|
| 173 | - if ($lat < 72.45884545) return 18; |
|
| 174 | - if ($lat < 73.45177442) return 17; |
|
| 175 | - if ($lat < 74.43893416) return 16; |
|
| 176 | - if ($lat < 75.42056257) return 15; |
|
| 177 | - if ($lat < 76.39684391) return 14; |
|
| 178 | - if ($lat < 77.36789461) return 13; |
|
| 179 | - if ($lat < 78.33374083) return 12; |
|
| 180 | - if ($lat < 79.29428225) return 11; |
|
| 181 | - if ($lat < 80.24923213) return 10; |
|
| 182 | - if ($lat < 81.19801349) return 9; |
|
| 183 | - if ($lat < 82.13956981) return 8; |
|
| 184 | - if ($lat < 83.07199445) return 7; |
|
| 185 | - if ($lat < 83.99173563) return 6; |
|
| 186 | - if ($lat < 84.89166191) return 5; |
|
| 187 | - if ($lat < 85.75541621) return 4; |
|
| 188 | - if ($lat < 86.53536998) return 3; |
|
| 189 | - if ($lat < 87.00000000) return 2; |
|
| 152 | + if ($lat < 0) { |
|
| 153 | + $lat = -$lat; |
|
| 154 | + } |
|
| 155 | + // Table is simmetric about the equator. |
|
| 156 | + if ($lat < 10.47047130) { |
|
| 157 | + return 59; |
|
| 158 | + } |
|
| 159 | + if ($lat < 14.82817437) { |
|
| 160 | + return 58; |
|
| 161 | + } |
|
| 162 | + if ($lat < 18.18626357) { |
|
| 163 | + return 57; |
|
| 164 | + } |
|
| 165 | + if ($lat < 21.02939493) { |
|
| 166 | + return 56; |
|
| 167 | + } |
|
| 168 | + if ($lat < 23.54504487) { |
|
| 169 | + return 55; |
|
| 170 | + } |
|
| 171 | + if ($lat < 25.82924707) { |
|
| 172 | + return 54; |
|
| 173 | + } |
|
| 174 | + if ($lat < 27.93898710) { |
|
| 175 | + return 53; |
|
| 176 | + } |
|
| 177 | + if ($lat < 29.91135686) { |
|
| 178 | + return 52; |
|
| 179 | + } |
|
| 180 | + if ($lat < 31.77209708) { |
|
| 181 | + return 51; |
|
| 182 | + } |
|
| 183 | + if ($lat < 33.53993436) { |
|
| 184 | + return 50; |
|
| 185 | + } |
|
| 186 | + if ($lat < 35.22899598) { |
|
| 187 | + return 49; |
|
| 188 | + } |
|
| 189 | + if ($lat < 36.85025108) { |
|
| 190 | + return 48; |
|
| 191 | + } |
|
| 192 | + if ($lat < 38.41241892) { |
|
| 193 | + return 47; |
|
| 194 | + } |
|
| 195 | + if ($lat < 39.92256684) { |
|
| 196 | + return 46; |
|
| 197 | + } |
|
| 198 | + if ($lat < 41.38651832) { |
|
| 199 | + return 45; |
|
| 200 | + } |
|
| 201 | + if ($lat < 42.80914012) { |
|
| 202 | + return 44; |
|
| 203 | + } |
|
| 204 | + if ($lat < 44.19454951) { |
|
| 205 | + return 43; |
|
| 206 | + } |
|
| 207 | + if ($lat < 45.54626723) { |
|
| 208 | + return 42; |
|
| 209 | + } |
|
| 210 | + if ($lat < 46.86733252) { |
|
| 211 | + return 41; |
|
| 212 | + } |
|
| 213 | + if ($lat < 48.16039128) { |
|
| 214 | + return 40; |
|
| 215 | + } |
|
| 216 | + if ($lat < 49.42776439) { |
|
| 217 | + return 39; |
|
| 218 | + } |
|
| 219 | + if ($lat < 50.67150166) { |
|
| 220 | + return 38; |
|
| 221 | + } |
|
| 222 | + if ($lat < 51.89342469) { |
|
| 223 | + return 37; |
|
| 224 | + } |
|
| 225 | + if ($lat < 53.09516153) { |
|
| 226 | + return 36; |
|
| 227 | + } |
|
| 228 | + if ($lat < 54.27817472) { |
|
| 229 | + return 35; |
|
| 230 | + } |
|
| 231 | + if ($lat < 55.44378444) { |
|
| 232 | + return 34; |
|
| 233 | + } |
|
| 234 | + if ($lat < 56.59318756) { |
|
| 235 | + return 33; |
|
| 236 | + } |
|
| 237 | + if ($lat < 57.72747354) { |
|
| 238 | + return 32; |
|
| 239 | + } |
|
| 240 | + if ($lat < 58.84763776) { |
|
| 241 | + return 31; |
|
| 242 | + } |
|
| 243 | + if ($lat < 59.95459277) { |
|
| 244 | + return 30; |
|
| 245 | + } |
|
| 246 | + if ($lat < 61.04917774) { |
|
| 247 | + return 29; |
|
| 248 | + } |
|
| 249 | + if ($lat < 62.13216659) { |
|
| 250 | + return 28; |
|
| 251 | + } |
|
| 252 | + if ($lat < 63.20427479) { |
|
| 253 | + return 27; |
|
| 254 | + } |
|
| 255 | + if ($lat < 64.26616523) { |
|
| 256 | + return 26; |
|
| 257 | + } |
|
| 258 | + if ($lat < 65.31845310) { |
|
| 259 | + return 25; |
|
| 260 | + } |
|
| 261 | + if ($lat < 66.36171008) { |
|
| 262 | + return 24; |
|
| 263 | + } |
|
| 264 | + if ($lat < 67.39646774) { |
|
| 265 | + return 23; |
|
| 266 | + } |
|
| 267 | + if ($lat < 68.42322022) { |
|
| 268 | + return 22; |
|
| 269 | + } |
|
| 270 | + if ($lat < 69.44242631) { |
|
| 271 | + return 21; |
|
| 272 | + } |
|
| 273 | + if ($lat < 70.45451075) { |
|
| 274 | + return 20; |
|
| 275 | + } |
|
| 276 | + if ($lat < 71.45986473) { |
|
| 277 | + return 19; |
|
| 278 | + } |
|
| 279 | + if ($lat < 72.45884545) { |
|
| 280 | + return 18; |
|
| 281 | + } |
|
| 282 | + if ($lat < 73.45177442) { |
|
| 283 | + return 17; |
|
| 284 | + } |
|
| 285 | + if ($lat < 74.43893416) { |
|
| 286 | + return 16; |
|
| 287 | + } |
|
| 288 | + if ($lat < 75.42056257) { |
|
| 289 | + return 15; |
|
| 290 | + } |
|
| 291 | + if ($lat < 76.39684391) { |
|
| 292 | + return 14; |
|
| 293 | + } |
|
| 294 | + if ($lat < 77.36789461) { |
|
| 295 | + return 13; |
|
| 296 | + } |
|
| 297 | + if ($lat < 78.33374083) { |
|
| 298 | + return 12; |
|
| 299 | + } |
|
| 300 | + if ($lat < 79.29428225) { |
|
| 301 | + return 11; |
|
| 302 | + } |
|
| 303 | + if ($lat < 80.24923213) { |
|
| 304 | + return 10; |
|
| 305 | + } |
|
| 306 | + if ($lat < 81.19801349) { |
|
| 307 | + return 9; |
|
| 308 | + } |
|
| 309 | + if ($lat < 82.13956981) { |
|
| 310 | + return 8; |
|
| 311 | + } |
|
| 312 | + if ($lat < 83.07199445) { |
|
| 313 | + return 7; |
|
| 314 | + } |
|
| 315 | + if ($lat < 83.99173563) { |
|
| 316 | + return 6; |
|
| 317 | + } |
|
| 318 | + if ($lat < 84.89166191) { |
|
| 319 | + return 5; |
|
| 320 | + } |
|
| 321 | + if ($lat < 85.75541621) { |
|
| 322 | + return 4; |
|
| 323 | + } |
|
| 324 | + if ($lat < 86.53536998) { |
|
| 325 | + return 3; |
|
| 326 | + } |
|
| 327 | + if ($lat < 87.00000000) { |
|
| 328 | + return 2; |
|
| 329 | + } |
|
| 190 | 330 | return 1; |
| 191 | 331 | } |
| 192 | 332 | |
| 193 | 333 | private function cprN($lat,$isodd) { |
| 194 | 334 | $nl = $this->cprNL($lat) - $isodd; |
| 195 | - if ($nl > 1) return $nl; |
|
| 196 | - else return 1; |
|
| 335 | + if ($nl > 1) { |
|
| 336 | + return $nl; |
|
| 337 | + } else { |
|
| 338 | + return 1; |
|
| 339 | + } |
|
| 197 | 340 | } |
| 198 | 341 | |
| 199 | 342 | private function parityCheck($msg, $bin) { |
@@ -216,10 +359,13 @@ discard block |
||
| 216 | 359 | $crc = 0; |
| 217 | 360 | $checksum = intval(substr($msg,22,6),16); |
| 218 | 361 | for ($j = 0; $j < strlen($bin); $j++) { |
| 219 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
| 362 | + if ($bin[$j]) { |
|
| 363 | + $crc = $crc^intval($modes_checksum_table[$j],0); |
|
| 364 | + } |
|
| 220 | 365 | } |
| 221 | - if ($crc == $checksum) return true; |
|
| 222 | - else { |
|
| 366 | + if ($crc == $checksum) { |
|
| 367 | + return true; |
|
| 368 | + } else { |
|
| 223 | 369 | //echo "**** CRC ERROR ****\n"; |
| 224 | 370 | return false; |
| 225 | 371 | } |
@@ -269,22 +415,37 @@ discard block |
||
| 269 | 415 | $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
| 270 | 416 | $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
| 271 | 417 | $msg['callsign'] = ''; |
| 272 | - if (isset($data['altitude'])) $msg['altitude'] = $data['altitude']; |
|
| 273 | - else $msg['altitude'] = ''; |
|
| 418 | + if (isset($data['altitude'])) { |
|
| 419 | + $msg['altitude'] = $data['altitude']; |
|
| 420 | + } else { |
|
| 421 | + $msg['altitude'] = ''; |
|
| 422 | + } |
|
| 274 | 423 | $msg['speed'] = $data['speed']; |
| 275 | - if (isset($data['heading'])) $msg['track'] = $data['heading']; |
|
| 276 | - else $msg['track'] = ''; |
|
| 424 | + if (isset($data['heading'])) { |
|
| 425 | + $msg['track'] = $data['heading']; |
|
| 426 | + } else { |
|
| 427 | + $msg['track'] = ''; |
|
| 428 | + } |
|
| 277 | 429 | $msg['latitude'] = $data['latitude']; |
| 278 | 430 | $msg['longitude'] = $data['longitude']; |
| 279 | - if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate']; |
|
| 280 | - else $msg['verticalrate'] = ''; |
|
| 281 | - if (isset($data['squawk'])) $msg['squawk'] = $data['squawk']; |
|
| 282 | - else $msg['squawk'] = 0; |
|
| 431 | + if (isset($data['verticalrate'])) { |
|
| 432 | + $msg['verticalrate'] = $data['verticalrate']; |
|
| 433 | + } else { |
|
| 434 | + $msg['verticalrate'] = ''; |
|
| 435 | + } |
|
| 436 | + if (isset($data['squawk'])) { |
|
| 437 | + $msg['squawk'] = $data['squawk']; |
|
| 438 | + } else { |
|
| 439 | + $msg['squawk'] = 0; |
|
| 440 | + } |
|
| 283 | 441 | $msg['alert'] = 0; |
| 284 | 442 | $msg['emergency'] = 0; |
| 285 | 443 | $msg['SPI'] = 0; |
| 286 | - if (isset($data['ground'])) $msg['ground'] = 1; |
|
| 287 | - else $msg['ground'] = 0; |
|
| 444 | + if (isset($data['ground'])) { |
|
| 445 | + $msg['ground'] = 1; |
|
| 446 | + } else { |
|
| 447 | + $msg['ground'] = 0; |
|
| 448 | + } |
|
| 288 | 449 | $result[] = implode(',',$msg); |
| 289 | 450 | } |
| 290 | 451 | return $result; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | $limit_start = 0; |
| 16 | 16 | $limit_end = 25; |
| 17 | 17 | $absolute_difference = 25; |
| 18 | - } else { |
|
| 18 | + } else { |
|
| 19 | 19 | $limit_explode = explode(",", $_GET['limit']); |
| 20 | 20 | $limit_start = $limit_explode[0]; |
| 21 | 21 | $limit_end = $limit_explode[1]; |
@@ -47,7 +47,9 @@ discard block |
||
| 47 | 47 | $METAR = new METAR(); |
| 48 | 48 | $metar_info = $METAR->getMETAR($airport_icao); |
| 49 | 49 | //print_r($metar_info); |
| 50 | - if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
| 50 | + if (isset($metar_info[0]['metar'])) { |
|
| 51 | + $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
| 52 | + } |
|
| 51 | 53 | //print_r($metar_parse); |
| 52 | 54 | } |
| 53 | 55 | |
@@ -61,7 +63,9 @@ discard block |
||
| 61 | 63 | print '<option></option>'; |
| 62 | 64 | $Stats = new Stats(); |
| 63 | 65 | $airport_names = $Stats->getAllAirportNames(); |
| 64 | - if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
|
| 66 | + if (empty($airport_names)) { |
|
| 67 | + $airport_names = $Spotter->getAllAirportNames(); |
|
| 68 | + } |
|
| 65 | 69 | ksort($airport_names); |
| 66 | 70 | foreach($airport_names as $airport_name) |
| 67 | 71 | { |
@@ -95,7 +99,9 @@ discard block |
||
| 95 | 99 | print '</div>'; |
| 96 | 100 | print '<div><span class="label">'._("Coordinates").'</span><a href="http://maps.google.ca/maps?z=10&t=k&q='.$airport_array[0]['latitude'].','.$airport_array[0]['longitude'].'" target="_blank">Google Map<i class="fa fa-angle-double-right"></i></a></div>'; |
| 97 | 101 | print '<div><span class="label">'._("Live Air Traffic").'</span><a href="http://www.liveatc.net/search/?icao='.$airport_array[0]['icao'].'" target="_blank">LiveATC.net<i class="fa fa-angle-double-right"></i></a></div>'; |
| 98 | - if (isset($airport_array[0]['diagram_pdf']) && $airport_array[0]['diagram_pdf'] != '') print '<div><span class="label">'._("Diagram").'</span><a href="'.$airport_array[0]['diagram_pdf'].'" target="_blank">'.$airport_array[0]['icao'].'<i class="fa fa-angle-double-right"></i></a></div>'; |
|
| 102 | + if (isset($airport_array[0]['diagram_pdf']) && $airport_array[0]['diagram_pdf'] != '') { |
|
| 103 | + print '<div><span class="label">'._("Diagram").'</span><a href="'.$airport_array[0]['diagram_pdf'].'" target="_blank">'.$airport_array[0]['icao'].'<i class="fa fa-angle-double-right"></i></a></div>'; |
|
| 104 | + } |
|
| 99 | 105 | print '</div>'; |
| 100 | 106 | |
| 101 | 107 | $Stats = new Stats(); |
@@ -103,7 +109,9 @@ discard block |
||
| 103 | 109 | // Use spotter also |
| 104 | 110 | if (isset($globalTimezone)) { |
| 105 | 111 | date_default_timezone_set($globalTimezone); |
| 106 | - } else date_default_timezone_set('UTC'); |
|
| 112 | + } else { |
|
| 113 | + date_default_timezone_set('UTC'); |
|
| 114 | + } |
|
| 107 | 115 | if (count($all_data) > 0) { |
| 108 | 116 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
| 109 | 117 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -105,8 +105,11 @@ |
||
| 105 | 105 | } elseif (isset($_GET['satellite'])) { |
| 106 | 106 | readfile(dirname(__FILE__).'/images/satellites/'.$filename); |
| 107 | 107 | } else { |
| 108 | - if ($color == 'FF0000') readfile(dirname(__FILE__).'/images/aircrafts/selected/'.$filename); |
|
| 109 | - else readfile(dirname(__FILE__).'/images/aircrafts/'.$filename); |
|
| 108 | + if ($color == 'FF0000') { |
|
| 109 | + readfile(dirname(__FILE__).'/images/aircrafts/selected/'.$filename); |
|
| 110 | + } else { |
|
| 111 | + readfile(dirname(__FILE__).'/images/aircrafts/'.$filename); |
|
| 112 | + } |
|
| 110 | 113 | } |
| 111 | 114 | } |
| 112 | 115 | ?> |
| 113 | 116 | \ No newline at end of file |
@@ -75,7 +75,9 @@ discard block |
||
| 75 | 75 | if ($error != '') { |
| 76 | 76 | $_SESSION['error'] = $error; |
| 77 | 77 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create database')); |
| 78 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
| 78 | + } else { |
|
| 79 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
| 80 | + } |
|
| 79 | 81 | $_SESSION['install'] = 'database_import'; |
| 80 | 82 | $_SESSION['next'] = 'Create and import tables'; |
| 81 | 83 | $result = array('error' => $error,'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -93,7 +95,9 @@ discard block |
||
| 93 | 95 | if ($error != '') { |
| 94 | 96 | $_SESSION['error'] = $error; |
| 95 | 97 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
| 96 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
| 98 | + } else { |
|
| 99 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
| 100 | + } |
|
| 97 | 101 | if ($globalSBS1 && !$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
| 98 | 102 | $_SESSION['install'] = 'populate'; |
| 99 | 103 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B'; |
@@ -107,7 +111,9 @@ discard block |
||
| 107 | 111 | $error .= $check_version; |
| 108 | 112 | $_SESSION['error'] = $error; |
| 109 | 113 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
| 110 | - if (!isset($_SESSION['next'])) $_SESSION['next'] = ''; |
|
| 114 | + if (!isset($_SESSION['next'])) { |
|
| 115 | + $_SESSION['next'] = ''; |
|
| 116 | + } |
|
| 111 | 117 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
| 112 | 118 | print json_encode($result); |
| 113 | 119 | } else { |
@@ -115,7 +121,9 @@ discard block |
||
| 115 | 121 | if ($error != '') { |
| 116 | 122 | $_SESSION['error'] = $error; |
| 117 | 123 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Update schema if needed')); |
| 118 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
| 124 | + } else { |
|
| 125 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
| 126 | + } |
|
| 119 | 127 | $_SESSION['install'] = 'sources'; |
| 120 | 128 | $_SESSION['next'] = 'Insert data in source table'; |
| 121 | 129 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -128,8 +136,10 @@ discard block |
||
| 128 | 136 | if ($error != '') { |
| 129 | 137 | $_SESSION['error'] = $error; |
| 130 | 138 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate waypoints database')); |
| 131 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
| 132 | -/* |
|
| 139 | + } else { |
|
| 140 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
| 141 | + } |
|
| 142 | + /* |
|
| 133 | 143 | $_SESSION['install'] = 'airspace'; |
| 134 | 144 | $_SESSION['next'] = 'Populate airspace table'; |
| 135 | 145 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -154,7 +164,9 @@ discard block |
||
| 154 | 164 | if ($error != '') { |
| 155 | 165 | $_SESSION['error'] = $error; |
| 156 | 166 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database')); |
| 157 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
| 167 | + } else { |
|
| 168 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
| 169 | + } |
|
| 158 | 170 | if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
| 159 | 171 | $_SESSION['install'] = 'notam'; |
| 160 | 172 | $_SESSION['next'] = 'Populate NOTAM table with externals data'; |
@@ -188,7 +200,9 @@ discard block |
||
| 188 | 200 | if ($error != '') { |
| 189 | 201 | $_SESSION['error'] = $error; |
| 190 | 202 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
| 191 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 203 | + } else { |
|
| 204 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 205 | + } |
|
| 192 | 206 | $_SESSION['install'] = 'populate_flarm'; |
| 193 | 207 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for FLARM'; |
| 194 | 208 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -209,18 +223,26 @@ discard block |
||
| 209 | 223 | if ($error != '') { |
| 210 | 224 | $_SESSION['error'] = $error; |
| 211 | 225 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM')); |
| 212 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
| 226 | + } else { |
|
| 227 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
| 228 | + } |
|
| 213 | 229 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
| 214 | 230 | $_SESSION['install'] = 'vatsim'; |
| 215 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
| 216 | - else $_SESSION['next'] = 'Insert VATSIM data'; |
|
| 231 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
| 232 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
| 233 | + } else { |
|
| 234 | + $_SESSION['next'] = 'Insert VATSIM data'; |
|
| 235 | + } |
|
| 217 | 236 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
| 218 | 237 | $_SESSION['install'] = 'vatsim'; |
| 219 | 238 | $_SESSION['next'] = 'Insert VATSIM data'; |
| 220 | 239 | } elseif (isset($globalIVAO) && $globalIVAO) { |
| 221 | 240 | $_SESSION['install'] = 'vatsim'; |
| 222 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
| 223 | - else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
| 241 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
| 242 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
| 243 | + } else { |
|
| 244 | + $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
| 245 | + } |
|
| 224 | 246 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
| 225 | 247 | $_SESSION['install'] = 'vatsim'; |
| 226 | 248 | $_SESSION['next'] = 'Insert phpVMS data'; |
@@ -245,7 +267,9 @@ discard block |
||
| 245 | 267 | if ($error != '') { |
| 246 | 268 | $_SESSION['error'] = $error; |
| 247 | 269 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate routes table with externals data')); |
| 248 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
| 270 | + } else { |
|
| 271 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
| 272 | + } |
|
| 249 | 273 | $_SESSION['install'] = 'translation'; |
| 250 | 274 | $_SESSION['next'] = 'Populate translation table with externals data'; |
| 251 | 275 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -265,7 +289,9 @@ discard block |
||
| 265 | 289 | if ($error != '') { |
| 266 | 290 | $_SESSION['error'] = $error; |
| 267 | 291 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data')); |
| 268 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
| 292 | + } else { |
|
| 293 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
| 294 | + } |
|
| 269 | 295 | if ($_SESSION['waypoints'] == 1) { |
| 270 | 296 | $_SESSION['install'] = 'waypoints'; |
| 271 | 297 | $_SESSION['next'] = 'Populate waypoints table'; |
@@ -300,7 +326,9 @@ discard block |
||
| 300 | 326 | if ($error != '') { |
| 301 | 327 | $_SESSION['error'] = $error; |
| 302 | 328 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data')); |
| 303 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
| 329 | + } else { |
|
| 330 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
| 331 | + } |
|
| 304 | 332 | $_SESSION['install'] = 'sources'; |
| 305 | 333 | $_SESSION['next'] = 'Insert data in source table'; |
| 306 | 334 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -321,12 +349,16 @@ discard block |
||
| 321 | 349 | if ($error != '') { |
| 322 | 350 | $_SESSION['error'] = $error; |
| 323 | 351 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data')); |
| 324 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
| 352 | + } else { |
|
| 353 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
| 354 | + } |
|
| 325 | 355 | } else { |
| 326 | 356 | if ($error != '') { |
| 327 | 357 | $_SESSION['error'] = $error; |
| 328 | 358 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data (no source defined)')); |
| 329 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
| 359 | + } else { |
|
| 360 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
| 361 | + } |
|
| 330 | 362 | } |
| 331 | 363 | /* |
| 332 | 364 | if (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) { |
@@ -376,7 +408,9 @@ discard block |
||
| 376 | 408 | $Source = new Source(); |
| 377 | 409 | $Source->deleteAllLocation(); |
| 378 | 410 | foreach ($sources as $src) { |
| 379 | - if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
| 411 | + if (isset($src['latitude']) && $src['latitude'] != '') { |
|
| 412 | + $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
| 413 | + } |
|
| 380 | 414 | } |
| 381 | 415 | $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert data in source table')); |
| 382 | 416 | unset($_SESSION['sources']); |
@@ -387,15 +421,21 @@ discard block |
||
| 387 | 421 | */ |
| 388 | 422 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
| 389 | 423 | $_SESSION['install'] = 'vatsim'; |
| 390 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
| 391 | - else $_SESSION['next'] = 'Insert VATSIM data'; |
|
| 424 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
| 425 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
| 426 | + } else { |
|
| 427 | + $_SESSION['next'] = 'Insert VATSIM data'; |
|
| 428 | + } |
|
| 392 | 429 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
| 393 | 430 | $_SESSION['install'] = 'vatsim'; |
| 394 | 431 | $_SESSION['next'] = 'Insert VATSIM data'; |
| 395 | 432 | } elseif (isset($globalIVAO) && $globalIVAO) { |
| 396 | 433 | $_SESSION['install'] = 'vatsim'; |
| 397 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
| 398 | - else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
| 434 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
| 435 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
| 436 | + } else { |
|
| 437 | + $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
| 438 | + } |
|
| 399 | 439 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
| 400 | 440 | $_SESSION['install'] = 'vatsim'; |
| 401 | 441 | $_SESSION['next'] = 'Insert phpVMS data'; |
@@ -416,33 +456,43 @@ discard block |
||
| 416 | 456 | if ($error != '') { |
| 417 | 457 | $_SESSION['error'] = $error; |
| 418 | 458 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
| 419 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 459 | + } else { |
|
| 460 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 461 | + } |
|
| 420 | 462 | } else { |
| 421 | 463 | $error .= update_db::update_vatsim(); |
| 422 | 464 | if ($error != '') { |
| 423 | 465 | $_SESSION['error'] = $error; |
| 424 | 466 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
| 425 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 467 | + } else { |
|
| 468 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 469 | + } |
|
| 426 | 470 | } |
| 427 | 471 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
| 428 | 472 | $error .= update_db::update_vatsim(); |
| 429 | 473 | if ($error != '') { |
| 430 | 474 | $_SESSION['error'] = $error; |
| 431 | 475 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
| 432 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 476 | + } else { |
|
| 477 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 478 | + } |
|
| 433 | 479 | } elseif (isset($globalIVAO) && $globalIVAO) { |
| 434 | 480 | if (file_exists('tmp/ivae_feb2013.zip')) { |
| 435 | 481 | $error .= update_db::update_IVAO(); |
| 436 | 482 | if ($error != '') { |
| 437 | 483 | $_SESSION['error'] = $error; |
| 438 | 484 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
| 439 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 485 | + } else { |
|
| 486 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 487 | + } |
|
| 440 | 488 | } else { |
| 441 | 489 | $error .= update_db::update_vatsim(); |
| 442 | 490 | if ($error != '') { |
| 443 | 491 | $_SESSION['error'] = $error; |
| 444 | 492 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data (IVAO not found)')); |
| 445 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
| 493 | + } else { |
|
| 494 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
| 495 | + } |
|
| 446 | 496 | } |
| 447 | 497 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
| 448 | 498 | $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert phpVMS data')); |
@@ -123,7 +123,9 @@ discard block |
||
| 123 | 123 | $temp += 1; |
| 124 | 124 | $flat = (float)($temp / (60.0 * 10000.0)); |
| 125 | 125 | $flat *= -1.0; |
| 126 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 126 | + } else { |
|
| 127 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 128 | + } |
|
| 127 | 129 | return $flat; // float |
| 128 | 130 | } |
| 129 | 131 | |
@@ -135,7 +137,9 @@ discard block |
||
| 135 | 137 | $temp += 1; |
| 136 | 138 | $flon = (float)($temp / (60.0 * 10000.0)); |
| 137 | 139 | $flon *= -1.0; |
| 138 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 140 | + } else { |
|
| 141 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 142 | + } |
|
| 139 | 143 | return $flon; |
| 140 | 144 | } |
| 141 | 145 | |
@@ -158,10 +162,8 @@ discard block |
||
| 158 | 162 | */ |
| 159 | 163 | private function asciidec_2_8bit($ascii) { |
| 160 | 164 | //only process in the following range: 48-87, 96-119 |
| 161 | - if ($ascii < 48) { } |
|
| 162 | - else { |
|
| 163 | - if($ascii>119) { } |
|
| 164 | - else { |
|
| 165 | + if ($ascii < 48) { } else { |
|
| 166 | + if($ascii>119) { } else { |
|
| 165 | 167 | if ($ascii>87 && $ascii<96) ; |
| 166 | 168 | else { |
| 167 | 169 | $ascii=$ascii+40; |
@@ -263,7 +265,9 @@ discard block |
||
| 263 | 265 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
| 264 | 266 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
| 265 | 267 | $ro->heading = bindec(substr($_aisdata,124,9)); |
| 266 | - if ($ro->heading == 511) $ro->heading = ''; |
|
| 268 | + if ($ro->heading == 511) { |
|
| 269 | + $ro->heading = ''; |
|
| 270 | + } |
|
| 267 | 271 | $ro->cls = 2; // class B |
| 268 | 272 | } else if ($ro->id == 19) { |
| 269 | 273 | $ro->cog = bindec(substr($_aisdata,112,12))/10; |
@@ -273,7 +277,9 @@ discard block |
||
| 273 | 277 | $ro->name = $this->binchar($_aisdata,143,120); |
| 274 | 278 | $ro->cls = 2; // class B |
| 275 | 279 | $ro->heading = bindec(substr($_aisdata,124,9)); |
| 276 | - if ($ro->heading == 511) $ro->heading = ''; |
|
| 280 | + if ($ro->heading == 511) { |
|
| 281 | + $ro->heading = ''; |
|
| 282 | + } |
|
| 277 | 283 | $ro->typeid = bindec(substr($_aisdata,263,8)); |
| 278 | 284 | $ro->type = $this->getShipType($ro->typeid); |
| 279 | 285 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
@@ -304,9 +310,13 @@ discard block |
||
| 304 | 310 | $ro->cls = 2; // class B |
| 305 | 311 | } else if ($ro->id == 27) { |
| 306 | 312 | $ro->cog = bindec(substr($_aisdata,85,9)); |
| 307 | - if ($ro->cog == 511) $ro->cog = 0.0; |
|
| 313 | + if ($ro->cog == 511) { |
|
| 314 | + $ro->cog = 0.0; |
|
| 315 | + } |
|
| 308 | 316 | $ro->sog = bindec(substr($_aisdata,79,6)); |
| 309 | - if ($ro->sog == 63) $ro->sog = 0.0; |
|
| 317 | + if ($ro->sog == 63) { |
|
| 318 | + $ro->sog = 0.0; |
|
| 319 | + } |
|
| 310 | 320 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
| 311 | 321 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
| 312 | 322 | $ro->cls = 1; // class A |
@@ -354,28 +364,48 @@ discard block |
||
| 354 | 364 | } |
| 355 | 365 | |
| 356 | 366 | public function getShipType($code) { |
| 357 | - if (isset($this->shiptype[$code])) return $this->shiptype[$code]; |
|
| 358 | - else return ''; |
|
| 367 | + if (isset($this->shiptype[$code])) { |
|
| 368 | + return $this->shiptype[$code]; |
|
| 369 | + } else { |
|
| 370 | + return ''; |
|
| 371 | + } |
|
| 359 | 372 | } |
| 360 | 373 | |
| 361 | 374 | public function getShipTypeID($type) { |
| 362 | 375 | $typeid = array_search($type,$this->shiptype); |
| 363 | - if ($typeid !== FALSE) return $typeid; |
|
| 364 | - elseif ($type == 'Cargo' || $type == 'General Cargo' || $type == 'Bulk Carrier' || $type == 'Container Ship' || $type == 'Cargo A' || $type == 'Reefer' || $type == 'Vehicles Carrier' || $type == 'Ro-Ro Cargo') return 70; |
|
| 365 | - elseif ($type == 'Passengers Ship' || $type == 'Passenger' || $type == 'Ro-Ro/Passenger Ship' || $type == 'Motor Passenger') return 60; |
|
| 366 | - elseif ($type == 'Tanker' || $type == 'Crude Oil Tanker' || $type == 'Oil Products Tanker' || $type == 'Oil/Chemical Tanker' || $type == 'Bunkering Tanker') return 80; |
|
| 367 | - elseif ($type == 'Lpg Tanker' || $type == 'Lng Tanker') return 84; |
|
| 368 | - elseif ($type == 'Sailing Vessel') return 36; |
|
| 369 | - elseif ($type == 'Yacht') return 37; |
|
| 370 | - elseif ($type == 'Trailing Suction Hopper Dredger' || $type == 'Drilling Jack Up' || $type == 'Suction Dredger' || $type == 'Hopper Dredger') return 33; |
|
| 371 | - elseif ($type == 'High speed craft') return 40; |
|
| 372 | - elseif ($type == 'Crew Boat') return 53; |
|
| 373 | - elseif ($type == 'Icebreaker') return 52; |
|
| 374 | - elseif ($type == 'Pollution Control Vessel') return 54; |
|
| 375 | - elseif ($type == 'Other Type') return 90; |
|
| 376 | - elseif ($type == 'Anchor Handling Vessel' || $type == 'Offshore Supply Ship' || $type == 'Research/Survey Vessel' || $type == 'Utility Vessel' || $type == 'Pipe Burying Vessel' || $type == 'Heavy Lift Vessel' || $type == 'Crane Ship' || $type == 'Buoy-laying Vessel') return 59; |
|
| 377 | - elseif ($type == 'Fish Carrier' || $type == 'Trawler' || $type == 'Trawlers' || $type == 'Fishing Vessel' || $type == 'Trawlers|unknown Not Fishing' || $type == 'Purse Seines|trawlers' || $type == 'Purse Seines' || $type == 'Trollers' || $type == 'Set Longlines' || $type == 'Set Gillnets|trawlers') return 30; |
|
| 378 | - else return 0; |
|
| 376 | + if ($typeid !== FALSE) { |
|
| 377 | + return $typeid; |
|
| 378 | + } elseif ($type == 'Cargo' || $type == 'General Cargo' || $type == 'Bulk Carrier' || $type == 'Container Ship' || $type == 'Cargo A' || $type == 'Reefer' || $type == 'Vehicles Carrier' || $type == 'Ro-Ro Cargo') { |
|
| 379 | + return 70; |
|
| 380 | + } elseif ($type == 'Passengers Ship' || $type == 'Passenger' || $type == 'Ro-Ro/Passenger Ship' || $type == 'Motor Passenger') { |
|
| 381 | + return 60; |
|
| 382 | + } elseif ($type == 'Tanker' || $type == 'Crude Oil Tanker' || $type == 'Oil Products Tanker' || $type == 'Oil/Chemical Tanker' || $type == 'Bunkering Tanker') { |
|
| 383 | + return 80; |
|
| 384 | + } elseif ($type == 'Lpg Tanker' || $type == 'Lng Tanker') { |
|
| 385 | + return 84; |
|
| 386 | + } elseif ($type == 'Sailing Vessel') { |
|
| 387 | + return 36; |
|
| 388 | + } elseif ($type == 'Yacht') { |
|
| 389 | + return 37; |
|
| 390 | + } elseif ($type == 'Trailing Suction Hopper Dredger' || $type == 'Drilling Jack Up' || $type == 'Suction Dredger' || $type == 'Hopper Dredger') { |
|
| 391 | + return 33; |
|
| 392 | + } elseif ($type == 'High speed craft') { |
|
| 393 | + return 40; |
|
| 394 | + } elseif ($type == 'Crew Boat') { |
|
| 395 | + return 53; |
|
| 396 | + } elseif ($type == 'Icebreaker') { |
|
| 397 | + return 52; |
|
| 398 | + } elseif ($type == 'Pollution Control Vessel') { |
|
| 399 | + return 54; |
|
| 400 | + } elseif ($type == 'Other Type') { |
|
| 401 | + return 90; |
|
| 402 | + } elseif ($type == 'Anchor Handling Vessel' || $type == 'Offshore Supply Ship' || $type == 'Research/Survey Vessel' || $type == 'Utility Vessel' || $type == 'Pipe Burying Vessel' || $type == 'Heavy Lift Vessel' || $type == 'Crane Ship' || $type == 'Buoy-laying Vessel') { |
|
| 403 | + return 59; |
|
| 404 | + } elseif ($type == 'Fish Carrier' || $type == 'Trawler' || $type == 'Trawlers' || $type == 'Fishing Vessel' || $type == 'Trawlers|unknown Not Fishing' || $type == 'Purse Seines|trawlers' || $type == 'Purse Seines' || $type == 'Trollers' || $type == 'Set Longlines' || $type == 'Set Gillnets|trawlers') { |
|
| 405 | + return 30; |
|
| 406 | + } else { |
|
| 407 | + return 0; |
|
| 408 | + } |
|
| 379 | 409 | } |
| 380 | 410 | |
| 381 | 411 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
@@ -412,11 +442,20 @@ discard block |
||
| 412 | 442 | // assume 1st ! is valid |
| 413 | 443 | // find * ensure that it is at correct position |
| 414 | 444 | $end = strrpos ( $rawdata , '*' ); |
| 415 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
| 445 | + if ($end === FALSE) { |
|
| 446 | + return -1; |
|
| 447 | + } |
|
| 448 | + // check for NULLS!!! |
|
| 416 | 449 | $cs = substr( $rawdata, $end + 1 ); |
| 417 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
| 450 | + if ( strlen($cs) != 2 ) { |
|
| 451 | + return -1; |
|
| 452 | + } |
|
| 453 | + // correct cs length |
|
| 418 | 454 | $dcs = (int)hexdec( $cs ); |
| 419 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
| 455 | + for ( $alias=1; $alias<$end; $alias++) { |
|
| 456 | + $chksum ^= ord( $rawdata[$alias] ); |
|
| 457 | + } |
|
| 458 | + // perform XOR for NMEA checksum |
|
| 420 | 459 | if ( $chksum == $dcs ) { // NMEA checksum pass |
| 421 | 460 | $pcs = explode(',', $rawdata); |
| 422 | 461 | // !AI??? identifier |
@@ -427,8 +466,14 @@ discard block |
||
| 427 | 466 | $num_seq = (int)$pcs[1]; // number of sequences |
| 428 | 467 | $seq = (int)$pcs[2]; // get sequence |
| 429 | 468 | // get msg sequence id |
| 430 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
| 431 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
| 469 | + if ($pcs[3] == '') { |
|
| 470 | + $msg_sid = -1; |
|
| 471 | + } |
|
| 472 | + // non-multipart message, set to -1 |
|
| 473 | + else { |
|
| 474 | + $msg_sid = (int)$pcs[3]; |
|
| 475 | + } |
|
| 476 | + // multipart message |
|
| 432 | 477 | $ais_ch = $pcs[4]; // get AIS channel |
| 433 | 478 | // message sequence checking |
| 434 | 479 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -491,10 +536,18 @@ discard block |
||
| 491 | 536 | //DEBUG echo "[$start $end $tst]\n"; |
| 492 | 537 | $result = $this->process_ais_raw( $tst, "" ); |
| 493 | 538 | $last_pos = $end + 1; |
| 494 | - } else break; |
|
| 539 | + } else { |
|
| 540 | + break; |
|
| 541 | + } |
|
| 542 | + } |
|
| 543 | + if ($last_pos > 0) { |
|
| 544 | + $cbuf = substr($cbuf, $last_pos); |
|
| 495 | 545 | } |
| 496 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
| 497 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
| 546 | + // move... |
|
| 547 | + if (strlen($cbuf) > 1024) { |
|
| 548 | + $cbuf = ""; |
|
| 549 | + } |
|
| 550 | + // prevent overflow simple mode... |
|
| 498 | 551 | return $result; |
| 499 | 552 | } |
| 500 | 553 | |
@@ -514,7 +567,9 @@ discard block |
||
| 514 | 567 | if ($lat<0.0) { |
| 515 | 568 | $lat = -$lat; |
| 516 | 569 | $neg=true; |
| 517 | - } else $neg=false; |
|
| 570 | + } else { |
|
| 571 | + $neg=false; |
|
| 572 | + } |
|
| 518 | 573 | $latd = 0x00000000; |
| 519 | 574 | $latd = intval ($lat * 600000.0); |
| 520 | 575 | if ($neg==true) { |
@@ -530,7 +585,9 @@ discard block |
||
| 530 | 585 | if ($lon<0.0) { |
| 531 | 586 | $lon = -$lon; |
| 532 | 587 | $neg=true; |
| 533 | - } else $neg=false; |
|
| 588 | + } else { |
|
| 589 | + $neg=false; |
|
| 590 | + } |
|
| 534 | 591 | $lond = 0x00000000; |
| 535 | 592 | $lond = intval ($lon * 600000.0); |
| 536 | 593 | if ($neg==true) { |
@@ -543,9 +600,14 @@ discard block |
||
| 543 | 600 | |
| 544 | 601 | private function char2bin($name, $max_len) { |
| 545 | 602 | $len = strlen($name); |
| 546 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
| 547 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 548 | - else $pad = ''; |
|
| 603 | + if ($len > $max_len) { |
|
| 604 | + $name = substr($name,0,$max_len); |
|
| 605 | + } |
|
| 606 | + if ($len < $max_len) { |
|
| 607 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 608 | + } else { |
|
| 609 | + $pad = ''; |
|
| 610 | + } |
|
| 549 | 611 | $rv = ''; |
| 550 | 612 | $ais_chars = array( |
| 551 | 613 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -558,9 +620,12 @@ discard block |
||
| 558 | 620 | ); |
| 559 | 621 | // " |
| 560 | 622 | $_a = str_split($name); |
| 561 | - if ($_a) foreach ($_a as $_1) { |
|
| 623 | + if ($_a) { |
|
| 624 | + foreach ($_a as $_1) { |
|
| 562 | 625 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
| 563 | - else $dec = 0; |
|
| 626 | + } else { |
|
| 627 | + $dec = 0; |
|
| 628 | + } |
|
| 564 | 629 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
| 565 | 630 | $rv .= $bin; |
| 566 | 631 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -572,7 +637,9 @@ discard block |
||
| 572 | 637 | $len_bit = strlen($_enc); |
| 573 | 638 | $rem6 = $len_bit % 6; |
| 574 | 639 | $pad6_len = 0; |
| 575 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
| 640 | + if ($rem6) { |
|
| 641 | + $pad6_len = 6 - $rem6; |
|
| 642 | + } |
|
| 576 | 643 | //echo $pad6_len.'<br>'; |
| 577 | 644 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
| 578 | 645 | $len_enc = strlen($_enc) / 6; |
@@ -581,8 +648,11 @@ discard block |
||
| 581 | 648 | for ($i=0; $i<$len_enc; $i++) { |
| 582 | 649 | $offset = $i * 6; |
| 583 | 650 | $dec = bindec(substr($_enc,$offset,6)); |
| 584 | - if ($dec < 40) $dec += 48; |
|
| 585 | - else $dec += 56; |
|
| 651 | + if ($dec < 40) { |
|
| 652 | + $dec += 48; |
|
| 653 | + } else { |
|
| 654 | + $dec += 56; |
|
| 655 | + } |
|
| 586 | 656 | //echo chr($dec)." $dec<br/>"; |
| 587 | 657 | $itu .= chr($dec); |
| 588 | 658 | } |
@@ -595,26 +665,42 @@ discard block |
||
| 595 | 665 | } |
| 596 | 666 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
| 597 | 667 | $lsb = $chksum & 0x0F; |
| 598 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
| 599 | - else $lsbc = '0'; |
|
| 668 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
| 669 | + $lsbc = $hex_arr[$lsb]; |
|
| 670 | + } else { |
|
| 671 | + $lsbc = '0'; |
|
| 672 | + } |
|
| 600 | 673 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
| 601 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
| 602 | - else $msbc = '0'; |
|
| 674 | + if ($msb >=0 && $msb <= 15 ) { |
|
| 675 | + $msbc = $hex_arr[$msb]; |
|
| 676 | + } else { |
|
| 677 | + $msbc = '0'; |
|
| 678 | + } |
|
| 603 | 679 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
| 604 | 680 | return $itu; |
| 605 | 681 | } |
| 606 | 682 | |
| 607 | 683 | public function parse($buffer) { |
| 608 | 684 | $data = $this->process_ais_buf($buffer); |
| 609 | - if (!is_object($data)) return array(); |
|
| 685 | + if (!is_object($data)) { |
|
| 686 | + return array(); |
|
| 687 | + } |
|
| 610 | 688 | $result = array(); |
| 611 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
| 612 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
| 689 | + if ($data->lon != 0) { |
|
| 690 | + $result['longitude'] = $data->lon; |
|
| 691 | + } |
|
| 692 | + if ($data->lat != 0) { |
|
| 693 | + $result['latitude'] = $data->lat; |
|
| 694 | + } |
|
| 613 | 695 | $result['ident'] = trim($data->name); |
| 614 | 696 | $result['timestamp'] = $data->ts; |
| 615 | 697 | $result['mmsi'] = $data->mmsi; |
| 616 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
| 617 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
| 698 | + if ($data->sog != -1.0) { |
|
| 699 | + $result['speed'] = $data->sog; |
|
| 700 | + } |
|
| 701 | + if ($data->cog != 0) { |
|
| 702 | + $result['heading'] = $data->cog; |
|
| 703 | + } |
|
| 618 | 704 | /* |
| 619 | 705 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
| 620 | 706 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -624,15 +710,25 @@ discard block |
||
| 624 | 710 | |
| 625 | 711 | public function mmsitype($mmsi) { |
| 626 | 712 | if (strlen($mmsi) == 9) { |
| 627 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
| 628 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
| 629 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
| 630 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
| 631 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
| 632 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
| 633 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
| 634 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
| 635 | - else return 'Ship'; |
|
| 713 | + if (substr($mmsi,0,3) == '974') { |
|
| 714 | + return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
| 715 | + } elseif (substr($mmsi,0,3) == '972') { |
|
| 716 | + return 'MOB (Man Overboard) device'; |
|
| 717 | + } elseif (substr($mmsi,0,3) == '970') { |
|
| 718 | + return 'AIS SART (Search and Rescue Transmitter)'; |
|
| 719 | + } elseif (substr($mmsi,0,3) == '111') { |
|
| 720 | + return 'SAR (Search and Rescue) aircraft'; |
|
| 721 | + } elseif (substr($mmsi,0,2) == '98') { |
|
| 722 | + return 'Auxiliary craft associated with a parent ship'; |
|
| 723 | + } elseif (substr($mmsi,0,2) == '99') { |
|
| 724 | + return 'Aids to Navigation'; |
|
| 725 | + } elseif (substr($mmsi,0,2) == '00') { |
|
| 726 | + return 'Coastal stations'; |
|
| 727 | + } elseif (substr($mmsi,0,1) == '0') { |
|
| 728 | + return 'Group of ships'; |
|
| 729 | + } else { |
|
| 730 | + return 'Ship'; |
|
| 731 | + } |
|
| 636 | 732 | } |
| 637 | 733 | |
| 638 | 734 | |
@@ -648,32 +744,61 @@ discard block |
||
| 648 | 744 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
| 649 | 745 | return array(); |
| 650 | 746 | } |
| 651 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
| 652 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
| 747 | + if ($data->lon != 0) { |
|
| 748 | + $result['longitude'] = $data->lon; |
|
| 749 | + } |
|
| 750 | + if ($data->lat != 0) { |
|
| 751 | + $result['latitude'] = $data->lat; |
|
| 752 | + } |
|
| 653 | 753 | $result['ident'] = trim(str_replace('@','',$data->name)); |
| 654 | 754 | $result['timestamp'] = $data->ts; |
| 655 | 755 | $result['mmsi'] = $data->mmsi; |
| 656 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
| 756 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') { |
|
| 757 | + $result['mmsi'] = '3'.$result['mmsi']; |
|
| 758 | + } |
|
| 657 | 759 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
| 658 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
| 659 | - if ($data->heading !== '') $result['heading'] = $data->heading; |
|
| 660 | - elseif ($data->cog != 0) $result['heading'] = $data->cog; |
|
| 661 | - if ($data->status != '') $result['status'] = $data->status; |
|
| 662 | - if ($data->statusid !== '') $result['statusid'] = $data->statusid; |
|
| 663 | - if ($data->type !== '') $result['type'] = $data->type; |
|
| 664 | - if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
|
| 665 | - if ($data->imo !== '') $result['imo'] = $data->imo; |
|
| 666 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
| 760 | + if ($data->sog != -1.0) { |
|
| 761 | + $result['speed'] = $data->sog; |
|
| 762 | + } |
|
| 763 | + if ($data->heading !== '') { |
|
| 764 | + $result['heading'] = $data->heading; |
|
| 765 | + } elseif ($data->cog != 0) { |
|
| 766 | + $result['heading'] = $data->cog; |
|
| 767 | + } |
|
| 768 | + if ($data->status != '') { |
|
| 769 | + $result['status'] = $data->status; |
|
| 770 | + } |
|
| 771 | + if ($data->statusid !== '') { |
|
| 772 | + $result['statusid'] = $data->statusid; |
|
| 773 | + } |
|
| 774 | + if ($data->type !== '') { |
|
| 775 | + $result['type'] = $data->type; |
|
| 776 | + } |
|
| 777 | + if ($data->typeid !== '') { |
|
| 778 | + $result['typeid'] = $data->typeid; |
|
| 779 | + } |
|
| 780 | + if ($data->imo !== '') { |
|
| 781 | + $result['imo'] = $data->imo; |
|
| 782 | + } |
|
| 783 | + if ($data->callsign !== '') { |
|
| 784 | + $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
| 785 | + } |
|
| 667 | 786 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
| 668 | 787 | $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
| 669 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
| 788 | + if ($eta_ts != '') { |
|
| 789 | + $result['eta_ts'] = $eta_ts; |
|
| 790 | + } |
|
| 670 | 791 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
| 671 | 792 | $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
| 672 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
| 793 | + if ($eta_ts != '') { |
|
| 794 | + $result['eta_ts'] = $eta_ts; |
|
| 795 | + } |
|
| 673 | 796 | } |
| 674 | 797 | if ($data->destination != '') { |
| 675 | 798 | $dest = trim(str_replace('@','',$data->destination)); |
| 676 | - if ($dest != '') $result['destination'] = $dest; |
|
| 799 | + if ($dest != '') { |
|
| 800 | + $result['destination'] = $dest; |
|
| 801 | + } |
|
| 677 | 802 | } |
| 678 | 803 | $result['all'] = (array) $data; |
| 679 | 804 | /* |
@@ -42,7 +42,9 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function checkAll() { |
| 44 | 44 | global $globalDebug; |
| 45 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 45 | + if ($globalDebug) { |
|
| 46 | + echo "Update last seen tracked data...\n"; |
|
| 47 | + } |
|
| 46 | 48 | foreach ($this->all_tracked as $key => $flight) { |
| 47 | 49 | if (isset($this->all_tracked[$key]['id'])) { |
| 48 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -55,12 +57,16 @@ discard block |
||
| 55 | 57 | public function del() { |
| 56 | 58 | global $globalDebug; |
| 57 | 59 | // Delete old infos |
| 58 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 60 | + if ($globalDebug) { |
|
| 61 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 62 | + } |
|
| 59 | 63 | foreach ($this->all_tracked as $key => $flight) { |
| 60 | 64 | if (isset($flight['lastupdate'])) { |
| 61 | 65 | if ($flight['lastupdate'] < (time()-3000)) { |
| 62 | 66 | if (isset($this->all_tracked[$key]['id'])) { |
| 63 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 67 | + if ($globalDebug) { |
|
| 68 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 69 | + } |
|
| 64 | 70 | /* |
| 65 | 71 | $TrackerLive = new TrackerLive(); |
| 66 | 72 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
@@ -70,7 +76,9 @@ discard block |
||
| 70 | 76 | $Tracker = new Tracker($this->db); |
| 71 | 77 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 72 | 78 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
| 73 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 79 | + if ($globalDebug && $result != 'success') { |
|
| 80 | + echo '!!! ERROR : '.$result."\n"; |
|
| 81 | + } |
|
| 74 | 82 | } |
| 75 | 83 | // Put in archive |
| 76 | 84 | // $Tracker->db = null; |
@@ -83,7 +91,9 @@ discard block |
||
| 83 | 91 | |
| 84 | 92 | public function add($line) { |
| 85 | 93 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
| 86 | - if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015'; |
|
| 94 | + if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') { |
|
| 95 | + $globalCoordMinChangeTracker = '0.015'; |
|
| 96 | + } |
|
| 87 | 97 | date_default_timezone_set('UTC'); |
| 88 | 98 | $dataFound = false; |
| 89 | 99 | $send = false; |
@@ -97,19 +107,29 @@ discard block |
||
| 97 | 107 | // Increment message number |
| 98 | 108 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 99 | 109 | $current_date = date('Y-m-d'); |
| 100 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 101 | - else $source = ''; |
|
| 102 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 110 | + if (isset($line['source_name'])) { |
|
| 111 | + $source = $line['source_name']; |
|
| 112 | + } else { |
|
| 113 | + $source = ''; |
|
| 114 | + } |
|
| 115 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 116 | + $source = $line['format_source']; |
|
| 117 | + } |
|
| 103 | 118 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 104 | 119 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 105 | 120 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 106 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 121 | + } else { |
|
| 122 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 123 | + } |
|
| 107 | 124 | } |
| 108 | 125 | |
| 109 | 126 | |
| 110 | 127 | $Common = new Common(); |
| 111 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
| 112 | - else $id = trim($line['id']); |
|
| 128 | + if (!isset($line['id'])) { |
|
| 129 | + $id = trim($line['ident']); |
|
| 130 | + } else { |
|
| 131 | + $id = trim($line['id']); |
|
| 132 | + } |
|
| 113 | 133 | |
| 114 | 134 | if (!isset($this->all_tracked[$id])) { |
| 115 | 135 | $this->all_tracked[$id] = array(); |
@@ -117,31 +137,46 @@ discard block |
||
| 117 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
| 118 | 138 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 119 | 139 | if (!isset($line['id'])) { |
| 120 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 140 | + if (!isset($globalDaemon)) { |
|
| 141 | + $globalDaemon = TRUE; |
|
| 142 | + } |
|
| 121 | 143 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 122 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 123 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 144 | + } else { |
|
| 145 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 146 | + } |
|
| 147 | + if ($globalAllTracked !== FALSE) { |
|
| 148 | + $dataFound = true; |
|
| 149 | + } |
|
| 124 | 150 | } |
| 125 | 151 | |
| 126 | 152 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 127 | 153 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
| 128 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 129 | 155 | } else { |
| 130 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 131 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 156 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 157 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 158 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 159 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 160 | + } |
|
| 132 | 161 | return ''; |
| 133 | 162 | } |
| 134 | 163 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 135 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 164 | + if ($globalDebug) { |
|
| 165 | + echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 166 | + } |
|
| 136 | 167 | return ''; |
| 137 | 168 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 138 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 169 | + if ($globalDebug) { |
|
| 170 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 171 | + } |
|
| 139 | 172 | return ''; |
| 140 | 173 | } elseif (!isset($line['datetime'])) { |
| 141 | 174 | date_default_timezone_set('UTC'); |
| 142 | 175 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 143 | 176 | } else { |
| 144 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 177 | + if ($globalDebug) { |
|
| 178 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 179 | + } |
|
| 145 | 180 | return ''; |
| 146 | 181 | } |
| 147 | 182 | |
@@ -153,11 +188,17 @@ discard block |
||
| 153 | 188 | $Tracker = new Tracker($this->db); |
| 154 | 189 | $fromsource = NULL; |
| 155 | 190 | $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 156 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 191 | + if ($globalDebug && $result != 'success') { |
|
| 192 | + echo '!!! ERROR : '.$result."\n"; |
|
| 193 | + } |
|
| 157 | 194 | $Tracker->db = null; |
| 158 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 195 | + if ($globalDebugTimeElapsed) { |
|
| 196 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 159 | 201 | } |
| 160 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 161 | 202 | } |
| 162 | 203 | |
| 163 | 204 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -168,14 +209,21 @@ discard block |
||
| 168 | 209 | if ($distance > 100 && $distance < 10000) { |
| 169 | 210 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 170 | 211 | $speed = $speed*3.6; |
| 171 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 172 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
| 212 | + if ($speed < 1000) { |
|
| 213 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 214 | + } |
|
| 215 | + if ($globalDebug) { |
|
| 216 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
| 217 | + } |
|
| 173 | 218 | } |
| 174 | 219 | } |
| 175 | 220 | |
| 176 | 221 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 177 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 178 | - else unset($timediff); |
|
| 222 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 223 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 224 | + } else { |
|
| 225 | + unset($timediff); |
|
| 226 | + } |
|
| 179 | 227 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
| 180 | 228 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 181 | 229 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) { |
@@ -183,20 +231,30 @@ discard block |
||
| 183 | 231 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 184 | 232 | $this->all_tracked[$id]['putinarchive'] = true; |
| 185 | 233 | |
| 186 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 234 | + if ($globalDebug) { |
|
| 235 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 236 | + } |
|
| 187 | 237 | $timeelapsed = microtime(true); |
| 188 | 238 | $Tracker = new Tracker($this->db); |
| 189 | 239 | $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 190 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 240 | + if (!empty($all_country)) { |
|
| 241 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 242 | + } |
|
| 191 | 243 | $Tracker->db = null; |
| 192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 244 | + if ($globalDebugTimeElapsed) { |
|
| 245 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 246 | + } |
|
| 193 | 247 | $this->tmd = 0; |
| 194 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 248 | + if ($globalDebug) { |
|
| 249 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 250 | + } |
|
| 195 | 251 | } |
| 196 | 252 | } |
| 197 | 253 | |
| 198 | 254 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 199 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 255 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 256 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 257 | + } |
|
| 200 | 258 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 201 | 259 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 202 | 260 | $dataFound = true; |
@@ -205,8 +263,12 @@ discard block |
||
| 205 | 263 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 206 | 264 | } |
| 207 | 265 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 208 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 209 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 266 | + if ($line['longitude'] > 180) { |
|
| 267 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 268 | + } |
|
| 269 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 270 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 271 | + } |
|
| 210 | 272 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 211 | 273 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 212 | 274 | $dataFound = true; |
@@ -226,7 +288,9 @@ discard block |
||
| 226 | 288 | } |
| 227 | 289 | } |
| 228 | 290 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 229 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 291 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 292 | + $dataFound = true; |
|
| 293 | + } |
|
| 230 | 294 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 231 | 295 | } |
| 232 | 296 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -246,7 +310,9 @@ discard block |
||
| 246 | 310 | |
| 247 | 311 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 248 | 312 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 249 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 313 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) { |
|
| 314 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 315 | + } |
|
| 250 | 316 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
| 251 | 317 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
| 252 | 318 | //$dataFound = true; |
@@ -258,15 +324,21 @@ discard block |
||
| 258 | 324 | } |
| 259 | 325 | |
| 260 | 326 | if (isset($line['heading']) && $line['heading'] != '') { |
| 261 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 327 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 328 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 329 | + } |
|
| 262 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 263 | 331 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 264 | 332 | //$dataFound = true; |
| 265 | 333 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 266 | 334 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 267 | 335 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 268 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 269 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 336 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 337 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 338 | + } |
|
| 339 | + if ($globalDebug) { |
|
| 340 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 341 | + } |
|
| 270 | 342 | } |
| 271 | 343 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 272 | 344 | |
@@ -275,20 +347,31 @@ discard block |
||
| 275 | 347 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
| 276 | 348 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 277 | 349 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 278 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 350 | + if ($globalDebug) { |
|
| 351 | + echo "Check if aircraft is already in DB..."; |
|
| 352 | + } |
|
| 279 | 353 | $timeelapsed = microtime(true); |
| 280 | 354 | $TrackerLive = new TrackerLive($this->db); |
| 281 | 355 | if (isset($line['id'])) { |
| 282 | 356 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
| 283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 357 | + if ($globalDebugTimeElapsed) { |
|
| 358 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 359 | + } |
|
| 284 | 360 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 285 | 361 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 287 | - } else $recent_ident = ''; |
|
| 362 | + if ($globalDebugTimeElapsed) { |
|
| 363 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 364 | + } |
|
| 365 | + } else { |
|
| 366 | + $recent_ident = ''; |
|
| 367 | + } |
|
| 288 | 368 | $TrackerLive->db=null; |
| 289 | 369 | |
| 290 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 291 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 370 | + if ($globalDebug && $recent_ident == '') { |
|
| 371 | + echo " Not in DB.\n"; |
|
| 372 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 373 | + echo " Already in DB.\n"; |
|
| 374 | + } |
|
| 292 | 375 | } else { |
| 293 | 376 | $recent_ident = ''; |
| 294 | 377 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -296,27 +379,41 @@ discard block |
||
| 296 | 379 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 297 | 380 | if($recent_ident == "") |
| 298 | 381 | { |
| 299 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 382 | + if ($globalDebug) { |
|
| 383 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 384 | + } |
|
| 300 | 385 | //adds the spotter data for the archive |
| 301 | 386 | $highlight = ''; |
| 302 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 387 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 388 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 389 | + } |
|
| 303 | 390 | $timeelapsed = microtime(true); |
| 304 | 391 | $Tracker = new Tracker($this->db); |
| 305 | 392 | $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
| 306 | 393 | $Tracker->db = null; |
| 307 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 394 | + if ($globalDebug && isset($result)) { |
|
| 395 | + echo $result."\n"; |
|
| 396 | + } |
|
| 397 | + if ($globalDebugTimeElapsed) { |
|
| 398 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 399 | + } |
|
| 309 | 400 | |
| 310 | 401 | |
| 311 | 402 | // Add source stat in DB |
| 312 | 403 | $Stats = new Stats($this->db); |
| 313 | 404 | if (!empty($this->stats)) { |
| 314 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 405 | + if ($globalDebug) { |
|
| 406 | + echo 'Add source stats : '; |
|
| 407 | + } |
|
| 315 | 408 | foreach($this->stats as $date => $data) { |
| 316 | 409 | foreach($data as $source => $sourced) { |
| 317 | 410 | //print_r($sourced); |
| 318 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
| 319 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
| 411 | + if (isset($sourced['polar'])) { |
|
| 412 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
| 413 | + } |
|
| 414 | + if (isset($sourced['hist'])) { |
|
| 415 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
| 416 | + } |
|
| 320 | 417 | if (isset($sourced['msg'])) { |
| 321 | 418 | if (time() - $sourced['msg']['date'] > 10) { |
| 322 | 419 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -329,7 +426,9 @@ discard block |
||
| 329 | 426 | unset($this->stats[$date]); |
| 330 | 427 | } |
| 331 | 428 | } |
| 332 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 429 | + if ($globalDebug) { |
|
| 430 | + echo 'Done'."\n"; |
|
| 431 | + } |
|
| 333 | 432 | |
| 334 | 433 | } |
| 335 | 434 | $Stats->db = null; |
@@ -339,12 +438,16 @@ discard block |
||
| 339 | 438 | $this->all_tracked[$id]['addedTracker'] = 1; |
| 340 | 439 | //print_r($this->all_tracked[$id]); |
| 341 | 440 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 342 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 441 | + if ($globalDebug) { |
|
| 442 | + echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 443 | + } |
|
| 343 | 444 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 344 | 445 | $TrackerLive = new TrackerLive($this->db); |
| 345 | 446 | $TrackerLive->deleteLiveTrackerData(); |
| 346 | 447 | $TrackerLive->db=null; |
| 347 | - if ($globalDebug) echo " Done\n"; |
|
| 448 | + if ($globalDebug) { |
|
| 449 | + echo " Done\n"; |
|
| 450 | + } |
|
| 348 | 451 | $this->last_delete = time(); |
| 349 | 452 | } |
| 350 | 453 | } else { |
@@ -367,19 +470,25 @@ discard block |
||
| 367 | 470 | |
| 368 | 471 | if (!$ignoreImport) { |
| 369 | 472 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 370 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 473 | + if ($globalDebug) { |
|
| 474 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 475 | + } |
|
| 371 | 476 | $timeelapsed = microtime(true); |
| 372 | 477 | $TrackerLive = new TrackerLive($this->db); |
| 373 | 478 | $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
| 374 | 479 | $TrackerLive->db = null; |
| 375 | 480 | $this->all_tracked[$id]['putinarchive'] = false; |
| 376 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 481 | + if ($globalDebugTimeElapsed) { |
|
| 482 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 483 | + } |
|
| 377 | 484 | |
| 378 | 485 | // Put statistics in $this->stats variable |
| 379 | 486 | |
| 380 | 487 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 381 | 488 | $source = $this->all_tracked[$id]['source_name']; |
| 382 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
| 489 | + if ($source == '') { |
|
| 490 | + $source = $this->all_tracked[$id]['format_source']; |
|
| 491 | + } |
|
| 383 | 492 | if (!isset($this->source_location[$source])) { |
| 384 | 493 | $Location = new Source($this->db); |
| 385 | 494 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -400,7 +509,9 @@ discard block |
||
| 400 | 509 | $stats_heading = round($stats_heading/22.5); |
| 401 | 510 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 402 | 511 | $current_date = date('Y-m-d'); |
| 403 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 512 | + if ($stats_heading == 16) { |
|
| 513 | + $stats_heading = 0; |
|
| 514 | + } |
|
| 404 | 515 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 405 | 516 | for ($i=0;$i<=15;$i++) { |
| 406 | 517 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -418,7 +529,9 @@ discard block |
||
| 418 | 529 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 419 | 530 | end($this->stats[$current_date][$source]['hist']); |
| 420 | 531 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 421 | - } else $mini = 0; |
|
| 532 | + } else { |
|
| 533 | + $mini = 0; |
|
| 534 | + } |
|
| 422 | 535 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 423 | 536 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 424 | 537 | } |
@@ -429,19 +542,29 @@ discard block |
||
| 429 | 542 | } |
| 430 | 543 | |
| 431 | 544 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 432 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 433 | - if ($globalDebug) echo $result."\n"; |
|
| 434 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 545 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 546 | + $send = true; |
|
| 547 | + } |
|
| 548 | + if ($globalDebug) { |
|
| 549 | + echo $result."\n"; |
|
| 550 | + } |
|
| 551 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 552 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 553 | + } |
|
| 435 | 554 | //$this->del(); |
| 436 | 555 | |
| 437 | 556 | |
| 438 | 557 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 558 | + if ($globalDebug) { |
|
| 559 | + echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 560 | + } |
|
| 440 | 561 | $TrackerLive = new TrackerLive($this->db); |
| 441 | 562 | $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 442 | 563 | $TrackerLive->db = null; |
| 443 | 564 | //TrackerLive->deleteLiveTrackerData(); |
| 444 | - if ($globalDebug) echo " Done\n"; |
|
| 565 | + if ($globalDebug) { |
|
| 566 | + echo " Done\n"; |
|
| 567 | + } |
|
| 445 | 568 | $this->last_delete_hourly = time(); |
| 446 | 569 | } |
| 447 | 570 | |
@@ -449,7 +572,9 @@ discard block |
||
| 449 | 572 | //$ignoreImport = false; |
| 450 | 573 | } |
| 451 | 574 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 452 | - if ($send) return $this->all_tracked[$id]; |
|
| 575 | + if ($send) { |
|
| 576 | + return $this->all_tracked[$id]; |
|
| 577 | + } |
|
| 453 | 578 | } |
| 454 | 579 | } |
| 455 | 580 | } |