@@ -39,30 +39,30 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | function quaternionrotate($heading, $attitude = 0, $bank = 0) { |
42 | - // Assuming the angles are in radians. |
|
43 | - $c1 = cos($heading/2); |
|
44 | - $s1 = sin($heading/2); |
|
45 | - $c2 = cos($attitude/2); |
|
46 | - $s2 = sin($attitude/2); |
|
47 | - $c3 = cos($bank/2); |
|
48 | - $s3 = sin($bank/2); |
|
49 | - $c1c2 = $c1*$c2; |
|
50 | - $s1s2 = $s1*$s2; |
|
51 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
52 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
53 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
54 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
55 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
42 | + // Assuming the angles are in radians. |
|
43 | + $c1 = cos($heading/2); |
|
44 | + $s1 = sin($heading/2); |
|
45 | + $c2 = cos($attitude/2); |
|
46 | + $s2 = sin($attitude/2); |
|
47 | + $c3 = cos($bank/2); |
|
48 | + $s3 = sin($bank/2); |
|
49 | + $c1c2 = $c1*$c2; |
|
50 | + $s1s2 = $s1*$s2; |
|
51 | + $w =$c1c2*$c3 - $s1s2*$s3; |
|
52 | + $x =$c1c2*$s3 + $s1s2*$c3; |
|
53 | + $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
54 | + $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
55 | + return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
56 | 56 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
57 | 57 | |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | 61 | if (isset($_GET['download'])) { |
62 | - if ($_GET['download'] == "true") |
|
63 | - { |
|
62 | + if ($_GET['download'] == "true") |
|
63 | + { |
|
64 | 64 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
65 | - } |
|
65 | + } |
|
66 | 66 | } |
67 | 67 | header('Content-Type: text/javascript'); |
68 | 68 | |
@@ -229,10 +229,10 @@ discard block |
||
229 | 229 | $image = "images/placeholder_thumb.png"; |
230 | 230 | } |
231 | 231 | |
232 | - if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id']; |
|
233 | - elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid']; |
|
234 | - elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id']; |
|
235 | - if ($prev_flightaware_id != $id) { |
|
232 | + if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id']; |
|
233 | + elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid']; |
|
234 | + elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id']; |
|
235 | + if ($prev_flightaware_id != $id) { |
|
236 | 236 | if ($prev_flightaware_id != '') { |
237 | 237 | $output .= ']'; |
238 | 238 | $output .= '}'; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
272 | 272 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
273 | 273 | } else $aircraft_shadow = ''; |
274 | - $output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5'; |
|
274 | + $output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5'; |
|
275 | 275 | if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] && isset($_COOKIE['IconColor'])) { |
276 | 276 | $rgb = $Common->hex2rgb($_COOKIE['IconColor']); |
277 | 277 | $output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}'; |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $rgb = $Common->hex2rgb($_COOKIE['IconColor']); |
302 | 302 | $output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}'; |
303 | 303 | } |
304 | - $output .= '},'; |
|
304 | + $output .= '},'; |
|
305 | 305 | } elseif ($aircraft_icao != '') { |
306 | 306 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
307 | 307 | if (isset($aircraft_info[0]['engine_type'])) { |
@@ -10,61 +10,61 @@ discard block |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | |
13 | - /** |
|
14 | - * Get SQL query part for filter used |
|
15 | - * @param Array $filter the filter |
|
16 | - * @return Array the SQL part |
|
17 | - */ |
|
18 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
13 | + /** |
|
14 | + * Get SQL query part for filter used |
|
15 | + * @param Array $filter the filter |
|
16 | + * @return Array the SQL part |
|
17 | + */ |
|
18 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | 19 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | - if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
|
21 | + if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
|
22 | 22 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
23 | 23 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
24 | 24 | } |
25 | - } else { |
|
25 | + } else { |
|
26 | 26 | $filter = $globalStatsFilters[$globalFilterName]; |
27 | - } |
|
27 | + } |
|
28 | 28 | } |
29 | 29 | if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | 32 | if (isset($filter['source']) && !empty($filter['source'])) { |
33 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
33 | + $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
34 | 34 | } |
35 | 35 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
36 | 36 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
37 | 37 | $filter_query = $filter_query_join.$filter_query_where; |
38 | 38 | return $filter_query; |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | - public function getAll() { |
|
42 | - $filter_query = $this->getFilter(array()); |
|
43 | - $query = "SELECT * FROM atc".$filter_query; |
|
44 | - $query_values = array(); |
|
45 | - try { |
|
46 | - $sth = $this->db->prepare($query); |
|
47 | - $sth->execute($query_values); |
|
48 | - } catch(PDOException $e) { |
|
49 | - return "error : ".$e->getMessage(); |
|
50 | - } |
|
51 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
52 | - return $all; |
|
53 | - } |
|
41 | + public function getAll() { |
|
42 | + $filter_query = $this->getFilter(array()); |
|
43 | + $query = "SELECT * FROM atc".$filter_query; |
|
44 | + $query_values = array(); |
|
45 | + try { |
|
46 | + $sth = $this->db->prepare($query); |
|
47 | + $sth->execute($query_values); |
|
48 | + } catch(PDOException $e) { |
|
49 | + return "error : ".$e->getMessage(); |
|
50 | + } |
|
51 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
52 | + return $all; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | public function getById($id) { |
56 | - $filter_query = $this->getFilter(array(),true); |
|
57 | - $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
|
58 | - $query_values = array(':id' => $id); |
|
59 | - try { |
|
60 | - $sth = $this->db->prepare($query); |
|
61 | - $sth->execute($query_values); |
|
62 | - } catch(PDOException $e) { |
|
63 | - return "error : ".$e->getMessage(); |
|
64 | - } |
|
65 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
66 | - return $all; |
|
67 | - } |
|
56 | + $filter_query = $this->getFilter(array(),true); |
|
57 | + $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
|
58 | + $query_values = array(':id' => $id); |
|
59 | + try { |
|
60 | + $sth = $this->db->prepare($query); |
|
61 | + $sth->execute($query_values); |
|
62 | + } catch(PDOException $e) { |
|
63 | + return "error : ".$e->getMessage(); |
|
64 | + } |
|
65 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
66 | + return $all; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | public function getByIdent($ident,$format_source = '') { |
70 | 70 | $filter_query = $this->getFilter(array(),true); |
@@ -117,53 +117,53 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - public function deleteById($id) { |
|
121 | - $query = "DELETE FROM atc WHERE atc_id = :id"; |
|
122 | - $query_values = array(':id' => $id); |
|
123 | - try { |
|
124 | - $sth = $this->db->prepare($query); |
|
125 | - $sth->execute($query_values); |
|
126 | - } catch(PDOException $e) { |
|
127 | - return "error : ".$e->getMessage(); |
|
128 | - } |
|
129 | - } |
|
120 | + public function deleteById($id) { |
|
121 | + $query = "DELETE FROM atc WHERE atc_id = :id"; |
|
122 | + $query_values = array(':id' => $id); |
|
123 | + try { |
|
124 | + $sth = $this->db->prepare($query); |
|
125 | + $sth->execute($query_values); |
|
126 | + } catch(PDOException $e) { |
|
127 | + return "error : ".$e->getMessage(); |
|
128 | + } |
|
129 | + } |
|
130 | 130 | |
131 | - public function deleteByIdent($ident,$format_source) { |
|
132 | - $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
|
133 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
134 | - try { |
|
135 | - $sth = $this->db->prepare($query); |
|
136 | - $sth->execute($query_values); |
|
137 | - } catch(PDOException $e) { |
|
138 | - return "error : ".$e->getMessage(); |
|
139 | - } |
|
140 | - } |
|
131 | + public function deleteByIdent($ident,$format_source) { |
|
132 | + $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
|
133 | + $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
134 | + try { |
|
135 | + $sth = $this->db->prepare($query); |
|
136 | + $sth->execute($query_values); |
|
137 | + } catch(PDOException $e) { |
|
138 | + return "error : ".$e->getMessage(); |
|
139 | + } |
|
140 | + } |
|
141 | 141 | |
142 | - public function deleteAll() { |
|
143 | - $query = "DELETE FROM atc"; |
|
144 | - $query_values = array(); |
|
145 | - try { |
|
146 | - $sth = $this->db->prepare($query); |
|
147 | - $sth->execute($query_values); |
|
148 | - } catch(PDOException $e) { |
|
149 | - return "error : ".$e->getMessage(); |
|
150 | - } |
|
151 | - } |
|
142 | + public function deleteAll() { |
|
143 | + $query = "DELETE FROM atc"; |
|
144 | + $query_values = array(); |
|
145 | + try { |
|
146 | + $sth = $this->db->prepare($query); |
|
147 | + $sth->execute($query_values); |
|
148 | + } catch(PDOException $e) { |
|
149 | + return "error : ".$e->getMessage(); |
|
150 | + } |
|
151 | + } |
|
152 | 152 | |
153 | 153 | public function deleteOldATC() { |
154 | - global $globalDBdriver; |
|
155 | - if ($globalDBdriver == 'mysql') { |
|
156 | - $query = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen"; |
|
157 | - } else { |
|
158 | - $query = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR' >= atc.atc_lastseen"; |
|
159 | - } |
|
160 | - try { |
|
161 | - $sth = $this->db->prepare($query); |
|
162 | - $sth->execute(); |
|
163 | - } catch(PDOException $e) { |
|
164 | - return "error"; |
|
165 | - } |
|
166 | - return "success"; |
|
167 | - } |
|
154 | + global $globalDBdriver; |
|
155 | + if ($globalDBdriver == 'mysql') { |
|
156 | + $query = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen"; |
|
157 | + } else { |
|
158 | + $query = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR' >= atc.atc_lastseen"; |
|
159 | + } |
|
160 | + try { |
|
161 | + $sth = $this->db->prepare($query); |
|
162 | + $sth->execute(); |
|
163 | + } catch(PDOException $e) { |
|
164 | + return "error"; |
|
165 | + } |
|
166 | + return "success"; |
|
167 | + } |
|
168 | 168 | } |
169 | 169 | ?> |
170 | 170 | \ No newline at end of file |
@@ -8,20 +8,20 @@ discard block |
||
8 | 8 | require_once(dirname(__FILE__).'/class.Stats.php'); |
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
11 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
11 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | class SpotterImport { |
15 | - private $all_flights = array(); |
|
16 | - private $last_delete_hourly = 0; |
|
17 | - private $last_delete = 0; |
|
18 | - private $stats = array(); |
|
19 | - private $tmd = 0; |
|
20 | - private $source_location = array(); |
|
21 | - public $db = null; |
|
22 | - public $nb = 0; |
|
23 | - |
|
24 | - public function __construct($dbc = null) { |
|
15 | + private $all_flights = array(); |
|
16 | + private $last_delete_hourly = 0; |
|
17 | + private $last_delete = 0; |
|
18 | + private $stats = array(); |
|
19 | + private $tmd = 0; |
|
20 | + private $source_location = array(); |
|
21 | + public $db = null; |
|
22 | + public $nb = 0; |
|
23 | + |
|
24 | + public function __construct($dbc = null) { |
|
25 | 25 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB; |
26 | 26 | if (!(isset($globalNoDB) && $globalNoDB)) { |
27 | 27 | $Connection = new Connection($dbc); |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | $currentdate = date('Y-m-d'); |
34 | 34 | $sourcestat = $Stats->getStatsSource($currentdate); |
35 | 35 | if (!empty($sourcestat)) { |
36 | - foreach($sourcestat as $srcst) { |
|
37 | - $type = $srcst['stats_type']; |
|
36 | + foreach($sourcestat as $srcst) { |
|
37 | + $type = $srcst['stats_type']; |
|
38 | 38 | if ($type == 'polar' || $type == 'hist') { |
39 | - $source = $srcst['source_name']; |
|
40 | - $data = $srcst['source_data']; |
|
41 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
42 | - } |
|
43 | - } |
|
39 | + $source = $srcst['source_name']; |
|
40 | + $data = $srcst['source_data']; |
|
41 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
42 | + } |
|
43 | + } |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | //$APRSSpotter->connect(); |
49 | 49 | } |
50 | 50 | |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | - public function get_Schedule($id,$ident) { |
|
53 | + public function get_Schedule($id,$ident) { |
|
54 | 54 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
55 | 55 | // Get schedule here, so it's done only one time |
56 | 56 | |
@@ -70,42 +70,42 @@ discard block |
||
70 | 70 | $operator = $Spotter->getOperator($ident); |
71 | 71 | $scheduleexist = false; |
72 | 72 | if ($Schedule->checkSchedule($operator) == 0) { |
73 | - $operator = $Translation->checkTranslation($ident); |
|
74 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
73 | + $operator = $Translation->checkTranslation($ident); |
|
74 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
75 | 75 | $schedule = $Schedule->fetchSchedule($operator); |
76 | 76 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
77 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
78 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
79 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
80 | - // Should also check if route schedule = route from DB |
|
81 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
77 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
78 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
79 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
80 | + // Should also check if route schedule = route from DB |
|
81 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
82 | 82 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
83 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
84 | - if (trim($airport_icao) != '') { |
|
83 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
84 | + if (trim($airport_icao) != '') { |
|
85 | 85 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
86 | 86 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
87 | - } |
|
87 | + } |
|
88 | + } |
|
88 | 89 | } |
89 | - } |
|
90 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
90 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
91 | 91 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
92 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
93 | - if (trim($airport_icao) != '') { |
|
92 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
93 | + if (trim($airport_icao) != '') { |
|
94 | 94 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
95 | 95 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
96 | - } |
|
96 | + } |
|
97 | 97 | } |
98 | - } |
|
99 | - $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']); |
|
98 | + } |
|
99 | + $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']); |
|
100 | 100 | } |
101 | - } else $scheduleexist = true; |
|
101 | + } else $scheduleexist = true; |
|
102 | 102 | } else $scheduleexist = true; |
103 | 103 | // close connection, at least one way will work ? |
104 | - if ($scheduleexist) { |
|
104 | + if ($scheduleexist) { |
|
105 | 105 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
106 | - $sch = $Schedule->getSchedule($operator); |
|
106 | + $sch = $Schedule->getSchedule($operator); |
|
107 | 107 | $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'])); |
108 | - } |
|
108 | + } |
|
109 | 109 | $Spotter->db = null; |
110 | 110 | $Schedule->db = null; |
111 | 111 | $Translation->db = null; |
@@ -120,78 +120,78 @@ discard block |
||
120 | 120 | } |
121 | 121 | */ |
122 | 122 | } |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | - public function checkAll() { |
|
125 | + public function checkAll() { |
|
126 | 126 | global $globalDebug, $globalNoImport; |
127 | 127 | if ($globalDebug) echo "Update last seen flights data...\n"; |
128 | 128 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
129 | - foreach ($this->all_flights as $key => $flight) { |
|
129 | + foreach ($this->all_flights as $key => $flight) { |
|
130 | 130 | if (isset($this->all_flights[$key]['id'])) { |
131 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
132 | - $Spotter = new Spotter($this->db); |
|
133 | - $real_arrival = $this->arrival($key); |
|
134 | - if (isset($this->all_flights[$key]['altitude'])) $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']); |
|
135 | - } |
|
136 | - } |
|
131 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
132 | + $Spotter = new Spotter($this->db); |
|
133 | + $real_arrival = $this->arrival($key); |
|
134 | + if (isset($this->all_flights[$key]['altitude'])) $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']); |
|
135 | + } |
|
136 | + } |
|
137 | + } |
|
137 | 138 | } |
138 | - } |
|
139 | 139 | |
140 | - public function arrival($key) { |
|
140 | + public function arrival($key) { |
|
141 | 141 | global $globalClosestMinDist, $globalDebug; |
142 | 142 | if ($globalDebug) echo 'Update arrival...'."\n"; |
143 | 143 | $Spotter = new Spotter($this->db); |
144 | - $airport_icao = ''; |
|
145 | - $airport_time = ''; |
|
146 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
144 | + $airport_icao = ''; |
|
145 | + $airport_time = ''; |
|
146 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
147 | 147 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
148 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
149 | - if (isset($closestAirports[0])) { |
|
150 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
151 | - $airport_icao = $closestAirports[0]['icao']; |
|
152 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
153 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
154 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
155 | - foreach ($closestAirports as $airport) { |
|
156 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
157 | - $airport_icao = $airport['icao']; |
|
158 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
159 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
160 | - break; |
|
161 | - } |
|
162 | - } |
|
163 | - } 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))) { |
|
164 | - $airport_icao = $closestAirports[0]['icao']; |
|
165 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
166 | - } else { |
|
167 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
168 | - } |
|
169 | - } else { |
|
170 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
171 | - } |
|
172 | - |
|
173 | - } else { |
|
174 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
175 | - } |
|
176 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - |
|
181 | - public function del() { |
|
148 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
149 | + if (isset($closestAirports[0])) { |
|
150 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
151 | + $airport_icao = $closestAirports[0]['icao']; |
|
152 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
153 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
154 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
155 | + foreach ($closestAirports as $airport) { |
|
156 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
157 | + $airport_icao = $airport['icao']; |
|
158 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
159 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
160 | + break; |
|
161 | + } |
|
162 | + } |
|
163 | + } 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))) { |
|
164 | + $airport_icao = $closestAirports[0]['icao']; |
|
165 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
166 | + } else { |
|
167 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
168 | + } |
|
169 | + } else { |
|
170 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
171 | + } |
|
172 | + |
|
173 | + } else { |
|
174 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
175 | + } |
|
176 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + |
|
181 | + public function del() { |
|
182 | 182 | global $globalDebug, $globalNoImport, $globalNoDB; |
183 | 183 | // Delete old infos |
184 | 184 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
185 | 185 | foreach ($this->all_flights as $key => $flight) { |
186 | - if (isset($flight['lastupdate'])) { |
|
186 | + if (isset($flight['lastupdate'])) { |
|
187 | 187 | if ($flight['lastupdate'] < (time()-5900)) { |
188 | - $this->delKey($key); |
|
188 | + $this->delKey($key); |
|
189 | + } |
|
189 | 190 | } |
190 | - } |
|
191 | 191 | } |
192 | - } |
|
192 | + } |
|
193 | 193 | |
194 | - public function delKey($key) { |
|
194 | + public function delKey($key) { |
|
195 | 195 | global $globalDebug, $globalNoImport, $globalNoDB; |
196 | 196 | // Delete old infos |
197 | 197 | if (isset($this->all_flights[$key]['id'])) { |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | } |
207 | 207 | } |
208 | 208 | unset($this->all_flights[$key]); |
209 | - } |
|
209 | + } |
|
210 | 210 | |
211 | - public function add($line) { |
|
211 | + public function add($line) { |
|
212 | 212 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate; |
213 | 213 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
214 | 214 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
@@ -234,20 +234,20 @@ discard block |
||
234 | 234 | |
235 | 235 | // SBS format is CSV format |
236 | 236 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
237 | - //print_r($line); |
|
238 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
239 | - 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)) { |
|
237 | + //print_r($line); |
|
238 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
239 | + 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)) { |
|
240 | 240 | |
241 | 241 | // Increment message number |
242 | 242 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
243 | - $current_date = date('Y-m-d'); |
|
244 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
245 | - else $source = ''; |
|
246 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
247 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
248 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
249 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
250 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
243 | + $current_date = date('Y-m-d'); |
|
244 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
245 | + else $source = ''; |
|
246 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
247 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
248 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
249 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
250 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /* |
@@ -263,49 +263,49 @@ discard block |
||
263 | 263 | //$this->db = $dbc; |
264 | 264 | |
265 | 265 | //$hex = trim($line['hex']); |
266 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
267 | - else $id = trim($line['id']); |
|
266 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
267 | + else $id = trim($line['id']); |
|
268 | 268 | |
269 | 269 | if (!isset($this->all_flights[$id])) { |
270 | - $this->all_flights[$id] = array(); |
|
271 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
272 | - $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' => '')); |
|
273 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
274 | - if (!isset($line['id'])) { |
|
270 | + $this->all_flights[$id] = array(); |
|
271 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
272 | + $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' => '')); |
|
273 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
274 | + if (!isset($line['id'])) { |
|
275 | 275 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
276 | 276 | // 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'))); |
277 | 277 | // 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'))); |
278 | 278 | 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'))); |
279 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
280 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
281 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
279 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
280 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
281 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
282 | 282 | } |
283 | 283 | if (isset($line['source_type']) && $line['source_type'] != '') { |
284 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
284 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | //print_r($this->all_flights); |
288 | 288 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
289 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
290 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
289 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
290 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
291 | 291 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
292 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
293 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
292 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
293 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
294 | 294 | $timeelapsed = microtime(true); |
295 | 295 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
296 | - $Spotter = new Spotter($this->db); |
|
297 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
296 | + $Spotter = new Spotter($this->db); |
|
297 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
298 | 298 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
299 | - } else { |
|
299 | + } else { |
|
300 | 300 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
301 | - } |
|
302 | - $Spotter->db = null; |
|
303 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
304 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
301 | + } |
|
302 | + $Spotter->db = null; |
|
303 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
304 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
305 | + } |
|
305 | 306 | } |
306 | - } |
|
307 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
308 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
307 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
308 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
309 | 309 | } |
310 | 310 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
311 | 311 | $icao = $line['aircraft_icao']; |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | } |
336 | 336 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
337 | 337 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
338 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
338 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
339 | 339 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
340 | - } else { |
|
340 | + } else { |
|
341 | 341 | 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"; |
342 | 342 | 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"; |
343 | 343 | /* |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | print_r($line); |
347 | 347 | */ |
348 | 348 | return ''; |
349 | - } |
|
349 | + } |
|
350 | 350 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
351 | 351 | if ($globalDebug) echo "!!! Date is too old ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
352 | 352 | return ''; |
@@ -362,21 +362,21 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
365 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
365 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
366 | 366 | } |
367 | 367 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
368 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
368 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
369 | 369 | } |
370 | 370 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
371 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
371 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
372 | 372 | } |
373 | 373 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
374 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
374 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | 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'])) { |
378 | 378 | |
379 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
379 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
380 | 380 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 2300) { |
381 | 381 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
382 | 382 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -385,23 +385,23 @@ discard block |
||
385 | 385 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
386 | 386 | 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'])); |
387 | 387 | } else { |
388 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
389 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
388 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
389 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
390 | 390 | $timeelapsed = microtime(true); |
391 | - $Spotter = new Spotter($this->db); |
|
392 | - $fromsource = NULL; |
|
393 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
394 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
391 | + $Spotter = new Spotter($this->db); |
|
392 | + $fromsource = NULL; |
|
393 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
394 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
395 | 395 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
396 | 396 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
397 | 397 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
398 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
398 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
399 | 399 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
400 | 400 | $Spotter->db = null; |
401 | 401 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
402 | - } |
|
402 | + } |
|
403 | 403 | } |
404 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
404 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
405 | 405 | |
406 | 406 | /* |
407 | 407 | if (!isset($line['id'])) { |
@@ -411,86 +411,86 @@ discard block |
||
411 | 411 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
412 | 412 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
413 | 413 | */ |
414 | - 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'])); |
|
414 | + 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'])); |
|
415 | 415 | |
416 | - //$putinarchive = true; |
|
417 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
416 | + //$putinarchive = true; |
|
417 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
418 | 418 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
419 | - } |
|
420 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
419 | + } |
|
420 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
421 | 421 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
422 | - } |
|
423 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
424 | - $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' => '')); |
|
425 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
422 | + } |
|
423 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
424 | + $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' => '')); |
|
425 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
426 | 426 | $timeelapsed = microtime(true); |
427 | 427 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
428 | 428 | $Spotter = new Spotter($this->db); |
429 | 429 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
430 | 430 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
431 | - $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' => '')); |
|
431 | + $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' => '')); |
|
432 | 432 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
433 | - } |
|
434 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
433 | + } |
|
434 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
435 | 435 | $timeelapsed = microtime(true); |
436 | 436 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
437 | - $Spotter = new Spotter($this->db); |
|
438 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
439 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
437 | + $Spotter = new Spotter($this->db); |
|
438 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
439 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
440 | 440 | $Translation = new Translation($this->db); |
441 | 441 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
442 | 442 | $route = $Spotter->getRouteInfo($ident); |
443 | 443 | $Translation->db = null; |
444 | - } |
|
445 | - $Spotter->db = null; |
|
446 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
447 | - } |
|
444 | + } |
|
445 | + $Spotter->db = null; |
|
446 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
447 | + } |
|
448 | 448 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
449 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
450 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
449 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
450 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
451 | 451 | // $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'])); |
452 | - $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'])); |
|
453 | - } |
|
452 | + $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'])); |
|
453 | + } |
|
454 | 454 | } |
455 | 455 | if (!isset($globalFork)) $globalFork = TRUE; |
456 | 456 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
457 | 457 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
458 | 458 | } |
459 | - } |
|
459 | + } |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | if (isset($line['speed']) && $line['speed'] != '') { |
463 | 463 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
464 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
465 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
466 | - //$dataFound = true; |
|
464 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
465 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
466 | + //$dataFound = true; |
|
467 | 467 | } 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'])) { |
468 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
469 | - if ($distance > 1000 && $distance < 10000) { |
|
470 | - // use datetime |
|
468 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
469 | + if ($distance > 1000 && $distance < 10000) { |
|
470 | + // use datetime |
|
471 | 471 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
472 | 472 | $speed = $speed*3.6; |
473 | 473 | if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
474 | 474 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
475 | - } |
|
475 | + } |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
479 | 479 | |
480 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude']) && !is_int($line['latitude']) && !is_int($line['longitude'])) { |
|
481 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
482 | - else unset($timediff); |
|
483 | - if ($this->tmd > 5 || (isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
480 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude']) && !is_int($line['latitude']) && !is_int($line['longitude'])) { |
|
481 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
482 | + else unset($timediff); |
|
483 | + if ($this->tmd > 5 || (isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
484 | 484 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
485 | - if ((isset($timediff) && $timediff > $globalAircraftMaxUpdate) || !$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'])) { |
|
485 | + if ((isset($timediff) && $timediff > $globalAircraftMaxUpdate) || !$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'])) { |
|
486 | 486 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
487 | 487 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
488 | 488 | $this->all_flights[$id]['putinarchive'] = true; |
489 | 489 | $this->tmd = 0; |
490 | 490 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
491 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
492 | - $timeelapsed = microtime(true); |
|
493 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
491 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
492 | + $timeelapsed = microtime(true); |
|
493 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
494 | 494 | $Spotter = new Spotter($this->db); |
495 | 495 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
496 | 496 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -498,18 +498,18 @@ discard block |
||
498 | 498 | $Spotter->db = null; |
499 | 499 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
500 | 500 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
501 | - } |
|
501 | + } |
|
502 | + } |
|
502 | 503 | } |
503 | - } |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
507 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
507 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
508 | 508 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
509 | 509 | 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') { |
510 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
511 | - $dataFound = true; |
|
512 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
510 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
511 | + $dataFound = true; |
|
512 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
513 | 513 | } |
514 | 514 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
515 | 515 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -520,20 +520,20 @@ discard block |
||
520 | 520 | //$putinarchive = true; |
521 | 521 | } |
522 | 522 | */ |
523 | - /* |
|
523 | + /* |
|
524 | 524 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
525 | 525 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
526 | 526 | } |
527 | 527 | */ |
528 | 528 | } |
529 | 529 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
530 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
531 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
530 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
531 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
532 | 532 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
533 | 533 | 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') { |
534 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
535 | - $dataFound = true; |
|
536 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
534 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
535 | + $dataFound = true; |
|
536 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
537 | 537 | } |
538 | 538 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
539 | 539 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -551,77 +551,77 @@ discard block |
||
551 | 551 | */ |
552 | 552 | } |
553 | 553 | |
554 | - } else if ($globalDebug && $timediff > 30) { |
|
554 | + } else if ($globalDebug && $timediff > 30) { |
|
555 | 555 | $this->tmd = $this->tmd + 1; |
556 | 556 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
557 | 557 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
558 | 558 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
559 | 559 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
560 | - } |
|
560 | + } |
|
561 | 561 | } |
562 | 562 | if (isset($line['last_update']) && $line['last_update'] != '') { |
563 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
564 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
563 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
564 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
565 | 565 | } |
566 | 566 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
567 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
568 | - //$dataFound = true; |
|
567 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
568 | + //$dataFound = true; |
|
569 | 569 | } |
570 | 570 | if (isset($line['format_source']) && $line['format_source'] != '') { |
571 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
571 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
572 | 572 | } |
573 | 573 | if (isset($line['source_name']) && $line['source_name'] != '') { |
574 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
574 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
575 | 575 | } |
576 | 576 | if (isset($line['emergency']) && $line['emergency'] != '') { |
577 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
578 | - //$dataFound = true; |
|
577 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
578 | + //$dataFound = true; |
|
579 | 579 | } |
580 | 580 | if (isset($line['ground']) && $line['ground'] != '') { |
581 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
581 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
582 | 582 | // Here we force archive of flight because after ground it's a new one (or should be) |
583 | 583 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
584 | 584 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
585 | 585 | 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'))); |
586 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
586 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
587 | 587 | 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'])); |
588 | - } |
|
589 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
590 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
591 | - //$dataFound = true; |
|
588 | + } |
|
589 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
590 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
591 | + //$dataFound = true; |
|
592 | 592 | } |
593 | 593 | if (isset($line['squawk']) && $line['squawk'] != '') { |
594 | - 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'])) { |
|
595 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
596 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
597 | - $highlight = ''; |
|
598 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
599 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
600 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
601 | - if ($highlight != '') { |
|
594 | + 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'])) { |
|
595 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
596 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
597 | + $highlight = ''; |
|
598 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
599 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
600 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
601 | + if ($highlight != '') { |
|
602 | 602 | $timeelapsed = microtime(true); |
603 | 603 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
604 | - $Spotter = new Spotter($this->db); |
|
605 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
606 | - $Spotter->db = null; |
|
607 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
604 | + $Spotter = new Spotter($this->db); |
|
605 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
606 | + $Spotter->db = null; |
|
607 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
608 | 608 | } |
609 | 609 | //$putinarchive = true; |
610 | 610 | //$highlight = ''; |
611 | - } |
|
611 | + } |
|
612 | 612 | |
613 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
614 | - //$dataFound = true; |
|
613 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
614 | + //$dataFound = true; |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | if (isset($line['altitude']) && $line['altitude'] != '') { |
618 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
618 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
619 | 619 | 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; |
620 | 620 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
621 | 621 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
622 | 622 | //$dataFound = true; |
623 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
624 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
623 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
624 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
625 | 625 | 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() - 2300) { |
626 | 626 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
627 | 627 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -630,27 +630,27 @@ discard block |
||
630 | 630 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
631 | 631 | 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'])); |
632 | 632 | } |
633 | - } |
|
634 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
633 | + } |
|
634 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
638 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
638 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | if (isset($line['heading']) && $line['heading'] != '') { |
642 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
643 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
644 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
645 | - //$dataFound = true; |
|
642 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
643 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
644 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
645 | + //$dataFound = true; |
|
646 | 646 | } 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']) { |
647 | - $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']); |
|
648 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
649 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
650 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
647 | + $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']); |
|
648 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
649 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
650 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
651 | 651 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
652 | - // If not enough messages and ACARS set heading to 0 |
|
653 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
652 | + // If not enough messages and ACARS set heading to 0 |
|
653 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
654 | 654 | } |
655 | 655 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
656 | 656 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -662,125 +662,125 @@ discard block |
||
662 | 662 | //if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
663 | 663 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
664 | 664 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
665 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
666 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
667 | - 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'])) { |
|
668 | - //print_r($this->all_flights); |
|
669 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
670 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
671 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
665 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
666 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
667 | + 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'])) { |
|
668 | + //print_r($this->all_flights); |
|
669 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
670 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
671 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
672 | 672 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
673 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
674 | - $timeelapsed = microtime(true); |
|
675 | - $SpotterLive = new SpotterLive($this->db); |
|
676 | - 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')) { |
|
673 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
674 | + $timeelapsed = microtime(true); |
|
675 | + $SpotterLive = new SpotterLive($this->db); |
|
676 | + 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')) { |
|
677 | 677 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
678 | 678 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
679 | - } elseif (isset($line['id'])) { |
|
679 | + } elseif (isset($line['id'])) { |
|
680 | 680 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
681 | 681 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
682 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
682 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
683 | 683 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
684 | 684 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
685 | - } else $recent_ident = ''; |
|
686 | - $SpotterLive->db=null; |
|
687 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
688 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
685 | + } else $recent_ident = ''; |
|
686 | + $SpotterLive->db=null; |
|
687 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
688 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
689 | 689 | } else $recent_ident = ''; |
690 | - } else { |
|
690 | + } else { |
|
691 | 691 | $recent_ident = ''; |
692 | 692 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
693 | - } |
|
694 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
695 | - if($recent_ident == "") |
|
696 | - { |
|
693 | + } |
|
694 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
695 | + if($recent_ident == "") |
|
696 | + { |
|
697 | 697 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
698 | 698 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
699 | 699 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
700 | 700 | //adds the spotter data for the archive |
701 | 701 | $ignoreImport = false; |
702 | 702 | foreach($globalAirportIgnore as $airportIgnore) { |
703 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
703 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
704 | 704 | $ignoreImport = true; |
705 | - } |
|
705 | + } |
|
706 | 706 | } |
707 | 707 | if (count($globalAirportAccept) > 0) { |
708 | - $ignoreImport = true; |
|
709 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
708 | + $ignoreImport = true; |
|
709 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
710 | 710 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
711 | - $ignoreImport = false; |
|
711 | + $ignoreImport = false; |
|
712 | + } |
|
712 | 713 | } |
713 | - } |
|
714 | 714 | } |
715 | 715 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
716 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
716 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
717 | 717 | 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)) { |
718 | - $ignoreImport = true; |
|
718 | + $ignoreImport = true; |
|
719 | + } |
|
719 | 720 | } |
720 | - } |
|
721 | 721 | } |
722 | 722 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
723 | - $ignoreImport = true; |
|
724 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
723 | + $ignoreImport = true; |
|
724 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
725 | 725 | 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)) { |
726 | - $ignoreImport = false; |
|
726 | + $ignoreImport = false; |
|
727 | + } |
|
727 | 728 | } |
728 | - } |
|
729 | 729 | } |
730 | 730 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
731 | - $ignoreImport = true; |
|
732 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
731 | + $ignoreImport = true; |
|
732 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
733 | 733 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
734 | - $ignoreImport = false; |
|
734 | + $ignoreImport = false; |
|
735 | + } |
|
735 | 736 | } |
736 | - } |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | if (!$ignoreImport) { |
740 | - $highlight = ''; |
|
741 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
742 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
743 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
744 | - 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'))); |
|
745 | - $timeelapsed = microtime(true); |
|
746 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
740 | + $highlight = ''; |
|
741 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
742 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
743 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
744 | + 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'))); |
|
745 | + $timeelapsed = microtime(true); |
|
746 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
747 | 747 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
748 | - $Spotter = new Spotter($this->db); |
|
749 | - $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']); |
|
750 | - $Spotter->db = null; |
|
751 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
748 | + $Spotter = new Spotter($this->db); |
|
749 | + $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']); |
|
750 | + $Spotter->db = null; |
|
751 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
752 | + } |
|
752 | 753 | } |
753 | - } |
|
754 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
755 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
754 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
755 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
756 | 756 | |
757 | - // Add source stat in DB |
|
758 | - $Stats = new Stats($this->db); |
|
759 | - if (!empty($this->stats)) { |
|
757 | + // Add source stat in DB |
|
758 | + $Stats = new Stats($this->db); |
|
759 | + if (!empty($this->stats)) { |
|
760 | 760 | if ($globalDebug) echo 'Add source stats : '; |
761 | - foreach($this->stats as $date => $data) { |
|
762 | - foreach($data as $source => $sourced) { |
|
763 | - //print_r($sourced); |
|
764 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
765 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
766 | - if (isset($sourced['msg'])) { |
|
767 | - if (time() - $sourced['msg']['date'] > 10) { |
|
768 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
769 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
770 | - unset($this->stats[$date][$source]['msg']); |
|
771 | - } |
|
772 | - } |
|
773 | - } |
|
774 | - if ($date != date('Y-m-d')) { |
|
775 | - unset($this->stats[$date]); |
|
776 | - } |
|
777 | - } |
|
778 | - if ($globalDebug) echo 'Done'."\n"; |
|
779 | - |
|
780 | - } |
|
781 | - $Stats->db = null; |
|
782 | - } |
|
783 | - $this->del(); |
|
761 | + foreach($this->stats as $date => $data) { |
|
762 | + foreach($data as $source => $sourced) { |
|
763 | + //print_r($sourced); |
|
764 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
765 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
766 | + if (isset($sourced['msg'])) { |
|
767 | + if (time() - $sourced['msg']['date'] > 10) { |
|
768 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
769 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
770 | + unset($this->stats[$date][$source]['msg']); |
|
771 | + } |
|
772 | + } |
|
773 | + } |
|
774 | + if ($date != date('Y-m-d')) { |
|
775 | + unset($this->stats[$date]); |
|
776 | + } |
|
777 | + } |
|
778 | + if ($globalDebug) echo 'Done'."\n"; |
|
779 | + |
|
780 | + } |
|
781 | + $Stats->db = null; |
|
782 | + } |
|
783 | + $this->del(); |
|
784 | 784 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
785 | 785 | //$ignoreImport = false; |
786 | 786 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -798,41 +798,41 @@ discard block |
||
798 | 798 | */ |
799 | 799 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
800 | 800 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
801 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
802 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
803 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
801 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
802 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
803 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
804 | 804 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
805 | - $SpotterLive = new SpotterLive($this->db); |
|
806 | - $SpotterLive->deleteLiveSpotterData(); |
|
807 | - $SpotterLive->db=null; |
|
805 | + $SpotterLive = new SpotterLive($this->db); |
|
806 | + $SpotterLive->deleteLiveSpotterData(); |
|
807 | + $SpotterLive->db=null; |
|
808 | 808 | } |
809 | - } |
|
810 | - if ($globalDebug) echo " Done\n"; |
|
811 | - $this->last_delete = time(); |
|
809 | + } |
|
810 | + if ($globalDebug) echo " Done\n"; |
|
811 | + $this->last_delete = time(); |
|
812 | 812 | } |
813 | - } else { |
|
813 | + } else { |
|
814 | 814 | 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')) { |
815 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
816 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
815 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
816 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
817 | 817 | } |
818 | 818 | if (isset($globalDaemon) && !$globalDaemon) { |
819 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
819 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
820 | 820 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
821 | - $Spotter = new Spotter($this->db); |
|
822 | - $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']); |
|
823 | - $Spotter->db = null; |
|
821 | + $Spotter = new Spotter($this->db); |
|
822 | + $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']); |
|
823 | + $Spotter->db = null; |
|
824 | + } |
|
824 | 825 | } |
825 | - } |
|
826 | 826 | } |
827 | 827 | |
828 | - } |
|
828 | + } |
|
829 | 829 | } |
830 | - } |
|
831 | - //adds the spotter LIVE data |
|
832 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
833 | - //echo "\nAdd in Live !! \n"; |
|
834 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
835 | - if ($globalDebug) { |
|
830 | + } |
|
831 | + //adds the spotter LIVE data |
|
832 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
833 | + //echo "\nAdd in Live !! \n"; |
|
834 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
835 | + if ($globalDebug) { |
|
836 | 836 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
837 | 837 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
838 | 838 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -840,60 +840,60 @@ discard block |
||
840 | 840 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
841 | 841 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
842 | 842 | } |
843 | - } |
|
844 | - $ignoreImport = false; |
|
845 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
846 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
843 | + } |
|
844 | + $ignoreImport = false; |
|
845 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
846 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
847 | 847 | |
848 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
849 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
850 | - $ignoreImport = true; |
|
848 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
849 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
850 | + $ignoreImport = true; |
|
851 | + } |
|
851 | 852 | } |
852 | - } |
|
853 | - if (count($globalAirportAccept) > 0) { |
|
854 | - $ignoreImport = true; |
|
855 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
856 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
853 | + if (count($globalAirportAccept) > 0) { |
|
854 | + $ignoreImport = true; |
|
855 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
856 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
857 | 857 | $ignoreImport = false; |
858 | - } |
|
858 | + } |
|
859 | 859 | } |
860 | - } |
|
861 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
860 | + } |
|
861 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
862 | 862 | foreach($globalAirlineIgnore as $airlineIgnore) { |
863 | - 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)) { |
|
863 | + 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)) { |
|
864 | 864 | $ignoreImport = true; |
865 | - } |
|
865 | + } |
|
866 | 866 | } |
867 | - } |
|
868 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
867 | + } |
|
868 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
869 | 869 | $ignoreImport = true; |
870 | 870 | foreach($globalAirlineAccept as $airlineAccept) { |
871 | - 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)) { |
|
871 | + 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)) { |
|
872 | 872 | $ignoreImport = false; |
873 | - } |
|
873 | + } |
|
874 | + } |
|
874 | 875 | } |
875 | - } |
|
876 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
876 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
877 | 877 | $ignoreImport = true; |
878 | 878 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
879 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
880 | - $ignoreImport = false; |
|
881 | - } |
|
879 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
880 | + $ignoreImport = false; |
|
881 | + } |
|
882 | + } |
|
882 | 883 | } |
883 | - } |
|
884 | 884 | |
885 | - if (!$ignoreImport) { |
|
885 | + if (!$ignoreImport) { |
|
886 | 886 | 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'])) { |
887 | 887 | 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'))); |
888 | 888 | $timeelapsed = microtime(true); |
889 | 889 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
890 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
890 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
891 | 891 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
892 | 892 | $SpotterLive = new SpotterLive($this->db); |
893 | 893 | $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']); |
894 | 894 | $SpotterLive->db = null; |
895 | 895 | if ($globalDebug) echo $result."\n"; |
896 | - } |
|
896 | + } |
|
897 | 897 | } |
898 | 898 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
899 | 899 | $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']); |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | //if ($line['format_source'] != 'aprs') { |
906 | 906 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
907 | 907 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
908 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
908 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
909 | 909 | $source = $this->all_flights[$id]['source_name']; |
910 | 910 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
911 | 911 | if (!isset($this->source_location[$source])) { |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | if ($stats_heading == 16) $stats_heading = 0; |
932 | 932 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
933 | 933 | for ($i=0;$i<=15;$i++) { |
934 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
934 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
935 | 935 | } |
936 | 936 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
937 | 937 | } else { |
@@ -944,17 +944,17 @@ discard block |
||
944 | 944 | //var_dump($this->stats); |
945 | 945 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
946 | 946 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
947 | - end($this->stats[$current_date][$source]['hist']); |
|
948 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
947 | + end($this->stats[$current_date][$source]['hist']); |
|
948 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
949 | 949 | } else $mini = 0; |
950 | 950 | for ($i=$mini;$i<=$distance;$i+=10) { |
951 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
951 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
952 | 952 | } |
953 | 953 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
954 | 954 | } else { |
955 | 955 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
956 | 956 | } |
957 | - } |
|
957 | + } |
|
958 | 958 | } |
959 | 959 | |
960 | 960 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | //$this->del(); |
965 | 965 | |
966 | 966 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
967 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
967 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
968 | 968 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
969 | 969 | $SpotterLive = new SpotterLive($this->db); |
970 | 970 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -972,19 +972,19 @@ discard block |
||
972 | 972 | //SpotterLive->deleteLiveSpotterData(); |
973 | 973 | if ($globalDebug) echo " Done\n"; |
974 | 974 | $this->last_delete_hourly = time(); |
975 | - } else { |
|
975 | + } else { |
|
976 | 976 | $this->del(); |
977 | 977 | $this->last_delete_hourly = time(); |
978 | - } |
|
978 | + } |
|
979 | 979 | } |
980 | 980 | |
981 | - } |
|
982 | - //$ignoreImport = false; |
|
981 | + } |
|
982 | + //$ignoreImport = false; |
|
983 | 983 | } |
984 | 984 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
985 | 985 | if ($send) return $this->all_flights[$id]; |
986 | - } |
|
986 | + } |
|
987 | + } |
|
987 | 988 | } |
988 | - } |
|
989 | 989 | } |
990 | 990 | ?> |
@@ -720,12 +720,12 @@ |
||
720 | 720 | update_airportsLayer(); |
721 | 721 | } |
722 | 722 | <?php |
723 | - if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
|
723 | + if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
|
724 | 724 | ?> |
725 | 725 | update_atcLayer(); |
726 | 726 | setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
727 | 727 | <?php |
728 | - } |
|
728 | + } |
|
729 | 729 | ?> |
730 | 730 | |
731 | 731 | function iconColor(color) { |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | 16 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
17 | 17 | if (isset($globalMarine) && $globalMarine) { |
18 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
18 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -24,42 +24,42 @@ discard block |
||
24 | 24 | // Check if schema is at latest version |
25 | 25 | $Connection = new Connection(); |
26 | 26 | if ($Connection->latest() === false) { |
27 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | - exit(); |
|
27 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | + exit(); |
|
29 | 29 | } |
30 | 30 | if (PHP_SAPI != 'cli') { |
31 | - echo "This script MUST be called from console, not a web browser."; |
|
31 | + echo "This script MUST be called from console, not a web browser."; |
|
32 | 32 | // exit(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | // This is to be compatible with old version of settings.php |
36 | 36 | if (!isset($globalSources)) { |
37 | - if (isset($globalSBS1Hosts)) { |
|
38 | - //$hosts = $globalSBS1Hosts; |
|
39 | - foreach ($globalSBS1Hosts as $host) { |
|
40 | - $globalSources[] = array('host' => $host); |
|
41 | - } |
|
42 | - } else { |
|
43 | - if (!isset($globalSBS1Host)) { |
|
44 | - echo '$globalSources MUST be defined !'; |
|
45 | - die; |
|
37 | + if (isset($globalSBS1Hosts)) { |
|
38 | + //$hosts = $globalSBS1Hosts; |
|
39 | + foreach ($globalSBS1Hosts as $host) { |
|
40 | + $globalSources[] = array('host' => $host); |
|
41 | + } |
|
42 | + } else { |
|
43 | + if (!isset($globalSBS1Host)) { |
|
44 | + echo '$globalSources MUST be defined !'; |
|
45 | + die; |
|
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | 48 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
49 | - } |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
56 | - $globalSources = array(); |
|
57 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | - else $globalSources[] = array('host' => $options['s']); |
|
56 | + $globalSources = array(); |
|
57 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | + else $globalSources[] = array('host' => $options['s']); |
|
59 | 59 | } elseif (isset($options['source'])) { |
60 | - $globalSources = array(); |
|
61 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | - else $globalSources[] = array('host' => $options['source']); |
|
60 | + $globalSources = array(); |
|
61 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | + else $globalSources[] = array('host' => $options['source']); |
|
63 | 63 | } |
64 | 64 | if (isset($options['aprsserverhost'])) { |
65 | 65 | $globalServerAPRS = TRUE; |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
75 | 75 | else $id_source = 1; |
76 | 76 | if (isset($globalServer) && $globalServer) { |
77 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
78 | - $SI=new SpotterServer(); |
|
77 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
78 | + $SI=new SpotterServer(); |
|
79 | 79 | /* |
80 | 80 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
81 | 81 | $SI = new adsb2aprs(); |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | } else $SI=new SpotterImport($Connection->db); |
85 | 85 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
86 | 86 | if (isset($globalMarine) && $globalMarine) { |
87 | - $AIS = new AIS(); |
|
88 | - $MI = new MarineImport($Connection->db); |
|
87 | + $AIS = new AIS(); |
|
88 | + $MI = new MarineImport($Connection->db); |
|
89 | 89 | } |
90 | 90 | //$APRS=new APRS($Connection->db); |
91 | 91 | $SBS=new SBS(); |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | //$servertz = system('date +%Z'); |
96 | 96 | // signal handler - playing nice with sockets and dump1090 |
97 | 97 | if (function_exists('pcntl_fork')) { |
98 | - pcntl_signal(SIGINT, function() { |
|
99 | - global $sockets; |
|
100 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
101 | - die("Bye!\n"); |
|
102 | - }); |
|
103 | - pcntl_signal_dispatch(); |
|
98 | + pcntl_signal(SIGINT, function() { |
|
99 | + global $sockets; |
|
100 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
101 | + die("Bye!\n"); |
|
102 | + }); |
|
103 | + pcntl_signal_dispatch(); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // let's try and connect |
@@ -110,36 +110,36 @@ discard block |
||
110 | 110 | $reset = 0; |
111 | 111 | |
112 | 112 | function connect_all($hosts) { |
113 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
114 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
115 | - $reset++; |
|
116 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
117 | - foreach ($hosts as $id => $value) { |
|
113 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
114 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
115 | + $reset++; |
|
116 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
117 | + foreach ($hosts as $id => $value) { |
|
118 | 118 | $host = $value['host']; |
119 | 119 | $globalSources[$id]['last_exec'] = 0; |
120 | 120 | // Here we check type of source(s) |
121 | 121 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
122 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | - //$formats[$id] = 'deltadbtxt'; |
|
124 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
125 | - //$last_exec['deltadbtxt'] = 0; |
|
126 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
127 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
128 | - //$formats[$id] = 'vatsimtxt'; |
|
129 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
130 | - //$last_exec['vatsimtxt'] = 0; |
|
131 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
132 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
133 | - //$formats[$id] = 'aircraftlistjson'; |
|
134 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
135 | - //$last_exec['aircraftlistjson'] = 0; |
|
136 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
137 | - } else if (preg_match('/opensky/i',$host)) { |
|
138 | - //$formats[$id] = 'aircraftlistjson'; |
|
139 | - $globalSources[$id]['format'] = 'opensky'; |
|
140 | - //$last_exec['aircraftlistjson'] = 0; |
|
141 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
142 | - /* |
|
122 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | + //$formats[$id] = 'deltadbtxt'; |
|
124 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
125 | + //$last_exec['deltadbtxt'] = 0; |
|
126 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
127 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
128 | + //$formats[$id] = 'vatsimtxt'; |
|
129 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
130 | + //$last_exec['vatsimtxt'] = 0; |
|
131 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
132 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
133 | + //$formats[$id] = 'aircraftlistjson'; |
|
134 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
135 | + //$last_exec['aircraftlistjson'] = 0; |
|
136 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
137 | + } else if (preg_match('/opensky/i',$host)) { |
|
138 | + //$formats[$id] = 'aircraftlistjson'; |
|
139 | + $globalSources[$id]['format'] = 'opensky'; |
|
140 | + //$last_exec['aircraftlistjson'] = 0; |
|
141 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
142 | + /* |
|
143 | 143 | // Disabled for now, site change source format |
144 | 144 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
145 | 145 | //$formats[$id] = 'radarvirtueljson'; |
@@ -151,115 +151,115 @@ discard block |
||
151 | 151 | exit(0); |
152 | 152 | } |
153 | 153 | */ |
154 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
155 | - //$formats[$id] = 'planeupdatefaa'; |
|
156 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
157 | - //$last_exec['planeupdatefaa'] = 0; |
|
158 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
159 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
160 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
161 | - exit(0); |
|
162 | - } |
|
163 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
164 | - //$formats[$id] = 'phpvmacars'; |
|
165 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
166 | - //$last_exec['phpvmacars'] = 0; |
|
167 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
168 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
169 | - //$formats[$id] = 'phpvmacars'; |
|
170 | - $globalSources[$id]['format'] = 'vam'; |
|
171 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
172 | - } else if (preg_match('/whazzup/i',$host)) { |
|
173 | - //$formats[$id] = 'whazzup'; |
|
174 | - $globalSources[$id]['format'] = 'whazzup'; |
|
175 | - //$last_exec['whazzup'] = 0; |
|
176 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
177 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
178 | - //$formats[$id] = 'pirepsjson'; |
|
179 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
180 | - //$last_exec['pirepsjson'] = 0; |
|
181 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
182 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
183 | - //$formats[$id] = 'fr24json'; |
|
184 | - $globalSources[$id]['format'] = 'fr24json'; |
|
185 | - //$last_exec['fr24json'] = 0; |
|
186 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
187 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
188 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
189 | - exit(0); |
|
190 | - } |
|
191 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
192 | - //$formats[$id] = 'fr24json'; |
|
193 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
194 | - //$last_exec['fr24json'] = 0; |
|
195 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
196 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
197 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
198 | - exit(0); |
|
199 | - } |
|
200 | - //} else if (preg_match('/10001/',$host)) { |
|
201 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
202 | - //$formats[$id] = 'tsv'; |
|
203 | - $globalSources[$id]['format'] = 'tsv'; |
|
204 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
205 | - } |
|
206 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
207 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
208 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
209 | - if ($idf !== false) { |
|
210 | - $httpfeeds[$id] = $idf; |
|
211 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
212 | - } |
|
213 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
214 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
215 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
216 | - $hostport = explode(':',$host); |
|
217 | - if (isset($hostport[1])) { |
|
154 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
155 | + //$formats[$id] = 'planeupdatefaa'; |
|
156 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
157 | + //$last_exec['planeupdatefaa'] = 0; |
|
158 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
159 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
160 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
161 | + exit(0); |
|
162 | + } |
|
163 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
164 | + //$formats[$id] = 'phpvmacars'; |
|
165 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
166 | + //$last_exec['phpvmacars'] = 0; |
|
167 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
168 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
169 | + //$formats[$id] = 'phpvmacars'; |
|
170 | + $globalSources[$id]['format'] = 'vam'; |
|
171 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
172 | + } else if (preg_match('/whazzup/i',$host)) { |
|
173 | + //$formats[$id] = 'whazzup'; |
|
174 | + $globalSources[$id]['format'] = 'whazzup'; |
|
175 | + //$last_exec['whazzup'] = 0; |
|
176 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
177 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
178 | + //$formats[$id] = 'pirepsjson'; |
|
179 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
180 | + //$last_exec['pirepsjson'] = 0; |
|
181 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
182 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
183 | + //$formats[$id] = 'fr24json'; |
|
184 | + $globalSources[$id]['format'] = 'fr24json'; |
|
185 | + //$last_exec['fr24json'] = 0; |
|
186 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
187 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
188 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
189 | + exit(0); |
|
190 | + } |
|
191 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
192 | + //$formats[$id] = 'fr24json'; |
|
193 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
194 | + //$last_exec['fr24json'] = 0; |
|
195 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
196 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
197 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
198 | + exit(0); |
|
199 | + } |
|
200 | + //} else if (preg_match('/10001/',$host)) { |
|
201 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
202 | + //$formats[$id] = 'tsv'; |
|
203 | + $globalSources[$id]['format'] = 'tsv'; |
|
204 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
205 | + } |
|
206 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
207 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
208 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
209 | + if ($idf !== false) { |
|
210 | + $httpfeeds[$id] = $idf; |
|
211 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
212 | + } |
|
213 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
214 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
215 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
216 | + $hostport = explode(':',$host); |
|
217 | + if (isset($hostport[1])) { |
|
218 | 218 | $port = $hostport[1]; |
219 | 219 | $hostn = $hostport[0]; |
220 | - } else { |
|
220 | + } else { |
|
221 | 221 | $port = $globalSources[$id]['port']; |
222 | 222 | $hostn = $globalSources[$id]['host']; |
223 | - } |
|
224 | - $Common = new Common(); |
|
225 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
226 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
227 | - } else { |
|
228 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
229 | - } |
|
230 | - if ($s) { |
|
231 | - $sockets[$id] = $s; |
|
232 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
233 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
223 | + } |
|
224 | + $Common = new Common(); |
|
225 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
226 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
227 | + } else { |
|
228 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
229 | + } |
|
230 | + if ($s) { |
|
231 | + $sockets[$id] = $s; |
|
232 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
233 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
234 | 234 | //$formats[$id] = 'aprs'; |
235 | 235 | $globalSources[$id]['format'] = 'aprs'; |
236 | 236 | //$aprs_connect = 0; |
237 | 237 | //$use_aprs = true; |
238 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
238 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
239 | 239 | $globalSources[$id]['format'] = 'vrstcp'; |
240 | - } elseif ($port == '10001') { |
|
241 | - //$formats[$id] = 'tsv'; |
|
242 | - $globalSources[$id]['format'] = 'tsv'; |
|
243 | - } elseif ($port == '30002') { |
|
244 | - //$formats[$id] = 'raw'; |
|
245 | - $globalSources[$id]['format'] = 'raw'; |
|
246 | - } elseif ($port == '5001') { |
|
247 | - //$formats[$id] = 'raw'; |
|
248 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
249 | - } elseif ($port == '30005') { |
|
240 | + } elseif ($port == '10001') { |
|
241 | + //$formats[$id] = 'tsv'; |
|
242 | + $globalSources[$id]['format'] = 'tsv'; |
|
243 | + } elseif ($port == '30002') { |
|
244 | + //$formats[$id] = 'raw'; |
|
245 | + $globalSources[$id]['format'] = 'raw'; |
|
246 | + } elseif ($port == '5001') { |
|
247 | + //$formats[$id] = 'raw'; |
|
248 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
249 | + } elseif ($port == '30005') { |
|
250 | 250 | // Not yet supported |
251 | - //$formats[$id] = 'beast'; |
|
252 | - $globalSources[$id]['format'] = 'beast'; |
|
253 | - //} else $formats[$id] = 'sbs'; |
|
254 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
255 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
251 | + //$formats[$id] = 'beast'; |
|
252 | + $globalSources[$id]['format'] = 'beast'; |
|
253 | + //} else $formats[$id] = 'sbs'; |
|
254 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
255 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
256 | 256 | } |
257 | 257 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
258 | - } else { |
|
258 | + } else { |
|
259 | 259 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
260 | - } |
|
261 | - } |
|
262 | - } |
|
260 | + } |
|
261 | + } |
|
262 | + } |
|
263 | 263 | } |
264 | 264 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
265 | 265 | |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | //connect_all($globalSources); |
283 | 283 | |
284 | 284 | if (isset($globalProxy) && $globalProxy) { |
285 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
285 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
286 | 286 | } else { |
287 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
287 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // APRS Configuration |
@@ -293,18 +293,18 @@ discard block |
||
293 | 293 | die; |
294 | 294 | } |
295 | 295 | foreach ($globalSources as $key => $source) { |
296 | - if (!isset($source['format'])) { |
|
297 | - $globalSources[$key]['format'] = 'auto'; |
|
298 | - } |
|
296 | + if (!isset($source['format'])) { |
|
297 | + $globalSources[$key]['format'] = 'auto'; |
|
298 | + } |
|
299 | 299 | } |
300 | 300 | connect_all($globalSources); |
301 | 301 | foreach ($globalSources as $key => $source) { |
302 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
302 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
303 | 303 | $aprs_connect = 0; |
304 | 304 | $use_aprs = true; |
305 | 305 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
306 | 306 | break; |
307 | - } |
|
307 | + } |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | if ($use_aprs) { |
@@ -345,116 +345,116 @@ discard block |
||
345 | 345 | |
346 | 346 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
347 | 347 | while ($i > 0) { |
348 | - if (!$globalDaemon) $i = $endtime-time(); |
|
349 | - // Delete old ATC |
|
350 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
348 | + if (!$globalDaemon) $i = $endtime-time(); |
|
349 | + // Delete old ATC |
|
350 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
351 | 351 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
352 | - $ATC->deleteOldATC(); |
|
353 | - } |
|
352 | + $ATC->deleteOldATC(); |
|
353 | + } |
|
354 | 354 | |
355 | - //if (count($last_exec) > 0) { |
|
356 | - if (count($last_exec) == count($globalSources)) { |
|
355 | + //if (count($last_exec) > 0) { |
|
356 | + if (count($last_exec) == count($globalSources)) { |
|
357 | 357 | $max = $globalMinFetch; |
358 | 358 | foreach ($last_exec as $last) { |
359 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
359 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
360 | 360 | } |
361 | 361 | if ($max != $globalMinFetch) { |
362 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
363 | - sleep($globalMinFetch-$max+2); |
|
362 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
363 | + sleep($globalMinFetch-$max+2); |
|
364 | + } |
|
364 | 365 | } |
365 | - } |
|
366 | 366 | |
367 | 367 | |
368 | - //foreach ($formats as $id => $value) { |
|
369 | - foreach ($globalSources as $id => $value) { |
|
368 | + //foreach ($formats as $id => $value) { |
|
369 | + foreach ($globalSources as $id => $value) { |
|
370 | 370 | date_default_timezone_set('UTC'); |
371 | 371 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
372 | 372 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
373 | - //$buffer = $Common->getData($hosts[$id]); |
|
374 | - $buffer = $Common->getData($value['host']); |
|
375 | - if ($buffer != '') $reset = 0; |
|
376 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
377 | - $buffer = explode('\n',$buffer); |
|
378 | - foreach ($buffer as $line) { |
|
379 | - if ($line != '' && count($line) > 7) { |
|
380 | - $line = explode(',', $line); |
|
381 | - $data = array(); |
|
382 | - $data['hex'] = $line[1]; // hex |
|
383 | - $data['ident'] = $line[2]; // ident |
|
384 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
385 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
386 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
387 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
388 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
389 | - $data['verticalrate'] = ''; // vertical rate |
|
390 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
391 | - $data['emergency'] = ''; // emergency |
|
392 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
393 | - $data['format_source'] = 'deltadbtxt'; |
|
394 | - $data['id_source'] = $id_source; |
|
395 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
396 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
397 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
398 | - $SI->add($data); |
|
399 | - unset($data); |
|
400 | - } |
|
401 | - } |
|
402 | - $last_exec[$id]['last'] = time(); |
|
373 | + //$buffer = $Common->getData($hosts[$id]); |
|
374 | + $buffer = $Common->getData($value['host']); |
|
375 | + if ($buffer != '') $reset = 0; |
|
376 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
377 | + $buffer = explode('\n',$buffer); |
|
378 | + foreach ($buffer as $line) { |
|
379 | + if ($line != '' && count($line) > 7) { |
|
380 | + $line = explode(',', $line); |
|
381 | + $data = array(); |
|
382 | + $data['hex'] = $line[1]; // hex |
|
383 | + $data['ident'] = $line[2]; // ident |
|
384 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
385 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
386 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
387 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
388 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
389 | + $data['verticalrate'] = ''; // vertical rate |
|
390 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
391 | + $data['emergency'] = ''; // emergency |
|
392 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
393 | + $data['format_source'] = 'deltadbtxt'; |
|
394 | + $data['id_source'] = $id_source; |
|
395 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
396 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
397 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
398 | + $SI->add($data); |
|
399 | + unset($data); |
|
400 | + } |
|
401 | + } |
|
402 | + $last_exec[$id]['last'] = time(); |
|
403 | 403 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
404 | - date_default_timezone_set('CET'); |
|
405 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
406 | - date_default_timezone_set('UTC'); |
|
407 | - if ($buffer != '') $reset = 0; |
|
408 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
409 | - $buffer = explode('\n',$buffer); |
|
410 | - foreach ($buffer as $line) { |
|
404 | + date_default_timezone_set('CET'); |
|
405 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
406 | + date_default_timezone_set('UTC'); |
|
407 | + if ($buffer != '') $reset = 0; |
|
408 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
409 | + $buffer = explode('\n',$buffer); |
|
410 | + foreach ($buffer as $line) { |
|
411 | 411 | if ($line != '') { |
412 | - echo "'".$line."'\n"; |
|
413 | - $add = false; |
|
414 | - $ais_data = $AIS->parse_line(trim($line)); |
|
415 | - $data = array(); |
|
416 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
417 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
418 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
419 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
420 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
421 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
422 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
423 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
424 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
425 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
426 | - if (isset($ais_data['timestamp'])) { |
|
412 | + echo "'".$line."'\n"; |
|
413 | + $add = false; |
|
414 | + $ais_data = $AIS->parse_line(trim($line)); |
|
415 | + $data = array(); |
|
416 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
417 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
418 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
419 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
420 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
421 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
422 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
423 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
424 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
425 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
426 | + if (isset($ais_data['timestamp'])) { |
|
427 | 427 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
428 | 428 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
429 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
430 | - $add = true; |
|
429 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
430 | + $add = true; |
|
431 | 431 | } |
432 | - } else { |
|
432 | + } else { |
|
433 | 433 | $data['datetime'] = date('Y-m-d H:i:s'); |
434 | 434 | $add = true; |
435 | - } |
|
436 | - $data['format_source'] = 'aisnmeatxt'; |
|
437 | - $data['id_source'] = $id_source; |
|
438 | - //print_r($data); |
|
439 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
440 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
441 | - unset($data); |
|
435 | + } |
|
436 | + $data['format_source'] = 'aisnmeatxt'; |
|
437 | + $data['id_source'] = $id_source; |
|
438 | + //print_r($data); |
|
439 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
440 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
441 | + unset($data); |
|
442 | 442 | } |
443 | - } |
|
444 | - $last_exec[$id]['last'] = time(); |
|
443 | + } |
|
444 | + $last_exec[$id]['last'] = time(); |
|
445 | 445 | } elseif ($value['format'] == 'aisnmeahttp') { |
446 | - $arr = $httpfeeds; |
|
447 | - $w = $e = null; |
|
446 | + $arr = $httpfeeds; |
|
447 | + $w = $e = null; |
|
448 | 448 | |
449 | - if (isset($arr[$id])) { |
|
449 | + if (isset($arr[$id])) { |
|
450 | 450 | $nn = stream_select($arr,$w,$e,$timeout); |
451 | 451 | if ($nn > 0) { |
452 | - foreach ($httpfeeds as $feed) { |
|
452 | + foreach ($httpfeeds as $feed) { |
|
453 | 453 | $buffer = stream_get_line($feed,2000,"\n"); |
454 | 454 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
455 | 455 | $buffer = explode('\n',$buffer); |
456 | 456 | foreach ($buffer as $line) { |
457 | - if ($line != '') { |
|
457 | + if ($line != '') { |
|
458 | 458 | $ais_data = $AIS->parse_line(trim($line)); |
459 | 459 | $data = array(); |
460 | 460 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -472,96 +472,96 @@ discard block |
||
472 | 472 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
473 | 473 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
474 | 474 | if (isset($ais_data['timestamp'])) { |
475 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
475 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
476 | 476 | } else { |
477 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
477 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
478 | 478 | } |
479 | 479 | $data['format_source'] = 'aisnmeahttp'; |
480 | 480 | $data['id_source'] = $id_source; |
481 | 481 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
482 | 482 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
483 | 483 | unset($data); |
484 | - } |
|
484 | + } |
|
485 | + } |
|
485 | 486 | } |
486 | - } |
|
487 | 487 | } else { |
488 | - $format = $value['format']; |
|
489 | - if (isset($tt[$format])) $tt[$format]++; |
|
490 | - else $tt[$format] = 0; |
|
491 | - if ($tt[$format] > 30) { |
|
488 | + $format = $value['format']; |
|
489 | + if (isset($tt[$format])) $tt[$format]++; |
|
490 | + else $tt[$format] = 0; |
|
491 | + if ($tt[$format] > 30) { |
|
492 | 492 | if ($globalDebug) echo 'Reconnect...'."\n"; |
493 | 493 | sleep(2); |
494 | 494 | $sourceeen[] = $value; |
495 | 495 | connect_all($sourceeen); |
496 | 496 | $sourceeen = array(); |
497 | - } |
|
497 | + } |
|
498 | + } |
|
498 | 499 | } |
499 | - } |
|
500 | 500 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
501 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
502 | - if ($buffer != '') { |
|
501 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
502 | + if ($buffer != '') { |
|
503 | 503 | //echo $buffer; |
504 | 504 | $all_data = json_decode($buffer,true); |
505 | 505 | //print_r($all_data); |
506 | 506 | if (isset($all_data[0]['DATA'])) { |
507 | - foreach ($all_data[0]['DATA'] as $line) { |
|
507 | + foreach ($all_data[0]['DATA'] as $line) { |
|
508 | 508 | if ($line != '') { |
509 | - $data = array(); |
|
510 | - $data['ident'] = $line['NAME']; |
|
511 | - $data['mmsi'] = $line['MMSI']; |
|
512 | - $data['speed'] = $line['SOG']; |
|
513 | - $data['heading'] = $line['COG']; |
|
514 | - $data['latitude'] = $line['LAT']; |
|
515 | - $data['longitude'] = $line['LNG']; |
|
516 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
517 | - $data['imo'] = $line['IMO']; |
|
518 | - //$data['arrival_code'] = $ais_data['destination']; |
|
519 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
520 | - $data['format_source'] = 'myshiptracking'; |
|
521 | - $data['id_source'] = $id_source; |
|
522 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
523 | - $MI->add($data); |
|
524 | - unset($data); |
|
509 | + $data = array(); |
|
510 | + $data['ident'] = $line['NAME']; |
|
511 | + $data['mmsi'] = $line['MMSI']; |
|
512 | + $data['speed'] = $line['SOG']; |
|
513 | + $data['heading'] = $line['COG']; |
|
514 | + $data['latitude'] = $line['LAT']; |
|
515 | + $data['longitude'] = $line['LNG']; |
|
516 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
517 | + $data['imo'] = $line['IMO']; |
|
518 | + //$data['arrival_code'] = $ais_data['destination']; |
|
519 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
520 | + $data['format_source'] = 'myshiptracking'; |
|
521 | + $data['id_source'] = $id_source; |
|
522 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
523 | + $MI->add($data); |
|
524 | + unset($data); |
|
525 | + } |
|
525 | 526 | } |
526 | - } |
|
527 | 527 | } |
528 | - } |
|
529 | - $last_exec[$id]['last'] = time(); |
|
528 | + } |
|
529 | + $last_exec[$id]['last'] = time(); |
|
530 | 530 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
531 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
532 | - if ($buffer != '') { |
|
531 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
532 | + if ($buffer != '') { |
|
533 | 533 | $all_data = json_decode($buffer,true); |
534 | 534 | if (isset($all_data[0]['mmsi'])) { |
535 | - foreach ($all_data as $line) { |
|
535 | + foreach ($all_data as $line) { |
|
536 | 536 | if ($line != '') { |
537 | - $data = array(); |
|
538 | - $data['ident'] = $line['shipname']; |
|
539 | - $data['callsign'] = $line['callsign']; |
|
540 | - $data['mmsi'] = $line['mmsi']; |
|
541 | - $data['speed'] = $line['sog']; |
|
542 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
543 | - $data['latitude'] = $line['latitude']; |
|
544 | - $data['longitude'] = $line['longitude']; |
|
545 | - $data['type_id'] = $line['shiptype']; |
|
546 | - $data['arrival_code'] = $line['destination']; |
|
547 | - $data['datetime'] = $line['time']; |
|
548 | - $data['format_source'] = 'boatbeaconapp'; |
|
549 | - $data['id_source'] = $id_source; |
|
550 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
551 | - $MI->add($data); |
|
552 | - unset($data); |
|
537 | + $data = array(); |
|
538 | + $data['ident'] = $line['shipname']; |
|
539 | + $data['callsign'] = $line['callsign']; |
|
540 | + $data['mmsi'] = $line['mmsi']; |
|
541 | + $data['speed'] = $line['sog']; |
|
542 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
543 | + $data['latitude'] = $line['latitude']; |
|
544 | + $data['longitude'] = $line['longitude']; |
|
545 | + $data['type_id'] = $line['shiptype']; |
|
546 | + $data['arrival_code'] = $line['destination']; |
|
547 | + $data['datetime'] = $line['time']; |
|
548 | + $data['format_source'] = 'boatbeaconapp'; |
|
549 | + $data['id_source'] = $id_source; |
|
550 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
551 | + $MI->add($data); |
|
552 | + unset($data); |
|
553 | + } |
|
553 | 554 | } |
554 | - } |
|
555 | 555 | } |
556 | 556 | |
557 | - } |
|
558 | - $last_exec[$id]['last'] = time(); |
|
557 | + } |
|
558 | + $last_exec[$id]['last'] = time(); |
|
559 | 559 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
560 | - $buffer = $Common->getData($value['host']); |
|
561 | - if ($buffer != '') { |
|
560 | + $buffer = $Common->getData($value['host']); |
|
561 | + if ($buffer != '') { |
|
562 | 562 | $all_data = json_decode($buffer,true); |
563 | 563 | if (isset($all_data['features'][0]['id'])) { |
564 | - foreach ($all_data['features'] as $line) { |
|
564 | + foreach ($all_data['features'] as $line) { |
|
565 | 565 | $data = array(); |
566 | 566 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
567 | 567 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -580,59 +580,59 @@ discard block |
||
580 | 580 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
581 | 581 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
582 | 582 | unset($data); |
583 | - } |
|
583 | + } |
|
584 | 584 | } |
585 | 585 | |
586 | - } |
|
587 | - $last_exec[$id]['last'] = time(); |
|
586 | + } |
|
587 | + $last_exec[$id]['last'] = time(); |
|
588 | 588 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
589 | - echo 'download...'; |
|
590 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
591 | - echo 'done !'."\n"; |
|
592 | - if ($buffer != '') $reset = 0; |
|
593 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
594 | - $buffer = explode('\n',$buffer); |
|
595 | - foreach ($buffer as $line) { |
|
589 | + echo 'download...'; |
|
590 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
591 | + echo 'done !'."\n"; |
|
592 | + if ($buffer != '') $reset = 0; |
|
593 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
594 | + $buffer = explode('\n',$buffer); |
|
595 | + foreach ($buffer as $line) { |
|
596 | 596 | if ($line != '') { |
597 | - $data = array(); |
|
598 | - $data['mmsi'] = (int)substr($line,0,9); |
|
599 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
600 | - //$data['status'] = substr($line,21,2); |
|
601 | - //$data['type'] = substr($line,24,3); |
|
602 | - $data['latitude'] = substr($line,29,9); |
|
603 | - $data['longitude'] = substr($line,41,9); |
|
604 | - $data['speed'] = round(substr($line,51,5)); |
|
605 | - //$data['course'] = substr($line,57,5); |
|
606 | - $data['heading'] = round(substr($line,63,3)); |
|
607 | - //$data['draft'] = substr($line,67,4); |
|
608 | - //$data['length'] = substr($line,72,3); |
|
609 | - //$data['beam'] = substr($line,76,2); |
|
610 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
611 | - //$data['callsign'] = trim(substr($line,100,7); |
|
612 | - //$data['dest'] = substr($line,108,20); |
|
613 | - //$data['etaDate'] = substr($line,129,5); |
|
614 | - //$data['etaTime'] = substr($line,135,5); |
|
615 | - $data['format_source'] = 'shipplotter'; |
|
616 | - $data['id_source'] = $id_source; |
|
617 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
618 | - //print_r($data); |
|
619 | - echo 'Add...'."\n"; |
|
620 | - $MI->add($data); |
|
621 | - unset($data); |
|
597 | + $data = array(); |
|
598 | + $data['mmsi'] = (int)substr($line,0,9); |
|
599 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
600 | + //$data['status'] = substr($line,21,2); |
|
601 | + //$data['type'] = substr($line,24,3); |
|
602 | + $data['latitude'] = substr($line,29,9); |
|
603 | + $data['longitude'] = substr($line,41,9); |
|
604 | + $data['speed'] = round(substr($line,51,5)); |
|
605 | + //$data['course'] = substr($line,57,5); |
|
606 | + $data['heading'] = round(substr($line,63,3)); |
|
607 | + //$data['draft'] = substr($line,67,4); |
|
608 | + //$data['length'] = substr($line,72,3); |
|
609 | + //$data['beam'] = substr($line,76,2); |
|
610 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
611 | + //$data['callsign'] = trim(substr($line,100,7); |
|
612 | + //$data['dest'] = substr($line,108,20); |
|
613 | + //$data['etaDate'] = substr($line,129,5); |
|
614 | + //$data['etaTime'] = substr($line,135,5); |
|
615 | + $data['format_source'] = 'shipplotter'; |
|
616 | + $data['id_source'] = $id_source; |
|
617 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
618 | + //print_r($data); |
|
619 | + echo 'Add...'."\n"; |
|
620 | + $MI->add($data); |
|
621 | + unset($data); |
|
622 | 622 | } |
623 | - } |
|
624 | - $last_exec[$id]['last'] = time(); |
|
623 | + } |
|
624 | + $last_exec[$id]['last'] = time(); |
|
625 | 625 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
626 | 626 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
627 | - //$buffer = $Common->getData($hosts[$id]); |
|
628 | - $buffer = $Common->getData($value['host']); |
|
629 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
630 | - $buffer = explode('\n',$buffer); |
|
631 | - $reset = 0; |
|
632 | - foreach ($buffer as $line) { |
|
633 | - if ($line != '') { |
|
634 | - $line = explode(':', $line); |
|
635 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
627 | + //$buffer = $Common->getData($hosts[$id]); |
|
628 | + $buffer = $Common->getData($value['host']); |
|
629 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
630 | + $buffer = explode('\n',$buffer); |
|
631 | + $reset = 0; |
|
632 | + foreach ($buffer as $line) { |
|
633 | + if ($line != '') { |
|
634 | + $line = explode(':', $line); |
|
635 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
636 | 636 | $data = array(); |
637 | 637 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
638 | 638 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -645,37 +645,37 @@ discard block |
||
645 | 645 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
646 | 646 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
647 | 647 | $data['latitude'] = $line[5]; // lat |
648 | - $data['longitude'] = $line[6]; // long |
|
649 | - $data['verticalrate'] = ''; // vertical rate |
|
650 | - $data['squawk'] = ''; // squawk |
|
651 | - $data['emergency'] = ''; // emergency |
|
652 | - $data['waypoints'] = $line[30]; |
|
648 | + $data['longitude'] = $line[6]; // long |
|
649 | + $data['verticalrate'] = ''; // vertical rate |
|
650 | + $data['squawk'] = ''; // squawk |
|
651 | + $data['emergency'] = ''; // emergency |
|
652 | + $data['waypoints'] = $line[30]; |
|
653 | 653 | $data['datetime'] = date('Y-m-d H:i:s'); |
654 | 654 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
655 | 655 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
656 | - $data['departure_airport_icao'] = $line[11]; |
|
657 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
658 | - $data['arrival_airport_icao'] = $line[13]; |
|
656 | + $data['departure_airport_icao'] = $line[11]; |
|
657 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
658 | + $data['arrival_airport_icao'] = $line[13]; |
|
659 | 659 | $data['frequency'] = $line[4]; |
660 | 660 | $data['type'] = $line[18]; |
661 | 661 | $data['range'] = $line[19]; |
662 | 662 | if (isset($line[35])) $data['info'] = $line[35]; |
663 | - $data['id_source'] = $id_source; |
|
664 | - //$data['arrival_airport_time'] = ; |
|
665 | - if ($line[9] != '') { |
|
666 | - $aircraft_data = explode('/',$line[9]); |
|
667 | - if (isset($aircraft_data[1])) { |
|
668 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
669 | - } |
|
670 | - } |
|
671 | - /* |
|
663 | + $data['id_source'] = $id_source; |
|
664 | + //$data['arrival_airport_time'] = ; |
|
665 | + if ($line[9] != '') { |
|
666 | + $aircraft_data = explode('/',$line[9]); |
|
667 | + if (isset($aircraft_data[1])) { |
|
668 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
669 | + } |
|
670 | + } |
|
671 | + /* |
|
672 | 672 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
673 | 673 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
674 | 674 | */ |
675 | - $data['format_source'] = $value['format']; |
|
675 | + $data['format_source'] = $value['format']; |
|
676 | 676 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
677 | 677 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
678 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
678 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
679 | 679 | elseif ($line[3] == 'ATC') { |
680 | 680 | //print_r($data); |
681 | 681 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -696,255 +696,255 @@ discard block |
||
696 | 696 | else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
697 | 697 | } |
698 | 698 | } |
699 | - unset($data); |
|
700 | - } |
|
701 | - } |
|
702 | - } |
|
703 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
704 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
705 | - $last_exec[$id]['last'] = time(); |
|
706 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
707 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
708 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
709 | - if ($buffer != '') { |
|
710 | - $all_data = json_decode($buffer,true); |
|
711 | - if (isset($all_data['acList'])) { |
|
699 | + unset($data); |
|
700 | + } |
|
701 | + } |
|
702 | + } |
|
703 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
704 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
705 | + $last_exec[$id]['last'] = time(); |
|
706 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
707 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
708 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
709 | + if ($buffer != '') { |
|
710 | + $all_data = json_decode($buffer,true); |
|
711 | + if (isset($all_data['acList'])) { |
|
712 | 712 | $reset = 0; |
713 | 713 | foreach ($all_data['acList'] as $line) { |
714 | - $data = array(); |
|
715 | - $data['hex'] = $line['Icao']; // hex |
|
716 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
717 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
718 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
719 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
720 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
721 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
722 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
723 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
724 | - $data['emergency'] = ''; // emergency |
|
725 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
714 | + $data = array(); |
|
715 | + $data['hex'] = $line['Icao']; // hex |
|
716 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
717 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
718 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
719 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
720 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
721 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
722 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
723 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
724 | + $data['emergency'] = ''; // emergency |
|
725 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
726 | 726 | |
727 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
728 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
727 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
728 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
729 | 729 | |
730 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
731 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
732 | - $data['format_source'] = 'aircraftlistjson'; |
|
733 | - $data['id_source'] = $id_source; |
|
734 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
735 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
736 | - if (isset($data['latitude'])) $SI->add($data); |
|
737 | - unset($data); |
|
730 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
731 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
732 | + $data['format_source'] = 'aircraftlistjson'; |
|
733 | + $data['id_source'] = $id_source; |
|
734 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
735 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
736 | + if (isset($data['latitude'])) $SI->add($data); |
|
737 | + unset($data); |
|
738 | 738 | } |
739 | - } elseif (is_array($all_data)) { |
|
739 | + } elseif (is_array($all_data)) { |
|
740 | 740 | $reset = 0; |
741 | 741 | foreach ($all_data as $line) { |
742 | - $data = array(); |
|
743 | - $data['hex'] = $line['hex']; // hex |
|
744 | - $data['ident'] = $line['flight']; // ident |
|
745 | - $data['altitude'] = $line['altitude']; // altitude |
|
746 | - $data['speed'] = $line['speed']; // speed |
|
747 | - $data['heading'] = $line['track']; // heading |
|
748 | - $data['latitude'] = $line['lat']; // lat |
|
749 | - $data['longitude'] = $line['lon']; // long |
|
750 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
751 | - $data['squawk'] = $line['squawk']; // squawk |
|
752 | - $data['emergency'] = ''; // emergency |
|
753 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
754 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
755 | - $data['format_source'] = 'aircraftlistjson'; |
|
756 | - $data['id_source'] = $id_source; |
|
757 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
758 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
759 | - $SI->add($data); |
|
760 | - unset($data); |
|
742 | + $data = array(); |
|
743 | + $data['hex'] = $line['hex']; // hex |
|
744 | + $data['ident'] = $line['flight']; // ident |
|
745 | + $data['altitude'] = $line['altitude']; // altitude |
|
746 | + $data['speed'] = $line['speed']; // speed |
|
747 | + $data['heading'] = $line['track']; // heading |
|
748 | + $data['latitude'] = $line['lat']; // lat |
|
749 | + $data['longitude'] = $line['lon']; // long |
|
750 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
751 | + $data['squawk'] = $line['squawk']; // squawk |
|
752 | + $data['emergency'] = ''; // emergency |
|
753 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
754 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
755 | + $data['format_source'] = 'aircraftlistjson'; |
|
756 | + $data['id_source'] = $id_source; |
|
757 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
758 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
759 | + $SI->add($data); |
|
760 | + unset($data); |
|
761 | + } |
|
762 | + } |
|
761 | 763 | } |
762 | - } |
|
763 | - } |
|
764 | - //$last_exec['aircraftlistjson'] = time(); |
|
765 | - $last_exec[$id]['last'] = time(); |
|
766 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
767 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
768 | - $buffer = $Common->getData($value['host']); |
|
769 | - $all_data = json_decode($buffer,true); |
|
770 | - if (isset($all_data['planes'])) { |
|
764 | + //$last_exec['aircraftlistjson'] = time(); |
|
765 | + $last_exec[$id]['last'] = time(); |
|
766 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
767 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
768 | + $buffer = $Common->getData($value['host']); |
|
769 | + $all_data = json_decode($buffer,true); |
|
770 | + if (isset($all_data['planes'])) { |
|
771 | 771 | $reset = 0; |
772 | 772 | foreach ($all_data['planes'] as $key => $line) { |
773 | - $data = array(); |
|
774 | - $data['hex'] = $key; // hex |
|
775 | - $data['ident'] = $line[3]; // ident |
|
776 | - $data['altitude'] = $line[6]; // altitude |
|
777 | - $data['speed'] = $line[8]; // speed |
|
778 | - $data['heading'] = $line[7]; // heading |
|
779 | - $data['latitude'] = $line[4]; // lat |
|
780 | - $data['longitude'] = $line[5]; // long |
|
781 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
782 | - $data['squawk'] = $line[10]; // squawk |
|
783 | - $data['emergency'] = ''; // emergency |
|
784 | - $data['registration'] = $line[2]; |
|
785 | - $data['aircraft_icao'] = $line[0]; |
|
786 | - $deparr = explode('-',$line[1]); |
|
787 | - if (count($deparr) == 2) { |
|
773 | + $data = array(); |
|
774 | + $data['hex'] = $key; // hex |
|
775 | + $data['ident'] = $line[3]; // ident |
|
776 | + $data['altitude'] = $line[6]; // altitude |
|
777 | + $data['speed'] = $line[8]; // speed |
|
778 | + $data['heading'] = $line[7]; // heading |
|
779 | + $data['latitude'] = $line[4]; // lat |
|
780 | + $data['longitude'] = $line[5]; // long |
|
781 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
782 | + $data['squawk'] = $line[10]; // squawk |
|
783 | + $data['emergency'] = ''; // emergency |
|
784 | + $data['registration'] = $line[2]; |
|
785 | + $data['aircraft_icao'] = $line[0]; |
|
786 | + $deparr = explode('-',$line[1]); |
|
787 | + if (count($deparr) == 2) { |
|
788 | 788 | $data['departure_airport_icao'] = $deparr[0]; |
789 | 789 | $data['arrival_airport_icao'] = $deparr[1]; |
790 | - } |
|
791 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
792 | - $data['format_source'] = 'planeupdatefaa'; |
|
793 | - $data['id_source'] = $id_source; |
|
794 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
795 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
796 | - $SI->add($data); |
|
797 | - unset($data); |
|
790 | + } |
|
791 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
792 | + $data['format_source'] = 'planeupdatefaa'; |
|
793 | + $data['id_source'] = $id_source; |
|
794 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
795 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
796 | + $SI->add($data); |
|
797 | + unset($data); |
|
798 | + } |
|
798 | 799 | } |
799 | - } |
|
800 | - //$last_exec['planeupdatefaa'] = time(); |
|
801 | - $last_exec[$id]['last'] = time(); |
|
802 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
803 | - $buffer = $Common->getData($value['host']); |
|
804 | - $all_data = json_decode($buffer,true); |
|
805 | - if (isset($all_data['states'])) { |
|
800 | + //$last_exec['planeupdatefaa'] = time(); |
|
801 | + $last_exec[$id]['last'] = time(); |
|
802 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
803 | + $buffer = $Common->getData($value['host']); |
|
804 | + $all_data = json_decode($buffer,true); |
|
805 | + if (isset($all_data['states'])) { |
|
806 | 806 | $reset = 0; |
807 | 807 | foreach ($all_data['states'] as $key => $line) { |
808 | - $data = array(); |
|
809 | - $data['hex'] = $line[0]; // hex |
|
810 | - $data['ident'] = trim($line[1]); // ident |
|
811 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
812 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
813 | - $data['heading'] = round($line[10]); // heading |
|
814 | - $data['latitude'] = $line[6]; // lat |
|
815 | - $data['longitude'] = $line[5]; // long |
|
816 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
817 | - //$data['squawk'] = $line[10]; // squawk |
|
818 | - //$data['emergency'] = ''; // emergency |
|
819 | - //$data['registration'] = $line[2]; |
|
820 | - //$data['aircraft_icao'] = $line[0]; |
|
821 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
822 | - $data['format_source'] = 'opensky'; |
|
823 | - $data['id_source'] = $id_source; |
|
824 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
825 | - $SI->add($data); |
|
826 | - unset($data); |
|
808 | + $data = array(); |
|
809 | + $data['hex'] = $line[0]; // hex |
|
810 | + $data['ident'] = trim($line[1]); // ident |
|
811 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
812 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
813 | + $data['heading'] = round($line[10]); // heading |
|
814 | + $data['latitude'] = $line[6]; // lat |
|
815 | + $data['longitude'] = $line[5]; // long |
|
816 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
817 | + //$data['squawk'] = $line[10]; // squawk |
|
818 | + //$data['emergency'] = ''; // emergency |
|
819 | + //$data['registration'] = $line[2]; |
|
820 | + //$data['aircraft_icao'] = $line[0]; |
|
821 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
822 | + $data['format_source'] = 'opensky'; |
|
823 | + $data['id_source'] = $id_source; |
|
824 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
825 | + $SI->add($data); |
|
826 | + unset($data); |
|
827 | 827 | } |
828 | - } |
|
829 | - //$last_exec['planeupdatefaa'] = time(); |
|
830 | - $last_exec[$id]['last'] = time(); |
|
831 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
832 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
833 | - //$buffer = $Common->getData($hosts[$id]); |
|
834 | - $buffer = $Common->getData($value['host']); |
|
835 | - $all_data = json_decode($buffer,true); |
|
836 | - if (!empty($all_data)) $reset = 0; |
|
837 | - foreach ($all_data as $key => $line) { |
|
828 | + } |
|
829 | + //$last_exec['planeupdatefaa'] = time(); |
|
830 | + $last_exec[$id]['last'] = time(); |
|
831 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
832 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
833 | + //$buffer = $Common->getData($hosts[$id]); |
|
834 | + $buffer = $Common->getData($value['host']); |
|
835 | + $all_data = json_decode($buffer,true); |
|
836 | + if (!empty($all_data)) $reset = 0; |
|
837 | + foreach ($all_data as $key => $line) { |
|
838 | 838 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
839 | - $data = array(); |
|
840 | - $data['hex'] = $line[0]; |
|
841 | - $data['ident'] = $line[16]; //$line[13] |
|
842 | - $data['altitude'] = $line[4]; // altitude |
|
843 | - $data['speed'] = $line[5]; // speed |
|
844 | - $data['heading'] = $line[3]; // heading |
|
845 | - $data['latitude'] = $line[1]; // lat |
|
846 | - $data['longitude'] = $line[2]; // long |
|
847 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
848 | - $data['squawk'] = $line[6]; // squawk |
|
849 | - $data['aircraft_icao'] = $line[8]; |
|
850 | - $data['registration'] = $line[9]; |
|
851 | - $data['departure_airport_iata'] = $line[11]; |
|
852 | - $data['arrival_airport_iata'] = $line[12]; |
|
853 | - $data['emergency'] = ''; // emergency |
|
854 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
855 | - $data['format_source'] = 'fr24json'; |
|
856 | - $data['id_source'] = $id_source; |
|
857 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
858 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
859 | - $SI->add($data); |
|
860 | - unset($data); |
|
839 | + $data = array(); |
|
840 | + $data['hex'] = $line[0]; |
|
841 | + $data['ident'] = $line[16]; //$line[13] |
|
842 | + $data['altitude'] = $line[4]; // altitude |
|
843 | + $data['speed'] = $line[5]; // speed |
|
844 | + $data['heading'] = $line[3]; // heading |
|
845 | + $data['latitude'] = $line[1]; // lat |
|
846 | + $data['longitude'] = $line[2]; // long |
|
847 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
848 | + $data['squawk'] = $line[6]; // squawk |
|
849 | + $data['aircraft_icao'] = $line[8]; |
|
850 | + $data['registration'] = $line[9]; |
|
851 | + $data['departure_airport_iata'] = $line[11]; |
|
852 | + $data['arrival_airport_iata'] = $line[12]; |
|
853 | + $data['emergency'] = ''; // emergency |
|
854 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
855 | + $data['format_source'] = 'fr24json'; |
|
856 | + $data['id_source'] = $id_source; |
|
857 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
858 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
859 | + $SI->add($data); |
|
860 | + unset($data); |
|
861 | + } |
|
861 | 862 | } |
862 | - } |
|
863 | - //$last_exec['fr24json'] = time(); |
|
864 | - $last_exec[$id]['last'] = time(); |
|
865 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
866 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
867 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
868 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
869 | - //echo $buffer; |
|
870 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
871 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
872 | - $all_data = json_decode($buffer,true); |
|
873 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
863 | + //$last_exec['fr24json'] = time(); |
|
864 | + $last_exec[$id]['last'] = time(); |
|
865 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
866 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
867 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
868 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
869 | + //echo $buffer; |
|
870 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
871 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
872 | + $all_data = json_decode($buffer,true); |
|
873 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
874 | 874 | die(json_last_error_msg()); |
875 | - } |
|
876 | - if (isset($all_data['mrkrs'])) { |
|
875 | + } |
|
876 | + if (isset($all_data['mrkrs'])) { |
|
877 | 877 | $reset = 0; |
878 | 878 | foreach ($all_data['mrkrs'] as $key => $line) { |
879 | - if (isset($line['inf'])) { |
|
879 | + if (isset($line['inf'])) { |
|
880 | 880 | $data = array(); |
881 | 881 | $data['hex'] = $line['inf']['ia']; |
882 | 882 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
883 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
884 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
885 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
886 | - $data['latitude'] = $line['pt'][0]; // lat |
|
887 | - $data['longitude'] = $line['pt'][1]; // long |
|
888 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
889 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
890 | - //$data['aircraft_icao'] = $line[8]; |
|
891 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
883 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
884 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
885 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
886 | + $data['latitude'] = $line['pt'][0]; // lat |
|
887 | + $data['longitude'] = $line['pt'][1]; // long |
|
888 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
889 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
890 | + //$data['aircraft_icao'] = $line[8]; |
|
891 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
892 | 892 | //$data['departure_airport_iata'] = $line[11]; |
893 | 893 | //$data['arrival_airport_iata'] = $line[12]; |
894 | - //$data['emergency'] = ''; // emergency |
|
894 | + //$data['emergency'] = ''; // emergency |
|
895 | 895 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
896 | - $data['format_source'] = 'radarvirtueljson'; |
|
897 | - $data['id_source'] = $id_source; |
|
896 | + $data['format_source'] = 'radarvirtueljson'; |
|
897 | + $data['id_source'] = $id_source; |
|
898 | 898 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
899 | 899 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
900 | 900 | $SI->add($data); |
901 | 901 | unset($data); |
902 | - } |
|
902 | + } |
|
903 | 903 | } |
904 | - } |
|
905 | - //$last_exec['radarvirtueljson'] = time(); |
|
906 | - $last_exec[$id]['last'] = time(); |
|
907 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
908 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
909 | - //$buffer = $Common->getData($hosts[$id]); |
|
910 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
911 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
904 | + } |
|
905 | + //$last_exec['radarvirtueljson'] = time(); |
|
906 | + $last_exec[$id]['last'] = time(); |
|
907 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
908 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
909 | + //$buffer = $Common->getData($hosts[$id]); |
|
910 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
911 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
912 | 912 | |
913 | - if (isset($all_data['pireps'])) { |
|
913 | + if (isset($all_data['pireps'])) { |
|
914 | 914 | $reset = 0; |
915 | - foreach ($all_data['pireps'] as $line) { |
|
916 | - $data = array(); |
|
917 | - $data['id'] = $line['id']; |
|
918 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
919 | - $data['ident'] = $line['callsign']; // ident |
|
920 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
921 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
922 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
923 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
924 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
925 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
926 | - $data['latitude'] = $line['lat']; // lat |
|
927 | - $data['longitude'] = $line['lon']; // long |
|
928 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
929 | - //$data['squawk'] = $line['squawk']; // squawk |
|
930 | - //$data['emergency'] = ''; // emergency |
|
931 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
932 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
933 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
934 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
935 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
936 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
937 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
938 | - else $data['info'] = ''; |
|
939 | - $data['format_source'] = 'pireps'; |
|
940 | - $data['id_source'] = $id_source; |
|
941 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
942 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
943 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
944 | - if ($line['icon'] == 'plane') { |
|
915 | + foreach ($all_data['pireps'] as $line) { |
|
916 | + $data = array(); |
|
917 | + $data['id'] = $line['id']; |
|
918 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
919 | + $data['ident'] = $line['callsign']; // ident |
|
920 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
921 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
922 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
923 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
924 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
925 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
926 | + $data['latitude'] = $line['lat']; // lat |
|
927 | + $data['longitude'] = $line['lon']; // long |
|
928 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
929 | + //$data['squawk'] = $line['squawk']; // squawk |
|
930 | + //$data['emergency'] = ''; // emergency |
|
931 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
932 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
933 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
934 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
935 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
936 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
937 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
938 | + else $data['info'] = ''; |
|
939 | + $data['format_source'] = 'pireps'; |
|
940 | + $data['id_source'] = $id_source; |
|
941 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
942 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
943 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
944 | + if ($line['icon'] == 'plane') { |
|
945 | 945 | $SI->add($data); |
946 | - // print_r($data); |
|
947 | - } elseif ($line['icon'] == 'ct') { |
|
946 | + // print_r($data); |
|
947 | + } elseif ($line['icon'] == 'ct') { |
|
948 | 948 | $data['info'] = str_replace('^§','<br />',$data['info']); |
949 | 949 | $data['info'] = str_replace('&sect;','',$data['info']); |
950 | 950 | $typec = substr($data['ident'],-3); |
@@ -959,199 +959,199 @@ discard block |
||
959 | 959 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
960 | 960 | else $data['type'] = 'Observer'; |
961 | 961 | if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
962 | - } |
|
963 | - unset($data); |
|
962 | + } |
|
963 | + unset($data); |
|
964 | 964 | } |
965 | - } |
|
966 | - //$last_exec['pirepsjson'] = time(); |
|
967 | - $last_exec[$id]['last'] = time(); |
|
968 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
969 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
970 | - //$buffer = $Common->getData($hosts[$id]); |
|
971 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
972 | - $buffer = $Common->getData($value['host']); |
|
973 | - $all_data = json_decode($buffer,true); |
|
974 | - if ($buffer != '' && is_array($all_data)) { |
|
965 | + } |
|
966 | + //$last_exec['pirepsjson'] = time(); |
|
967 | + $last_exec[$id]['last'] = time(); |
|
968 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
969 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
970 | + //$buffer = $Common->getData($hosts[$id]); |
|
971 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
972 | + $buffer = $Common->getData($value['host']); |
|
973 | + $all_data = json_decode($buffer,true); |
|
974 | + if ($buffer != '' && is_array($all_data)) { |
|
975 | 975 | $reset = 0; |
976 | 976 | foreach ($all_data as $line) { |
977 | - $data = array(); |
|
978 | - //$data['id'] = $line['id']; // id not usable |
|
979 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
980 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
981 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
982 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
983 | - $data['ident'] = $line['flightnum']; // ident |
|
984 | - $data['altitude'] = $line['alt']; // altitude |
|
985 | - $data['speed'] = $line['gs']; // speed |
|
986 | - $data['heading'] = $line['heading']; // heading |
|
987 | - $data['latitude'] = $line['lat']; // lat |
|
988 | - $data['longitude'] = $line['lng']; // long |
|
989 | - $data['verticalrate'] = ''; // verticale rate |
|
990 | - $data['squawk'] = ''; // squawk |
|
991 | - $data['emergency'] = ''; // emergency |
|
992 | - //$data['datetime'] = $line['lastupdate']; |
|
993 | - $data['last_update'] = $line['lastupdate']; |
|
994 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
995 | - $data['departure_airport_icao'] = $line['depicao']; |
|
996 | - $data['departure_airport_time'] = $line['deptime']; |
|
997 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
998 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
999 | - $data['registration'] = $line['aircraft']; |
|
1000 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1001 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1002 | - if (isset($line['aircraftname'])) { |
|
977 | + $data = array(); |
|
978 | + //$data['id'] = $line['id']; // id not usable |
|
979 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
980 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
981 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
982 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
983 | + $data['ident'] = $line['flightnum']; // ident |
|
984 | + $data['altitude'] = $line['alt']; // altitude |
|
985 | + $data['speed'] = $line['gs']; // speed |
|
986 | + $data['heading'] = $line['heading']; // heading |
|
987 | + $data['latitude'] = $line['lat']; // lat |
|
988 | + $data['longitude'] = $line['lng']; // long |
|
989 | + $data['verticalrate'] = ''; // verticale rate |
|
990 | + $data['squawk'] = ''; // squawk |
|
991 | + $data['emergency'] = ''; // emergency |
|
992 | + //$data['datetime'] = $line['lastupdate']; |
|
993 | + $data['last_update'] = $line['lastupdate']; |
|
994 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
995 | + $data['departure_airport_icao'] = $line['depicao']; |
|
996 | + $data['departure_airport_time'] = $line['deptime']; |
|
997 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
998 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
999 | + $data['registration'] = $line['aircraft']; |
|
1000 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1001 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1002 | + if (isset($line['aircraftname'])) { |
|
1003 | 1003 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1004 | 1004 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1005 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1006 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1007 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1008 | - else { |
|
1009 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1010 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1011 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1012 | - } |
|
1013 | - } |
|
1014 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1015 | - $data['id_source'] = $id_source; |
|
1016 | - $data['format_source'] = 'phpvmacars'; |
|
1017 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1018 | - $SI->add($data); |
|
1019 | - unset($data); |
|
1005 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1006 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1007 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1008 | + else { |
|
1009 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1010 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1011 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1012 | + } |
|
1013 | + } |
|
1014 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1015 | + $data['id_source'] = $id_source; |
|
1016 | + $data['format_source'] = 'phpvmacars'; |
|
1017 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1018 | + $SI->add($data); |
|
1019 | + unset($data); |
|
1020 | 1020 | } |
1021 | 1021 | if ($globalDebug) echo 'No more data...'."\n"; |
1022 | 1022 | unset($buffer); |
1023 | 1023 | unset($all_data); |
1024 | - } |
|
1025 | - //$last_exec['phpvmacars'] = time(); |
|
1026 | - $last_exec[$id]['last'] = time(); |
|
1027 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1028 | - //$buffer = $Common->getData($hosts[$id]); |
|
1029 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1030 | - $buffer = $Common->getData($value['host']); |
|
1031 | - $all_data = json_decode($buffer,true); |
|
1032 | - if ($buffer != '' && is_array($all_data)) { |
|
1024 | + } |
|
1025 | + //$last_exec['phpvmacars'] = time(); |
|
1026 | + $last_exec[$id]['last'] = time(); |
|
1027 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1028 | + //$buffer = $Common->getData($hosts[$id]); |
|
1029 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1030 | + $buffer = $Common->getData($value['host']); |
|
1031 | + $all_data = json_decode($buffer,true); |
|
1032 | + if ($buffer != '' && is_array($all_data)) { |
|
1033 | 1033 | $reset = 0; |
1034 | 1034 | foreach ($all_data as $line) { |
1035 | - $data = array(); |
|
1036 | - //$data['id'] = $line['id']; // id not usable |
|
1037 | - $data['id'] = trim($line['flight_id']); |
|
1038 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1039 | - $data['pilot_name'] = $line['pilot_name']; |
|
1040 | - $data['pilot_id'] = $line['pilot_id']; |
|
1041 | - $data['ident'] = trim($line['callsign']); // ident |
|
1042 | - $data['altitude'] = $line['altitude']; // altitude |
|
1043 | - $data['speed'] = $line['gs']; // speed |
|
1044 | - $data['heading'] = $line['heading']; // heading |
|
1045 | - $data['latitude'] = $line['latitude']; // lat |
|
1046 | - $data['longitude'] = $line['longitude']; // long |
|
1047 | - $data['verticalrate'] = ''; // verticale rate |
|
1048 | - $data['squawk'] = ''; // squawk |
|
1049 | - $data['emergency'] = ''; // emergency |
|
1050 | - //$data['datetime'] = $line['lastupdate']; |
|
1051 | - $data['last_update'] = $line['last_update']; |
|
1052 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1053 | - $data['departure_airport_icao'] = $line['departure']; |
|
1054 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1055 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1056 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1057 | - //$data['registration'] = $line['aircraft']; |
|
1058 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1059 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1060 | - $data['id_source'] = $id_source; |
|
1061 | - $data['format_source'] = 'vam'; |
|
1062 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1063 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1064 | - $SI->add($data); |
|
1065 | - unset($data); |
|
1035 | + $data = array(); |
|
1036 | + //$data['id'] = $line['id']; // id not usable |
|
1037 | + $data['id'] = trim($line['flight_id']); |
|
1038 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1039 | + $data['pilot_name'] = $line['pilot_name']; |
|
1040 | + $data['pilot_id'] = $line['pilot_id']; |
|
1041 | + $data['ident'] = trim($line['callsign']); // ident |
|
1042 | + $data['altitude'] = $line['altitude']; // altitude |
|
1043 | + $data['speed'] = $line['gs']; // speed |
|
1044 | + $data['heading'] = $line['heading']; // heading |
|
1045 | + $data['latitude'] = $line['latitude']; // lat |
|
1046 | + $data['longitude'] = $line['longitude']; // long |
|
1047 | + $data['verticalrate'] = ''; // verticale rate |
|
1048 | + $data['squawk'] = ''; // squawk |
|
1049 | + $data['emergency'] = ''; // emergency |
|
1050 | + //$data['datetime'] = $line['lastupdate']; |
|
1051 | + $data['last_update'] = $line['last_update']; |
|
1052 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1053 | + $data['departure_airport_icao'] = $line['departure']; |
|
1054 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1055 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1056 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1057 | + //$data['registration'] = $line['aircraft']; |
|
1058 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1059 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1060 | + $data['id_source'] = $id_source; |
|
1061 | + $data['format_source'] = 'vam'; |
|
1062 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1063 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1064 | + $SI->add($data); |
|
1065 | + unset($data); |
|
1066 | 1066 | } |
1067 | 1067 | if ($globalDebug) echo 'No more data...'."\n"; |
1068 | 1068 | unset($buffer); |
1069 | 1069 | unset($all_data); |
1070 | - } |
|
1071 | - //$last_exec['phpvmacars'] = time(); |
|
1072 | - $last_exec[$id]['last'] = time(); |
|
1070 | + } |
|
1071 | + //$last_exec['phpvmacars'] = time(); |
|
1072 | + $last_exec[$id]['last'] = time(); |
|
1073 | 1073 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1074 | 1074 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1075 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1076 | - //$last_exec[$id]['last'] = time(); |
|
1075 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1076 | + //$last_exec[$id]['last'] = time(); |
|
1077 | 1077 | |
1078 | - //$read = array( $sockets[$id] ); |
|
1079 | - $read = $sockets; |
|
1080 | - $write = NULL; |
|
1081 | - $e = NULL; |
|
1082 | - $n = socket_select($read, $write, $e, $timeout); |
|
1083 | - if ($e != NULL) var_dump($e); |
|
1084 | - if ($n > 0) { |
|
1078 | + //$read = array( $sockets[$id] ); |
|
1079 | + $read = $sockets; |
|
1080 | + $write = NULL; |
|
1081 | + $e = NULL; |
|
1082 | + $n = socket_select($read, $write, $e, $timeout); |
|
1083 | + if ($e != NULL) var_dump($e); |
|
1084 | + if ($n > 0) { |
|
1085 | 1085 | $reset = 0; |
1086 | 1086 | foreach ($read as $nb => $r) { |
1087 | - //$value = $formats[$nb]; |
|
1088 | - $format = $globalSources[$nb]['format']; |
|
1089 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1087 | + //$value = $formats[$nb]; |
|
1088 | + $format = $globalSources[$nb]['format']; |
|
1089 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1090 | 1090 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1091 | - } elseif ($format == 'vrstcp') { |
|
1091 | + } elseif ($format == 'vrstcp') { |
|
1092 | 1092 | $buffer = @socket_read($r, 6000); |
1093 | - } else { |
|
1093 | + } else { |
|
1094 | 1094 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1095 | - } |
|
1096 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1097 | - //echo $buffer."\n"; |
|
1098 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1099 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1100 | - $error = false; |
|
1101 | - //$SI::del(); |
|
1102 | - if ($format == 'vrstcp') { |
|
1095 | + } |
|
1096 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1097 | + //echo $buffer."\n"; |
|
1098 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1099 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1100 | + $error = false; |
|
1101 | + //$SI::del(); |
|
1102 | + if ($format == 'vrstcp') { |
|
1103 | 1103 | $buffer = explode('},{',$buffer); |
1104 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1105 | - // SBS format is CSV format |
|
1106 | - if ($buffer !== FALSE && $buffer != '') { |
|
1104 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1105 | + // SBS format is CSV format |
|
1106 | + if ($buffer !== FALSE && $buffer != '') { |
|
1107 | 1107 | $tt[$format] = 0; |
1108 | 1108 | if ($format == 'acarssbs3') { |
1109 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1110 | - $ACARS->add(trim($buffer)); |
|
1111 | - $ACARS->deleteLiveAcarsData(); |
|
1109 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1110 | + $ACARS->add(trim($buffer)); |
|
1111 | + $ACARS->deleteLiveAcarsData(); |
|
1112 | 1112 | } elseif ($format == 'raw') { |
1113 | - // AVR format |
|
1114 | - $data = $SBS->parse($buffer); |
|
1115 | - if (is_array($data)) { |
|
1113 | + // AVR format |
|
1114 | + $data = $SBS->parse($buffer); |
|
1115 | + if (is_array($data)) { |
|
1116 | 1116 | $data['datetime'] = date('Y-m-d H:i:s'); |
1117 | 1117 | $data['format_source'] = 'raw'; |
1118 | 1118 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1119 | 1119 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1120 | 1120 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1121 | 1121 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1122 | - } |
|
1122 | + } |
|
1123 | 1123 | } elseif ($format == 'ais') { |
1124 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1125 | - $data = array(); |
|
1126 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1127 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1128 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1129 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1130 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1131 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1132 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1133 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1134 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1135 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1136 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1137 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1138 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1139 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1140 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1141 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1124 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1125 | + $data = array(); |
|
1126 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1127 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1128 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1129 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1130 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1131 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1132 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1133 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1134 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1135 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1136 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1137 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1138 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1139 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1140 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1141 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1142 | 1142 | |
1143 | - if (isset($ais_data['timestamp'])) { |
|
1143 | + if (isset($ais_data['timestamp'])) { |
|
1144 | 1144 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1145 | - } else { |
|
1145 | + } else { |
|
1146 | 1146 | $data['datetime'] = date('Y-m-d H:i:s'); |
1147 | - } |
|
1148 | - $data['format_source'] = 'aisnmea'; |
|
1149 | - $data['id_source'] = $id_source; |
|
1150 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1151 | - unset($data); |
|
1152 | - } elseif ($format == 'flightgearsp') { |
|
1153 | - //echo $buffer."\n"; |
|
1154 | - if (strlen($buffer) > 5) { |
|
1147 | + } |
|
1148 | + $data['format_source'] = 'aisnmea'; |
|
1149 | + $data['id_source'] = $id_source; |
|
1150 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1151 | + unset($data); |
|
1152 | + } elseif ($format == 'flightgearsp') { |
|
1153 | + //echo $buffer."\n"; |
|
1154 | + if (strlen($buffer) > 5) { |
|
1155 | 1155 | $line = explode(',',$buffer); |
1156 | 1156 | $data = array(); |
1157 | 1157 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1168,38 +1168,38 @@ discard block |
||
1168 | 1168 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1169 | 1169 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1170 | 1170 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1171 | - } |
|
1172 | - } elseif ($format == 'acars') { |
|
1173 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1174 | - $ACARS->add(trim($buffer)); |
|
1175 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1176 | - $ACARS->deleteLiveAcarsData(); |
|
1171 | + } |
|
1172 | + } elseif ($format == 'acars') { |
|
1173 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1174 | + $ACARS->add(trim($buffer)); |
|
1175 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1176 | + $ACARS->deleteLiveAcarsData(); |
|
1177 | 1177 | } elseif ($format == 'flightgearmp') { |
1178 | - if (substr($buffer,0,1) != '#') { |
|
1178 | + if (substr($buffer,0,1) != '#') { |
|
1179 | 1179 | $data = array(); |
1180 | 1180 | //echo $buffer."\n"; |
1181 | 1181 | $line = explode(' ',$buffer); |
1182 | 1182 | if (count($line) == 11) { |
1183 | - $userserver = explode('@',$line[0]); |
|
1184 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1185 | - $data['ident'] = $userserver[0]; |
|
1186 | - $data['registration'] = $userserver[0]; |
|
1187 | - $data['latitude'] = $line[4]; |
|
1188 | - $data['longitude'] = $line[5]; |
|
1189 | - $data['altitude'] = $line[6]; |
|
1190 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1191 | - $aircraft_type = $line[10]; |
|
1192 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1193 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1194 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1195 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1183 | + $userserver = explode('@',$line[0]); |
|
1184 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1185 | + $data['ident'] = $userserver[0]; |
|
1186 | + $data['registration'] = $userserver[0]; |
|
1187 | + $data['latitude'] = $line[4]; |
|
1188 | + $data['longitude'] = $line[5]; |
|
1189 | + $data['altitude'] = $line[6]; |
|
1190 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1191 | + $aircraft_type = $line[10]; |
|
1192 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1193 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1194 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1195 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1196 | + } |
|
1196 | 1197 | } |
1197 | - } |
|
1198 | 1198 | } elseif ($format == 'beast') { |
1199 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1200 | - die; |
|
1199 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1200 | + die; |
|
1201 | 1201 | } elseif ($format == 'vrstcp') { |
1202 | - foreach($buffer as $all_data) { |
|
1202 | + foreach($buffer as $all_data) { |
|
1203 | 1203 | $line = json_decode('{'.$all_data.'}',true); |
1204 | 1204 | $data = array(); |
1205 | 1205 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1219,113 +1219,113 @@ discard block |
||
1219 | 1219 | */ |
1220 | 1220 | $data['datetime'] = date('Y-m-d H:i:s'); |
1221 | 1221 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1222 | - $data['format_source'] = 'vrstcp'; |
|
1222 | + $data['format_source'] = 'vrstcp'; |
|
1223 | 1223 | $data['id_source'] = $id_source; |
1224 | 1224 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1225 | 1225 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1226 | 1226 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1227 | 1227 | unset($data); |
1228 | - } |
|
1228 | + } |
|
1229 | 1229 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1230 | - $line = explode("\t", $buffer); |
|
1231 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1230 | + $line = explode("\t", $buffer); |
|
1231 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1232 | 1232 | $key = $line[$k]; |
1233 | - $lined[$key] = $line[$k+1]; |
|
1234 | - } |
|
1235 | - if (count($lined) > 3) { |
|
1236 | - $data['hex'] = $lined['hexid']; |
|
1237 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1238 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1239 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1240 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1241 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1242 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1243 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1244 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1245 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1246 | - $data['id_source'] = $id_source; |
|
1247 | - $data['format_source'] = 'tsv'; |
|
1248 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1249 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1233 | + $lined[$key] = $line[$k+1]; |
|
1234 | + } |
|
1235 | + if (count($lined) > 3) { |
|
1236 | + $data['hex'] = $lined['hexid']; |
|
1237 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1238 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1239 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1240 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1241 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1242 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1243 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1244 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1245 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1246 | + $data['id_source'] = $id_source; |
|
1247 | + $data['format_source'] = 'tsv'; |
|
1248 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1249 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1250 | 1250 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1251 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1252 | - unset($lined); |
|
1253 | - unset($data); |
|
1254 | - } else $error = true; |
|
1251 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1252 | + unset($lined); |
|
1253 | + unset($data); |
|
1254 | + } else $error = true; |
|
1255 | 1255 | } elseif ($format == 'aprs' && $use_aprs) { |
1256 | - if ($aprs_connect == 0) { |
|
1256 | + if ($aprs_connect == 0) { |
|
1257 | 1257 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1258 | 1258 | $aprs_connect = 1; |
1259 | - } |
|
1259 | + } |
|
1260 | 1260 | |
1261 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1261 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1262 | 1262 | $aprs_last_tx = time(); |
1263 | 1263 | $data_aprs = "# Keep alive"; |
1264 | 1264 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1265 | - } |
|
1265 | + } |
|
1266 | 1266 | |
1267 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1268 | - //echo 'APRS data : '.$buffer."\n"; |
|
1269 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1270 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1271 | - //echo $buffer."\n"; |
|
1272 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1267 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1268 | + //echo 'APRS data : '.$buffer."\n"; |
|
1269 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1270 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1271 | + //echo $buffer."\n"; |
|
1272 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1273 | 1273 | $line = $APRS->parse($buffer); |
1274 | 1274 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1275 | 1275 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1276 | - $aprs_last_tx = time(); |
|
1277 | - $data = array(); |
|
1278 | - //print_r($line); |
|
1279 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1280 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1281 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1282 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1283 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1284 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1285 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1286 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1287 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1288 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1289 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1290 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1291 | - $data['latitude'] = $line['latitude']; |
|
1292 | - $data['longitude'] = $line['longitude']; |
|
1293 | - //$data['verticalrate'] = $line[16]; |
|
1294 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1295 | - else $data['speed'] = 0; |
|
1296 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1297 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1298 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1299 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1300 | - //else $data['heading'] = 0; |
|
1301 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1302 | - if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1303 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1304 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1305 | - $data['id_source'] = $id_source; |
|
1306 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1307 | - else $data['format_source'] = 'aprs'; |
|
1308 | - $data['source_name'] = $line['source']; |
|
1309 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1310 | - else $data['source_type'] = 'flarm'; |
|
1311 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1312 | - $currentdate = date('Y-m-d H:i:s'); |
|
1313 | - $aprsdate = strtotime($data['datetime']); |
|
1314 | - // Accept data if time <= system time + 20s |
|
1315 | - //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1316 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1276 | + $aprs_last_tx = time(); |
|
1277 | + $data = array(); |
|
1278 | + //print_r($line); |
|
1279 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1280 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1281 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1282 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1283 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1284 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1285 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1286 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1287 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1288 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1289 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1290 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1291 | + $data['latitude'] = $line['latitude']; |
|
1292 | + $data['longitude'] = $line['longitude']; |
|
1293 | + //$data['verticalrate'] = $line[16]; |
|
1294 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1295 | + else $data['speed'] = 0; |
|
1296 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1297 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1298 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1299 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1300 | + //else $data['heading'] = 0; |
|
1301 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1302 | + if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1303 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1304 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1305 | + $data['id_source'] = $id_source; |
|
1306 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1307 | + else $data['format_source'] = 'aprs'; |
|
1308 | + $data['source_name'] = $line['source']; |
|
1309 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1310 | + else $data['source_type'] = 'flarm'; |
|
1311 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1312 | + $currentdate = date('Y-m-d H:i:s'); |
|
1313 | + $aprsdate = strtotime($data['datetime']); |
|
1314 | + // Accept data if time <= system time + 20s |
|
1315 | + //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1316 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1317 | 1317 | $send = $SI->add($data); |
1318 | - } elseif ($data['source_type'] == 'ais') { |
|
1318 | + } elseif ($data['source_type'] == 'ais') { |
|
1319 | 1319 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1320 | - } elseif (isset($line['stealth'])) { |
|
1320 | + } elseif (isset($line['stealth'])) { |
|
1321 | 1321 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1322 | 1322 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1323 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1324 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1323 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1324 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1325 | 1325 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1326 | 1326 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1327 | - } |
|
1328 | - unset($data); |
|
1327 | + } |
|
1328 | + unset($data); |
|
1329 | 1329 | } |
1330 | 1330 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1331 | 1331 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1335,12 +1335,12 @@ discard block |
||
1335 | 1335 | } |
1336 | 1336 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1337 | 1337 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1338 | - } |
|
1338 | + } |
|
1339 | 1339 | } else { |
1340 | - $line = explode(',', $buffer); |
|
1341 | - if (count($line) > 20) { |
|
1342 | - $data['hex'] = $line[4]; |
|
1343 | - /* |
|
1340 | + $line = explode(',', $buffer); |
|
1341 | + if (count($line) > 20) { |
|
1342 | + $data['hex'] = $line[4]; |
|
1343 | + /* |
|
1344 | 1344 | $data['datetime'] = $line[6].' '.$line[7]; |
1345 | 1345 | date_default_timezone_set($globalTimezone); |
1346 | 1346 | $datetime = new DateTime($data['datetime']); |
@@ -1348,30 +1348,30 @@ discard block |
||
1348 | 1348 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1349 | 1349 | date_default_timezone_set('UTC'); |
1350 | 1350 | */ |
1351 | - // Force datetime to current UTC datetime |
|
1352 | - date_default_timezone_set('UTC'); |
|
1353 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1354 | - $data['ident'] = trim($line[10]); |
|
1355 | - $data['latitude'] = $line[14]; |
|
1356 | - $data['longitude'] = $line[15]; |
|
1357 | - $data['verticalrate'] = $line[16]; |
|
1358 | - $data['emergency'] = $line[20]; |
|
1359 | - $data['speed'] = $line[12]; |
|
1360 | - $data['squawk'] = $line[17]; |
|
1361 | - $data['altitude'] = $line[11]; |
|
1362 | - $data['heading'] = $line[13]; |
|
1363 | - $data['ground'] = $line[21]; |
|
1364 | - $data['emergency'] = $line[19]; |
|
1365 | - $data['format_source'] = 'sbs'; |
|
1351 | + // Force datetime to current UTC datetime |
|
1352 | + date_default_timezone_set('UTC'); |
|
1353 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1354 | + $data['ident'] = trim($line[10]); |
|
1355 | + $data['latitude'] = $line[14]; |
|
1356 | + $data['longitude'] = $line[15]; |
|
1357 | + $data['verticalrate'] = $line[16]; |
|
1358 | + $data['emergency'] = $line[20]; |
|
1359 | + $data['speed'] = $line[12]; |
|
1360 | + $data['squawk'] = $line[17]; |
|
1361 | + $data['altitude'] = $line[11]; |
|
1362 | + $data['heading'] = $line[13]; |
|
1363 | + $data['ground'] = $line[21]; |
|
1364 | + $data['emergency'] = $line[19]; |
|
1365 | + $data['format_source'] = 'sbs'; |
|
1366 | 1366 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1367 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1367 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1368 | 1368 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1369 | - $data['id_source'] = $id_source; |
|
1370 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1371 | - else $error = true; |
|
1372 | - unset($data); |
|
1373 | - } else $error = true; |
|
1374 | - if ($error) { |
|
1369 | + $data['id_source'] = $id_source; |
|
1370 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1371 | + else $error = true; |
|
1372 | + unset($data); |
|
1373 | + } else $error = true; |
|
1374 | + if ($error) { |
|
1375 | 1375 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1376 | 1376 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1377 | 1377 | } else { |
@@ -1387,13 +1387,13 @@ discard block |
||
1387 | 1387 | connect_all($sourceer); |
1388 | 1388 | $sourceer = array(); |
1389 | 1389 | } |
1390 | - } |
|
1390 | + } |
|
1391 | 1391 | } |
1392 | 1392 | // Sleep for xxx microseconds |
1393 | 1393 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1394 | - } else { |
|
1394 | + } else { |
|
1395 | 1395 | if ($format == 'flightgearmp') { |
1396 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1396 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1397 | 1397 | //@socket_close($r); |
1398 | 1398 | sleep($globalMinFetch); |
1399 | 1399 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1402,9 +1402,9 @@ discard block |
||
1402 | 1402 | break; |
1403 | 1403 | |
1404 | 1404 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1405 | - if (isset($tt[$format])) $tt[$format]++; |
|
1406 | - else $tt[$format] = 0; |
|
1407 | - if ($tt[$format] > 30) { |
|
1405 | + if (isset($tt[$format])) $tt[$format]++; |
|
1406 | + else $tt[$format] = 0; |
|
1407 | + if ($tt[$format] > 30) { |
|
1408 | 1408 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1409 | 1409 | //@socket_close($r); |
1410 | 1410 | sleep(2); |
@@ -1415,23 +1415,23 @@ discard block |
||
1415 | 1415 | //connect_all($globalSources); |
1416 | 1416 | $tt[$format]=0; |
1417 | 1417 | break; |
1418 | - } |
|
1418 | + } |
|
1419 | + } |
|
1419 | 1420 | } |
1420 | - } |
|
1421 | 1421 | } |
1422 | - } else { |
|
1422 | + } else { |
|
1423 | 1423 | $error = socket_strerror(socket_last_error()); |
1424 | 1424 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1425 | 1425 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1426 | 1426 | if (isset($globalDebug)) echo "Restarting...\n"; |
1427 | 1427 | // Restart the script if possible |
1428 | 1428 | if (is_array($sockets)) { |
1429 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1429 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1430 | 1430 | |
1431 | - foreach ($sockets as $sock) { |
|
1431 | + foreach ($sockets as $sock) { |
|
1432 | 1432 | @socket_shutdown($sock,2); |
1433 | 1433 | @socket_close($sock); |
1434 | - } |
|
1434 | + } |
|
1435 | 1435 | |
1436 | 1436 | } |
1437 | 1437 | if ($globalDebug) echo "Waiting..."; |
@@ -1446,13 +1446,13 @@ discard block |
||
1446 | 1446 | if ($globalDebug) echo "Restart all connections..."; |
1447 | 1447 | connect_all($globalSources); |
1448 | 1448 | } |
1449 | - } |
|
1449 | + } |
|
1450 | 1450 | } |
1451 | 1451 | if ($globalDaemon === false) { |
1452 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1453 | - $SI->checkAll(); |
|
1452 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1453 | + $SI->checkAll(); |
|
1454 | + } |
|
1454 | 1455 | } |
1455 | - } |
|
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | ?> |
@@ -40,15 +40,15 @@ |
||
40 | 40 | //print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>'; |
41 | 41 | print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>'; |
42 | 42 | if ($spotter_item['atc_range'] > 0) { |
43 | - print '<div><span>'._("Range").'</span>'; |
|
44 | - print $spotter_item['atc_range']; |
|
45 | - print '</div>'; |
|
43 | + print '<div><span>'._("Range").'</span>'; |
|
44 | + print $spotter_item['atc_range']; |
|
45 | + print '</div>'; |
|
46 | 46 | } |
47 | 47 | print '</div>'; |
48 | 48 | if ($spotter_item['info'] != '') { |
49 | - print '<div class="notamtext"><span>'._("Info").'</span>'; |
|
50 | - print $spotter_item['info']; |
|
51 | - print '</div>'; |
|
49 | + print '<div class="notamtext"><span>'._("Info").'</span>'; |
|
50 | + print $spotter_item['info']; |
|
51 | + print '</div>'; |
|
52 | 52 | } |
53 | 53 | print '</div>'; |
54 | 54 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | date_default_timezone_set('UTC'); |
25 | 25 | //waypoint plotting |
26 | 26 | $output .= '{"type": "Feature",'; |
27 | - $output .= '"properties": {'; |
|
27 | + $output .= '"properties": {'; |
|
28 | 28 | $output .= '"ref": "'.$spotter_item['atc_id'].'",'; |
29 | 29 | $output .= '"ident": "'.$spotter_item['ident'].'",'; |
30 | 30 | $output .= '"frequency": "'.$spotter_item['frequency'].'",'; |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | } else { |
51 | 51 | $output .= '"icon": "images/atc.png"'; |
52 | 52 | } |
53 | - $output .= '},'; |
|
54 | - $output .= '"geometry": {'; |
|
53 | + $output .= '},'; |
|
54 | + $output .= '"geometry": {'; |
|
55 | 55 | $output .= '"type": "Point",'; |
56 | 56 | $output .= '"coordinates": ['; |
57 | - $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
57 | + $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
58 | 58 | $output .= ']'; |
59 | - $output .= '}'; |
|
59 | + $output .= '}'; |
|
60 | 60 | $output .= '},'; |
61 | 61 | $radius = $spotter_item['atc_range']*100; |
62 | 62 | if ($radius > 0) { |
63 | 63 | $output .= '{"type": "Feature",'; |
64 | - $output .= '"properties": {'; |
|
64 | + $output .= '"properties": {'; |
|
65 | 65 | $output .= '"ref": "'.$spotter_item['atc_id'].'",'; |
66 | 66 | $output .= '"ident": "'.$spotter_item['ident'].'",'; |
67 | 67 | $output .= '"frequency": "'.$spotter_item['frequency'].'",'; |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | } else { |
88 | 88 | $output .= '"atccolor": "#888219"'; |
89 | 89 | } |
90 | - $output .= '},'; |
|
91 | - $output .= '"geometry": {'; |
|
90 | + $output .= '},'; |
|
91 | + $output .= '"geometry": {'; |
|
92 | 92 | $output .= '"type": "Point",'; |
93 | 93 | $output .= '"coordinates": ['; |
94 | - $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
94 | + $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
95 | 95 | $output .= ']'; |
96 | - $output .= '}'; |
|
96 | + $output .= '}'; |
|
97 | 97 | $output .= '},'; |
98 | 98 | } |
99 | 99 | } |