@@ -7,18 +7,18 @@ discard block |
||
7 | 7 | die(); |
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
11 | -$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING)); |
|
12 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
13 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
10 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
11 | +$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING)); |
|
12 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
13 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
14 | 14 | $filter = array(); |
15 | -if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
16 | -if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
17 | -$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter); |
|
15 | +if ($year != '') $filter = array_merge($filter, array('year' => $year)); |
|
16 | +if ($month != '') $filter = array_merge($filter, array('month' => $month)); |
|
17 | +$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort, $filter); |
|
18 | 18 | |
19 | 19 | if (!empty($spotter_array)) |
20 | 20 | { |
21 | - $title = sprintf(_("Most Common Routes of %s"),$spotter_array[0]['aircraft_owner']); |
|
21 | + $title = sprintf(_("Most Common Routes of %s"), $spotter_array[0]['aircraft_owner']); |
|
22 | 22 | require_once('header.php'); |
23 | 23 | print '<div class="info column">'; |
24 | 24 | print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>'; |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | include('owner-sub-menu.php'); |
30 | 30 | print '<div class="column">'; |
31 | 31 | print '<h2>'._("Most Common Routes").'</h2>'; |
32 | - print '<p>'.sprintf(_("The statistic below shows the most common routes from flights owner by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>'; |
|
32 | + print '<p>'.sprintf(_("The statistic below shows the most common routes from flights owner by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>'; |
|
33 | 33 | |
34 | - $route_array = $Spotter->countAllRoutesByOwner($owner,$filter); |
|
34 | + $route_array = $Spotter->countAllRoutesByOwner($owner, $filter); |
|
35 | 35 | if (!empty($route_array)) |
36 | 36 | { |
37 | 37 | print '<div class="table-responsive">'; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | print '</thead>'; |
47 | 47 | print '<tbody>'; |
48 | 48 | $i = 1; |
49 | - foreach($route_array as $route_item) |
|
49 | + foreach ($route_array as $route_item) |
|
50 | 50 | { |
51 | 51 | print '<tr>'; |
52 | 52 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | $currentdate = date('Y-m-d'); |
35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
36 | 36 | if (!empty($sourcestat)) { |
37 | - foreach($sourcestat as $srcst) { |
|
37 | + foreach ($sourcestat as $srcst) { |
|
38 | 38 | $type = $srcst['stats_type']; |
39 | 39 | if ($type == 'polar' || $type == 'hist') { |
40 | 40 | $source = $srcst['source_name']; |
41 | 41 | $data = $srcst['source_data']; |
42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
42 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | if (isset($globalGeoid) && $globalGeoid) { |
52 | 52 | try { |
53 | 53 | $GeoidClass = new GeoidHeight(); |
54 | - } catch(Exception $e) { |
|
54 | + } catch (Exception $e) { |
|
55 | 55 | if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
56 | 56 | $GeoidClass = FALSE; |
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - public function get_Schedule($id,$ident) { |
|
61 | + public function get_Schedule($id, $ident) { |
|
62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
63 | 63 | // Get schedule here, so it's done only one time |
64 | 64 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | 85 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | 88 | // Should also check if route schedule = route from DB |
89 | 89 | if ($schedule['DepartureAirportIATA'] != '') { |
90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
107 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
108 | 108 | } |
109 | 109 | } else $scheduleexist = true; |
110 | 110 | } else $scheduleexist = true; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if ($scheduleexist) { |
113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
114 | 114 | $sch = $Schedule->getSchedule($operator); |
115 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
115 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
116 | 116 | } |
117 | 117 | $Spotter->db = null; |
118 | 118 | $Schedule->db = null; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
140 | 140 | $Spotter = new Spotter($this->db); |
141 | 141 | $real_arrival = $this->arrival($key); |
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
142 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $airport_time = ''; |
154 | 154 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
155 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
156 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
157 | 157 | if (isset($closestAirports[0])) { |
158 | 158 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
159 | 159 | $airport_icao = $closestAirports[0]['icao']; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | break; |
169 | 169 | } |
170 | 170 | } |
171 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
171 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
172 | 172 | $airport_icao = $closestAirports[0]['icao']; |
173 | 173 | $airport_time = $this->all_flights[$key]['datetime']; |
174 | 174 | } else { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } else { |
182 | 182 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
183 | 183 | } |
184 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
184 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
193 | 193 | foreach ($this->all_flights as $key => $flight) { |
194 | 194 | if (isset($flight['lastupdate'])) { |
195 | - if ($flight['lastupdate'] < (time()-5900)) { |
|
195 | + if ($flight['lastupdate'] < (time() - 5900)) { |
|
196 | 196 | $this->delKey($key); |
197 | 197 | } |
198 | 198 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $real_arrival = $this->arrival($key); |
209 | 209 | $Spotter = new Spotter($this->db); |
210 | 210 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
211 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
211 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
212 | 212 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
213 | 213 | } |
214 | 214 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $send = false; |
242 | 242 | |
243 | 243 | // SBS format is CSV format |
244 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
244 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
245 | 245 | //print_r($line); |
246 | 246 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
247 | 247 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
@@ -277,25 +277,25 @@ discard block |
||
277 | 277 | if (!isset($this->all_flights[$id])) { |
278 | 278 | if ($globalDebug) echo 'New flight...'."\n"; |
279 | 279 | $this->all_flights[$id] = array(); |
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
282 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
283 | 283 | if (!isset($line['id'])) { |
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
286 | 286 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
287 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
288 | 288 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
289 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
290 | 290 | if ($globalAllFlights !== FALSE) $dataFound = true; |
291 | 291 | } |
292 | 292 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | //print_r($this->all_flights); |
297 | 297 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
298 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
298 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
299 | 299 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
300 | 300 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
301 | 301 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -304,20 +304,20 @@ discard block |
||
304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
305 | 305 | $Spotter = new Spotter($this->db); |
306 | 306 | if (isset($this->all_flights[$id]['source_type'])) { |
307 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
307 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
308 | 308 | } else { |
309 | 309 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | 310 | } |
311 | 311 | $Spotter->db = null; |
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
312 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
313 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | if ($globalAllFlights !== FALSE) $dataFound = true; |
317 | 317 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
318 | 318 | } |
319 | 319 | if (isset($line['id']) && !isset($line['hex'])) { |
320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
321 | 321 | } |
322 | 322 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
323 | 323 | $icao = $line['aircraft_icao']; |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
327 | 327 | $Spotter->db = null; |
328 | 328 | } |
329 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
329 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
330 | 330 | } |
331 | 331 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
332 | 332 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $Spotter = new Spotter($this->db); |
335 | 335 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
336 | 336 | $Spotter->db = null; |
337 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
337 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -342,15 +342,15 @@ discard block |
||
342 | 342 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
343 | 343 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
344 | 344 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
345 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
345 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
346 | 346 | } |
347 | 347 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
348 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
348 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
349 | 349 | } |
350 | 350 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
351 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
351 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
352 | 352 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
353 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
353 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
354 | 354 | } else { |
355 | 355 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
356 | 356 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -361,31 +361,31 @@ discard block |
||
361 | 361 | */ |
362 | 362 | return ''; |
363 | 363 | } |
364 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
364 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
365 | 365 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
366 | 366 | return ''; |
367 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
367 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
368 | 368 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
369 | 369 | return ''; |
370 | 370 | } elseif (!isset($line['datetime'])) { |
371 | 371 | date_default_timezone_set('UTC'); |
372 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
372 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
373 | 373 | } else { |
374 | 374 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
375 | 375 | return ''; |
376 | 376 | } |
377 | 377 | |
378 | 378 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
379 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
379 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
380 | 380 | } |
381 | 381 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
382 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
382 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
383 | 383 | } |
384 | 384 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
385 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
385 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
386 | 386 | } |
387 | 387 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
388 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
388 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -393,13 +393,13 @@ discard block |
||
393 | 393 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
394 | 394 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
395 | 395 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
396 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
397 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
398 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
399 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
400 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
396 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
397 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
398 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
399 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
400 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
401 | 401 | } else { |
402 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
402 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
403 | 403 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
404 | 404 | $timeelapsed = microtime(true); |
405 | 405 | $Spotter = new Spotter($this->db); |
@@ -409,13 +409,13 @@ discard block |
||
409 | 409 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
410 | 410 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
411 | 411 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
412 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
412 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
413 | 413 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
414 | 414 | $Spotter->db = null; |
415 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
415 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
416 | 416 | } |
417 | 417 | } |
418 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
418 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
419 | 419 | |
420 | 420 | /* |
421 | 421 | if (!isset($line['id'])) { |
@@ -425,25 +425,25 @@ discard block |
||
425 | 425 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
426 | 426 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
427 | 427 | */ |
428 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
428 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
429 | 429 | |
430 | 430 | //$putinarchive = true; |
431 | 431 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
432 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
432 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
433 | 433 | } |
434 | 434 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
435 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
435 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
436 | 436 | } |
437 | 437 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
438 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
438 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
439 | 439 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
440 | 440 | $timeelapsed = microtime(true); |
441 | 441 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 442 | $Spotter = new Spotter($this->db); |
443 | 443 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
444 | 444 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
445 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
446 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
445 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
446 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
447 | 447 | } |
448 | 448 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
449 | 449 | $timeelapsed = microtime(true); |
@@ -457,35 +457,35 @@ discard block |
||
457 | 457 | $Translation->db = null; |
458 | 458 | } |
459 | 459 | $Spotter->db = null; |
460 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
460 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
461 | 461 | } |
462 | 462 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
463 | 463 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
464 | 464 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
465 | 465 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
466 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
466 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | if (!isset($globalFork)) $globalFork = TRUE; |
470 | 470 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
471 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
471 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
472 | 472 | } |
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | 476 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
477 | 477 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
478 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
479 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
478 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
479 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
480 | 480 | //$dataFound = true; |
481 | 481 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
482 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
482 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
483 | 483 | if ($distance > 1000 && $distance < 10000) { |
484 | 484 | // use datetime |
485 | 485 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
486 | 486 | $speed = $speed*3.6; |
487 | 487 | if ($speed < 1000) { |
488 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
488 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
489 | 489 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
490 | 490 | } else { |
491 | 491 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -500,9 +500,9 @@ discard block |
||
500 | 500 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
501 | 501 | return false; |
502 | 502 | } |
503 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
503 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
504 | 504 | else unset($timediff); |
505 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
505 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
506 | 506 | else unset($timediff_archive); |
507 | 507 | if ($this->tmd > 5 |
508 | 508 | || (isset($line['format_source']) |
@@ -526,14 +526,14 @@ discard block |
||
526 | 526 | || ($timediff > 30 |
527 | 527 | && isset($this->all_flights[$id]['latitude']) |
528 | 528 | && isset($this->all_flights[$id]['longitude']) |
529 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
529 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
530 | 530 | ) |
531 | 531 | ) { |
532 | 532 | |
533 | 533 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
534 | 534 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
535 | 535 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
536 | - || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
536 | + || !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
537 | 537 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
538 | 538 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
539 | 539 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -543,11 +543,11 @@ discard block |
||
543 | 543 | $timeelapsed = microtime(true); |
544 | 544 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
545 | 545 | $Spotter = new Spotter($this->db); |
546 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
546 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
547 | 547 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
548 | 548 | else $this->all_flights[$id]['over_country'] = ''; |
549 | 549 | $Spotter->db = null; |
550 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
550 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
551 | 551 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
552 | 552 | } |
553 | 553 | } |
@@ -573,13 +573,13 @@ discard block |
||
573 | 573 | $this->all_flights[$id]['time_last_coord'] = time(); |
574 | 574 | } |
575 | 575 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
576 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
576 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
577 | 577 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
578 | 578 | $dataFound = true; |
579 | 579 | $this->all_flights[$id]['time_last_coord'] = time(); |
580 | 580 | } |
581 | 581 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
582 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
582 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
583 | 583 | /* |
584 | 584 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
585 | 585 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -601,13 +601,13 @@ discard block |
||
601 | 601 | $this->all_flights[$id]['time_last_coord'] = time(); |
602 | 602 | } |
603 | 603 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
604 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
604 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
605 | 605 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
606 | 606 | $dataFound = true; |
607 | 607 | $this->all_flights[$id]['time_last_coord'] = time(); |
608 | 608 | } |
609 | 609 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
610 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
610 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
611 | 611 | /* |
612 | 612 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
613 | 613 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -625,46 +625,46 @@ discard block |
||
625 | 625 | } else if ($globalDebug && $timediff > 30) { |
626 | 626 | $this->tmd = $this->tmd + 1; |
627 | 627 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
628 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
629 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
628 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
629 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
630 | 630 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
631 | 631 | } |
632 | 632 | } |
633 | 633 | if (isset($line['last_update']) && $line['last_update'] != '') { |
634 | 634 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
635 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
635 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
636 | 636 | } |
637 | 637 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
638 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
638 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
639 | 639 | //$dataFound = true; |
640 | 640 | } |
641 | 641 | if (isset($line['format_source']) && $line['format_source'] != '') { |
642 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
642 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
643 | 643 | } |
644 | 644 | if (isset($line['source_name']) && $line['source_name'] != '') { |
645 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
645 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
646 | 646 | } |
647 | 647 | if (isset($line['emergency']) && $line['emergency'] != '') { |
648 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
648 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
649 | 649 | //$dataFound = true; |
650 | 650 | } |
651 | 651 | if (isset($line['ground']) && $line['ground'] != '') { |
652 | 652 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
653 | 653 | // Here we force archive of flight because after ground it's a new one (or should be) |
654 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
655 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
656 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
657 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
658 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
654 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
655 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
656 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
657 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
658 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
659 | 659 | } |
660 | 660 | if ($line['ground'] != 1) $line['ground'] = 0; |
661 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
661 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
662 | 662 | //$dataFound = true; |
663 | 663 | } |
664 | 664 | if (isset($line['squawk']) && $line['squawk'] != '') { |
665 | 665 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
666 | 666 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
667 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
667 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
668 | 668 | $highlight = ''; |
669 | 669 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
670 | 670 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -673,66 +673,66 @@ discard block |
||
673 | 673 | $timeelapsed = microtime(true); |
674 | 674 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
675 | 675 | $Spotter = new Spotter($this->db); |
676 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
676 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
677 | 677 | $Spotter->db = null; |
678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
678 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
679 | 679 | } |
680 | 680 | //$putinarchive = true; |
681 | 681 | //$highlight = ''; |
682 | 682 | } |
683 | 683 | |
684 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
684 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
685 | 685 | //$dataFound = true; |
686 | 686 | } |
687 | 687 | |
688 | 688 | if (isset($line['altitude']) && $line['altitude'] != '') { |
689 | 689 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
690 | 690 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
691 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
691 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
692 | 692 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
693 | 693 | $line['altitude'] = $line['altitude'] - $geoid; |
694 | 694 | } |
695 | 695 | } |
696 | 696 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
697 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
698 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
699 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
697 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
698 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
699 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
700 | 700 | //$dataFound = true; |
701 | 701 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
702 | 702 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
703 | 703 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
704 | 704 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
705 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
706 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
707 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
708 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
709 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
705 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
706 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
707 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
708 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
709 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
710 | 710 | } |
711 | 711 | } |
712 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
712 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
716 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
716 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | if (isset($line['heading']) && $line['heading'] != '') { |
720 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
721 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
722 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
720 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
721 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
722 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
723 | 723 | //$dataFound = true; |
724 | 724 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
725 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
726 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
727 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
725 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
726 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
727 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | 728 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
729 | 729 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
730 | 730 | // If not enough messages and ACARS set heading to 0 |
731 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
731 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
732 | 732 | } |
733 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
734 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
735 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
733 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
734 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
735 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
736 | 736 | |
737 | 737 | // print_r($this->all_flights[$id]); |
738 | 738 | //gets the callsign from the last hour |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
744 | 744 | $this->all_flights[$id]['lastupdate'] = time(); |
745 | 745 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
746 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
746 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
747 | 747 | //print_r($this->all_flights); |
748 | 748 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
749 | 749 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -754,61 +754,61 @@ discard block |
||
754 | 754 | $SpotterLive = new SpotterLive($this->db); |
755 | 755 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
756 | 756 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
757 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
757 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
758 | 758 | } elseif (isset($line['id'])) { |
759 | 759 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
760 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
760 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
761 | 761 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
762 | 762 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
763 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
763 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
764 | 764 | } else $recent_ident = ''; |
765 | - $SpotterLive->db=null; |
|
765 | + $SpotterLive->db = null; |
|
766 | 766 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
767 | 767 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
768 | 768 | } else $recent_ident = ''; |
769 | 769 | } else { |
770 | 770 | $recent_ident = ''; |
771 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
771 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
772 | 772 | } |
773 | 773 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
774 | - if($recent_ident == "") |
|
774 | + if ($recent_ident == "") |
|
775 | 775 | { |
776 | 776 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
777 | 777 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
778 | 778 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
779 | 779 | //adds the spotter data for the archive |
780 | 780 | $ignoreImport = false; |
781 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
781 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
782 | 782 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
783 | 783 | $ignoreImport = true; |
784 | 784 | } |
785 | 785 | } |
786 | 786 | if (count($globalAirportAccept) > 0) { |
787 | 787 | $ignoreImport = true; |
788 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
788 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
789 | 789 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
790 | 790 | $ignoreImport = false; |
791 | 791 | } |
792 | 792 | } |
793 | 793 | } |
794 | 794 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
795 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
796 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
795 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
796 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
797 | 797 | $ignoreImport = true; |
798 | 798 | } |
799 | 799 | } |
800 | 800 | } |
801 | 801 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
802 | 802 | $ignoreImport = true; |
803 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
804 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
803 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
804 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
805 | 805 | $ignoreImport = false; |
806 | 806 | } |
807 | 807 | } |
808 | 808 | } |
809 | 809 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
810 | 810 | $ignoreImport = true; |
811 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
811 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
812 | 812 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
813 | 813 | $ignoreImport = false; |
814 | 814 | } |
@@ -820,32 +820,32 @@ discard block |
||
820 | 820 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
821 | 821 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
822 | 822 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
823 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
823 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
824 | 824 | $timeelapsed = microtime(true); |
825 | 825 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
826 | 826 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
827 | 827 | $Spotter = new Spotter($this->db); |
828 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
828 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
829 | 829 | $Spotter->db = null; |
830 | 830 | if ($globalDebug && isset($result)) echo $result."\n"; |
831 | 831 | } |
832 | 832 | } |
833 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
833 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
834 | 834 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
835 | 835 | |
836 | 836 | // Add source stat in DB |
837 | 837 | $Stats = new Stats($this->db); |
838 | 838 | if (!empty($this->stats)) { |
839 | 839 | if ($globalDebug) echo 'Add source stats : '; |
840 | - foreach($this->stats as $date => $data) { |
|
841 | - foreach($data as $source => $sourced) { |
|
840 | + foreach ($this->stats as $date => $data) { |
|
841 | + foreach ($data as $source => $sourced) { |
|
842 | 842 | //print_r($sourced); |
843 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
844 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
843 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
844 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
845 | 845 | if (isset($sourced['msg'])) { |
846 | 846 | if (time() - $sourced['msg']['date'] > 10) { |
847 | 847 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
848 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
848 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
849 | 849 | unset($this->stats[$date][$source]['msg']); |
850 | 850 | } |
851 | 851 | } |
@@ -883,14 +883,14 @@ discard block |
||
883 | 883 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
884 | 884 | $SpotterLive = new SpotterLive($this->db); |
885 | 885 | $SpotterLive->deleteLiveSpotterData(); |
886 | - $SpotterLive->db=null; |
|
886 | + $SpotterLive->db = null; |
|
887 | 887 | } |
888 | 888 | } |
889 | 889 | if ($globalDebug) echo " Done\n"; |
890 | 890 | $this->last_delete = time(); |
891 | 891 | } |
892 | 892 | } else { |
893 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
893 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
894 | 894 | $this->all_flights[$id]['id'] = $recent_ident; |
895 | 895 | $this->all_flights[$id]['addedSpotter'] = 1; |
896 | 896 | } |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
899 | 899 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
900 | 900 | $Spotter = new Spotter($this->db); |
901 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
901 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
902 | 902 | $Spotter->db = null; |
903 | 903 | } |
904 | 904 | } |
@@ -924,37 +924,37 @@ discard block |
||
924 | 924 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
925 | 925 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
926 | 926 | |
927 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
927 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
928 | 928 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
929 | 929 | $ignoreImport = true; |
930 | 930 | } |
931 | 931 | } |
932 | 932 | if (count($globalAirportAccept) > 0) { |
933 | 933 | $ignoreImport = true; |
934 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
934 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
935 | 935 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
936 | 936 | $ignoreImport = false; |
937 | 937 | } |
938 | 938 | } |
939 | 939 | } |
940 | 940 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
941 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
942 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
941 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
942 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
943 | 943 | $ignoreImport = true; |
944 | 944 | } |
945 | 945 | } |
946 | 946 | } |
947 | 947 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
948 | 948 | $ignoreImport = true; |
949 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
950 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
949 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
950 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
951 | 951 | $ignoreImport = false; |
952 | 952 | } |
953 | 953 | } |
954 | 954 | } |
955 | 955 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
956 | 956 | $ignoreImport = true; |
957 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
957 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
958 | 958 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
959 | 959 | $ignoreImport = false; |
960 | 960 | } |
@@ -962,23 +962,23 @@ discard block |
||
962 | 962 | } |
963 | 963 | |
964 | 964 | if (!$ignoreImport) { |
965 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
966 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
965 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
966 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
967 | 967 | $timeelapsed = microtime(true); |
968 | 968 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
969 | 969 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
970 | 970 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
971 | 971 | $SpotterLive = new SpotterLive($this->db); |
972 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
972 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
973 | 973 | $SpotterLive->db = null; |
974 | 974 | if ($globalDebug) echo $result."\n"; |
975 | 975 | } |
976 | 976 | } |
977 | 977 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
978 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
978 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
979 | 979 | } |
980 | 980 | $this->all_flights[$id]['putinarchive'] = false; |
981 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
981 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
982 | 982 | |
983 | 983 | // Put statistics in $this->stats variable |
984 | 984 | //if ($line['format_source'] != 'aprs') { |
@@ -997,19 +997,19 @@ discard block |
||
997 | 997 | $latitude = $globalCenterLatitude; |
998 | 998 | $longitude = $globalCenterLongitude; |
999 | 999 | } |
1000 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
1000 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
1001 | 1001 | } else { |
1002 | 1002 | $latitude = $this->source_location[$source]['latitude']; |
1003 | 1003 | $longitude = $this->source_location[$source]['longitude']; |
1004 | 1004 | } |
1005 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1005 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1006 | 1006 | //$stats_heading = $stats_heading%22.5; |
1007 | 1007 | $stats_heading = round($stats_heading/22.5); |
1008 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1008 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1009 | 1009 | $current_date = date('Y-m-d'); |
1010 | 1010 | if ($stats_heading == 16) $stats_heading = 0; |
1011 | 1011 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1012 | - for ($i=0;$i<=15;$i++) { |
|
1012 | + for ($i = 0; $i <= 15; $i++) { |
|
1013 | 1013 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
1014 | 1014 | } |
1015 | 1015 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1024,9 +1024,9 @@ discard block |
||
1024 | 1024 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1025 | 1025 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1026 | 1026 | end($this->stats[$current_date][$source]['hist']); |
1027 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1027 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
1028 | 1028 | } else $mini = 0; |
1029 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
1029 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
1030 | 1030 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1031 | 1031 | } |
1032 | 1032 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | $this->all_flights[$id]['lastupdate'] = time(); |
1040 | 1040 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
1041 | 1041 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1042 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1042 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
1043 | 1043 | //$this->del(); |
1044 | 1044 | |
1045 | 1045 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -18,22 +18,22 @@ discard block |
||
18 | 18 | * @return Array the images list |
19 | 19 | * |
20 | 20 | */ |
21 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
21 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
22 | 22 | { |
23 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
24 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
25 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
23 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
24 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
25 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
26 | 26 | $reg = $registration; |
27 | 27 | if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
28 | 28 | $reg = trim($reg); |
29 | - $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 |
|
29 | + $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 | 30 | FROM spotter_image |
31 | 31 | WHERE spotter_image.registration = :registration LIMIT 1"; |
32 | 32 | $sth = $this->db->prepare($query); |
33 | 33 | $sth->execute(array(':registration' => $reg)); |
34 | 34 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
35 | 35 | if (!empty($result)) return $result; |
36 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
36 | + elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
37 | 37 | else return array(); |
38 | 38 | } |
39 | 39 | |
@@ -43,23 +43,23 @@ discard block |
||
43 | 43 | * @return Array the images list |
44 | 44 | * |
45 | 45 | */ |
46 | - public function getMarineImage($mmsi,$imo = '',$name = '') |
|
46 | + public function getMarineImage($mmsi, $imo = '', $name = '') |
|
47 | 47 | { |
48 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
49 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
50 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
48 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
49 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
50 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
51 | 51 | $name = trim($name); |
52 | - $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
52 | + $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
53 | 53 | FROM marine_image |
54 | 54 | WHERE marine_image.mmsi = :mmsi"; |
55 | 55 | $query_data = array(':mmsi' => $mmsi); |
56 | 56 | if ($imo != '') { |
57 | 57 | $query .= " AND marine_image.imo = :imo"; |
58 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
58 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
59 | 59 | } |
60 | 60 | if ($name != '') { |
61 | 61 | $query .= " AND marine_image.name = :name"; |
62 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
62 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
63 | 63 | } |
64 | 64 | $query .= " LIMIT 1"; |
65 | 65 | $sth = $this->db->prepare($query); |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
81 | 81 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
82 | 82 | if ($copyright != '') { |
83 | - $copyright = str_replace('Copyright ','',$copyright); |
|
84 | - $copyright = str_replace('© ','',$copyright); |
|
85 | - $copyright = str_replace('(c) ','',$copyright); |
|
83 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
84 | + $copyright = str_replace('© ', '', $copyright); |
|
85 | + $copyright = str_replace('(c) ', '', $copyright); |
|
86 | 86 | } |
87 | 87 | return $copyright; |
88 | 88 | } |
@@ -93,25 +93,25 @@ discard block |
||
93 | 93 | * @return String either success or error |
94 | 94 | * |
95 | 95 | */ |
96 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
96 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
97 | 97 | { |
98 | - global $globalDebug,$globalAircraftImageFetch; |
|
98 | + global $globalDebug, $globalAircraftImageFetch; |
|
99 | 99 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
100 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
100 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
101 | 101 | $registration = trim($registration); |
102 | 102 | //getting the aircraft image |
103 | 103 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
104 | 104 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
105 | 105 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
106 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
106 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
107 | 107 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
108 | 108 | if ($image_url['original'] != '') { |
109 | 109 | if ($globalDebug) echo 'Found !'."\n"; |
110 | - $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)"; |
|
110 | + $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 | 111 | try { |
112 | 112 | $sth = $this->db->prepare($query); |
113 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
114 | - } catch(PDOException $e) { |
|
113 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
114 | + } catch (PDOException $e) { |
|
115 | 115 | echo $e->getMessage()."\n"; |
116 | 116 | return "error"; |
117 | 117 | } |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | * @return String either success or error |
126 | 126 | * |
127 | 127 | */ |
128 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
128 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
129 | 129 | { |
130 | - global $globalDebug,$globalMarineImageFetch; |
|
130 | + global $globalDebug, $globalMarineImageFetch; |
|
131 | 131 | if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
132 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
133 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
134 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
132 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
133 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
134 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
135 | 135 | $name = trim($name); |
136 | 136 | $Marine = new Marine($this->db); |
137 | 137 | if ($imo == '' || $name == '') { |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | |
146 | 146 | //getting the aircraft image |
147 | 147 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
148 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
148 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
149 | 149 | if ($image_url['original'] != '') { |
150 | 150 | if ($globalDebug) echo 'Found !'."\n"; |
151 | - $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)"; |
|
151 | + $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 | 152 | try { |
153 | 153 | $sth = $this->db->prepare($query); |
154 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
155 | - } catch(PDOException $e) { |
|
154 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
155 | + } catch (PDOException $e) { |
|
156 | 156 | echo $e->getMessage()."\n"; |
157 | 157 | return "error"; |
158 | 158 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
173 | 173 | $Spotter = new Spotter($this->db); |
174 | 174 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
175 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
175 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
176 | 176 | if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) { |
177 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
177 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
178 | 178 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
179 | 179 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
180 | 180 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -188,25 +188,25 @@ discard block |
||
188 | 188 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
189 | 189 | else $aircraft_name = ''; |
190 | 190 | $aircraft_registration = $aircraft_icao; |
191 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
191 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
192 | 192 | unset($Spotter); |
193 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
193 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
194 | 194 | foreach ($globalAircraftImageSources as $source) { |
195 | 195 | $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); |
|
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 | 206 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
207 | 207 | } |
208 | 208 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
209 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
209 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * @return Array the aircraft thumbnail, orignal url and copyright |
219 | 219 | * |
220 | 220 | */ |
221 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
221 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
222 | 222 | { |
223 | 223 | global $globalMarineImageSources; |
224 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
224 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
225 | 225 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
226 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
226 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
227 | 227 | $name = trim($name); |
228 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
228 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
229 | 229 | /* |
230 | 230 | $Marine = new Marine($this->db); |
231 | 231 | if ($imo == '' || $name == '') { |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | } |
238 | 238 | unset($Marine); |
239 | 239 | */ |
240 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
240 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
241 | 241 | foreach ($globalMarineImageSources as $source) { |
242 | 242 | $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); |
|
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 | 248 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
249 | 249 | } |
250 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
250 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | * @return Array the aircraft thumbnail, orignal url and copyright |
259 | 259 | * |
260 | 260 | */ |
261 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
261 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
262 | 262 | $Common = new Common(); |
263 | 263 | // If aircraft registration is only number, also check with aircraft model |
264 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
265 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
264 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
265 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
266 | 266 | } else { |
267 | 267 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
268 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
268 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
269 | 269 | } |
270 | 270 | $data = $Common->getData($url); |
271 | 271 | if (substr($data, 0, 5) != "<?xml") return false; |
272 | 272 | if ($xml = simplexml_load_string($data)) { |
273 | 273 | if (isset($xml->channel->item)) { |
274 | 274 | $image_url = array(); |
275 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
275 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
276 | 276 | $image_url['thumbnail'] = $thumbnail_url; |
277 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
278 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
279 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
277 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
278 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
279 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
280 | 280 | $image_url['source'] = 'planespotters'; |
281 | 281 | return $image_url; |
282 | 282 | } |
@@ -292,31 +292,31 @@ discard block |
||
292 | 292 | * @return Array the aircraft thumbnail, orignal url and copyright |
293 | 293 | * |
294 | 294 | */ |
295 | - public function fromDeviantart($type,$registration, $name='') { |
|
295 | + public function fromDeviantart($type, $registration, $name = '') { |
|
296 | 296 | $Common = new Common(); |
297 | 297 | if ($type == 'aircraft') { |
298 | 298 | // If aircraft registration is only number, also check with aircraft model |
299 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
300 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
299 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
300 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
301 | 301 | } else { |
302 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
302 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
303 | 303 | } |
304 | 304 | } elseif ($type == 'marine') { |
305 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
305 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
306 | 306 | } else { |
307 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
307 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
308 | 308 | } |
309 | 309 | $data = $Common->getData($url); |
310 | 310 | if (substr($data, 0, 5) != "<?xml") return false; |
311 | 311 | if ($xml = simplexml_load_string($data)) { |
312 | 312 | if (isset($xml->channel->item->link)) { |
313 | 313 | $image_url = array(); |
314 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
314 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
315 | 315 | $image_url['thumbnail'] = $thumbnail_url; |
316 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
316 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
317 | 317 | $image_url['original'] = $original_url; |
318 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
319 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
318 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
319 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
320 | 320 | $image_url['source'] = 'deviantart'; |
321 | 321 | return $image_url; |
322 | 322 | } |
@@ -332,32 +332,32 @@ discard block |
||
332 | 332 | * @return Array the aircraft thumbnail, orignal url and copyright |
333 | 333 | * |
334 | 334 | */ |
335 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
335 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
336 | 336 | $Common = new Common(); |
337 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
337 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
338 | 338 | $data = $Common->getData($url); |
339 | 339 | $dom = new DOMDocument(); |
340 | 340 | @$dom->loadHTML($data); |
341 | 341 | $all_pics = array(); |
342 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
342 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
343 | 343 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
344 | 344 | $all_pics[] = $image->getAttribute('src'); |
345 | 345 | } |
346 | 346 | } |
347 | 347 | $all_authors = array(); |
348 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
348 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
349 | 349 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
350 | 350 | $all_authors[] = $author->getAttribute('content'); |
351 | 351 | } |
352 | 352 | } |
353 | 353 | $all_ref = array(); |
354 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
354 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
355 | 355 | $all_ref[] = $link->getAttribute('href'); |
356 | 356 | } |
357 | 357 | if (isset($all_pics[0])) { |
358 | 358 | $image_url = array(); |
359 | 359 | $image_url['thumbnail'] = $all_pics[0]; |
360 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
360 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
361 | 361 | $image_url['copyright'] = $all_authors[0]; |
362 | 362 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
363 | 363 | $image_url['source'] = 'JetPhotos'; |
@@ -374,24 +374,24 @@ discard block |
||
374 | 374 | * @return Array the aircraft thumbnail, orignal url and copyright |
375 | 375 | * |
376 | 376 | */ |
377 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
377 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
378 | 378 | $Common = new Common(); |
379 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
379 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
380 | 380 | $data = $Common->getData($url); |
381 | 381 | $dom = new DOMDocument(); |
382 | 382 | @$dom->loadHTML($data); |
383 | 383 | $all_pics = array(); |
384 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
384 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
385 | 385 | $all_pics[] = $image->getAttribute('src'); |
386 | 386 | } |
387 | 387 | $all_links = array(); |
388 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
389 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
388 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
389 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
390 | 390 | } |
391 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
391 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
392 | 392 | $image_url = array(); |
393 | 393 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
394 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
394 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
395 | 395 | $image_url['copyright'] = $all_links[6]['text']; |
396 | 396 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
397 | 397 | $image_url['source'] = 'PlanePictures'; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @return Array the aircraft thumbnail, orignal url and copyright |
409 | 409 | * |
410 | 410 | */ |
411 | - public function fromFlickr($type,$registration,$name='') { |
|
411 | + public function fromFlickr($type, $registration, $name = '') { |
|
412 | 412 | $Common = new Common(); |
413 | 413 | if ($type == 'aircraft') { |
414 | 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); |
@@ -421,12 +421,12 @@ discard block |
||
421 | 421 | if (substr($data, 0, 5) != "<?xml") return false; |
422 | 422 | if ($xml = simplexml_load_string($data)) { |
423 | 423 | if (isset($xml->channel->item)) { |
424 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
424 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
425 | 425 | $image_url = array(); |
426 | 426 | $image_url['thumbnail'] = $original_url; |
427 | 427 | $image_url['original'] = $original_url; |
428 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
429 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
428 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
429 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
430 | 430 | $image_url['source'] = 'flickr'; |
431 | 431 | return $image_url; |
432 | 432 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | return false; |
435 | 435 | } |
436 | 436 | |
437 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
437 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
438 | 438 | $Common = new Common(); |
439 | 439 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
440 | 440 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @return Array the aircraft thumbnail, orignal url and copyright |
459 | 459 | * |
460 | 460 | */ |
461 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
461 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
462 | 462 | global $globalImageBingKey; |
463 | 463 | $Common = new Common(); |
464 | 464 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
@@ -469,8 +469,8 @@ discard block |
||
469 | 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 | 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'; |
471 | 471 | } |
472 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
473 | - $data = $Common->getData($url,'get','',$headers); |
|
472 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
473 | + $data = $Common->getData($url, 'get', '', $headers); |
|
474 | 474 | $result = json_decode($data); |
475 | 475 | if (isset($result->d->results[0]->MediaUrl)) { |
476 | 476 | $image_url = array(); |
@@ -495,14 +495,14 @@ discard block |
||
495 | 495 | * @return Array the aircraft thumbnail, orignal url and copyright |
496 | 496 | * |
497 | 497 | */ |
498 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
498 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
499 | 499 | $Common = new Common(); |
500 | 500 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
501 | 501 | $data = $Common->getData($url); |
502 | 502 | $result = json_decode($data); |
503 | 503 | if (isset($result->count) && $result->count > 0) { |
504 | 504 | $image_url = array(); |
505 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
505 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
506 | 506 | $image_url['source_website'] = $result->data[0]->link; |
507 | 507 | $image_url['thumbnail'] = $result->data[0]->image; |
508 | 508 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @return Array the aircraft thumbnail, orignal url and copyright |
521 | 521 | * |
522 | 522 | */ |
523 | - public function fromWikimedia($type,$registration,$name='') { |
|
523 | + public function fromWikimedia($type, $registration, $name = '') { |
|
524 | 524 | $Common = new Common(); |
525 | 525 | if ($type == 'aircraft') { |
526 | 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); |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $result = json_decode($data); |
534 | 534 | if (isset($result->query->search[0]->title)) { |
535 | 535 | $fileo = $result->query->search[0]->title; |
536 | - if (substr($fileo,-3) == 'pdf') return false; |
|
536 | + if (substr($fileo, -3) == 'pdf') return false; |
|
537 | 537 | $file = urlencode($fileo); |
538 | 538 | $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 | 539 | $data2 = $Common->getData($url2); |
@@ -558,11 +558,11 @@ discard block |
||
558 | 558 | if (isset($result2->query->pages)) { |
559 | 559 | foreach ($result2->query->pages as $page) { |
560 | 560 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
561 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
561 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
562 | 562 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
563 | 563 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
564 | 564 | } |
565 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
565 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
566 | 566 | return $image_url; |
567 | 567 | } |
568 | 568 | } |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @return Array the aircraft thumbnail, orignal url and copyright |
582 | 582 | * |
583 | 583 | */ |
584 | - public function fromCustomSource($type,$registration,$name='') { |
|
584 | + public function fromCustomSource($type, $registration, $name = '') { |
|
585 | 585 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
586 | 586 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
587 | 587 | if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') { |
@@ -598,15 +598,15 @@ discard block |
||
598 | 598 | print_r($source); |
599 | 599 | print_r($customsources); |
600 | 600 | } |
601 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
602 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
601 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
602 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
603 | 603 | if ($Common->urlexist($url)) { |
604 | 604 | $image_url = array(); |
605 | 605 | $image_url['thumbnail'] = $url_thumbnail; |
606 | 606 | $image_url['original'] = $url; |
607 | 607 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
608 | 608 | else $exifCopyright = ''; |
609 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
609 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
610 | 610 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
611 | 611 | else $image_url['copyright'] = $source['source_website']; |
612 | 612 | $image_url['source_website'] = $source['source_website']; |
@@ -630,19 +630,19 @@ discard block |
||
630 | 630 | print_r($source); |
631 | 631 | print_r($customsources); |
632 | 632 | } |
633 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
634 | - $url = str_replace('{mmsi}',$registration,$url); |
|
635 | - $url = str_replace('{name}',$name,$url); |
|
636 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
637 | - $url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail); |
|
638 | - $url_thumbnail = str_replace('{name}',$name,$url_thumbnail); |
|
633 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
634 | + $url = str_replace('{mmsi}', $registration, $url); |
|
635 | + $url = str_replace('{name}', $name, $url); |
|
636 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
637 | + $url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail); |
|
638 | + $url_thumbnail = str_replace('{name}', $name, $url_thumbnail); |
|
639 | 639 | if ($Common->urlexist($url)) { |
640 | 640 | $image_url = array(); |
641 | 641 | $image_url['thumbnail'] = $url_thumbnail; |
642 | 642 | $image_url['original'] = $url; |
643 | 643 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
644 | 644 | else $exifCopyright = ''; |
645 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
645 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
646 | 646 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
647 | 647 | else $image_url['copyright'] = $source['source_website']; |
648 | 648 | $image_url['source_website'] = $source['source_website']; |
@@ -5,7 +5,7 @@ |
||
5 | 5 | |
6 | 6 | if ($_POST['registration'] != "") |
7 | 7 | { |
8 | - $registration = filter_input(INPUT_POST,'registration',FILTER_SANITIZE_STRING); |
|
8 | + $registration = filter_input(INPUT_POST, 'registration', FILTER_SANITIZE_STRING); |
|
9 | 9 | header('Location: '.$globalURL.'/registration/'.$registration); |
10 | 10 | } else { |
11 | 11 | if ($globalURL == '') { |
@@ -5,11 +5,11 @@ |
||
5 | 5 | |
6 | 6 | if ($_POST['aircraft_manufacturer'] != "") |
7 | 7 | { |
8 | - $aircraft_manufacturer = filter_input(INPUT_POST,'aircraft_manufacturer',FILTER_SANITIZE_STRING); |
|
8 | + $aircraft_manufacturer = filter_input(INPUT_POST, 'aircraft_manufacturer', FILTER_SANITIZE_STRING); |
|
9 | 9 | header('Location: '.$globalURL.'/manufacturer/'.$aircraft_manufacturer); |
10 | 10 | } elseif ($_GET['aircraft_manufacturer'] != "") |
11 | 11 | { |
12 | - $aircraft_manufacturer = filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING); |
|
12 | + $aircraft_manufacturer = filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING); |
|
13 | 13 | header('Location: '.$globalURL.'/manufacturer/'.$aircraft_manufacturer); |
14 | 14 | } else { |
15 | 15 | if ($globalURL == '') { |
@@ -5,7 +5,7 @@ |
||
5 | 5 | $Spotter = new Spotter(); |
6 | 6 | if ($_GET['flightaware_id'] != "") |
7 | 7 | { |
8 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
8 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
9 | 9 | $spotter_id = $Spotter->getSpotterIDBasedOnFlightAwareID($flightaware_id); |
10 | 10 | if ($spotter_id != "") |
11 | 11 | { |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | if (isset($_POST['country']) && $_POST['country'] != "") |
6 | 6 | { |
7 | - $country = filter_input(INPUT_POST,'country',FILTER_SANITIZE_STRING); |
|
7 | + $country = filter_input(INPUT_POST, 'country', FILTER_SANITIZE_STRING); |
|
8 | 8 | header('Location: '.$globalURL.'/country/'.$country); |
9 | 9 | } else { |
10 | 10 | if ($globalURL == '') { |
@@ -167,8 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | |
169 | 169 | private function urshift($n, $s) { |
170 | - return ($n >= 0) ? ($n >> $s) : |
|
171 | - (($n & 0x7fffffff) >> $s) | |
|
170 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| |
|
172 | 171 | (0x40000000 >> ($s - 1)); |
173 | 172 | } |
174 | 173 | |
@@ -180,7 +179,7 @@ discard block |
||
180 | 179 | //$split_input = str_split($input); |
181 | 180 | |
182 | 181 | /* Find the end of header checking for NULL bytes while doing it. */ |
183 | - $splitpos = strpos($input,':'); |
|
182 | + $splitpos = strpos($input, ':'); |
|
184 | 183 | |
185 | 184 | /* Check that end was found and body has at least one byte. */ |
186 | 185 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
@@ -190,15 +189,15 @@ discard block |
||
190 | 189 | |
191 | 190 | if ($debug) echo 'input : '.$input."\n"; |
192 | 191 | /* Save header and body. */ |
193 | - $body = substr($input,$splitpos+1,$input_len); |
|
192 | + $body = substr($input, $splitpos + 1, $input_len); |
|
194 | 193 | $body_len = strlen($body); |
195 | - $header = substr($input,0,$splitpos); |
|
194 | + $header = substr($input, 0, $splitpos); |
|
196 | 195 | //$header_len = strlen($header); |
197 | 196 | if ($debug) echo 'header : '.$header."\n"; |
198 | 197 | |
199 | 198 | /* Parse source, target and path. */ |
200 | 199 | //FLRDF0A52>APRS,qAS,LSTB |
201 | - if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
|
200 | + if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { |
|
202 | 201 | $ident = $matches[1]; |
203 | 202 | $all_elements = $matches[2]; |
204 | 203 | if ($ident == 'AIRCRAFT') { |
@@ -215,14 +214,14 @@ discard block |
||
215 | 214 | if ($debug) 'No ident'."\n"; |
216 | 215 | return false; |
217 | 216 | } |
218 | - $elements = explode(',',$all_elements); |
|
217 | + $elements = explode(',', $all_elements); |
|
219 | 218 | $source = end($elements); |
220 | 219 | $result['source'] = $source; |
221 | 220 | foreach ($elements as $element) { |
222 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
221 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { |
|
223 | 222 | //echo "ok"; |
224 | 223 | //if ($element == 'TCPIP*') return false; |
225 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
224 | + } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { |
|
226 | 225 | if ($debug) echo 'element : '.$element."\n"; |
227 | 226 | return false; |
228 | 227 | } |
@@ -235,14 +234,14 @@ discard block |
||
235 | 234 | */ |
236 | 235 | } |
237 | 236 | |
238 | - $type = substr($body,0,1); |
|
237 | + $type = substr($body, 0, 1); |
|
239 | 238 | if ($debug) echo 'type : '.$type."\n"; |
240 | 239 | if ($type == ';') { |
241 | 240 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
242 | - $result['address'] = trim(substr($body,1,9)); |
|
241 | + $result['address'] = trim(substr($body, 1, 9)); |
|
243 | 242 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
244 | - $result['mmsi'] = trim(substr($body,1,9)); |
|
245 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
243 | + $result['mmsi'] = trim(substr($body, 1, 9)); |
|
244 | + } else $result['ident'] = trim(substr($body, 1, 9)); |
|
246 | 245 | } elseif ($type == ',') { |
247 | 246 | // Invalid data or test data |
248 | 247 | return false; |
@@ -250,24 +249,24 @@ discard block |
||
250 | 249 | |
251 | 250 | // Check for Timestamp |
252 | 251 | $find = false; |
253 | - $body_parse = substr($body,1); |
|
252 | + $body_parse = substr($body, 1); |
|
254 | 253 | //echo 'Body : '.$body."\n"; |
255 | - if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
|
256 | - $body_parse = substr($body_parse,10); |
|
254 | + if (preg_match('/^;(.){9}\*/', $body, $matches)) { |
|
255 | + $body_parse = substr($body_parse, 10); |
|
257 | 256 | $find = true; |
258 | 257 | //echo $body_parse."\n"; |
259 | 258 | } |
260 | - if (preg_match('/^`(.*)\//',$body,$matches)) { |
|
261 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
259 | + if (preg_match('/^`(.*)\//', $body, $matches)) { |
|
260 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
262 | 261 | $find = true; |
263 | 262 | //echo $body_parse."\n"; |
264 | 263 | } |
265 | - if (preg_match("/^'(.*)\//",$body,$matches)) { |
|
266 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
264 | + if (preg_match("/^'(.*)\//", $body, $matches)) { |
|
265 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
267 | 266 | $find = true; |
268 | 267 | //echo $body_parse."\n"; |
269 | 268 | } |
270 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
|
269 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { |
|
271 | 270 | $find = true; |
272 | 271 | //print_r($matches); |
273 | 272 | $timestamp = $matches[0]; |
@@ -282,19 +281,19 @@ discard block |
||
282 | 281 | // This work or not ? |
283 | 282 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
284 | 283 | } |
285 | - $body_parse = substr($body_parse,7); |
|
284 | + $body_parse = substr($body_parse, 7); |
|
286 | 285 | $result['timestamp'] = $timestamp; |
287 | 286 | //echo date('Ymd H:i:s',$timestamp); |
288 | 287 | } |
289 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
|
288 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { |
|
290 | 289 | $find = true; |
291 | 290 | $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
292 | - $body_parse = substr($body_parse,8); |
|
291 | + $body_parse = substr($body_parse, 8); |
|
293 | 292 | $result['timestamp'] = $timestamp; |
294 | 293 | //echo date('Ymd H:i:s',$timestamp); |
295 | 294 | } |
296 | 295 | //if (strlen($body_parse) > 19) { |
297 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
296 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) { |
|
298 | 297 | $find = true; |
299 | 298 | // 4658.70N/00707.78Ez |
300 | 299 | //print_r(str_split($body_parse)); |
@@ -321,11 +320,11 @@ discard block |
||
321 | 320 | */ |
322 | 321 | $latitude = $lat + floatval($lat_min)/60; |
323 | 322 | $longitude = $lon + floatval($lon_min)/60; |
324 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
325 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
323 | + if ($sind == 'S') $latitude = 0 - $latitude; |
|
324 | + if ($wind == 'W') $longitude = 0 - $longitude; |
|
326 | 325 | $result['latitude'] = $latitude; |
327 | 326 | $result['longitude'] = $longitude; |
328 | - $body_parse = substr($body_parse,18); |
|
327 | + $body_parse = substr($body_parse, 18); |
|
329 | 328 | $body_parse_len = strlen($body_parse); |
330 | 329 | } |
331 | 330 | $body_parse_len = strlen($body_parse); |
@@ -357,7 +356,7 @@ discard block |
||
357 | 356 | //echo $body_parse; |
358 | 357 | //if ($type != ';' && $type != '>') { |
359 | 358 | if ($type != '') { |
360 | - $body_parse = substr($body_parse,1); |
|
359 | + $body_parse = substr($body_parse, 1); |
|
361 | 360 | $body_parse_len = strlen($body_parse); |
362 | 361 | $result['symbol_code'] = $symbol_code; |
363 | 362 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
@@ -368,16 +367,16 @@ discard block |
||
368 | 367 | //$body_parse_len = strlen($body_parse); |
369 | 368 | if ($body_parse_len >= 7) { |
370 | 369 | |
371 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
372 | - $course = substr($body_parse,0,3); |
|
370 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { |
|
371 | + $course = substr($body_parse, 0, 3); |
|
373 | 372 | $tmp_s = intval($course); |
374 | 373 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
375 | - $speed = substr($body_parse,4,3); |
|
374 | + $speed = substr($body_parse, 4, 3); |
|
376 | 375 | if ($speed != '...') { |
377 | 376 | //$result['speed'] = round($speed*1.852); |
378 | 377 | $result['speed'] = intval($speed); |
379 | 378 | } |
380 | - $body_parse = substr($body_parse,7); |
|
379 | + $body_parse = substr($body_parse, 7); |
|
381 | 380 | } |
382 | 381 | // Check PHGR, PHG, RNG |
383 | 382 | } |
@@ -387,12 +386,12 @@ discard block |
||
387 | 386 | } |
388 | 387 | */ |
389 | 388 | if (strlen($body_parse) > 0) { |
390 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
389 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { |
|
391 | 390 | $altitude = intval($matches[1]); |
392 | 391 | //$result['altitude'] = round($altitude*0.3048); |
393 | 392 | $result['altitude'] = $altitude; |
394 | 393 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
395 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
394 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); |
|
396 | 395 | } |
397 | 396 | } |
398 | 397 | |
@@ -404,13 +403,13 @@ discard block |
||
404 | 403 | */ |
405 | 404 | // DAO |
406 | 405 | |
407 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
406 | + if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { |
|
408 | 407 | |
409 | 408 | $dao = $matches[1]; |
410 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
409 | + if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { |
|
411 | 410 | $dao_split = str_split($dao); |
412 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
413 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
411 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; |
|
412 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; |
|
414 | 413 | |
415 | 414 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
416 | 415 | else $result['latitude'] += $lat_off; |
@@ -418,50 +417,50 @@ discard block |
||
418 | 417 | else $result['longitude'] += $lon_off; |
419 | 418 | } |
420 | 419 | |
421 | - $body_parse = substr($body_parse,6); |
|
420 | + $body_parse = substr($body_parse, 6); |
|
422 | 421 | } |
423 | 422 | echo 'bodyparse : '.$body_parse."\n"; |
424 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
425 | - $result['ident'] = str_replace('_',' ',$matches[1]); |
|
423 | + if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
424 | + $result['ident'] = str_replace('_', ' ', $matches[1]); |
|
426 | 425 | } |
427 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
426 | + if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { |
|
428 | 427 | $result['squawk'] = $matches[1]; |
429 | 428 | } |
430 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
429 | + if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { |
|
431 | 430 | $result['aircraft_icao'] = $matches[1]; |
432 | 431 | } |
433 | - if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
432 | + if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) { |
|
434 | 433 | $result['verticalrate'] = $matches[1]; |
435 | 434 | } |
436 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
435 | + if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) { |
|
437 | 436 | $result['typeid'] = $matches[1]; |
438 | 437 | } |
439 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
438 | + if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) { |
|
440 | 439 | $result['statusid'] = $matches[1]; |
441 | 440 | } |
442 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
441 | + if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) { |
|
443 | 442 | $result['imo'] = $matches[1]; |
444 | 443 | } |
445 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
444 | + if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) { |
|
446 | 445 | $result['arrival_date'] = $matches[1]; |
447 | 446 | } |
448 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
449 | - $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
|
447 | + if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
448 | + $result['arrival_code'] = str_replace('_', ' ', $matches[1]); |
|
450 | 449 | } |
451 | 450 | // OGN comment |
452 | 451 | // echo "Before OGN : ".$body_parse."\n"; |
453 | 452 | //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
454 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
453 | + if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { |
|
455 | 454 | $id = $matches[1]; |
456 | 455 | //$mode = substr($id,0,2); |
457 | - $address = substr($id,2); |
|
456 | + $address = substr($id, 2); |
|
458 | 457 | //print_r($matches); |
459 | - $addressType = (intval(substr($id,0,2),16))&3; |
|
458 | + $addressType = (intval(substr($id, 0, 2), 16))&3; |
|
460 | 459 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
461 | 460 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
462 | 461 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
463 | 462 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
464 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
|
463 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); |
|
465 | 464 | $result['aircrafttype_code'] = $aircraftType; |
466 | 465 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
467 | 466 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
@@ -478,7 +477,7 @@ discard block |
||
478 | 477 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
479 | 478 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
480 | 479 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
481 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
|
480 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; |
|
482 | 481 | $result['stealth'] = $stealth; |
483 | 482 | $result['address'] = $address; |
484 | 483 | } |
@@ -490,96 +489,96 @@ discard block |
||
490 | 489 | //$body_parse = substr($body_parse,1); |
491 | 490 | //$body_parse_len = strlen($body_parse); |
492 | 491 | //echo 'weather'."\n"; |
493 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
492 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
494 | 493 | $result['wind_dir'] = intval($matches[1]); |
495 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
496 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
497 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
498 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
499 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
494 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); |
|
495 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); |
|
496 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); |
|
497 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
498 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
500 | 499 | $result['wind_dir'] = intval($matches[1]); |
501 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
502 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
503 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
504 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
505 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
500 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
501 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
502 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
503 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
504 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
506 | 505 | $result['wind_dir'] = intval($matches[1]); |
507 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
508 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
509 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
510 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
506 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
507 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
508 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
509 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { |
|
511 | 510 | $result['wind_dir'] = intval($matches[1]); |
512 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
513 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
514 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
511 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
512 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
513 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
515 | 514 | } |
516 | 515 | //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
517 | 516 | //g012t088r000p000P000h38b10110 |
518 | 517 | //g011t086r000p000P000h29b10198 |
519 | - 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)) { |
|
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['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
524 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
518 | + 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)) { |
|
519 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
520 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
521 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
522 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
523 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); |
|
525 | 524 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
526 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
527 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
528 | - } 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)) { |
|
529 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
530 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
531 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
532 | - if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
533 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
525 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); |
|
526 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
527 | + } 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)) { |
|
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[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1); |
|
532 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); |
|
534 | 533 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
535 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
536 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
537 | - } 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)) { |
|
538 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
539 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
540 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
541 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
542 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
534 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); |
|
535 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
536 | + } 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)) { |
|
537 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
538 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
539 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
540 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
541 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); |
|
543 | 542 | if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
544 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
545 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
546 | - } 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)) { |
|
547 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
548 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
549 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
550 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
543 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); |
|
544 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
545 | + } 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)) { |
|
546 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
547 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
548 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
549 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); |
|
551 | 550 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
552 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
553 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
554 | - } 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)) { |
|
555 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
556 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
557 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
558 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
551 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
552 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
553 | + } 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)) { |
|
554 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
555 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
556 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
557 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
559 | 558 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
560 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
561 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
562 | - } 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)) { |
|
563 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
564 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
565 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
566 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
559 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
560 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
561 | + } 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)) { |
|
562 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
563 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
564 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
565 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
567 | 566 | if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
568 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
569 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
570 | - } 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)) { |
|
571 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
572 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
567 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); |
|
568 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
569 | + } 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)) { |
|
570 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
571 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
573 | 572 | if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
574 | - if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); |
|
575 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
576 | - } 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)) { |
|
577 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
578 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
579 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
573 | + if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1); |
|
574 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
575 | + } 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)) { |
|
576 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
577 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
578 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
580 | 579 | if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
581 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
582 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
580 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
581 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
583 | 582 | } |
584 | 583 | $result['comment'] = trim($body_parse); |
585 | 584 | } |
@@ -587,42 +586,42 @@ discard block |
||
587 | 586 | |
588 | 587 | } |
589 | 588 | //} |
590 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
591 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
589 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); |
|
590 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); |
|
592 | 591 | if ($debug) print_r($result); |
593 | 592 | return $result; |
594 | 593 | } |
595 | 594 | |
596 | 595 | public function connect() { |
597 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
596 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
598 | 597 | $aprs_connect = 0; |
599 | 598 | $aprs_keep = 120; |
600 | 599 | $aprs_last_tx = time(); |
601 | 600 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
602 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
601 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
603 | 602 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
604 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
603 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
605 | 604 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
606 | 605 | else $aprs_pass = '-1'; |
607 | 606 | |
608 | - $aprs_filter = ''; |
|
607 | + $aprs_filter = ''; |
|
609 | 608 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
610 | 609 | $Common = new Common(); |
611 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); |
|
610 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); |
|
612 | 611 | if ($s !== false) { |
613 | 612 | echo 'Connected to APRS server! '."\n"; |
614 | 613 | $authstart = time(); |
615 | 614 | $this->socket = $s; |
616 | - $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
|
617 | - socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); |
|
618 | - while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
|
615 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); |
|
616 | + socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1); |
|
617 | + while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { |
|
619 | 618 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
620 | 619 | echo 'APRS user verified !'."\n"; |
621 | 620 | $this->connected = true; |
622 | 621 | return true; |
623 | 622 | break; |
624 | 623 | } |
625 | - if (time()-$authstart > 5) { |
|
624 | + if (time() - $authstart > 5) { |
|
626 | 625 | echo 'APRS timeout'."\n"; |
627 | 626 | break; |
628 | 627 | } |
@@ -637,7 +636,7 @@ discard block |
||
637 | 636 | public function send($data) { |
638 | 637 | global $globalDebug; |
639 | 638 | if ($this->connected === false) $this->connect(); |
640 | - $send = socket_send( $this->socket , $data , strlen($data),0); |
|
639 | + $send = socket_send($this->socket, $data, strlen($data), 0); |
|
641 | 640 | if ($send === FALSE) { |
642 | 641 | if ($globalDebug) echo 'Reconnect...'; |
643 | 642 | socket_close($this->socket); |
@@ -647,17 +646,17 @@ discard block |
||
647 | 646 | } |
648 | 647 | |
649 | 648 | class APRSSpotter extends APRS { |
650 | - public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) { |
|
649 | + public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) { |
|
651 | 650 | $Common = new Common(); |
652 | 651 | date_default_timezone_set('UTC'); |
653 | 652 | if ($latitude != '' && $longitude != '') { |
654 | 653 | $lat = $latitude; |
655 | 654 | $long = $longitude; |
656 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
657 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
658 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
659 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
660 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
655 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
656 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
657 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
658 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
659 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
661 | 660 | $w = $w1.$w2; |
662 | 661 | //$w = '00'; |
663 | 662 | $custom = ''; |
@@ -684,26 +683,26 @@ discard block |
||
684 | 683 | $geoid= round($GeoidClass->get($lat,$long)*3.28084,2); |
685 | 684 | $altitude_real = round($altitude_real + $geoid); |
686 | 685 | */ |
687 | - $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
686 | + $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
688 | 687 | } |
689 | 688 | } |
690 | 689 | } |
691 | 690 | class APRSMarine extends APRS { |
692 | - public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) { |
|
691 | + public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) { |
|
693 | 692 | $Common = new Common(); |
694 | 693 | date_default_timezone_set('UTC'); |
695 | 694 | if ($latitude != '' && $longitude != '') { |
696 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
697 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
698 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
699 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
700 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
695 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
696 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
697 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
698 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
699 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
701 | 700 | $w = $w1.$w2; |
702 | 701 | //$w = '00'; |
703 | 702 | $custom = ''; |
704 | 703 | if ($ident != '') { |
705 | 704 | if ($custom != '') $custom .= '/'; |
706 | - $custom .= 'CS='.str_replace(' ','_',$ident); |
|
705 | + $custom .= 'CS='.str_replace(' ', '_', $ident); |
|
707 | 706 | } |
708 | 707 | if ($typeid != '') { |
709 | 708 | if ($custom != '') $custom .= '/'; |
@@ -723,11 +722,11 @@ discard block |
||
723 | 722 | } |
724 | 723 | if ($arrival_code != '') { |
725 | 724 | if ($custom != '') $custom .= '/'; |
726 | - $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
|
725 | + $custom .= 'AC='.str_replace(' ', '_', $arrival_code); |
|
727 | 726 | } |
728 | 727 | if ($custom != '') $custom = ' '.$custom; |
729 | 728 | $altitude = 0; |
730 | - $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"); |
|
729 | + $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"); |
|
731 | 730 | } |
732 | 731 | } |
733 | 732 | } |
@@ -5,17 +5,17 @@ discard block |
||
5 | 5 | require_once('require/class.Stats.php'); |
6 | 6 | require_once('require/class.METAR.php'); |
7 | 7 | |
8 | -if (!isset($_GET['airport'])){ |
|
8 | +if (!isset($_GET['airport'])) { |
|
9 | 9 | header('Location: '.$globalURL.'/airport'); |
10 | 10 | } else { |
11 | 11 | $Spotter = new Spotter(); |
12 | 12 | //calculation for the pagination |
13 | - if(!isset($_GET['limit'])) |
|
13 | + if (!isset($_GET['limit'])) |
|
14 | 14 | { |
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]; |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | $limit_next = $limit_end + $absolute_difference; |
29 | 29 | $limit_previous_1 = $limit_start - $absolute_difference; |
30 | 30 | $limit_previous_2 = $limit_end - $absolute_difference; |
31 | - $airport_icao = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING); |
|
31 | + $airport_icao = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING); |
|
32 | 32 | $airport = $airport_icao; |
33 | 33 | $page_url = $globalURL.'/airport/'.$airport_icao; |
34 | 34 | |
35 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
35 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
36 | 36 | if ($sort != '') { |
37 | - $spotter_array = $Spotter->getSpotterDataByAirport($airport_icao,$limit_start.",".$absolute_difference, $sort); |
|
37 | + $spotter_array = $Spotter->getSpotterDataByAirport($airport_icao, $limit_start.",".$absolute_difference, $sort); |
|
38 | 38 | } else { |
39 | - $spotter_array = $Spotter->getSpotterDataByAirport($airport_icao,$limit_start.",".$absolute_difference, ''); |
|
39 | + $spotter_array = $Spotter->getSpotterDataByAirport($airport_icao, $limit_start.",".$absolute_difference, ''); |
|
40 | 40 | } |
41 | 41 | $airport_array = $Spotter->getAllAirportInfo($airport_icao); |
42 | 42 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | //print_r($metar_parse); |
52 | 52 | } |
53 | 53 | |
54 | - $title = sprintf(_("Detailed View for %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']); |
|
54 | + $title = sprintf(_("Detailed View for %s, %s (%s)"), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']); |
|
55 | 55 | |
56 | 56 | require_once('header.php'); |
57 | 57 | |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | $airport_names = $Stats->getAllAirportNames(); |
64 | 64 | if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
65 | 65 | ksort($airport_names); |
66 | - foreach($airport_names as $airport_name) |
|
66 | + foreach ($airport_names as $airport_name) |
|
67 | 67 | { |
68 | - if($airport_icao == $airport_name['airport_icao']) |
|
68 | + if ($airport_icao == $airport_name['airport_icao']) |
|
69 | 69 | { |
70 | 70 | print '<option value="'.$airport_name['airport_icao'].'" selected="selected">'.$airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')</option>'; |
71 | 71 | } else { |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | $date_data = ''; |
112 | 112 | $departure_data = ''; |
113 | 113 | $arrival_data = ''; |
114 | - foreach($all_data as $data) |
|
114 | + foreach ($all_data as $data) |
|
115 | 115 | { |
116 | 116 | $date_data .= '"'.$data['date'].'",'; |
117 | 117 | $departure_data .= $data['departure'].','; |
118 | 118 | $arrival_data .= $data['arrival'].','; |
119 | 119 | } |
120 | - $date_data = "['x',".substr($date_data,0,-1)."]"; |
|
121 | - $departure_data = "['departure',".substr($departure_data,0,-1)."]"; |
|
122 | - $arrival_data = "['arrival',".substr($arrival_data,0,-1)."]"; |
|
120 | + $date_data = "['x',".substr($date_data, 0, -1)."]"; |
|
121 | + $departure_data = "['departure',".substr($departure_data, 0, -1)."]"; |
|
122 | + $arrival_data = "['arrival',".substr($arrival_data, 0, -1)."]"; |
|
123 | 123 | print 'c3.generate({ |
124 | 124 | bindto: "#chart", |
125 | 125 | data: { |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | print _("Dew point:").' '.$metar_parse['dew'].' °C'." - "; |
177 | 177 | } |
178 | 178 | if (isset($metar_parse['temperature']) && isset($metar_parse['dew'])) { |
179 | - $humidity = round(100 * pow((112 - (0.1 * $metar_parse['temperature']) + $metar_parse['dew']) / (112 + (0.9 * $metar_parse['temperature'])), 8),1); |
|
179 | + $humidity = round(100*pow((112 - (0.1*$metar_parse['temperature']) + $metar_parse['dew'])/(112 + (0.9*$metar_parse['temperature'])), 8), 1); |
|
180 | 180 | print _("Humidity:").' '.$humidity.'%'." - "; |
181 | 181 | } |
182 | 182 | if (isset($metar_parse['QNH'])) { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | print '<div class="table column">'; |
193 | 193 | if ($airport_array[0]['iata'] != "NA") |
194 | 194 | { |
195 | - print '<p>'.sprintf(_("The table below shows the detailed information of all flights to/from <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>'; |
|
195 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights to/from <strong>%s, %s (%s)</strong>."), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']).'</p>'; |
|
196 | 196 | } |
197 | 197 | include('table-output.php'); |
198 | 198 | print '<div class="pagination">'; |