@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | class MarineImport { |
16 | - private $all_tracked = array(); |
|
17 | - private $last_delete_hourly = 0; |
|
18 | - private $last_delete = 0; |
|
19 | - private $stats = array(); |
|
20 | - private $tmd = 0; |
|
21 | - private $source_location = array(); |
|
22 | - public $db = null; |
|
23 | - public $nb = 0; |
|
16 | + private $all_tracked = array(); |
|
17 | + private $last_delete_hourly = 0; |
|
18 | + private $last_delete = 0; |
|
19 | + private $stats = array(); |
|
20 | + private $tmd = 0; |
|
21 | + private $source_location = array(); |
|
22 | + public $db = null; |
|
23 | + public $nb = 0; |
|
24 | 24 | |
25 | - public function __construct($dbc = null) { |
|
25 | + public function __construct($dbc = null) { |
|
26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
28 | - $Connection = new Connection($dbc); |
|
29 | - $this->db = $Connection->db(); |
|
30 | - date_default_timezone_set('UTC'); |
|
28 | + $Connection = new Connection($dbc); |
|
29 | + $this->db = $Connection->db(); |
|
30 | + date_default_timezone_set('UTC'); |
|
31 | 31 | } |
32 | 32 | // Get previous source stats |
33 | 33 | /* |
@@ -46,57 +46,57 @@ discard block |
||
46 | 46 | } |
47 | 47 | */ |
48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
49 | - $APRSMarine = new APRSMarine(); |
|
50 | - //$APRSSpotter->connect(); |
|
49 | + $APRSMarine = new APRSMarine(); |
|
50 | + //$APRSSpotter->connect(); |
|
51 | + } |
|
51 | 52 | } |
52 | - } |
|
53 | 53 | |
54 | - public function checkAll() { |
|
54 | + public function checkAll() { |
|
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
58 | - foreach ($this->all_tracked as $key => $flight) { |
|
57 | + if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
58 | + foreach ($this->all_tracked as $key => $flight) { |
|
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | - //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
61 | - $Marine = new Marine($this->db); |
|
62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
60 | + //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
61 | + $Marine = new Marine($this->db); |
|
62 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
63 | 63 | } |
64 | - } |
|
64 | + } |
|
65 | + } |
|
65 | 66 | } |
66 | - } |
|
67 | 67 | |
68 | - public function del() { |
|
68 | + public function del() { |
|
69 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 70 | // Delete old infos |
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | - if (isset($flight['lastupdate'])) { |
|
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | - if (isset($this->all_tracked[$key]['id'])) { |
|
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | - /* |
|
73 | + if (isset($flight['lastupdate'])) { |
|
74 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | + if (isset($this->all_tracked[$key]['id'])) { |
|
77 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | + /* |
|
79 | 79 | $MarineLive = new MarineLive(); |
80 | 80 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
81 | 81 | $MarineLive->db = null; |
82 | 82 | */ |
83 | - //$real_arrival = $this->arrival($key); |
|
84 | - $Marine = new Marine($this->db); |
|
85 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
83 | + //$real_arrival = $this->arrival($key); |
|
84 | + $Marine = new Marine($this->db); |
|
85 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
86 | 86 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | - } |
|
89 | - // Put in archive |
|
88 | + } |
|
89 | + // Put in archive |
|
90 | 90 | // $Marine->db = null; |
91 | 91 | } |
92 | - } |
|
93 | - unset($this->all_tracked[$key]); |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - } |
|
92 | + } |
|
93 | + unset($this->all_tracked[$key]); |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - public function add($line) { |
|
99 | + public function add($line) { |
|
100 | 100 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
@@ -105,83 +105,83 @@ discard block |
||
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | 107 | if(is_array($line) && isset($line['mmsi'])) { |
108 | - //print_r($line); |
|
109 | - if (isset($line['mmsi'])) { |
|
108 | + //print_r($line); |
|
109 | + if (isset($line['mmsi'])) { |
|
110 | 110 | |
111 | 111 | |
112 | 112 | // Increment message number |
113 | 113 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | - $current_date = date('Y-m-d'); |
|
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
114 | + $current_date = date('Y-m-d'); |
|
115 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | + else $source = ''; |
|
117 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | 125 | $Common = new Common(); |
126 | 126 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
127 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | + else $id = trim($line['id']); |
|
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | - $this->all_tracked[$id] = array(); |
|
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | - if (!isset($line['id'])) { |
|
131 | + $this->all_tracked[$id] = array(); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | + if (!isset($line['id'])) { |
|
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
147 | 147 | if (!empty($identity)) { |
148 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
148 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
150 | 150 | } |
151 | 151 | //print_r($identity); |
152 | 152 | unset($Marine); |
153 | 153 | //$dataFound = true; |
154 | - } |
|
154 | + } |
|
155 | 155 | } |
156 | 156 | if (isset($line['type_id'])) { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
159 | 159 | } |
160 | 160 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
162 | 162 | } |
163 | 163 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
165 | 165 | } |
166 | 166 | if (isset($line['imo']) && $line['imo'] != '') { |
167 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
167 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
168 | 168 | } |
169 | 169 | if (isset($line['callsign']) && $line['callsign'] != '') { |
170 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
170 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
171 | 171 | } |
172 | 172 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
173 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
173 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
174 | 174 | } |
175 | 175 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
176 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
176 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
180 | 180 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
182 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
182 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
183 | 183 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
184 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
184 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
185 | 185 | $timeelapsed = microtime(true); |
186 | 186 | $Marine = new Marine($this->db); |
187 | 187 | $fromsource = NULL; |
@@ -189,20 +189,20 @@ discard block |
||
189 | 189 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
190 | 190 | $Marine->db = null; |
191 | 191 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
192 | - } |
|
192 | + } |
|
193 | 193 | } |
194 | - } |
|
195 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
194 | + } |
|
195 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
199 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
199 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
200 | 200 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
201 | - } else { |
|
201 | + } else { |
|
202 | 202 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
203 | 203 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
204 | 204 | return ''; |
205 | - } |
|
205 | + } |
|
206 | 206 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
207 | 207 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
208 | 208 | return ''; |
@@ -219,24 +219,24 @@ discard block |
||
219 | 219 | |
220 | 220 | |
221 | 221 | if (isset($line['speed'])) { |
222 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
222 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
224 | 224 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
225 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
226 | - if ($distance > 1000 && $distance < 10000) { |
|
225 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
226 | + if ($distance > 1000 && $distance < 10000) { |
|
227 | 227 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
228 | 228 | $speed = $speed*3.6; |
229 | 229 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
230 | 230 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
231 | - } |
|
231 | + } |
|
232 | 232 | } |
233 | 233 | |
234 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
235 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
236 | - else unset($timediff); |
|
237 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
234 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
235 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
236 | + else unset($timediff); |
|
237 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
238 | 238 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
239 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
239 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
240 | 240 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
241 | 241 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
242 | 242 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -244,211 +244,211 @@ discard block |
||
244 | 244 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
245 | 245 | $timeelapsed = microtime(true); |
246 | 246 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
247 | - $Marine = new Marine($this->db); |
|
248 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
249 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
250 | - $Marine->db = null; |
|
251 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
247 | + $Marine = new Marine($this->db); |
|
248 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
249 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
250 | + $Marine->db = null; |
|
251 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
252 | 252 | } |
253 | 253 | $this->tmd = 0; |
254 | 254 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
255 | - } |
|
255 | + } |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
259 | 259 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
260 | 260 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
261 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
262 | - $dataFound = true; |
|
263 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
261 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
262 | + $dataFound = true; |
|
263 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
264 | 264 | } |
265 | 265 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
266 | 266 | } |
267 | 267 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
268 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
268 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
269 | 269 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
270 | 270 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
271 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
272 | - $dataFound = true; |
|
273 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
271 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
272 | + $dataFound = true; |
|
273 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
274 | 274 | } |
275 | 275 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
276 | 276 | } |
277 | 277 | |
278 | - } else if ($globalDebug && $timediff > 20) { |
|
278 | + } else if ($globalDebug && $timediff > 20) { |
|
279 | 279 | $this->tmd = $this->tmd + 1; |
280 | 280 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
281 | 281 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
282 | 282 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
283 | 283 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
284 | - } |
|
284 | + } |
|
285 | 285 | } |
286 | 286 | if (isset($line['last_update']) && $line['last_update'] != '') { |
287 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
288 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
287 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
288 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
289 | 289 | } |
290 | 290 | if (isset($line['format_source']) && $line['format_source'] != '') { |
291 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
291 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
292 | 292 | } |
293 | 293 | if (isset($line['source_name']) && $line['source_name'] != '') { |
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
295 | 295 | } |
296 | 296 | if (isset($line['status']) && $line['status'] != '') { |
297 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
297 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
298 | 298 | } |
299 | 299 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
300 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
301 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
300 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
301 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
302 | 302 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
303 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
303 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
304 | 304 | $Marine = new Marine($this->db); |
305 | 305 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
306 | 306 | unset($Marine); |
307 | - } |
|
307 | + } |
|
308 | + } |
|
308 | 309 | } |
309 | - } |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
313 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
313 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | if (isset($line['heading']) && $line['heading'] != '') { |
317 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
318 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
319 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
320 | - //$dataFound = true; |
|
317 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
318 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
319 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
320 | + //$dataFound = true; |
|
321 | 321 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
322 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
323 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
324 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
325 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
322 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
323 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
324 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
325 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
326 | 326 | } |
327 | 327 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
328 | 328 | |
329 | 329 | |
330 | 330 | |
331 | 331 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
332 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
333 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
334 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
335 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
332 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
333 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
334 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
335 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
336 | 336 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
337 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
338 | - $timeelapsed = microtime(true); |
|
339 | - $MarineLive = new MarineLive($this->db); |
|
340 | - if (isset($line['id'])) { |
|
337 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
338 | + $timeelapsed = microtime(true); |
|
339 | + $MarineLive = new MarineLive($this->db); |
|
340 | + if (isset($line['id'])) { |
|
341 | 341 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
342 | 342 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
343 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
343 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
344 | 344 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
345 | 345 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
346 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
346 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
347 | 347 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
348 | 348 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
349 | - } else $recent_ident = ''; |
|
350 | - $MarineLive->db=null; |
|
351 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
352 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
349 | + } else $recent_ident = ''; |
|
350 | + $MarineLive->db=null; |
|
351 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
352 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
353 | 353 | } else $recent_ident = ''; |
354 | - } else { |
|
354 | + } else { |
|
355 | 355 | $recent_ident = ''; |
356 | 356 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
357 | - } |
|
358 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
359 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
360 | - { |
|
357 | + } |
|
358 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
359 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
360 | + { |
|
361 | 361 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
362 | 362 | //adds the spotter data for the archive |
363 | - $highlight = ''; |
|
364 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
365 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
363 | + $highlight = ''; |
|
364 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
365 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
366 | 366 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
367 | - $timeelapsed = microtime(true); |
|
368 | - $Marine = new Marine($this->db); |
|
369 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
370 | - $Marine->db = null; |
|
371 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
372 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
367 | + $timeelapsed = microtime(true); |
|
368 | + $Marine = new Marine($this->db); |
|
369 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
370 | + $Marine->db = null; |
|
371 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
372 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
373 | + } |
|
373 | 374 | } |
374 | - } |
|
375 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
375 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
376 | 376 | // Add source stat in DB |
377 | 377 | $Stats = new Stats($this->db); |
378 | 378 | if (!empty($this->stats)) { |
379 | - if ($globalDebug) echo 'Add source stats : '; |
|
380 | - foreach($this->stats as $date => $data) { |
|
379 | + if ($globalDebug) echo 'Add source stats : '; |
|
380 | + foreach($this->stats as $date => $data) { |
|
381 | 381 | foreach($data as $source => $sourced) { |
382 | - //print_r($sourced); |
|
383 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
384 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
385 | - if (isset($sourced['msg'])) { |
|
386 | - if (time() - $sourced['msg']['date'] > 10) { |
|
387 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
388 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
389 | - unset($this->stats[$date][$source]['msg']); |
|
390 | - } |
|
391 | - } |
|
392 | - } |
|
393 | - if ($date != date('Y-m-d')) { |
|
394 | - unset($this->stats[$date]); |
|
395 | - } |
|
396 | - } |
|
397 | - if ($globalDebug) echo 'Done'."\n"; |
|
382 | + //print_r($sourced); |
|
383 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
384 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
385 | + if (isset($sourced['msg'])) { |
|
386 | + if (time() - $sourced['msg']['date'] > 10) { |
|
387 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
388 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
389 | + unset($this->stats[$date][$source]['msg']); |
|
390 | + } |
|
391 | + } |
|
392 | + } |
|
393 | + if ($date != date('Y-m-d')) { |
|
394 | + unset($this->stats[$date]); |
|
395 | + } |
|
396 | + } |
|
397 | + if ($globalDebug) echo 'Done'."\n"; |
|
398 | 398 | } |
399 | 399 | $Stats->db = null; |
400 | - } |
|
400 | + } |
|
401 | 401 | |
402 | - $this->del(); |
|
402 | + $this->del(); |
|
403 | 403 | //$ignoreImport = false; |
404 | 404 | $this->all_tracked[$id]['addedMarine'] = 1; |
405 | 405 | //print_r($this->all_tracked[$id]); |
406 | 406 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
407 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
408 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
409 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
407 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
408 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
409 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
410 | 410 | $MarineLive = new MarineLive($this->db); |
411 | 411 | $MarineLive->deleteLiveMarineData(); |
412 | 412 | $MarineLive->db=null; |
413 | 413 | if ($globalDebug) echo " Done\n"; |
414 | - } |
|
415 | - $this->last_delete = time(); |
|
414 | + } |
|
415 | + $this->last_delete = time(); |
|
416 | 416 | } |
417 | - } elseif ($recent_ident != '') { |
|
417 | + } elseif ($recent_ident != '') { |
|
418 | 418 | $this->all_tracked[$id]['id'] = $recent_ident; |
419 | 419 | $this->all_tracked[$id]['addedMarine'] = 1; |
420 | 420 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
421 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
421 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
422 | 422 | $Marine = new Marine($this->db); |
423 | 423 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
424 | 424 | $Marine->db = null; |
425 | - } |
|
425 | + } |
|
426 | 426 | } |
427 | 427 | |
428 | - } |
|
428 | + } |
|
429 | + } |
|
429 | 430 | } |
430 | - } |
|
431 | - //adds the spotter LIVE data |
|
432 | - if ($globalDebug) { |
|
431 | + //adds the spotter LIVE data |
|
432 | + if ($globalDebug) { |
|
433 | 433 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
434 | - } |
|
435 | - $ignoreImport = false; |
|
434 | + } |
|
435 | + $ignoreImport = false; |
|
436 | 436 | |
437 | - if (!$ignoreImport) { |
|
437 | + if (!$ignoreImport) { |
|
438 | 438 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
439 | 439 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
440 | 440 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
441 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
441 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
442 | 442 | $timeelapsed = microtime(true); |
443 | 443 | $MarineLive = new MarineLive($this->db); |
444 | 444 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
445 | 445 | $MarineLive->db = null; |
446 | 446 | if ($globalDebug) echo $result."\n"; |
447 | 447 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
448 | - } |
|
448 | + } |
|
449 | 449 | } |
450 | 450 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
451 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
451 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
452 | 452 | } |
453 | 453 | $this->all_tracked[$id]['putinarchive'] = false; |
454 | 454 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | if ($stats_heading == 16) $stats_heading = 0; |
481 | 481 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
482 | 482 | for ($i=0;$i<=15;$i++) { |
483 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
483 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
484 | 484 | } |
485 | 485 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
486 | 486 | } else { |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | //var_dump($this->stats); |
494 | 494 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
495 | 495 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
496 | - end($this->stats[$current_date][$source]['hist']); |
|
497 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
496 | + end($this->stats[$current_date][$source]['hist']); |
|
497 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
498 | 498 | } else $mini = 0; |
499 | 499 | for ($i=$mini;$i<=$distance;$i+=10) { |
500 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
500 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
501 | 501 | } |
502 | 502 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
503 | 503 | } else { |
@@ -513,24 +513,24 @@ discard block |
||
513 | 513 | |
514 | 514 | |
515 | 515 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
516 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
516 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
517 | 517 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
518 | 518 | $MarineLive = new MarineLive($this->db); |
519 | 519 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
520 | 520 | $MarineLive->db = null; |
521 | 521 | //MarineLive->deleteLiveMarineData(); |
522 | 522 | if ($globalDebug) echo " Done\n"; |
523 | - } |
|
524 | - $this->last_delete_hourly = time(); |
|
523 | + } |
|
524 | + $this->last_delete_hourly = time(); |
|
525 | 525 | } |
526 | 526 | |
527 | - } |
|
528 | - //$ignoreImport = false; |
|
527 | + } |
|
528 | + //$ignoreImport = false; |
|
529 | 529 | } |
530 | 530 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
531 | 531 | if ($send) return $this->all_tracked[$id]; |
532 | - } |
|
532 | + } |
|
533 | + } |
|
533 | 534 | } |
534 | - } |
|
535 | 535 | } |
536 | 536 | ?> |
@@ -91,28 +91,28 @@ |
||
91 | 91 | $limit_previous_2 = $limit_end - $absolute_difference; |
92 | 92 | |
93 | 93 | if ( |
94 | - (isset($_GET['q']) && $_GET['q'] != '') || |
|
95 | - (isset($_GET['registration']) && $_GET['registration'] != '') || |
|
96 | - (isset($_GET['aircraft']) && $_GET['aircraft'] != '') || |
|
97 | - (isset($_GET['manufacturer']) && $_GET['manufacturer'] != '') || |
|
98 | - (isset($_GET['highlights']) && $_GET['highlights'] != '') || |
|
99 | - (isset($_GET['airline']) && $_GET['airline'] != '') || |
|
100 | - (isset($_GET['airline_country']) && $_GET['airline_country'] != '') || |
|
101 | - (isset($_GET['airline_type']) && $_GET['airline_type'] != '') || |
|
102 | - (isset($_GET['airport']) && $_GET['airport'] != '') || |
|
103 | - (isset($_GET['airport_country']) && $_GET['airport_country'] != '') || |
|
104 | - (isset($_GET['callsign']) && $_GET['callsign'] != '') || |
|
105 | - (isset($_GET['owner']) && $_GET['owner'] != '') || |
|
106 | - (isset($_GET['pilot_name']) && $_GET['pilot_name'] != '') || |
|
107 | - (isset($_GET['pilot_id']) && $_GET['pilot_id'] != '') || |
|
108 | - (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != '') || |
|
109 | - (isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != '') || |
|
110 | - (isset($_GET['mmsi']) && $_GET['mmsi'] != '') || |
|
111 | - (isset($_GET['imo']) && $_GET['imo'] != '') || |
|
112 | - ((isset($_GET['origlat']) && $_GET['origlat'] != '') && |
|
113 | - (isset($_GET['origlon']) && $_GET['origlon'] != '') && |
|
114 | - (isset($_GET['dist']) && $_GET['dist'] != '')) |
|
115 | - ){ |
|
94 | + (isset($_GET['q']) && $_GET['q'] != '') || |
|
95 | + (isset($_GET['registration']) && $_GET['registration'] != '') || |
|
96 | + (isset($_GET['aircraft']) && $_GET['aircraft'] != '') || |
|
97 | + (isset($_GET['manufacturer']) && $_GET['manufacturer'] != '') || |
|
98 | + (isset($_GET['highlights']) && $_GET['highlights'] != '') || |
|
99 | + (isset($_GET['airline']) && $_GET['airline'] != '') || |
|
100 | + (isset($_GET['airline_country']) && $_GET['airline_country'] != '') || |
|
101 | + (isset($_GET['airline_type']) && $_GET['airline_type'] != '') || |
|
102 | + (isset($_GET['airport']) && $_GET['airport'] != '') || |
|
103 | + (isset($_GET['airport_country']) && $_GET['airport_country'] != '') || |
|
104 | + (isset($_GET['callsign']) && $_GET['callsign'] != '') || |
|
105 | + (isset($_GET['owner']) && $_GET['owner'] != '') || |
|
106 | + (isset($_GET['pilot_name']) && $_GET['pilot_name'] != '') || |
|
107 | + (isset($_GET['pilot_id']) && $_GET['pilot_id'] != '') || |
|
108 | + (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != '') || |
|
109 | + (isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != '') || |
|
110 | + (isset($_GET['mmsi']) && $_GET['mmsi'] != '') || |
|
111 | + (isset($_GET['imo']) && $_GET['imo'] != '') || |
|
112 | + ((isset($_GET['origlat']) && $_GET['origlat'] != '') && |
|
113 | + (isset($_GET['origlon']) && $_GET['origlon'] != '') && |
|
114 | + (isset($_GET['dist']) && $_GET['dist'] != '')) |
|
115 | + ){ |
|
116 | 116 | $q = filter_input(INPUT_GET, 'q',FILTER_SANITIZE_STRING); |
117 | 117 | $registration = filter_input(INPUT_GET, 'registration',FILTER_SANITIZE_STRING); |
118 | 118 | $aircraft = filter_input(INPUT_GET, 'aircraft',FILTER_SANITIZE_STRING); |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | - * Creates the database connection |
|
60 | - * |
|
61 | - * @return Boolean of the database connection |
|
62 | - * |
|
63 | - */ |
|
59 | + * Creates the database connection |
|
60 | + * |
|
61 | + * @return Boolean of the database connection |
|
62 | + * |
|
63 | + */ |
|
64 | 64 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
65 | 65 | { |
66 | 66 | global $globalDBdriver, $globalDBhost, $globalDBuser, $globalDBpass, $globalDBname, $globalDebug, $globalDB, $globalDBport, $globalDBTimeOut, $globalDBretry, $globalDBPersistent; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | if($results->rowCount()>0) { |
161 | - return true; |
|
161 | + return true; |
|
162 | 162 | } |
163 | 163 | else return false; |
164 | 164 | } |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | $sum = $sum->fetchColumn(0); |
177 | 177 | } else $sum = 0; |
178 | 178 | if (intval($sum) !== 2) { |
179 | - return false; |
|
179 | + return false; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | } catch(PDOException $e) { |
183 | 183 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
184 | - throw $e; |
|
185 | - } |
|
186 | - //echo 'error ! '.$e->getMessage(); |
|
184 | + throw $e; |
|
185 | + } |
|
186 | + //echo 'error ! '.$e->getMessage(); |
|
187 | 187 | return false; |
188 | 188 | } |
189 | 189 | return true; |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | $version = 0; |
288 | 288 | if ($this->tableExists('aircraft')) { |
289 | 289 | if (!$this->tableExists('config')) { |
290 | - $version = '1'; |
|
291 | - return $version; |
|
290 | + $version = '1'; |
|
291 | + return $version; |
|
292 | 292 | } else { |
293 | 293 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
294 | 294 | try { |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | * @return Boolean if latest version or not |
310 | 310 | */ |
311 | 311 | public function latest() { |
312 | - global $globalNoDB; |
|
313 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
314 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
315 | - else return false; |
|
312 | + global $globalNoDB; |
|
313 | + if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
314 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
315 | + else return false; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | } |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | - * Executes the SQL statements to get the spotter information |
|
83 | - * |
|
84 | - * @param String $query the SQL query |
|
85 | - * @param Array $params parameter of the query |
|
86 | - * @param String $limitQuery the limit query |
|
87 | - * @return Array the spotter information |
|
88 | - * |
|
89 | - */ |
|
82 | + * Executes the SQL statements to get the spotter information |
|
83 | + * |
|
84 | + * @param String $query the SQL query |
|
85 | + * @param Array $params parameter of the query |
|
86 | + * @param String $limitQuery the limit query |
|
87 | + * @return Array the spotter information |
|
88 | + * |
|
89 | + */ |
|
90 | 90 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
91 | 91 | { |
92 | 92 | date_default_timezone_set('UTC'); |
@@ -214,11 +214,11 @@ discard block |
||
214 | 214 | |
215 | 215 | |
216 | 216 | /** |
217 | - * Gets all the spotter information based on the latest data entry |
|
218 | - * |
|
219 | - * @return Array the spotter information |
|
220 | - * |
|
221 | - */ |
|
217 | + * Gets all the spotter information based on the latest data entry |
|
218 | + * |
|
219 | + * @return Array the spotter information |
|
220 | + * |
|
221 | + */ |
|
222 | 222 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
223 | 223 | { |
224 | 224 | global $global_query; |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
270 | - * Gets all the spotter information based on the callsign |
|
271 | - * |
|
272 | - * @return Array the spotter information |
|
273 | - * |
|
274 | - */ |
|
270 | + * Gets all the spotter information based on the callsign |
|
271 | + * |
|
272 | + * @return Array the spotter information |
|
273 | + * |
|
274 | + */ |
|
275 | 275 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
276 | 276 | { |
277 | 277 | global $global_query; |
@@ -382,12 +382,12 @@ discard block |
||
382 | 382 | |
383 | 383 | |
384 | 384 | /** |
385 | - * Gets all source name |
|
386 | - * |
|
387 | - * @param String type format of source |
|
388 | - * @return Array list of source name |
|
389 | - * |
|
390 | - */ |
|
385 | + * Gets all source name |
|
386 | + * |
|
387 | + * @param String type format of source |
|
388 | + * @return Array list of source name |
|
389 | + * |
|
390 | + */ |
|
391 | 391 | public function getAllSourceName($type = '',$filters = array()) |
392 | 392 | { |
393 | 393 | $filter_query = $this->getFilter($filters,true,true); |
@@ -417,11 +417,11 @@ discard block |
||
417 | 417 | |
418 | 418 | |
419 | 419 | /** |
420 | - * Gets a list of all idents/callsigns |
|
421 | - * |
|
422 | - * @return Array list of ident/callsign names |
|
423 | - * |
|
424 | - */ |
|
420 | + * Gets a list of all idents/callsigns |
|
421 | + * |
|
422 | + * @return Array list of ident/callsign names |
|
423 | + * |
|
424 | + */ |
|
425 | 425 | public function getAllIdents($filters = array()) |
426 | 426 | { |
427 | 427 | $filter_query = $this->getFilter($filters,true,true); |
@@ -445,11 +445,11 @@ discard block |
||
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
448 | - * Gets all info from a mmsi |
|
449 | - * |
|
450 | - * @return Array list of mmsi info |
|
451 | - * |
|
452 | - */ |
|
448 | + * Gets all info from a mmsi |
|
449 | + * |
|
450 | + * @return Array list of mmsi info |
|
451 | + * |
|
452 | + */ |
|
453 | 453 | public function getIdentity($mmsi) |
454 | 454 | { |
455 | 455 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -506,18 +506,18 @@ discard block |
||
506 | 506 | |
507 | 507 | |
508 | 508 | /** |
509 | - * Update ident tracker data |
|
510 | - * |
|
511 | - * @param String $fammarine_id the ID |
|
512 | - * @param String $ident the marine ident |
|
513 | - * @return String success or false |
|
514 | - * |
|
515 | - */ |
|
509 | + * Update ident tracker data |
|
510 | + * |
|
511 | + * @param String $fammarine_id the ID |
|
512 | + * @param String $ident the marine ident |
|
513 | + * @return String success or false |
|
514 | + * |
|
515 | + */ |
|
516 | 516 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
517 | 517 | { |
518 | 518 | |
519 | 519 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
520 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
520 | + $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
521 | 521 | |
522 | 522 | try { |
523 | 523 | $sth = $this->db->prepare($query); |
@@ -531,19 +531,19 @@ discard block |
||
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
534 | - * Update Status data |
|
535 | - * |
|
536 | - * @param String $fammarine_id the ID |
|
537 | - * @param String $status_id the marine status id |
|
538 | - * @param String $status the marine status |
|
539 | - * @return String success or false |
|
540 | - * |
|
541 | - */ |
|
534 | + * Update Status data |
|
535 | + * |
|
536 | + * @param String $fammarine_id the ID |
|
537 | + * @param String $status_id the marine status id |
|
538 | + * @param String $status the marine status |
|
539 | + * @return String success or false |
|
540 | + * |
|
541 | + */ |
|
542 | 542 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
543 | 543 | { |
544 | 544 | |
545 | 545 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
546 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
546 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
547 | 547 | |
548 | 548 | try { |
549 | 549 | $sth = $this->db->prepare($query); |
@@ -556,17 +556,17 @@ discard block |
||
556 | 556 | |
557 | 557 | } |
558 | 558 | /** |
559 | - * Update latest marine data |
|
560 | - * |
|
561 | - * @param String $fammarine_id the ID |
|
562 | - * @param String $ident the marine ident |
|
563 | - * @return String success or false |
|
564 | - * |
|
565 | - */ |
|
559 | + * Update latest marine data |
|
560 | + * |
|
561 | + * @param String $fammarine_id the ID |
|
562 | + * @param String $ident the marine ident |
|
563 | + * @return String success or false |
|
564 | + * |
|
565 | + */ |
|
566 | 566 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
567 | 567 | { |
568 | 568 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
569 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
569 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
570 | 570 | |
571 | 571 | try { |
572 | 572 | $sth = $this->db->prepare($query); |
@@ -580,30 +580,30 @@ discard block |
||
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
583 | - * Adds a new spotter data |
|
584 | - * |
|
585 | - * @param String $fammarine_id the ID |
|
586 | - * @param String $ident the marine ident |
|
587 | - * @param String $departure_airport_icao the departure airport |
|
588 | - * @param String $arrival_airport_icao the arrival airport |
|
589 | - * @param String $latitude latitude of flight |
|
590 | - * @param String $longitude latitude of flight |
|
591 | - * @param String $waypoints waypoints of flight |
|
592 | - * @param String $heading heading of flight |
|
593 | - * @param String $groundspeed speed of flight |
|
594 | - * @param String $date date of flight |
|
595 | - * @param String $departure_airport_time departure time of flight |
|
596 | - * @param String $arrival_airport_time arrival time of flight |
|
597 | - * @param String $squawk squawk code of flight |
|
598 | - * @param String $route_stop route stop of flight |
|
599 | - * @param String $highlight highlight or not |
|
600 | - * @param String $ModeS ModesS code of flight |
|
601 | - * @param String $registration registration code of flight |
|
602 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
603 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
604 | - * @param String $verticalrate vertival rate of flight |
|
605 | - * @return String success or false |
|
606 | - */ |
|
583 | + * Adds a new spotter data |
|
584 | + * |
|
585 | + * @param String $fammarine_id the ID |
|
586 | + * @param String $ident the marine ident |
|
587 | + * @param String $departure_airport_icao the departure airport |
|
588 | + * @param String $arrival_airport_icao the arrival airport |
|
589 | + * @param String $latitude latitude of flight |
|
590 | + * @param String $longitude latitude of flight |
|
591 | + * @param String $waypoints waypoints of flight |
|
592 | + * @param String $heading heading of flight |
|
593 | + * @param String $groundspeed speed of flight |
|
594 | + * @param String $date date of flight |
|
595 | + * @param String $departure_airport_time departure time of flight |
|
596 | + * @param String $arrival_airport_time arrival time of flight |
|
597 | + * @param String $squawk squawk code of flight |
|
598 | + * @param String $route_stop route stop of flight |
|
599 | + * @param String $highlight highlight or not |
|
600 | + * @param String $ModeS ModesS code of flight |
|
601 | + * @param String $registration registration code of flight |
|
602 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
603 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
604 | + * @param String $verticalrate vertival rate of flight |
|
605 | + * @return String success or false |
|
606 | + */ |
|
607 | 607 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
608 | 608 | { |
609 | 609 | global $globalURL, $globalMarineImageFetch; |
@@ -700,13 +700,13 @@ discard block |
||
700 | 700 | unset($Image); |
701 | 701 | } |
702 | 702 | |
703 | - if ($latitude == '' && $longitude == '') { |
|
704 | - $latitude = 0; |
|
705 | - $longitude = 0; |
|
706 | - } |
|
707 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
708 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
709 | - if ($arrival_date == '') $arrival_date = NULL; |
|
703 | + if ($latitude == '' && $longitude == '') { |
|
704 | + $latitude = 0; |
|
705 | + $longitude = 0; |
|
706 | + } |
|
707 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
708 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
709 | + if ($arrival_date == '') $arrival_date = NULL; |
|
710 | 710 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
711 | 711 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
712 | 712 | |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | $sth->execute($query_values); |
718 | 718 | $this->db = null; |
719 | 719 | } catch (PDOException $e) { |
720 | - return "error : ".$e->getMessage(); |
|
720 | + return "error : ".$e->getMessage(); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | return "success"; |
@@ -726,11 +726,11 @@ discard block |
||
726 | 726 | |
727 | 727 | |
728 | 728 | /** |
729 | - * Gets the aircraft ident within the last hour |
|
730 | - * |
|
731 | - * @return String the ident |
|
732 | - * |
|
733 | - */ |
|
729 | + * Gets the aircraft ident within the last hour |
|
730 | + * |
|
731 | + * @return String the ident |
|
732 | + * |
|
733 | + */ |
|
734 | 734 | public function getIdentFromLastHour($ident) |
735 | 735 | { |
736 | 736 | global $globalDBdriver, $globalTimezone; |
@@ -746,11 +746,11 @@ discard block |
||
746 | 746 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
747 | 747 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
748 | 748 | $query_data = array(':ident' => $ident); |
749 | - } |
|
749 | + } |
|
750 | 750 | |
751 | 751 | $sth = $this->db->prepare($query); |
752 | 752 | $sth->execute($query_data); |
753 | - $ident_result=''; |
|
753 | + $ident_result=''; |
|
754 | 754 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
755 | 755 | { |
756 | 756 | $ident_result = $row['ident']; |
@@ -761,11 +761,11 @@ discard block |
||
761 | 761 | |
762 | 762 | |
763 | 763 | /** |
764 | - * Gets the aircraft data from the last 20 seconds |
|
765 | - * |
|
766 | - * @return Array the spotter data |
|
767 | - * |
|
768 | - */ |
|
764 | + * Gets the aircraft data from the last 20 seconds |
|
765 | + * |
|
766 | + * @return Array the spotter data |
|
767 | + * |
|
768 | + */ |
|
769 | 769 | public function getRealTimeData($q = '') |
770 | 770 | { |
771 | 771 | global $globalDBdriver; |
@@ -803,11 +803,11 @@ discard block |
||
803 | 803 | |
804 | 804 | |
805 | 805 | /** |
806 | - * Gets all number of flight over countries |
|
807 | - * |
|
808 | - * @return Array the airline country list |
|
809 | - * |
|
810 | - */ |
|
806 | + * Gets all number of flight over countries |
|
807 | + * |
|
808 | + * @return Array the airline country list |
|
809 | + * |
|
810 | + */ |
|
811 | 811 | |
812 | 812 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
813 | 813 | { |
@@ -880,11 +880,11 @@ discard block |
||
880 | 880 | |
881 | 881 | |
882 | 882 | /** |
883 | - * Gets all callsigns that have flown over |
|
884 | - * |
|
885 | - * @return Array the callsign list |
|
886 | - * |
|
887 | - */ |
|
883 | + * Gets all callsigns that have flown over |
|
884 | + * |
|
885 | + * @return Array the callsign list |
|
886 | + * |
|
887 | + */ |
|
888 | 888 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
889 | 889 | { |
890 | 890 | global $globalDBdriver; |
@@ -951,11 +951,11 @@ discard block |
||
951 | 951 | |
952 | 952 | |
953 | 953 | /** |
954 | - * Counts all dates |
|
955 | - * |
|
956 | - * @return Array the date list |
|
957 | - * |
|
958 | - */ |
|
954 | + * Counts all dates |
|
955 | + * |
|
956 | + * @return Array the date list |
|
957 | + * |
|
958 | + */ |
|
959 | 959 | public function countAllDates($filters = array()) |
960 | 960 | { |
961 | 961 | global $globalTimezone, $globalDBdriver; |
@@ -1001,11 +1001,11 @@ discard block |
||
1001 | 1001 | |
1002 | 1002 | |
1003 | 1003 | /** |
1004 | - * Counts all dates during the last 7 days |
|
1005 | - * |
|
1006 | - * @return Array the date list |
|
1007 | - * |
|
1008 | - */ |
|
1004 | + * Counts all dates during the last 7 days |
|
1005 | + * |
|
1006 | + * @return Array the date list |
|
1007 | + * |
|
1008 | + */ |
|
1009 | 1009 | public function countAllDatesLast7Days($filters = array()) |
1010 | 1010 | { |
1011 | 1011 | global $globalTimezone, $globalDBdriver; |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | $query .= " GROUP BY date_name |
1028 | 1028 | ORDER BY date_name ASC"; |
1029 | 1029 | $query_data = array(':offset' => $offset); |
1030 | - } |
|
1030 | + } |
|
1031 | 1031 | |
1032 | 1032 | $sth = $this->db->prepare($query); |
1033 | 1033 | $sth->execute($query_data); |
@@ -1047,11 +1047,11 @@ discard block |
||
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | /** |
1050 | - * Counts all dates during the last month |
|
1051 | - * |
|
1052 | - * @return Array the date list |
|
1053 | - * |
|
1054 | - */ |
|
1050 | + * Counts all dates during the last month |
|
1051 | + * |
|
1052 | + * @return Array the date list |
|
1053 | + * |
|
1054 | + */ |
|
1055 | 1055 | public function countAllDatesLastMonth($filters = array()) |
1056 | 1056 | { |
1057 | 1057 | global $globalTimezone, $globalDBdriver; |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | $query .= " GROUP BY date_name |
1074 | 1074 | ORDER BY date_name ASC"; |
1075 | 1075 | $query_data = array(':offset' => $offset); |
1076 | - } |
|
1076 | + } |
|
1077 | 1077 | |
1078 | 1078 | $sth = $this->db->prepare($query); |
1079 | 1079 | $sth->execute($query_data); |
@@ -1095,11 +1095,11 @@ discard block |
||
1095 | 1095 | |
1096 | 1096 | |
1097 | 1097 | /** |
1098 | - * Counts all month |
|
1099 | - * |
|
1100 | - * @return Array the month list |
|
1101 | - * |
|
1102 | - */ |
|
1098 | + * Counts all month |
|
1099 | + * |
|
1100 | + * @return Array the month list |
|
1101 | + * |
|
1102 | + */ |
|
1103 | 1103 | public function countAllMonths($filters = array()) |
1104 | 1104 | { |
1105 | 1105 | global $globalTimezone, $globalDBdriver; |
@@ -1144,11 +1144,11 @@ discard block |
||
1144 | 1144 | |
1145 | 1145 | |
1146 | 1146 | /** |
1147 | - * Counts all dates during the last year |
|
1148 | - * |
|
1149 | - * @return Array the date list |
|
1150 | - * |
|
1151 | - */ |
|
1147 | + * Counts all dates during the last year |
|
1148 | + * |
|
1149 | + * @return Array the date list |
|
1150 | + * |
|
1151 | + */ |
|
1152 | 1152 | public function countAllMonthsLastYear($filters) |
1153 | 1153 | { |
1154 | 1154 | global $globalTimezone, $globalDBdriver; |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | $query .= " GROUP BY year_name, month_name |
1171 | 1171 | ORDER BY year_name, month_name ASC"; |
1172 | 1172 | $query_data = array(':offset' => $offset); |
1173 | - } |
|
1173 | + } |
|
1174 | 1174 | |
1175 | 1175 | $sth = $this->db->prepare($query); |
1176 | 1176 | $sth->execute($query_data); |
@@ -1193,11 +1193,11 @@ discard block |
||
1193 | 1193 | |
1194 | 1194 | |
1195 | 1195 | /** |
1196 | - * Counts all hours |
|
1197 | - * |
|
1198 | - * @return Array the hour list |
|
1199 | - * |
|
1200 | - */ |
|
1196 | + * Counts all hours |
|
1197 | + * |
|
1198 | + * @return Array the hour list |
|
1199 | + * |
|
1200 | + */ |
|
1201 | 1201 | public function countAllHours($orderby,$filters = array()) |
1202 | 1202 | { |
1203 | 1203 | global $globalTimezone, $globalDBdriver; |
@@ -1260,11 +1260,11 @@ discard block |
||
1260 | 1260 | |
1261 | 1261 | |
1262 | 1262 | /** |
1263 | - * Counts all hours by date |
|
1264 | - * |
|
1265 | - * @return Array the hour list |
|
1266 | - * |
|
1267 | - */ |
|
1263 | + * Counts all hours by date |
|
1264 | + * |
|
1265 | + * @return Array the hour list |
|
1266 | + * |
|
1267 | + */ |
|
1268 | 1268 | public function countAllHoursByDate($date, $filters = array()) |
1269 | 1269 | { |
1270 | 1270 | global $globalTimezone, $globalDBdriver; |
@@ -1308,11 +1308,11 @@ discard block |
||
1308 | 1308 | |
1309 | 1309 | |
1310 | 1310 | /** |
1311 | - * Counts all hours by a ident/callsign |
|
1312 | - * |
|
1313 | - * @return Array the hour list |
|
1314 | - * |
|
1315 | - */ |
|
1311 | + * Counts all hours by a ident/callsign |
|
1312 | + * |
|
1313 | + * @return Array the hour list |
|
1314 | + * |
|
1315 | + */ |
|
1316 | 1316 | public function countAllHoursByIdent($ident, $filters = array()) |
1317 | 1317 | { |
1318 | 1318 | global $globalTimezone, $globalDBdriver; |
@@ -1357,11 +1357,11 @@ discard block |
||
1357 | 1357 | |
1358 | 1358 | |
1359 | 1359 | /** |
1360 | - * Counts all vessels |
|
1361 | - * |
|
1362 | - * @return Integer the number of vessels |
|
1363 | - * |
|
1364 | - */ |
|
1360 | + * Counts all vessels |
|
1361 | + * |
|
1362 | + * @return Integer the number of vessels |
|
1363 | + * |
|
1364 | + */ |
|
1365 | 1365 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
1366 | 1366 | { |
1367 | 1367 | global $globalDBdriver; |
@@ -1396,11 +1396,11 @@ discard block |
||
1396 | 1396 | } |
1397 | 1397 | |
1398 | 1398 | /** |
1399 | - * Counts all vessel type |
|
1400 | - * |
|
1401 | - * @return Integer the number of vessels |
|
1402 | - * |
|
1403 | - */ |
|
1399 | + * Counts all vessel type |
|
1400 | + * |
|
1401 | + * @return Integer the number of vessels |
|
1402 | + * |
|
1403 | + */ |
|
1404 | 1404 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
1405 | 1405 | { |
1406 | 1406 | global $globalDBdriver; |
@@ -1435,11 +1435,11 @@ discard block |
||
1435 | 1435 | |
1436 | 1436 | |
1437 | 1437 | /** |
1438 | - * Counts all hours of today |
|
1439 | - * |
|
1440 | - * @return Array the hour list |
|
1441 | - * |
|
1442 | - */ |
|
1438 | + * Counts all hours of today |
|
1439 | + * |
|
1440 | + * @return Array the hour list |
|
1441 | + * |
|
1442 | + */ |
|
1443 | 1443 | public function countAllHoursFromToday($filters = array()) |
1444 | 1444 | { |
1445 | 1445 | global $globalTimezone, $globalDBdriver; |
@@ -1479,12 +1479,12 @@ discard block |
||
1479 | 1479 | } |
1480 | 1480 | |
1481 | 1481 | |
1482 | - /** |
|
1483 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1484 | - * |
|
1485 | - * @return Integer the Barrie Spotter ID |
|
1482 | + /** |
|
1483 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1484 | + * |
|
1485 | + * @return Integer the Barrie Spotter ID |
|
1486 | 1486 | q * |
1487 | - */ |
|
1487 | + */ |
|
1488 | 1488 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1489 | 1489 | { |
1490 | 1490 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1505,13 +1505,13 @@ discard block |
||
1505 | 1505 | |
1506 | 1506 | |
1507 | 1507 | /** |
1508 | - * Parses a date string |
|
1509 | - * |
|
1510 | - * @param String $dateString the date string |
|
1511 | - * @param String $timezone the timezone of a user |
|
1512 | - * @return Array the time information |
|
1513 | - * |
|
1514 | - */ |
|
1508 | + * Parses a date string |
|
1509 | + * |
|
1510 | + * @param String $dateString the date string |
|
1511 | + * @param String $timezone the timezone of a user |
|
1512 | + * @return Array the time information |
|
1513 | + * |
|
1514 | + */ |
|
1515 | 1515 | public function parseDateString($dateString, $timezone = '') |
1516 | 1516 | { |
1517 | 1517 | $time_array = array(); |
@@ -1544,12 +1544,12 @@ discard block |
||
1544 | 1544 | } |
1545 | 1545 | |
1546 | 1546 | /** |
1547 | - * Parses the direction degrees to working |
|
1548 | - * |
|
1549 | - * @param Float $direction the direction in degrees |
|
1550 | - * @return Array the direction information |
|
1551 | - * |
|
1552 | - */ |
|
1547 | + * Parses the direction degrees to working |
|
1548 | + * |
|
1549 | + * @param Float $direction the direction in degrees |
|
1550 | + * @return Array the direction information |
|
1551 | + * |
|
1552 | + */ |
|
1553 | 1553 | public function parseDirection($direction = 0) |
1554 | 1554 | { |
1555 | 1555 | if ($direction == '') $direction = 0; |
@@ -1628,12 +1628,12 @@ discard block |
||
1628 | 1628 | |
1629 | 1629 | |
1630 | 1630 | /** |
1631 | - * Gets Country from latitude/longitude |
|
1632 | - * |
|
1633 | - * @param Float $latitude latitute of the flight |
|
1634 | - * @param Float $longitude longitute of the flight |
|
1635 | - * @return String the countrie |
|
1636 | - */ |
|
1631 | + * Gets Country from latitude/longitude |
|
1632 | + * |
|
1633 | + * @param Float $latitude latitute of the flight |
|
1634 | + * @param Float $longitude longitute of the flight |
|
1635 | + * @return String the countrie |
|
1636 | + */ |
|
1637 | 1637 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1638 | 1638 | { |
1639 | 1639 | global $globalDBdriver, $globalDebug; |
@@ -1670,11 +1670,11 @@ discard block |
||
1670 | 1670 | } |
1671 | 1671 | |
1672 | 1672 | /** |
1673 | - * Gets Country from iso2 |
|
1674 | - * |
|
1675 | - * @param String $iso2 ISO2 country code |
|
1676 | - * @return String the countrie |
|
1677 | - */ |
|
1673 | + * Gets Country from iso2 |
|
1674 | + * |
|
1675 | + * @param String $iso2 ISO2 country code |
|
1676 | + * @return String the countrie |
|
1677 | + */ |
|
1678 | 1678 | public function getCountryFromISO2($iso2) |
1679 | 1679 | { |
1680 | 1680 | global $globalDBdriver, $globalDebug; |
@@ -1703,12 +1703,12 @@ discard block |
||
1703 | 1703 | |
1704 | 1704 | |
1705 | 1705 | /** |
1706 | - * Gets the short url from bit.ly |
|
1707 | - * |
|
1708 | - * @param String $url the full url |
|
1709 | - * @return String the bit.ly url |
|
1710 | - * |
|
1711 | - */ |
|
1706 | + * Gets the short url from bit.ly |
|
1707 | + * |
|
1708 | + * @param String $url the full url |
|
1709 | + * @return String the bit.ly url |
|
1710 | + * |
|
1711 | + */ |
|
1712 | 1712 | public function getBitlyURL($url) |
1713 | 1713 | { |
1714 | 1714 | global $globalBitlyAccessToken; |
@@ -1735,11 +1735,11 @@ discard block |
||
1735 | 1735 | |
1736 | 1736 | |
1737 | 1737 | /** |
1738 | - * Gets all vessels types that have flown over |
|
1739 | - * |
|
1740 | - * @return Array the vessel type list |
|
1741 | - * |
|
1742 | - */ |
|
1738 | + * Gets all vessels types that have flown over |
|
1739 | + * |
|
1740 | + * @return Array the vessel type list |
|
1741 | + * |
|
1742 | + */ |
|
1743 | 1743 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
1744 | 1744 | { |
1745 | 1745 | global $globalDBdriver; |
@@ -1804,11 +1804,11 @@ discard block |
||
1804 | 1804 | } |
1805 | 1805 | |
1806 | 1806 | /** |
1807 | - * Gets all the tracker information |
|
1808 | - * |
|
1809 | - * @return Array the tracker information |
|
1810 | - * |
|
1811 | - */ |
|
1807 | + * Gets all the tracker information |
|
1808 | + * |
|
1809 | + * @return Array the tracker information |
|
1810 | + * |
|
1811 | + */ |
|
1812 | 1812 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
1813 | 1813 | { |
1814 | 1814 | global $globalTimezone, $globalDBdriver; |
@@ -14,10 +14,10 @@ discard block |
||
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
17 | - * Get SQL query part for filter used |
|
18 | - * @param Array $filter the filter |
|
19 | - * @return Array the SQL part |
|
20 | - */ |
|
17 | + * Get SQL query part for filter used |
|
18 | + * @param Array $filter the filter |
|
19 | + * @return Array the SQL part |
|
20 | + */ |
|
21 | 21 | |
22 | 22 | public function getFilter($filter = array(),$where = false,$and = false) { |
23 | 23 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | - * Executes the SQL statements to get the tracker information |
|
85 | - * |
|
86 | - * @param String $query the SQL query |
|
87 | - * @param Array $params parameter of the query |
|
88 | - * @param String $limitQuery the limit query |
|
89 | - * @return Array the tracker information |
|
90 | - * |
|
91 | - */ |
|
84 | + * Executes the SQL statements to get the tracker information |
|
85 | + * |
|
86 | + * @param String $query the SQL query |
|
87 | + * @param Array $params parameter of the query |
|
88 | + * @param String $limitQuery the limit query |
|
89 | + * @return Array the tracker information |
|
90 | + * |
|
91 | + */ |
|
92 | 92 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
93 | 93 | { |
94 | 94 | date_default_timezone_set('UTC'); |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | |
202 | 202 | |
203 | 203 | /** |
204 | - * Gets all the tracker information based on the latest data entry |
|
205 | - * |
|
206 | - * @return Array the tracker information |
|
207 | - * |
|
208 | - */ |
|
204 | + * Gets all the tracker information based on the latest data entry |
|
205 | + * |
|
206 | + * @return Array the tracker information |
|
207 | + * |
|
208 | + */ |
|
209 | 209 | public function getLatestTrackerData($limit = '', $sort = '', $filter = array()) |
210 | 210 | { |
211 | 211 | global $global_query; |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
266 | - * Gets all the tracker information based on the callsign |
|
267 | - * |
|
268 | - * @return Array the tracker information |
|
269 | - * |
|
270 | - */ |
|
266 | + * Gets all the tracker information based on the callsign |
|
267 | + * |
|
268 | + * @return Array the tracker information |
|
269 | + * |
|
270 | + */ |
|
271 | 271 | public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
272 | 272 | { |
273 | 273 | global $global_query; |
@@ -378,12 +378,12 @@ discard block |
||
378 | 378 | |
379 | 379 | |
380 | 380 | /** |
381 | - * Gets all source name |
|
382 | - * |
|
383 | - * @param String type format of source |
|
384 | - * @return Array list of source name |
|
385 | - * |
|
386 | - */ |
|
381 | + * Gets all source name |
|
382 | + * |
|
383 | + * @param String type format of source |
|
384 | + * @return Array list of source name |
|
385 | + * |
|
386 | + */ |
|
387 | 387 | public function getAllSourceName($type = '',$filters = array()) |
388 | 388 | { |
389 | 389 | $filter_query = $this->getFilter($filters,true,true); |
@@ -413,11 +413,11 @@ discard block |
||
413 | 413 | |
414 | 414 | |
415 | 415 | /** |
416 | - * Gets a list of all idents/callsigns |
|
417 | - * |
|
418 | - * @return Array list of ident/callsign names |
|
419 | - * |
|
420 | - */ |
|
416 | + * Gets a list of all idents/callsigns |
|
417 | + * |
|
418 | + * @return Array list of ident/callsign names |
|
419 | + * |
|
420 | + */ |
|
421 | 421 | public function getAllIdents($filters = array()) |
422 | 422 | { |
423 | 423 | $filter_query = $this->getFilter($filters,true,true); |
@@ -485,18 +485,18 @@ discard block |
||
485 | 485 | |
486 | 486 | |
487 | 487 | /** |
488 | - * Update ident tracker data |
|
489 | - * |
|
490 | - * @param String $flightaware_id the ID from flightaware |
|
491 | - * @param String $ident the flight ident |
|
492 | - * @return String success or false |
|
493 | - * |
|
494 | - */ |
|
488 | + * Update ident tracker data |
|
489 | + * |
|
490 | + * @param String $flightaware_id the ID from flightaware |
|
491 | + * @param String $ident the flight ident |
|
492 | + * @return String success or false |
|
493 | + * |
|
494 | + */ |
|
495 | 495 | public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
496 | 496 | { |
497 | 497 | |
498 | 498 | $query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid'; |
499 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
499 | + $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
500 | 500 | |
501 | 501 | try { |
502 | 502 | $sth = $this->db->prepare($query); |
@@ -509,18 +509,18 @@ discard block |
||
509 | 509 | |
510 | 510 | } |
511 | 511 | /** |
512 | - * Update latest tracker data |
|
513 | - * |
|
514 | - * @param String $flightaware_id the ID from flightaware |
|
515 | - * @param String $ident the flight ident |
|
516 | - * @param String $arrival_airport_icao the arrival airport |
|
517 | - * @return String success or false |
|
518 | - * |
|
519 | - */ |
|
512 | + * Update latest tracker data |
|
513 | + * |
|
514 | + * @param String $flightaware_id the ID from flightaware |
|
515 | + * @param String $ident the flight ident |
|
516 | + * @param String $arrival_airport_icao the arrival airport |
|
517 | + * @return String success or false |
|
518 | + * |
|
519 | + */ |
|
520 | 520 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
521 | 521 | { |
522 | 522 | $query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid'; |
523 | - $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
523 | + $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
524 | 524 | |
525 | 525 | try { |
526 | 526 | $sth = $this->db->prepare($query); |
@@ -534,32 +534,32 @@ discard block |
||
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
537 | - * Adds a new tracker data |
|
538 | - * |
|
539 | - * @param String $flightaware_id the ID from flightaware |
|
540 | - * @param String $ident the flight ident |
|
541 | - * @param String $aircraft_icao the aircraft type |
|
542 | - * @param String $departure_airport_icao the departure airport |
|
543 | - * @param String $arrival_airport_icao the arrival airport |
|
544 | - * @param String $latitude latitude of flight |
|
545 | - * @param String $longitude latitude of flight |
|
546 | - * @param String $waypoints waypoints of flight |
|
547 | - * @param String $altitude altitude of flight |
|
548 | - * @param String $heading heading of flight |
|
549 | - * @param String $groundspeed speed of flight |
|
550 | - * @param String $date date of flight |
|
551 | - * @param String $departure_airport_time departure time of flight |
|
552 | - * @param String $arrival_airport_time arrival time of flight |
|
553 | - * @param String $squawk squawk code of flight |
|
554 | - * @param String $route_stop route stop of flight |
|
555 | - * @param String $highlight highlight or not |
|
556 | - * @param String $ModeS ModesS code of flight |
|
557 | - * @param String $registration registration code of flight |
|
558 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
559 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
560 | - * @param String $verticalrate vertival rate of flight |
|
561 | - * @return String success or false |
|
562 | - */ |
|
537 | + * Adds a new tracker data |
|
538 | + * |
|
539 | + * @param String $flightaware_id the ID from flightaware |
|
540 | + * @param String $ident the flight ident |
|
541 | + * @param String $aircraft_icao the aircraft type |
|
542 | + * @param String $departure_airport_icao the departure airport |
|
543 | + * @param String $arrival_airport_icao the arrival airport |
|
544 | + * @param String $latitude latitude of flight |
|
545 | + * @param String $longitude latitude of flight |
|
546 | + * @param String $waypoints waypoints of flight |
|
547 | + * @param String $altitude altitude of flight |
|
548 | + * @param String $heading heading of flight |
|
549 | + * @param String $groundspeed speed of flight |
|
550 | + * @param String $date date of flight |
|
551 | + * @param String $departure_airport_time departure time of flight |
|
552 | + * @param String $arrival_airport_time arrival time of flight |
|
553 | + * @param String $squawk squawk code of flight |
|
554 | + * @param String $route_stop route stop of flight |
|
555 | + * @param String $highlight highlight or not |
|
556 | + * @param String $ModeS ModesS code of flight |
|
557 | + * @param String $registration registration code of flight |
|
558 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
559 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
560 | + * @param String $verticalrate vertival rate of flight |
|
561 | + * @return String success or false |
|
562 | + */ |
|
563 | 563 | public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
564 | 564 | { |
565 | 565 | global $globalURL; |
@@ -644,16 +644,16 @@ discard block |
||
644 | 644 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
645 | 645 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
646 | 646 | |
647 | - if ($latitude == '' && $longitude == '') { |
|
648 | - $latitude = 0; |
|
649 | - $longitude = 0; |
|
650 | - } |
|
651 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
652 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
653 | - $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
647 | + if ($latitude == '' && $longitude == '') { |
|
648 | + $latitude = 0; |
|
649 | + $longitude = 0; |
|
650 | + } |
|
651 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
652 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
653 | + $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
654 | 654 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
655 | 655 | |
656 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
656 | + $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
657 | 657 | |
658 | 658 | try { |
659 | 659 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | $sth->execute($query_values); |
662 | 662 | $this->db = null; |
663 | 663 | } catch (PDOException $e) { |
664 | - return "error : ".$e->getMessage(); |
|
664 | + return "error : ".$e->getMessage(); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | return "success"; |
@@ -670,11 +670,11 @@ discard block |
||
670 | 670 | |
671 | 671 | |
672 | 672 | /** |
673 | - * Gets the aircraft ident within the last hour |
|
674 | - * |
|
675 | - * @return String the ident |
|
676 | - * |
|
677 | - */ |
|
673 | + * Gets the aircraft ident within the last hour |
|
674 | + * |
|
675 | + * @return String the ident |
|
676 | + * |
|
677 | + */ |
|
678 | 678 | public function getIdentFromLastHour($ident) |
679 | 679 | { |
680 | 680 | global $globalDBdriver, $globalTimezone; |
@@ -690,11 +690,11 @@ discard block |
||
690 | 690 | AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
691 | 691 | AND tracker_output.date < now() AT TIME ZONE 'UTC'"; |
692 | 692 | $query_data = array(':ident' => $ident); |
693 | - } |
|
693 | + } |
|
694 | 694 | |
695 | 695 | $sth = $this->db->prepare($query); |
696 | 696 | $sth->execute($query_data); |
697 | - $ident_result=''; |
|
697 | + $ident_result=''; |
|
698 | 698 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
699 | 699 | { |
700 | 700 | $ident_result = $row['ident']; |
@@ -705,11 +705,11 @@ discard block |
||
705 | 705 | |
706 | 706 | |
707 | 707 | /** |
708 | - * Gets the aircraft data from the last 20 seconds |
|
709 | - * |
|
710 | - * @return Array the tracker data |
|
711 | - * |
|
712 | - */ |
|
708 | + * Gets the aircraft data from the last 20 seconds |
|
709 | + * |
|
710 | + * @return Array the tracker data |
|
711 | + * |
|
712 | + */ |
|
713 | 713 | public function getRealTimeData($q = '') |
714 | 714 | { |
715 | 715 | global $globalDBdriver; |
@@ -743,11 +743,11 @@ discard block |
||
743 | 743 | } |
744 | 744 | |
745 | 745 | /** |
746 | - * Gets all number of flight over countries |
|
747 | - * |
|
748 | - * @return Array the airline country list |
|
749 | - * |
|
750 | - */ |
|
746 | + * Gets all number of flight over countries |
|
747 | + * |
|
748 | + * @return Array the airline country list |
|
749 | + * |
|
750 | + */ |
|
751 | 751 | public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
752 | 752 | { |
753 | 753 | global $globalDBdriver, $globalArchive; |
@@ -817,11 +817,11 @@ discard block |
||
817 | 817 | } |
818 | 818 | |
819 | 819 | /** |
820 | - * Gets all callsigns that have flown over |
|
821 | - * |
|
822 | - * @return Array the callsign list |
|
823 | - * |
|
824 | - */ |
|
820 | + * Gets all callsigns that have flown over |
|
821 | + * |
|
822 | + * @return Array the callsign list |
|
823 | + * |
|
824 | + */ |
|
825 | 825 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
826 | 826 | { |
827 | 827 | global $globalDBdriver; |
@@ -888,11 +888,11 @@ discard block |
||
888 | 888 | |
889 | 889 | |
890 | 890 | /** |
891 | - * Counts all dates |
|
892 | - * |
|
893 | - * @return Array the date list |
|
894 | - * |
|
895 | - */ |
|
891 | + * Counts all dates |
|
892 | + * |
|
893 | + * @return Array the date list |
|
894 | + * |
|
895 | + */ |
|
896 | 896 | public function countAllDates($filters = array()) |
897 | 897 | { |
898 | 898 | global $globalTimezone, $globalDBdriver; |
@@ -938,11 +938,11 @@ discard block |
||
938 | 938 | |
939 | 939 | |
940 | 940 | /** |
941 | - * Counts all dates during the last 7 days |
|
942 | - * |
|
943 | - * @return Array the date list |
|
944 | - * |
|
945 | - */ |
|
941 | + * Counts all dates during the last 7 days |
|
942 | + * |
|
943 | + * @return Array the date list |
|
944 | + * |
|
945 | + */ |
|
946 | 946 | public function countAllDatesLast7Days($filters = array()) |
947 | 947 | { |
948 | 948 | global $globalTimezone, $globalDBdriver; |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $query .= " GROUP BY date_name |
965 | 965 | ORDER BY date_name ASC"; |
966 | 966 | $query_data = array(':offset' => $offset); |
967 | - } |
|
967 | + } |
|
968 | 968 | |
969 | 969 | $sth = $this->db->prepare($query); |
970 | 970 | $sth->execute($query_data); |
@@ -984,11 +984,11 @@ discard block |
||
984 | 984 | } |
985 | 985 | |
986 | 986 | /** |
987 | - * Counts all dates during the last month |
|
988 | - * |
|
989 | - * @return Array the date list |
|
990 | - * |
|
991 | - */ |
|
987 | + * Counts all dates during the last month |
|
988 | + * |
|
989 | + * @return Array the date list |
|
990 | + * |
|
991 | + */ |
|
992 | 992 | public function countAllDatesLastMonth($filters = array()) |
993 | 993 | { |
994 | 994 | global $globalTimezone, $globalDBdriver; |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | $query .= " GROUP BY date_name |
1011 | 1011 | ORDER BY date_name ASC"; |
1012 | 1012 | $query_data = array(':offset' => $offset); |
1013 | - } |
|
1013 | + } |
|
1014 | 1014 | |
1015 | 1015 | $sth = $this->db->prepare($query); |
1016 | 1016 | $sth->execute($query_data); |
@@ -1032,11 +1032,11 @@ discard block |
||
1032 | 1032 | |
1033 | 1033 | |
1034 | 1034 | /** |
1035 | - * Counts all month |
|
1036 | - * |
|
1037 | - * @return Array the month list |
|
1038 | - * |
|
1039 | - */ |
|
1035 | + * Counts all month |
|
1036 | + * |
|
1037 | + * @return Array the month list |
|
1038 | + * |
|
1039 | + */ |
|
1040 | 1040 | public function countAllMonths($filters = array()) |
1041 | 1041 | { |
1042 | 1042 | global $globalTimezone, $globalDBdriver; |
@@ -1081,11 +1081,11 @@ discard block |
||
1081 | 1081 | |
1082 | 1082 | |
1083 | 1083 | /** |
1084 | - * Counts all dates during the last year |
|
1085 | - * |
|
1086 | - * @return Array the date list |
|
1087 | - * |
|
1088 | - */ |
|
1084 | + * Counts all dates during the last year |
|
1085 | + * |
|
1086 | + * @return Array the date list |
|
1087 | + * |
|
1088 | + */ |
|
1089 | 1089 | public function countAllMonthsLastYear($filters) |
1090 | 1090 | { |
1091 | 1091 | global $globalTimezone, $globalDBdriver; |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | $query .= " GROUP BY year_name, month_name |
1108 | 1108 | ORDER BY year_name, month_name ASC"; |
1109 | 1109 | $query_data = array(':offset' => $offset); |
1110 | - } |
|
1110 | + } |
|
1111 | 1111 | |
1112 | 1112 | $sth = $this->db->prepare($query); |
1113 | 1113 | $sth->execute($query_data); |
@@ -1130,11 +1130,11 @@ discard block |
||
1130 | 1130 | |
1131 | 1131 | |
1132 | 1132 | /** |
1133 | - * Counts all hours |
|
1134 | - * |
|
1135 | - * @return Array the hour list |
|
1136 | - * |
|
1137 | - */ |
|
1133 | + * Counts all hours |
|
1134 | + * |
|
1135 | + * @return Array the hour list |
|
1136 | + * |
|
1137 | + */ |
|
1138 | 1138 | public function countAllHours($orderby,$filters = array()) |
1139 | 1139 | { |
1140 | 1140 | global $globalTimezone, $globalDBdriver; |
@@ -1197,11 +1197,11 @@ discard block |
||
1197 | 1197 | |
1198 | 1198 | |
1199 | 1199 | /** |
1200 | - * Counts all hours by date |
|
1201 | - * |
|
1202 | - * @return Array the hour list |
|
1203 | - * |
|
1204 | - */ |
|
1200 | + * Counts all hours by date |
|
1201 | + * |
|
1202 | + * @return Array the hour list |
|
1203 | + * |
|
1204 | + */ |
|
1205 | 1205 | public function countAllHoursByDate($date, $filters = array()) |
1206 | 1206 | { |
1207 | 1207 | global $globalTimezone, $globalDBdriver; |
@@ -1245,11 +1245,11 @@ discard block |
||
1245 | 1245 | |
1246 | 1246 | |
1247 | 1247 | /** |
1248 | - * Counts all hours by a ident/callsign |
|
1249 | - * |
|
1250 | - * @return Array the hour list |
|
1251 | - * |
|
1252 | - */ |
|
1248 | + * Counts all hours by a ident/callsign |
|
1249 | + * |
|
1250 | + * @return Array the hour list |
|
1251 | + * |
|
1252 | + */ |
|
1253 | 1253 | public function countAllHoursByIdent($ident, $filters = array()) |
1254 | 1254 | { |
1255 | 1255 | global $globalTimezone, $globalDBdriver; |
@@ -1294,11 +1294,11 @@ discard block |
||
1294 | 1294 | |
1295 | 1295 | |
1296 | 1296 | /** |
1297 | - * Counts all trackers that have flown over |
|
1298 | - * |
|
1299 | - * @return Integer the number of trackers |
|
1300 | - * |
|
1301 | - */ |
|
1297 | + * Counts all trackers that have flown over |
|
1298 | + * |
|
1299 | + * @return Integer the number of trackers |
|
1300 | + * |
|
1301 | + */ |
|
1302 | 1302 | public function countOverallTracker($filters = array(),$year = '',$month = '') |
1303 | 1303 | { |
1304 | 1304 | global $globalDBdriver; |
@@ -1333,11 +1333,11 @@ discard block |
||
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | /** |
1336 | - * Counts all trackers type that have flown over |
|
1337 | - * |
|
1338 | - * @return Integer the number of flights |
|
1339 | - * |
|
1340 | - */ |
|
1336 | + * Counts all trackers type that have flown over |
|
1337 | + * |
|
1338 | + * @return Integer the number of flights |
|
1339 | + * |
|
1340 | + */ |
|
1341 | 1341 | public function countOverallTrackerTypes($filters = array(),$year = '',$month = '') |
1342 | 1342 | { |
1343 | 1343 | global $globalDBdriver; |
@@ -1372,11 +1372,11 @@ discard block |
||
1372 | 1372 | |
1373 | 1373 | |
1374 | 1374 | /** |
1375 | - * Counts all hours of today |
|
1376 | - * |
|
1377 | - * @return Array the hour list |
|
1378 | - * |
|
1379 | - */ |
|
1375 | + * Counts all hours of today |
|
1376 | + * |
|
1377 | + * @return Array the hour list |
|
1378 | + * |
|
1379 | + */ |
|
1380 | 1380 | public function countAllHoursFromToday($filters = array()) |
1381 | 1381 | { |
1382 | 1382 | global $globalTimezone, $globalDBdriver; |
@@ -1416,12 +1416,12 @@ discard block |
||
1416 | 1416 | } |
1417 | 1417 | |
1418 | 1418 | |
1419 | - /** |
|
1420 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1421 | - * |
|
1422 | - * @return Integer the Barrie Spotter ID |
|
1419 | + /** |
|
1420 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1421 | + * |
|
1422 | + * @return Integer the Barrie Spotter ID |
|
1423 | 1423 | q * |
1424 | - */ |
|
1424 | + */ |
|
1425 | 1425 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
1426 | 1426 | { |
1427 | 1427 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -1442,13 +1442,13 @@ discard block |
||
1442 | 1442 | |
1443 | 1443 | |
1444 | 1444 | /** |
1445 | - * Parses a date string |
|
1446 | - * |
|
1447 | - * @param String $dateString the date string |
|
1448 | - * @param String $timezone the timezone of a user |
|
1449 | - * @return Array the time information |
|
1450 | - * |
|
1451 | - */ |
|
1445 | + * Parses a date string |
|
1446 | + * |
|
1447 | + * @param String $dateString the date string |
|
1448 | + * @param String $timezone the timezone of a user |
|
1449 | + * @return Array the time information |
|
1450 | + * |
|
1451 | + */ |
|
1452 | 1452 | public function parseDateString($dateString, $timezone = '') |
1453 | 1453 | { |
1454 | 1454 | $time_array = array(); |
@@ -1481,12 +1481,12 @@ discard block |
||
1481 | 1481 | } |
1482 | 1482 | |
1483 | 1483 | /** |
1484 | - * Parses the direction degrees to working |
|
1485 | - * |
|
1486 | - * @param Float $direction the direction in degrees |
|
1487 | - * @return Array the direction information |
|
1488 | - * |
|
1489 | - */ |
|
1484 | + * Parses the direction degrees to working |
|
1485 | + * |
|
1486 | + * @param Float $direction the direction in degrees |
|
1487 | + * @return Array the direction information |
|
1488 | + * |
|
1489 | + */ |
|
1490 | 1490 | public function parseDirection($direction = 0) |
1491 | 1491 | { |
1492 | 1492 | if ($direction == '') $direction = 0; |
@@ -1565,12 +1565,12 @@ discard block |
||
1565 | 1565 | |
1566 | 1566 | |
1567 | 1567 | /** |
1568 | - * Gets Country from latitude/longitude |
|
1569 | - * |
|
1570 | - * @param Float $latitude latitute of the flight |
|
1571 | - * @param Float $longitude longitute of the flight |
|
1572 | - * @return String the countrie |
|
1573 | - */ |
|
1568 | + * Gets Country from latitude/longitude |
|
1569 | + * |
|
1570 | + * @param Float $latitude latitute of the flight |
|
1571 | + * @param Float $longitude longitute of the flight |
|
1572 | + * @return String the countrie |
|
1573 | + */ |
|
1574 | 1574 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1575 | 1575 | { |
1576 | 1576 | global $globalDBdriver, $globalDebug; |
@@ -1607,11 +1607,11 @@ discard block |
||
1607 | 1607 | } |
1608 | 1608 | |
1609 | 1609 | /** |
1610 | - * Gets Country from iso2 |
|
1611 | - * |
|
1612 | - * @param String $iso2 ISO2 country code |
|
1613 | - * @return String the countrie |
|
1614 | - */ |
|
1610 | + * Gets Country from iso2 |
|
1611 | + * |
|
1612 | + * @param String $iso2 ISO2 country code |
|
1613 | + * @return String the countrie |
|
1614 | + */ |
|
1615 | 1615 | public function getCountryFromISO2($iso2) |
1616 | 1616 | { |
1617 | 1617 | global $globalDBdriver, $globalDebug; |
@@ -1639,11 +1639,11 @@ discard block |
||
1639 | 1639 | } |
1640 | 1640 | |
1641 | 1641 | /** |
1642 | - * Gets all vessels types that have flown over |
|
1643 | - * |
|
1644 | - * @return Array the vessel type list |
|
1645 | - * |
|
1646 | - */ |
|
1642 | + * Gets all vessels types that have flown over |
|
1643 | + * |
|
1644 | + * @return Array the vessel type list |
|
1645 | + * |
|
1646 | + */ |
|
1647 | 1647 | public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
1648 | 1648 | { |
1649 | 1649 | global $globalDBdriver; |
@@ -1708,11 +1708,11 @@ discard block |
||
1708 | 1708 | } |
1709 | 1709 | |
1710 | 1710 | /** |
1711 | - * Gets all the tracker information |
|
1712 | - * |
|
1713 | - * @return Array the tracker information |
|
1714 | - * |
|
1715 | - */ |
|
1711 | + * Gets all the tracker information |
|
1712 | + * |
|
1713 | + * @return Array the tracker information |
|
1714 | + * |
|
1715 | + */ |
|
1716 | 1716 | public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
1717 | 1717 | { |
1718 | 1718 | global $globalTimezone, $globalDBdriver; |
@@ -1817,12 +1817,12 @@ discard block |
||
1817 | 1817 | } |
1818 | 1818 | |
1819 | 1819 | /** |
1820 | - * Gets the short url from bit.ly |
|
1821 | - * |
|
1822 | - * @param String $url the full url |
|
1823 | - * @return String the bit.ly url |
|
1824 | - * |
|
1825 | - */ |
|
1820 | + * Gets the short url from bit.ly |
|
1821 | + * |
|
1822 | + * @param String $url the full url |
|
1823 | + * @return String the bit.ly url |
|
1824 | + * |
|
1825 | + */ |
|
1826 | 1826 | public function getBitlyURL($url) |
1827 | 1827 | { |
1828 | 1828 | global $globalBitlyAccessToken; |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
18 | 18 | if (isset($globalMarine) && $globalMarine) { |
19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,46 +25,46 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->connectionExists() === false) { |
28 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | - exit(); |
|
28 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if ($Connection->latest() === false) { |
32 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | - exit(); |
|
32 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | + exit(); |
|
34 | 34 | } |
35 | 35 | if (PHP_SAPI != 'cli') { |
36 | - echo "This script MUST be called from console, not a web browser."; |
|
36 | + echo "This script MUST be called from console, not a web browser."; |
|
37 | 37 | // exit(); |
38 | 38 | } |
39 | 39 | |
40 | 40 | // This is to be compatible with old version of settings.php |
41 | 41 | if (!isset($globalSources)) { |
42 | - if (isset($globalSBS1Hosts)) { |
|
43 | - //$hosts = $globalSBS1Hosts; |
|
44 | - foreach ($globalSBS1Hosts as $host) { |
|
45 | - $globalSources[] = array('host' => $host); |
|
46 | - } |
|
47 | - } else { |
|
48 | - if (!isset($globalSBS1Host)) { |
|
49 | - echo '$globalSources MUST be defined !'; |
|
50 | - die; |
|
42 | + if (isset($globalSBS1Hosts)) { |
|
43 | + //$hosts = $globalSBS1Hosts; |
|
44 | + foreach ($globalSBS1Hosts as $host) { |
|
45 | + $globalSources[] = array('host' => $host); |
|
46 | + } |
|
47 | + } else { |
|
48 | + if (!isset($globalSBS1Host)) { |
|
49 | + echo '$globalSources MUST be defined !'; |
|
50 | + die; |
|
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | 53 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
54 | - } |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['s']); |
|
64 | 64 | } elseif (isset($options['source'])) { |
65 | - $globalSources = array(); |
|
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
65 | + $globalSources = array(); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | + else $globalSources[] = array('host' => $options['source']); |
|
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
70 | 70 | $globalServerAPRS = TRUE; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
104 | 104 | else $id_source = 1; |
105 | 105 | if (isset($globalServer) && $globalServer) { |
106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | - $SI=new SpotterServer(); |
|
106 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | + $SI=new SpotterServer(); |
|
108 | 108 | /* |
109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 110 | $SI = new adsb2aprs(); |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | |
115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
116 | 116 | if (isset($globalMarine) && $globalMarine) { |
117 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
118 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
117 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
118 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
122 | 122 | if (isset($globalMarine) && $globalMarine) { |
123 | - $AIS = new AIS(); |
|
124 | - $MI = new MarineImport($Connection->db); |
|
123 | + $AIS = new AIS(); |
|
124 | + $MI = new MarineImport($Connection->db); |
|
125 | 125 | } |
126 | 126 | //$APRS=new APRS($Connection->db); |
127 | 127 | $SBS=new SBS(); |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | //$servertz = system('date +%Z'); |
135 | 135 | // signal handler - playing nice with sockets and dump1090 |
136 | 136 | if (function_exists('pcntl_fork')) { |
137 | - pcntl_signal(SIGINT, function() { |
|
138 | - global $sockets; |
|
139 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140 | - die("Bye!\n"); |
|
141 | - }); |
|
142 | - pcntl_signal_dispatch(); |
|
137 | + pcntl_signal(SIGINT, function() { |
|
138 | + global $sockets; |
|
139 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140 | + die("Bye!\n"); |
|
141 | + }); |
|
142 | + pcntl_signal_dispatch(); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // let's try and connect |
@@ -149,36 +149,36 @@ discard block |
||
149 | 149 | $reset = 0; |
150 | 150 | |
151 | 151 | function connect_all($hosts) { |
152 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
154 | - $reset++; |
|
155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156 | - foreach ($hosts as $id => $value) { |
|
152 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
154 | + $reset++; |
|
155 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156 | + foreach ($hosts as $id => $value) { |
|
157 | 157 | $host = $value['host']; |
158 | 158 | $globalSources[$id]['last_exec'] = 0; |
159 | 159 | // Here we check type of source(s) |
160 | 160 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
162 | - //$formats[$id] = 'deltadbtxt'; |
|
163 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
164 | - //$last_exec['deltadbtxt'] = 0; |
|
165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
167 | - //$formats[$id] = 'vatsimtxt'; |
|
168 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
169 | - //$last_exec['vatsimtxt'] = 0; |
|
170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
172 | - //$formats[$id] = 'aircraftlistjson'; |
|
173 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174 | - //$last_exec['aircraftlistjson'] = 0; |
|
175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176 | - } else if (preg_match('/opensky/i',$host)) { |
|
177 | - //$formats[$id] = 'aircraftlistjson'; |
|
178 | - $globalSources[$id]['format'] = 'opensky'; |
|
179 | - //$last_exec['aircraftlistjson'] = 0; |
|
180 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
181 | - /* |
|
161 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
162 | + //$formats[$id] = 'deltadbtxt'; |
|
163 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
164 | + //$last_exec['deltadbtxt'] = 0; |
|
165 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
167 | + //$formats[$id] = 'vatsimtxt'; |
|
168 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
169 | + //$last_exec['vatsimtxt'] = 0; |
|
170 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
172 | + //$formats[$id] = 'aircraftlistjson'; |
|
173 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174 | + //$last_exec['aircraftlistjson'] = 0; |
|
175 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176 | + } else if (preg_match('/opensky/i',$host)) { |
|
177 | + //$formats[$id] = 'aircraftlistjson'; |
|
178 | + $globalSources[$id]['format'] = 'opensky'; |
|
179 | + //$last_exec['aircraftlistjson'] = 0; |
|
180 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
181 | + /* |
|
182 | 182 | // Disabled for now, site change source format |
183 | 183 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
184 | 184 | //$formats[$id] = 'radarvirtueljson'; |
@@ -190,120 +190,120 @@ discard block |
||
190 | 190 | exit(0); |
191 | 191 | } |
192 | 192 | */ |
193 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
194 | - //$formats[$id] = 'planeupdatefaa'; |
|
195 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
196 | - //$last_exec['planeupdatefaa'] = 0; |
|
197 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
198 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
199 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
200 | - exit(0); |
|
201 | - } |
|
202 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
203 | - //$formats[$id] = 'phpvmacars'; |
|
204 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
205 | - //$last_exec['phpvmacars'] = 0; |
|
206 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
207 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
208 | - //$formats[$id] = 'phpvmacars'; |
|
209 | - $globalSources[$id]['format'] = 'vam'; |
|
210 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
211 | - } else if (preg_match('/whazzup/i',$host)) { |
|
212 | - //$formats[$id] = 'whazzup'; |
|
213 | - $globalSources[$id]['format'] = 'whazzup'; |
|
214 | - //$last_exec['whazzup'] = 0; |
|
215 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
216 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
217 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
218 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
219 | - } else if (preg_match('/airwhere/i',$host)) { |
|
220 | - $globalSources[$id]['format'] = 'airwhere'; |
|
221 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
222 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
223 | - //$formats[$id] = 'pirepsjson'; |
|
224 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
225 | - //$last_exec['pirepsjson'] = 0; |
|
226 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
227 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
228 | - //$formats[$id] = 'fr24json'; |
|
229 | - $globalSources[$id]['format'] = 'fr24json'; |
|
230 | - //$last_exec['fr24json'] = 0; |
|
231 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
232 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
233 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
234 | - exit(0); |
|
235 | - } |
|
236 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
237 | - //$formats[$id] = 'fr24json'; |
|
238 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
239 | - //$last_exec['fr24json'] = 0; |
|
240 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
241 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
242 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
243 | - exit(0); |
|
244 | - } |
|
245 | - //} else if (preg_match('/10001/',$host)) { |
|
246 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
247 | - //$formats[$id] = 'tsv'; |
|
248 | - $globalSources[$id]['format'] = 'tsv'; |
|
249 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
250 | - } |
|
251 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
252 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
253 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
254 | - if ($idf !== false) { |
|
255 | - $httpfeeds[$id] = $idf; |
|
256 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
257 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
258 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
259 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
260 | - $hostport = explode(':',$host); |
|
261 | - if (isset($hostport[1])) { |
|
193 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
194 | + //$formats[$id] = 'planeupdatefaa'; |
|
195 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
196 | + //$last_exec['planeupdatefaa'] = 0; |
|
197 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
198 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
199 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
200 | + exit(0); |
|
201 | + } |
|
202 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
203 | + //$formats[$id] = 'phpvmacars'; |
|
204 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
205 | + //$last_exec['phpvmacars'] = 0; |
|
206 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
207 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
208 | + //$formats[$id] = 'phpvmacars'; |
|
209 | + $globalSources[$id]['format'] = 'vam'; |
|
210 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
211 | + } else if (preg_match('/whazzup/i',$host)) { |
|
212 | + //$formats[$id] = 'whazzup'; |
|
213 | + $globalSources[$id]['format'] = 'whazzup'; |
|
214 | + //$last_exec['whazzup'] = 0; |
|
215 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
216 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
217 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
218 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
219 | + } else if (preg_match('/airwhere/i',$host)) { |
|
220 | + $globalSources[$id]['format'] = 'airwhere'; |
|
221 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
222 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
223 | + //$formats[$id] = 'pirepsjson'; |
|
224 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
225 | + //$last_exec['pirepsjson'] = 0; |
|
226 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
227 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
228 | + //$formats[$id] = 'fr24json'; |
|
229 | + $globalSources[$id]['format'] = 'fr24json'; |
|
230 | + //$last_exec['fr24json'] = 0; |
|
231 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
232 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
233 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
234 | + exit(0); |
|
235 | + } |
|
236 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
237 | + //$formats[$id] = 'fr24json'; |
|
238 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
239 | + //$last_exec['fr24json'] = 0; |
|
240 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
241 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
242 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
243 | + exit(0); |
|
244 | + } |
|
245 | + //} else if (preg_match('/10001/',$host)) { |
|
246 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
247 | + //$formats[$id] = 'tsv'; |
|
248 | + $globalSources[$id]['format'] = 'tsv'; |
|
249 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
250 | + } |
|
251 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
252 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
253 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
254 | + if ($idf !== false) { |
|
255 | + $httpfeeds[$id] = $idf; |
|
256 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
257 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
258 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
259 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
260 | + $hostport = explode(':',$host); |
|
261 | + if (isset($hostport[1])) { |
|
262 | 262 | $port = $hostport[1]; |
263 | 263 | $hostn = $hostport[0]; |
264 | - } else { |
|
264 | + } else { |
|
265 | 265 | $port = $globalSources[$id]['port']; |
266 | 266 | $hostn = $globalSources[$id]['host']; |
267 | - } |
|
268 | - $Common = new Common(); |
|
269 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
270 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
271 | - } else { |
|
272 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
273 | - } |
|
274 | - if ($s) { |
|
275 | - $sockets[$id] = $s; |
|
276 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
277 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
267 | + } |
|
268 | + $Common = new Common(); |
|
269 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
270 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
271 | + } else { |
|
272 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
273 | + } |
|
274 | + if ($s) { |
|
275 | + $sockets[$id] = $s; |
|
276 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
277 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
278 | 278 | //$formats[$id] = 'aprs'; |
279 | 279 | $globalSources[$id]['format'] = 'aprs'; |
280 | 280 | //$aprs_connect = 0; |
281 | 281 | //$use_aprs = true; |
282 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
282 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
283 | 283 | $globalSources[$id]['format'] = 'vrstcp'; |
284 | - } elseif ($port == '10001') { |
|
285 | - //$formats[$id] = 'tsv'; |
|
286 | - $globalSources[$id]['format'] = 'tsv'; |
|
287 | - } elseif ($port == '30002') { |
|
288 | - //$formats[$id] = 'raw'; |
|
289 | - $globalSources[$id]['format'] = 'raw'; |
|
290 | - } elseif ($port == '5001') { |
|
291 | - //$formats[$id] = 'raw'; |
|
292 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
293 | - } elseif ($port == '30005') { |
|
284 | + } elseif ($port == '10001') { |
|
285 | + //$formats[$id] = 'tsv'; |
|
286 | + $globalSources[$id]['format'] = 'tsv'; |
|
287 | + } elseif ($port == '30002') { |
|
288 | + //$formats[$id] = 'raw'; |
|
289 | + $globalSources[$id]['format'] = 'raw'; |
|
290 | + } elseif ($port == '5001') { |
|
291 | + //$formats[$id] = 'raw'; |
|
292 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
293 | + } elseif ($port == '30005') { |
|
294 | 294 | // Not yet supported |
295 | - //$formats[$id] = 'beast'; |
|
296 | - $globalSources[$id]['format'] = 'beast'; |
|
297 | - //} else $formats[$id] = 'sbs'; |
|
298 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
299 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
295 | + //$formats[$id] = 'beast'; |
|
296 | + $globalSources[$id]['format'] = 'beast'; |
|
297 | + //} else $formats[$id] = 'sbs'; |
|
298 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
299 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
300 | 300 | } |
301 | 301 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
302 | - } else { |
|
302 | + } else { |
|
303 | 303 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
304 | - } |
|
305 | - } |
|
306 | - } |
|
304 | + } |
|
305 | + } |
|
306 | + } |
|
307 | 307 | } |
308 | 308 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
309 | 309 | |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | //connect_all($globalSources); |
327 | 327 | |
328 | 328 | if (isset($globalProxy) && $globalProxy) { |
329 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
329 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
330 | 330 | } else { |
331 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
331 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | // APRS Configuration |
@@ -337,21 +337,21 @@ discard block |
||
337 | 337 | die; |
338 | 338 | } |
339 | 339 | foreach ($globalSources as $key => $source) { |
340 | - if (!isset($source['format'])) { |
|
341 | - $globalSources[$key]['format'] = 'auto'; |
|
342 | - } |
|
343 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
344 | - unset($globalSources[$key]); |
|
345 | - } |
|
340 | + if (!isset($source['format'])) { |
|
341 | + $globalSources[$key]['format'] = 'auto'; |
|
342 | + } |
|
343 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
344 | + unset($globalSources[$key]); |
|
345 | + } |
|
346 | 346 | } |
347 | 347 | connect_all($globalSources); |
348 | 348 | foreach ($globalSources as $key => $source) { |
349 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
349 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
350 | 350 | $aprs_connect = 0; |
351 | 351 | $use_aprs = true; |
352 | 352 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
353 | 353 | break; |
354 | - } |
|
354 | + } |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | if ($use_aprs) { |
@@ -392,129 +392,129 @@ discard block |
||
392 | 392 | |
393 | 393 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
394 | 394 | while ($i > 0) { |
395 | - if (!$globalDaemon) $i = $endtime-time(); |
|
396 | - // Delete old ATC |
|
397 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
395 | + if (!$globalDaemon) $i = $endtime-time(); |
|
396 | + // Delete old ATC |
|
397 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
398 | 398 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
399 | - $ATC->deleteOldATC(); |
|
400 | - } |
|
399 | + $ATC->deleteOldATC(); |
|
400 | + } |
|
401 | 401 | |
402 | - if (count($last_exec) == count($globalSources)) { |
|
402 | + if (count($last_exec) == count($globalSources)) { |
|
403 | 403 | $max = $globalMinFetch; |
404 | 404 | foreach ($last_exec as $last) { |
405 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
405 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
406 | 406 | } |
407 | 407 | if ($max != $globalMinFetch) { |
408 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
409 | - sleep($globalMinFetch-$max+2); |
|
408 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
409 | + sleep($globalMinFetch-$max+2); |
|
410 | + } |
|
410 | 411 | } |
411 | - } |
|
412 | 412 | |
413 | 413 | |
414 | - //foreach ($formats as $id => $value) { |
|
415 | - foreach ($globalSources as $id => $value) { |
|
414 | + //foreach ($formats as $id => $value) { |
|
415 | + foreach ($globalSources as $id => $value) { |
|
416 | 416 | date_default_timezone_set('UTC'); |
417 | 417 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
418 | 418 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
419 | 419 | if ($value['format'] == 'deltadbtxt' && |
420 | - ( |
|
420 | + ( |
|
421 | 421 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
422 | 422 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
423 | - ) |
|
423 | + ) |
|
424 | 424 | ) { |
425 | - //$buffer = $Common->getData($hosts[$id]); |
|
426 | - $buffer = $Common->getData($value['host']); |
|
427 | - if ($buffer != '') $reset = 0; |
|
428 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
429 | - $buffer = explode('\n',$buffer); |
|
430 | - foreach ($buffer as $line) { |
|
431 | - if ($line != '' && count($line) > 7) { |
|
432 | - $line = explode(',', $line); |
|
433 | - $data = array(); |
|
434 | - $data['hex'] = $line[1]; // hex |
|
435 | - $data['ident'] = $line[2]; // ident |
|
436 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
437 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
438 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
439 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
440 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
441 | - $data['verticalrate'] = ''; // vertical rate |
|
442 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
443 | - $data['emergency'] = ''; // emergency |
|
444 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
445 | - $data['format_source'] = 'deltadbtxt'; |
|
446 | - $data['id_source'] = $id_source; |
|
447 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
448 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
449 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
450 | - $SI->add($data); |
|
451 | - unset($data); |
|
452 | - } |
|
453 | - } |
|
454 | - $last_exec[$id]['last'] = time(); |
|
425 | + //$buffer = $Common->getData($hosts[$id]); |
|
426 | + $buffer = $Common->getData($value['host']); |
|
427 | + if ($buffer != '') $reset = 0; |
|
428 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
429 | + $buffer = explode('\n',$buffer); |
|
430 | + foreach ($buffer as $line) { |
|
431 | + if ($line != '' && count($line) > 7) { |
|
432 | + $line = explode(',', $line); |
|
433 | + $data = array(); |
|
434 | + $data['hex'] = $line[1]; // hex |
|
435 | + $data['ident'] = $line[2]; // ident |
|
436 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
437 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
438 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
439 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
440 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
441 | + $data['verticalrate'] = ''; // vertical rate |
|
442 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
443 | + $data['emergency'] = ''; // emergency |
|
444 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
445 | + $data['format_source'] = 'deltadbtxt'; |
|
446 | + $data['id_source'] = $id_source; |
|
447 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
448 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
449 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
450 | + $SI->add($data); |
|
451 | + unset($data); |
|
452 | + } |
|
453 | + } |
|
454 | + $last_exec[$id]['last'] = time(); |
|
455 | 455 | } elseif ($value['format'] == 'aisnmeatxt' && |
456 | - ( |
|
456 | + ( |
|
457 | 457 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
458 | 458 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
459 | - ) |
|
459 | + ) |
|
460 | 460 | ) { |
461 | - date_default_timezone_set('CET'); |
|
462 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
463 | - date_default_timezone_set('UTC'); |
|
464 | - if ($buffer != '') $reset = 0; |
|
465 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
466 | - $buffer = explode('\n',$buffer); |
|
467 | - foreach ($buffer as $line) { |
|
461 | + date_default_timezone_set('CET'); |
|
462 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
463 | + date_default_timezone_set('UTC'); |
|
464 | + if ($buffer != '') $reset = 0; |
|
465 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
466 | + $buffer = explode('\n',$buffer); |
|
467 | + foreach ($buffer as $line) { |
|
468 | 468 | if ($line != '') { |
469 | - //echo "'".$line."'\n"; |
|
470 | - $add = false; |
|
471 | - $ais_data = $AIS->parse_line(trim($line)); |
|
472 | - $data = array(); |
|
473 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
474 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
475 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
476 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
477 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
478 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
479 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
480 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
481 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
482 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
483 | - if (isset($ais_data['timestamp'])) { |
|
469 | + //echo "'".$line."'\n"; |
|
470 | + $add = false; |
|
471 | + $ais_data = $AIS->parse_line(trim($line)); |
|
472 | + $data = array(); |
|
473 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
474 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
475 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
476 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
477 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
478 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
479 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
480 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
481 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
482 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
483 | + if (isset($ais_data['timestamp'])) { |
|
484 | 484 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
485 | 485 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
486 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
487 | - $add = true; |
|
486 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
487 | + $add = true; |
|
488 | 488 | } |
489 | - } else { |
|
489 | + } else { |
|
490 | 490 | $data['datetime'] = date('Y-m-d H:i:s'); |
491 | 491 | $add = true; |
492 | - } |
|
493 | - $data['format_source'] = 'aisnmeatxt'; |
|
494 | - $data['id_source'] = $id_source; |
|
495 | - //print_r($data); |
|
496 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
497 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
498 | - unset($data); |
|
492 | + } |
|
493 | + $data['format_source'] = 'aisnmeatxt'; |
|
494 | + $data['id_source'] = $id_source; |
|
495 | + //print_r($data); |
|
496 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
497 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
498 | + unset($data); |
|
499 | 499 | } |
500 | - } |
|
501 | - $last_exec[$id]['last'] = time(); |
|
500 | + } |
|
501 | + $last_exec[$id]['last'] = time(); |
|
502 | 502 | } elseif ($value['format'] == 'aisnmeahttp') { |
503 | - $arr = $httpfeeds; |
|
504 | - $w = $e = null; |
|
503 | + $arr = $httpfeeds; |
|
504 | + $w = $e = null; |
|
505 | 505 | |
506 | - if (isset($arr[$id])) { |
|
506 | + if (isset($arr[$id])) { |
|
507 | 507 | $nn = stream_select($arr,$w,$e,$timeout); |
508 | 508 | if ($nn > 0) { |
509 | - foreach ($httpfeeds as $feed) { |
|
509 | + foreach ($httpfeeds as $feed) { |
|
510 | 510 | $buffer = stream_get_line($feed,2000,"\n"); |
511 | 511 | if ($buffer === FALSE) { |
512 | - connect_all($globalSources); |
|
512 | + connect_all($globalSources); |
|
513 | 513 | } |
514 | 514 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
515 | 515 | $buffer = explode('\n',$buffer); |
516 | 516 | foreach ($buffer as $line) { |
517 | - if ($line != '') { |
|
517 | + if ($line != '') { |
|
518 | 518 | $ais_data = $AIS->parse_line(trim($line)); |
519 | 519 | $data = array(); |
520 | 520 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -532,115 +532,115 @@ discard block |
||
532 | 532 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
533 | 533 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
534 | 534 | if (isset($ais_data['timestamp'])) { |
535 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
535 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
536 | 536 | } else { |
537 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
537 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
538 | 538 | } |
539 | 539 | $data['format_source'] = 'aisnmeahttp'; |
540 | 540 | $data['id_source'] = $id_source; |
541 | 541 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
542 | 542 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
543 | 543 | unset($data); |
544 | - } |
|
544 | + } |
|
545 | + } |
|
545 | 546 | } |
546 | - } |
|
547 | 547 | } else { |
548 | - $format = $value['format']; |
|
549 | - if (isset($tt[$format])) $tt[$format]++; |
|
550 | - else $tt[$format] = 0; |
|
551 | - if ($tt[$format] > 30) { |
|
548 | + $format = $value['format']; |
|
549 | + if (isset($tt[$format])) $tt[$format]++; |
|
550 | + else $tt[$format] = 0; |
|
551 | + if ($tt[$format] > 30) { |
|
552 | 552 | if ($globalDebug) echo 'Reconnect...'."\n"; |
553 | 553 | sleep(2); |
554 | 554 | //$sourceeen[] = $value; |
555 | 555 | //connect_all($sourceeen); |
556 | 556 | //$sourceeen = array(); |
557 | 557 | connect_all($globalSources); |
558 | - } |
|
558 | + } |
|
559 | + } |
|
559 | 560 | } |
560 | - } |
|
561 | 561 | } elseif ($value['format'] == 'myshiptracking' && |
562 | - ( |
|
562 | + ( |
|
563 | 563 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
564 | 564 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
565 | - ) |
|
565 | + ) |
|
566 | 566 | ) { |
567 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
568 | - if ($buffer != '') { |
|
567 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
568 | + if ($buffer != '') { |
|
569 | 569 | //echo $buffer; |
570 | 570 | $all_data = json_decode($buffer,true); |
571 | 571 | //print_r($all_data); |
572 | 572 | if (isset($all_data[0]['DATA'])) { |
573 | - foreach ($all_data[0]['DATA'] as $line) { |
|
573 | + foreach ($all_data[0]['DATA'] as $line) { |
|
574 | 574 | if ($line != '') { |
575 | - $data = array(); |
|
576 | - $data['ident'] = $line['NAME']; |
|
577 | - $data['mmsi'] = $line['MMSI']; |
|
578 | - if (strlen($data['mmsi']) > 9) { |
|
575 | + $data = array(); |
|
576 | + $data['ident'] = $line['NAME']; |
|
577 | + $data['mmsi'] = $line['MMSI']; |
|
578 | + if (strlen($data['mmsi']) > 9) { |
|
579 | 579 | $data['mmsi'] = substr($data['mmsi'],-9); |
580 | - } |
|
581 | - $data['speed'] = $line['SOG']; |
|
582 | - $data['heading'] = $line['COG']; |
|
583 | - $data['latitude'] = $line['LAT']; |
|
584 | - $data['longitude'] = $line['LNG']; |
|
585 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
586 | - $data['imo'] = $line['IMO']; |
|
587 | - //$data['arrival_code'] = $ais_data['destination']; |
|
588 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
589 | - $data['format_source'] = 'myshiptracking'; |
|
590 | - $data['id_source'] = $id_source; |
|
591 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
592 | - $MI->add($data); |
|
593 | - unset($data); |
|
580 | + } |
|
581 | + $data['speed'] = $line['SOG']; |
|
582 | + $data['heading'] = $line['COG']; |
|
583 | + $data['latitude'] = $line['LAT']; |
|
584 | + $data['longitude'] = $line['LNG']; |
|
585 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
586 | + $data['imo'] = $line['IMO']; |
|
587 | + //$data['arrival_code'] = $ais_data['destination']; |
|
588 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
589 | + $data['format_source'] = 'myshiptracking'; |
|
590 | + $data['id_source'] = $id_source; |
|
591 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
592 | + $MI->add($data); |
|
593 | + unset($data); |
|
594 | + } |
|
594 | 595 | } |
595 | - } |
|
596 | 596 | } |
597 | - } |
|
598 | - $last_exec[$id]['last'] = time(); |
|
597 | + } |
|
598 | + $last_exec[$id]['last'] = time(); |
|
599 | 599 | } elseif ($value['format'] == 'boatbeaconapp' && |
600 | - ( |
|
600 | + ( |
|
601 | 601 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
602 | 602 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
603 | - ) |
|
603 | + ) |
|
604 | 604 | ) { |
605 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
606 | - if ($buffer != '') { |
|
605 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
606 | + if ($buffer != '') { |
|
607 | 607 | $all_data = json_decode($buffer,true); |
608 | 608 | if (isset($all_data[0]['mmsi'])) { |
609 | - foreach ($all_data as $line) { |
|
609 | + foreach ($all_data as $line) { |
|
610 | 610 | if ($line != '') { |
611 | - $data = array(); |
|
612 | - $data['ident'] = $line['shipname']; |
|
613 | - $data['callsign'] = $line['callsign']; |
|
614 | - $data['mmsi'] = $line['mmsi']; |
|
615 | - $data['speed'] = $line['sog']; |
|
616 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
617 | - $data['latitude'] = $line['latitude']; |
|
618 | - $data['longitude'] = $line['longitude']; |
|
619 | - $data['type_id'] = $line['shiptype']; |
|
620 | - $data['arrival_code'] = $line['destination']; |
|
621 | - $data['datetime'] = $line['time']; |
|
622 | - $data['format_source'] = 'boatbeaconapp'; |
|
623 | - $data['id_source'] = $id_source; |
|
624 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
625 | - $MI->add($data); |
|
626 | - unset($data); |
|
611 | + $data = array(); |
|
612 | + $data['ident'] = $line['shipname']; |
|
613 | + $data['callsign'] = $line['callsign']; |
|
614 | + $data['mmsi'] = $line['mmsi']; |
|
615 | + $data['speed'] = $line['sog']; |
|
616 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
617 | + $data['latitude'] = $line['latitude']; |
|
618 | + $data['longitude'] = $line['longitude']; |
|
619 | + $data['type_id'] = $line['shiptype']; |
|
620 | + $data['arrival_code'] = $line['destination']; |
|
621 | + $data['datetime'] = $line['time']; |
|
622 | + $data['format_source'] = 'boatbeaconapp'; |
|
623 | + $data['id_source'] = $id_source; |
|
624 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
625 | + $MI->add($data); |
|
626 | + unset($data); |
|
627 | + } |
|
627 | 628 | } |
628 | - } |
|
629 | 629 | } |
630 | 630 | |
631 | - } |
|
632 | - $last_exec[$id]['last'] = time(); |
|
631 | + } |
|
632 | + $last_exec[$id]['last'] = time(); |
|
633 | 633 | } elseif ($value['format'] == 'boatnerd' && |
634 | - ( |
|
634 | + ( |
|
635 | 635 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
636 | 636 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
637 | - ) |
|
637 | + ) |
|
638 | 638 | ) { |
639 | - $buffer = $Common->getData($value['host']); |
|
640 | - if ($buffer != '') { |
|
639 | + $buffer = $Common->getData($value['host']); |
|
640 | + if ($buffer != '') { |
|
641 | 641 | $all_data = json_decode($buffer,true); |
642 | 642 | if (isset($all_data['features'][0]['id'])) { |
643 | - foreach ($all_data['features'] as $line) { |
|
643 | + foreach ($all_data['features'] as $line) { |
|
644 | 644 | $data = array(); |
645 | 645 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
646 | 646 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -659,78 +659,78 @@ discard block |
||
659 | 659 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
660 | 660 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
661 | 661 | unset($data); |
662 | - } |
|
662 | + } |
|
663 | 663 | } |
664 | 664 | |
665 | - } |
|
666 | - $last_exec[$id]['last'] = time(); |
|
665 | + } |
|
666 | + $last_exec[$id]['last'] = time(); |
|
667 | 667 | } elseif ($value['format'] == 'shipplotter' && |
668 | - ( |
|
668 | + ( |
|
669 | 669 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
670 | 670 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
671 | - ) |
|
671 | + ) |
|
672 | 672 | ) { |
673 | - echo 'download...'; |
|
674 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
675 | - echo 'done !'."\n"; |
|
676 | - if ($buffer != '') $reset = 0; |
|
677 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
678 | - $buffer = explode('\n',$buffer); |
|
679 | - foreach ($buffer as $line) { |
|
673 | + echo 'download...'; |
|
674 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
675 | + echo 'done !'."\n"; |
|
676 | + if ($buffer != '') $reset = 0; |
|
677 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
678 | + $buffer = explode('\n',$buffer); |
|
679 | + foreach ($buffer as $line) { |
|
680 | 680 | if ($line != '') { |
681 | - $data = array(); |
|
682 | - $data['mmsi'] = (int)substr($line,0,9); |
|
683 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
684 | - //$data['status'] = substr($line,21,2); |
|
685 | - //$data['type'] = substr($line,24,3); |
|
686 | - $data['latitude'] = substr($line,29,9); |
|
687 | - $data['longitude'] = substr($line,41,9); |
|
688 | - $data['speed'] = round(substr($line,51,5)); |
|
689 | - //$data['course'] = substr($line,57,5); |
|
690 | - $data['heading'] = round(substr($line,63,3)); |
|
691 | - //$data['draft'] = substr($line,67,4); |
|
692 | - //$data['length'] = substr($line,72,3); |
|
693 | - //$data['beam'] = substr($line,76,2); |
|
694 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
695 | - //$data['callsign'] = trim(substr($line,100,7); |
|
696 | - //$data['dest'] = substr($line,108,20); |
|
697 | - //$data['etaDate'] = substr($line,129,5); |
|
698 | - //$data['etaTime'] = substr($line,135,5); |
|
699 | - $data['format_source'] = 'shipplotter'; |
|
700 | - $data['id_source'] = $id_source; |
|
701 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
702 | - //print_r($data); |
|
703 | - echo 'Add...'."\n"; |
|
704 | - $MI->add($data); |
|
705 | - unset($data); |
|
681 | + $data = array(); |
|
682 | + $data['mmsi'] = (int)substr($line,0,9); |
|
683 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
684 | + //$data['status'] = substr($line,21,2); |
|
685 | + //$data['type'] = substr($line,24,3); |
|
686 | + $data['latitude'] = substr($line,29,9); |
|
687 | + $data['longitude'] = substr($line,41,9); |
|
688 | + $data['speed'] = round(substr($line,51,5)); |
|
689 | + //$data['course'] = substr($line,57,5); |
|
690 | + $data['heading'] = round(substr($line,63,3)); |
|
691 | + //$data['draft'] = substr($line,67,4); |
|
692 | + //$data['length'] = substr($line,72,3); |
|
693 | + //$data['beam'] = substr($line,76,2); |
|
694 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
695 | + //$data['callsign'] = trim(substr($line,100,7); |
|
696 | + //$data['dest'] = substr($line,108,20); |
|
697 | + //$data['etaDate'] = substr($line,129,5); |
|
698 | + //$data['etaTime'] = substr($line,135,5); |
|
699 | + $data['format_source'] = 'shipplotter'; |
|
700 | + $data['id_source'] = $id_source; |
|
701 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
702 | + //print_r($data); |
|
703 | + echo 'Add...'."\n"; |
|
704 | + $MI->add($data); |
|
705 | + unset($data); |
|
706 | 706 | } |
707 | - } |
|
708 | - $last_exec[$id]['last'] = time(); |
|
707 | + } |
|
708 | + $last_exec[$id]['last'] = time(); |
|
709 | 709 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
710 | 710 | } elseif ( |
711 | - ( |
|
711 | + ( |
|
712 | 712 | $value['format'] == 'whazzup' && |
713 | 713 | ( |
714 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
715 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
714 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
715 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
716 | 716 | ) |
717 | - ) || ( |
|
717 | + ) || ( |
|
718 | 718 | $value['format'] == 'vatsimtxt' && |
719 | 719 | ( |
720 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
721 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
720 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
721 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
722 | + ) |
|
722 | 723 | ) |
723 | - ) |
|
724 | 724 | ) { |
725 | - //$buffer = $Common->getData($hosts[$id]); |
|
726 | - $buffer = $Common->getData($value['host']); |
|
727 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
728 | - $buffer = explode('\n',$buffer); |
|
729 | - $reset = 0; |
|
730 | - foreach ($buffer as $line) { |
|
731 | - if ($line != '') { |
|
732 | - $line = explode(':', $line); |
|
733 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
725 | + //$buffer = $Common->getData($hosts[$id]); |
|
726 | + $buffer = $Common->getData($value['host']); |
|
727 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
728 | + $buffer = explode('\n',$buffer); |
|
729 | + $reset = 0; |
|
730 | + foreach ($buffer as $line) { |
|
731 | + if ($line != '') { |
|
732 | + $line = explode(':', $line); |
|
733 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
734 | 734 | $data = array(); |
735 | 735 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
736 | 736 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -743,37 +743,37 @@ discard block |
||
743 | 743 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
744 | 744 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
745 | 745 | $data['latitude'] = $line[5]; // lat |
746 | - $data['longitude'] = $line[6]; // long |
|
747 | - $data['verticalrate'] = ''; // vertical rate |
|
748 | - $data['squawk'] = ''; // squawk |
|
749 | - $data['emergency'] = ''; // emergency |
|
750 | - $data['waypoints'] = $line[30]; |
|
746 | + $data['longitude'] = $line[6]; // long |
|
747 | + $data['verticalrate'] = ''; // vertical rate |
|
748 | + $data['squawk'] = ''; // squawk |
|
749 | + $data['emergency'] = ''; // emergency |
|
750 | + $data['waypoints'] = $line[30]; |
|
751 | 751 | $data['datetime'] = date('Y-m-d H:i:s'); |
752 | 752 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
753 | 753 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
754 | - $data['departure_airport_icao'] = $line[11]; |
|
755 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
756 | - $data['arrival_airport_icao'] = $line[13]; |
|
754 | + $data['departure_airport_icao'] = $line[11]; |
|
755 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
756 | + $data['arrival_airport_icao'] = $line[13]; |
|
757 | 757 | $data['frequency'] = $line[4]; |
758 | 758 | $data['type'] = $line[18]; |
759 | 759 | $data['range'] = $line[19]; |
760 | 760 | if (isset($line[35])) $data['info'] = $line[35]; |
761 | - $data['id_source'] = $id_source; |
|
762 | - //$data['arrival_airport_time'] = ; |
|
763 | - if ($line[9] != '') { |
|
764 | - $aircraft_data = explode('/',$line[9]); |
|
765 | - if (isset($aircraft_data[1])) { |
|
766 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
767 | - } |
|
768 | - } |
|
769 | - /* |
|
761 | + $data['id_source'] = $id_source; |
|
762 | + //$data['arrival_airport_time'] = ; |
|
763 | + if ($line[9] != '') { |
|
764 | + $aircraft_data = explode('/',$line[9]); |
|
765 | + if (isset($aircraft_data[1])) { |
|
766 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
767 | + } |
|
768 | + } |
|
769 | + /* |
|
770 | 770 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
771 | 771 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
772 | 772 | */ |
773 | - $data['format_source'] = $value['format']; |
|
773 | + $data['format_source'] = $value['format']; |
|
774 | 774 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
775 | 775 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
776 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
776 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
777 | 777 | elseif ($line[3] == 'ATC') { |
778 | 778 | //print_r($data); |
779 | 779 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -794,21 +794,21 @@ discard block |
||
794 | 794 | 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']); |
795 | 795 | } |
796 | 796 | } |
797 | - unset($data); |
|
798 | - } |
|
799 | - } |
|
800 | - } |
|
801 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
802 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
803 | - $last_exec[$id]['last'] = time(); |
|
804 | - } elseif ($value['format'] == 'airwhere' && |
|
805 | - ( |
|
806 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
807 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
808 | - ) |
|
809 | - ) { |
|
810 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
811 | - if ($buffer != '') { |
|
797 | + unset($data); |
|
798 | + } |
|
799 | + } |
|
800 | + } |
|
801 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
802 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
803 | + $last_exec[$id]['last'] = time(); |
|
804 | + } elseif ($value['format'] == 'airwhere' && |
|
805 | + ( |
|
806 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
807 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
808 | + ) |
|
809 | + ) { |
|
810 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
811 | + if ($buffer != '') { |
|
812 | 812 | $all_data = simplexml_load_string($buffer); |
813 | 813 | foreach($all_data->children() as $childdata) { |
814 | 814 | $data = array(); |
@@ -830,10 +830,10 @@ discard block |
||
830 | 830 | $SI->add($data); |
831 | 831 | unset($data); |
832 | 832 | } |
833 | - } |
|
834 | - $Source->deleteOldLocationByType('gs'); |
|
835 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
836 | - if ($buffer != '') { |
|
833 | + } |
|
834 | + $Source->deleteOldLocationByType('gs'); |
|
835 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
836 | + if ($buffer != '') { |
|
837 | 837 | $all_data = simplexml_load_string($buffer); |
838 | 838 | foreach($all_data->children() as $childdata) { |
839 | 839 | $data = array(); |
@@ -851,8 +851,8 @@ discard block |
||
851 | 851 | } |
852 | 852 | unset($data); |
853 | 853 | } |
854 | - } |
|
855 | - $last_exec[$id]['last'] = time(); |
|
854 | + } |
|
855 | + $last_exec[$id]['last'] = time(); |
|
856 | 856 | /* |
857 | 857 | } if ($value['format'] == 'aircraftlistjson') { |
858 | 858 | print_r($globalSources); |
@@ -860,17 +860,17 @@ discard block |
||
860 | 860 | echo $globalMinFetch; |
861 | 861 | */ |
862 | 862 | } elseif ($value['format'] == 'aircraftlistjson' && |
863 | - ( |
|
863 | + ( |
|
864 | 864 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
865 | 865 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
866 | - ) |
|
866 | + ) |
|
867 | 867 | ) { |
868 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
869 | - if ($buffer != '') { |
|
870 | - $all_data = json_decode($buffer,true); |
|
868 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
869 | + if ($buffer != '') { |
|
870 | + $all_data = json_decode($buffer,true); |
|
871 | 871 | if (isset($all_data['acList'])) { |
872 | - $reset = 0; |
|
873 | - foreach ($all_data['acList'] as $line) { |
|
872 | + $reset = 0; |
|
873 | + foreach ($all_data['acList'] as $line) { |
|
874 | 874 | $data = array(); |
875 | 875 | $data['hex'] = $line['Icao']; // hex |
876 | 876 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -893,10 +893,10 @@ discard block |
||
893 | 893 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
894 | 894 | if (isset($data['latitude'])) $SI->add($data); |
895 | 895 | unset($data); |
896 | - } |
|
896 | + } |
|
897 | 897 | } elseif (is_array($all_data)) { |
898 | - $reset = 0; |
|
899 | - foreach ($all_data as $line) { |
|
898 | + $reset = 0; |
|
899 | + foreach ($all_data as $line) { |
|
900 | 900 | $data = array(); |
901 | 901 | $data['hex'] = $line['hex']; // hex |
902 | 902 | $data['ident'] = $line['flight']; // ident |
@@ -916,218 +916,218 @@ discard block |
||
916 | 916 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
917 | 917 | $SI->add($data); |
918 | 918 | unset($data); |
919 | - } |
|
919 | + } |
|
920 | 920 | } |
921 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
922 | - //$last_exec['aircraftlistjson'] = time(); |
|
923 | - $last_exec[$id]['last'] = time(); |
|
924 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
925 | - } elseif ($value['format'] == 'planeupdatefaa' && |
|
926 | - ( |
|
927 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
928 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
929 | - ) |
|
930 | - ) { |
|
931 | - $buffer = $Common->getData($value['host']); |
|
932 | - $all_data = json_decode($buffer,true); |
|
933 | - if (isset($all_data['planes'])) { |
|
921 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
922 | + //$last_exec['aircraftlistjson'] = time(); |
|
923 | + $last_exec[$id]['last'] = time(); |
|
924 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
925 | + } elseif ($value['format'] == 'planeupdatefaa' && |
|
926 | + ( |
|
927 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
928 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
929 | + ) |
|
930 | + ) { |
|
931 | + $buffer = $Common->getData($value['host']); |
|
932 | + $all_data = json_decode($buffer,true); |
|
933 | + if (isset($all_data['planes'])) { |
|
934 | 934 | $reset = 0; |
935 | 935 | foreach ($all_data['planes'] as $key => $line) { |
936 | - $data = array(); |
|
937 | - $data['hex'] = $key; // hex |
|
938 | - $data['ident'] = $line[3]; // ident |
|
939 | - $data['altitude'] = $line[6]; // altitude |
|
940 | - $data['speed'] = $line[8]; // speed |
|
941 | - $data['heading'] = $line[7]; // heading |
|
942 | - $data['latitude'] = $line[4]; // lat |
|
943 | - $data['longitude'] = $line[5]; // long |
|
944 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
945 | - $data['squawk'] = $line[10]; // squawk |
|
946 | - $data['emergency'] = ''; // emergency |
|
947 | - $data['registration'] = $line[2]; |
|
948 | - $data['aircraft_icao'] = $line[0]; |
|
949 | - $deparr = explode('-',$line[1]); |
|
950 | - if (count($deparr) == 2) { |
|
936 | + $data = array(); |
|
937 | + $data['hex'] = $key; // hex |
|
938 | + $data['ident'] = $line[3]; // ident |
|
939 | + $data['altitude'] = $line[6]; // altitude |
|
940 | + $data['speed'] = $line[8]; // speed |
|
941 | + $data['heading'] = $line[7]; // heading |
|
942 | + $data['latitude'] = $line[4]; // lat |
|
943 | + $data['longitude'] = $line[5]; // long |
|
944 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
945 | + $data['squawk'] = $line[10]; // squawk |
|
946 | + $data['emergency'] = ''; // emergency |
|
947 | + $data['registration'] = $line[2]; |
|
948 | + $data['aircraft_icao'] = $line[0]; |
|
949 | + $deparr = explode('-',$line[1]); |
|
950 | + if (count($deparr) == 2) { |
|
951 | 951 | $data['departure_airport_icao'] = $deparr[0]; |
952 | 952 | $data['arrival_airport_icao'] = $deparr[1]; |
953 | - } |
|
954 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
955 | - $data['format_source'] = 'planeupdatefaa'; |
|
956 | - $data['id_source'] = $id_source; |
|
957 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
958 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
959 | - $SI->add($data); |
|
960 | - unset($data); |
|
953 | + } |
|
954 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
955 | + $data['format_source'] = 'planeupdatefaa'; |
|
956 | + $data['id_source'] = $id_source; |
|
957 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
958 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
959 | + $SI->add($data); |
|
960 | + unset($data); |
|
961 | + } |
|
961 | 962 | } |
962 | - } |
|
963 | - //$last_exec['planeupdatefaa'] = time(); |
|
964 | - $last_exec[$id]['last'] = time(); |
|
963 | + //$last_exec['planeupdatefaa'] = time(); |
|
964 | + $last_exec[$id]['last'] = time(); |
|
965 | 965 | } elseif ($value['format'] == 'opensky' && |
966 | - ( |
|
966 | + ( |
|
967 | 967 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
968 | 968 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
969 | - ) |
|
969 | + ) |
|
970 | 970 | ) { |
971 | - $buffer = $Common->getData($value['host']); |
|
972 | - $all_data = json_decode($buffer,true); |
|
973 | - if (isset($all_data['states'])) { |
|
971 | + $buffer = $Common->getData($value['host']); |
|
972 | + $all_data = json_decode($buffer,true); |
|
973 | + if (isset($all_data['states'])) { |
|
974 | 974 | $reset = 0; |
975 | 975 | foreach ($all_data['states'] as $key => $line) { |
976 | - $data = array(); |
|
977 | - $data['hex'] = $line[0]; // hex |
|
978 | - $data['ident'] = trim($line[1]); // ident |
|
979 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
980 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
981 | - $data['heading'] = round($line[10]); // heading |
|
982 | - $data['latitude'] = $line[6]; // lat |
|
983 | - $data['longitude'] = $line[5]; // long |
|
984 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
985 | - //$data['squawk'] = $line[10]; // squawk |
|
986 | - //$data['emergency'] = ''; // emergency |
|
987 | - //$data['registration'] = $line[2]; |
|
988 | - //$data['aircraft_icao'] = $line[0]; |
|
989 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
990 | - $data['format_source'] = 'opensky'; |
|
991 | - $data['id_source'] = $id_source; |
|
992 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
993 | - $SI->add($data); |
|
994 | - unset($data); |
|
976 | + $data = array(); |
|
977 | + $data['hex'] = $line[0]; // hex |
|
978 | + $data['ident'] = trim($line[1]); // ident |
|
979 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
980 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
981 | + $data['heading'] = round($line[10]); // heading |
|
982 | + $data['latitude'] = $line[6]; // lat |
|
983 | + $data['longitude'] = $line[5]; // long |
|
984 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
985 | + //$data['squawk'] = $line[10]; // squawk |
|
986 | + //$data['emergency'] = ''; // emergency |
|
987 | + //$data['registration'] = $line[2]; |
|
988 | + //$data['aircraft_icao'] = $line[0]; |
|
989 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
990 | + $data['format_source'] = 'opensky'; |
|
991 | + $data['id_source'] = $id_source; |
|
992 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
993 | + $SI->add($data); |
|
994 | + unset($data); |
|
995 | 995 | } |
996 | - } |
|
997 | - //$last_exec['planeupdatefaa'] = time(); |
|
998 | - $last_exec[$id]['last'] = time(); |
|
996 | + } |
|
997 | + //$last_exec['planeupdatefaa'] = time(); |
|
998 | + $last_exec[$id]['last'] = time(); |
|
999 | 999 | //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
1000 | 1000 | } elseif ($value['format'] == 'fr24json' && |
1001 | - ( |
|
1001 | + ( |
|
1002 | 1002 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1003 | 1003 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1004 | - ) |
|
1004 | + ) |
|
1005 | 1005 | ) { |
1006 | - //$buffer = $Common->getData($hosts[$id]); |
|
1007 | - $buffer = $Common->getData($value['host']); |
|
1008 | - $all_data = json_decode($buffer,true); |
|
1009 | - if (!empty($all_data)) $reset = 0; |
|
1010 | - foreach ($all_data as $key => $line) { |
|
1006 | + //$buffer = $Common->getData($hosts[$id]); |
|
1007 | + $buffer = $Common->getData($value['host']); |
|
1008 | + $all_data = json_decode($buffer,true); |
|
1009 | + if (!empty($all_data)) $reset = 0; |
|
1010 | + foreach ($all_data as $key => $line) { |
|
1011 | 1011 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1012 | - $data = array(); |
|
1013 | - $data['hex'] = $line[0]; |
|
1014 | - $data['ident'] = $line[16]; //$line[13] |
|
1015 | - $data['altitude'] = $line[4]; // altitude |
|
1016 | - $data['speed'] = $line[5]; // speed |
|
1017 | - $data['heading'] = $line[3]; // heading |
|
1018 | - $data['latitude'] = $line[1]; // lat |
|
1019 | - $data['longitude'] = $line[2]; // long |
|
1020 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1021 | - $data['squawk'] = $line[6]; // squawk |
|
1022 | - $data['aircraft_icao'] = $line[8]; |
|
1023 | - $data['registration'] = $line[9]; |
|
1024 | - $data['departure_airport_iata'] = $line[11]; |
|
1025 | - $data['arrival_airport_iata'] = $line[12]; |
|
1026 | - $data['emergency'] = ''; // emergency |
|
1027 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1028 | - $data['format_source'] = 'fr24json'; |
|
1029 | - $data['id_source'] = $id_source; |
|
1030 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1031 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1032 | - $SI->add($data); |
|
1033 | - unset($data); |
|
1012 | + $data = array(); |
|
1013 | + $data['hex'] = $line[0]; |
|
1014 | + $data['ident'] = $line[16]; //$line[13] |
|
1015 | + $data['altitude'] = $line[4]; // altitude |
|
1016 | + $data['speed'] = $line[5]; // speed |
|
1017 | + $data['heading'] = $line[3]; // heading |
|
1018 | + $data['latitude'] = $line[1]; // lat |
|
1019 | + $data['longitude'] = $line[2]; // long |
|
1020 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1021 | + $data['squawk'] = $line[6]; // squawk |
|
1022 | + $data['aircraft_icao'] = $line[8]; |
|
1023 | + $data['registration'] = $line[9]; |
|
1024 | + $data['departure_airport_iata'] = $line[11]; |
|
1025 | + $data['arrival_airport_iata'] = $line[12]; |
|
1026 | + $data['emergency'] = ''; // emergency |
|
1027 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1028 | + $data['format_source'] = 'fr24json'; |
|
1029 | + $data['id_source'] = $id_source; |
|
1030 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1031 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1032 | + $SI->add($data); |
|
1033 | + unset($data); |
|
1034 | 1034 | } |
1035 | - } |
|
1036 | - //$last_exec['fr24json'] = time(); |
|
1037 | - $last_exec[$id]['last'] = time(); |
|
1035 | + } |
|
1036 | + //$last_exec['fr24json'] = time(); |
|
1037 | + $last_exec[$id]['last'] = time(); |
|
1038 | 1038 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1039 | 1039 | } elseif ($value['format'] == 'radarvirtueljson' && |
1040 | - ( |
|
1040 | + ( |
|
1041 | 1041 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1042 | 1042 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1043 | - ) |
|
1043 | + ) |
|
1044 | 1044 | ) { |
1045 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1046 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1047 | - //echo $buffer; |
|
1048 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1049 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1050 | - $all_data = json_decode($buffer,true); |
|
1051 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1045 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1046 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1047 | + //echo $buffer; |
|
1048 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1049 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1050 | + $all_data = json_decode($buffer,true); |
|
1051 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1052 | 1052 | die(json_last_error_msg()); |
1053 | - } |
|
1054 | - if (isset($all_data['mrkrs'])) { |
|
1053 | + } |
|
1054 | + if (isset($all_data['mrkrs'])) { |
|
1055 | 1055 | $reset = 0; |
1056 | 1056 | foreach ($all_data['mrkrs'] as $key => $line) { |
1057 | - if (isset($line['inf'])) { |
|
1057 | + if (isset($line['inf'])) { |
|
1058 | 1058 | $data = array(); |
1059 | 1059 | $data['hex'] = $line['inf']['ia']; |
1060 | 1060 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1061 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1062 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1063 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1064 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1065 | - $data['longitude'] = $line['pt'][1]; // long |
|
1066 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1067 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1068 | - //$data['aircraft_icao'] = $line[8]; |
|
1069 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1061 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1062 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1063 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1064 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1065 | + $data['longitude'] = $line['pt'][1]; // long |
|
1066 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1067 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1068 | + //$data['aircraft_icao'] = $line[8]; |
|
1069 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1070 | 1070 | //$data['departure_airport_iata'] = $line[11]; |
1071 | 1071 | //$data['arrival_airport_iata'] = $line[12]; |
1072 | - //$data['emergency'] = ''; // emergency |
|
1072 | + //$data['emergency'] = ''; // emergency |
|
1073 | 1073 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1074 | - $data['format_source'] = 'radarvirtueljson'; |
|
1075 | - $data['id_source'] = $id_source; |
|
1074 | + $data['format_source'] = 'radarvirtueljson'; |
|
1075 | + $data['id_source'] = $id_source; |
|
1076 | 1076 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1077 | 1077 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1078 | 1078 | $SI->add($data); |
1079 | 1079 | unset($data); |
1080 | - } |
|
1080 | + } |
|
1081 | + } |
|
1081 | 1082 | } |
1082 | - } |
|
1083 | - //$last_exec['radarvirtueljson'] = time(); |
|
1084 | - $last_exec[$id]['last'] = time(); |
|
1083 | + //$last_exec['radarvirtueljson'] = time(); |
|
1084 | + $last_exec[$id]['last'] = time(); |
|
1085 | 1085 | //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1086 | 1086 | } elseif ($value['format'] == 'pirepsjson' && |
1087 | - ( |
|
1087 | + ( |
|
1088 | 1088 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1089 | 1089 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1090 | - ) |
|
1090 | + ) |
|
1091 | 1091 | ) { |
1092 | - //$buffer = $Common->getData($hosts[$id]); |
|
1093 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1094 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1092 | + //$buffer = $Common->getData($hosts[$id]); |
|
1093 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1094 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1095 | 1095 | |
1096 | - if (isset($all_data['pireps'])) { |
|
1096 | + if (isset($all_data['pireps'])) { |
|
1097 | 1097 | $reset = 0; |
1098 | - foreach ($all_data['pireps'] as $line) { |
|
1099 | - $data = array(); |
|
1100 | - $data['id'] = $line['id']; |
|
1101 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1102 | - $data['ident'] = $line['callsign']; // ident |
|
1103 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1104 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1105 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1106 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1107 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1108 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1109 | - $data['latitude'] = $line['lat']; // lat |
|
1110 | - $data['longitude'] = $line['lon']; // long |
|
1111 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1112 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1113 | - //$data['emergency'] = ''; // emergency |
|
1114 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1115 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1116 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1117 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1118 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1119 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1120 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1121 | - else $data['info'] = ''; |
|
1122 | - $data['format_source'] = 'pireps'; |
|
1123 | - $data['id_source'] = $id_source; |
|
1124 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1125 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1126 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1127 | - if ($line['icon'] == 'plane') { |
|
1098 | + foreach ($all_data['pireps'] as $line) { |
|
1099 | + $data = array(); |
|
1100 | + $data['id'] = $line['id']; |
|
1101 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1102 | + $data['ident'] = $line['callsign']; // ident |
|
1103 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1104 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1105 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1106 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1107 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1108 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1109 | + $data['latitude'] = $line['lat']; // lat |
|
1110 | + $data['longitude'] = $line['lon']; // long |
|
1111 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1112 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1113 | + //$data['emergency'] = ''; // emergency |
|
1114 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1115 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1116 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1117 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1118 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1119 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1120 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1121 | + else $data['info'] = ''; |
|
1122 | + $data['format_source'] = 'pireps'; |
|
1123 | + $data['id_source'] = $id_source; |
|
1124 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1125 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1126 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1127 | + if ($line['icon'] == 'plane') { |
|
1128 | 1128 | $SI->add($data); |
1129 | - // print_r($data); |
|
1130 | - } elseif ($line['icon'] == 'ct') { |
|
1129 | + // print_r($data); |
|
1130 | + } elseif ($line['icon'] == 'ct') { |
|
1131 | 1131 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1132 | 1132 | $data['info'] = str_replace('&sect;','',$data['info']); |
1133 | 1133 | $typec = substr($data['ident'],-3); |
@@ -1142,148 +1142,148 @@ discard block |
||
1142 | 1142 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1143 | 1143 | else $data['type'] = 'Observer'; |
1144 | 1144 | 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']); |
1145 | - } |
|
1146 | - unset($data); |
|
1145 | + } |
|
1146 | + unset($data); |
|
1147 | + } |
|
1147 | 1148 | } |
1148 | - } |
|
1149 | - //$last_exec['pirepsjson'] = time(); |
|
1150 | - $last_exec[$id]['last'] = time(); |
|
1149 | + //$last_exec['pirepsjson'] = time(); |
|
1150 | + $last_exec[$id]['last'] = time(); |
|
1151 | 1151 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1152 | 1152 | } elseif ($value['format'] == 'phpvmacars' && |
1153 | - ( |
|
1153 | + ( |
|
1154 | 1154 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1155 | 1155 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1156 | - ) |
|
1156 | + ) |
|
1157 | 1157 | ) { |
1158 | - //$buffer = $Common->getData($hosts[$id]); |
|
1159 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1160 | - $buffer = $Common->getData($value['host']); |
|
1161 | - $all_data = json_decode($buffer,true); |
|
1162 | - if ($buffer != '' && is_array($all_data)) { |
|
1158 | + //$buffer = $Common->getData($hosts[$id]); |
|
1159 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1160 | + $buffer = $Common->getData($value['host']); |
|
1161 | + $all_data = json_decode($buffer,true); |
|
1162 | + if ($buffer != '' && is_array($all_data)) { |
|
1163 | 1163 | $reset = 0; |
1164 | 1164 | foreach ($all_data as $line) { |
1165 | - $data = array(); |
|
1166 | - //$data['id'] = $line['id']; // id not usable |
|
1167 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1168 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1169 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1170 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1171 | - $data['ident'] = $line['flightnum']; // ident |
|
1172 | - $data['altitude'] = $line['alt']; // altitude |
|
1173 | - $data['speed'] = $line['gs']; // speed |
|
1174 | - $data['heading'] = $line['heading']; // heading |
|
1175 | - $data['latitude'] = $line['lat']; // lat |
|
1176 | - $data['longitude'] = $line['lng']; // long |
|
1177 | - $data['verticalrate'] = ''; // verticale rate |
|
1178 | - $data['squawk'] = ''; // squawk |
|
1179 | - $data['emergency'] = ''; // emergency |
|
1180 | - //$data['datetime'] = $line['lastupdate']; |
|
1181 | - //$data['last_update'] = $line['lastupdate']; |
|
1182 | - if (isset($value['timezone'])) { |
|
1183 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1184 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1185 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1186 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1187 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1188 | - $data['departure_airport_time'] = $line['deptime']; |
|
1189 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1190 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1191 | - $data['registration'] = $line['aircraft']; |
|
1192 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1193 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1194 | - if (isset($line['aircraftname'])) { |
|
1165 | + $data = array(); |
|
1166 | + //$data['id'] = $line['id']; // id not usable |
|
1167 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1168 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1169 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1170 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1171 | + $data['ident'] = $line['flightnum']; // ident |
|
1172 | + $data['altitude'] = $line['alt']; // altitude |
|
1173 | + $data['speed'] = $line['gs']; // speed |
|
1174 | + $data['heading'] = $line['heading']; // heading |
|
1175 | + $data['latitude'] = $line['lat']; // lat |
|
1176 | + $data['longitude'] = $line['lng']; // long |
|
1177 | + $data['verticalrate'] = ''; // verticale rate |
|
1178 | + $data['squawk'] = ''; // squawk |
|
1179 | + $data['emergency'] = ''; // emergency |
|
1180 | + //$data['datetime'] = $line['lastupdate']; |
|
1181 | + //$data['last_update'] = $line['lastupdate']; |
|
1182 | + if (isset($value['timezone'])) { |
|
1183 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1184 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1185 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1186 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1187 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1188 | + $data['departure_airport_time'] = $line['deptime']; |
|
1189 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1190 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1191 | + $data['registration'] = $line['aircraft']; |
|
1192 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1193 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1194 | + if (isset($line['aircraftname'])) { |
|
1195 | 1195 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1196 | 1196 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1197 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1198 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1199 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1200 | - else { |
|
1201 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1202 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1203 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1204 | - } |
|
1205 | - } |
|
1206 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1207 | - $data['id_source'] = $id_source; |
|
1208 | - $data['format_source'] = 'phpvmacars'; |
|
1209 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1210 | - $SI->add($data); |
|
1211 | - unset($data); |
|
1197 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1198 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1199 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1200 | + else { |
|
1201 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1202 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1203 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1204 | + } |
|
1205 | + } |
|
1206 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1207 | + $data['id_source'] = $id_source; |
|
1208 | + $data['format_source'] = 'phpvmacars'; |
|
1209 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1210 | + $SI->add($data); |
|
1211 | + unset($data); |
|
1212 | 1212 | } |
1213 | 1213 | if ($globalDebug) echo 'No more data...'."\n"; |
1214 | 1214 | unset($buffer); |
1215 | 1215 | unset($all_data); |
1216 | - } |
|
1217 | - //$last_exec['phpvmacars'] = time(); |
|
1218 | - $last_exec[$id]['last'] = time(); |
|
1216 | + } |
|
1217 | + //$last_exec['phpvmacars'] = time(); |
|
1218 | + $last_exec[$id]['last'] = time(); |
|
1219 | 1219 | } elseif ($value['format'] == 'vam' && |
1220 | - ( |
|
1220 | + ( |
|
1221 | 1221 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1222 | 1222 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1223 | - ) |
|
1223 | + ) |
|
1224 | 1224 | ) { |
1225 | - //$buffer = $Common->getData($hosts[$id]); |
|
1226 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1227 | - $buffer = $Common->getData($value['host']); |
|
1228 | - $all_data = json_decode($buffer,true); |
|
1229 | - if ($buffer != '' && is_array($all_data)) { |
|
1225 | + //$buffer = $Common->getData($hosts[$id]); |
|
1226 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1227 | + $buffer = $Common->getData($value['host']); |
|
1228 | + $all_data = json_decode($buffer,true); |
|
1229 | + if ($buffer != '' && is_array($all_data)) { |
|
1230 | 1230 | $reset = 0; |
1231 | 1231 | foreach ($all_data as $line) { |
1232 | - $data = array(); |
|
1233 | - //$data['id'] = $line['id']; // id not usable |
|
1234 | - $data['id'] = trim($line['flight_id']); |
|
1235 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1236 | - $data['pilot_name'] = $line['pilot_name']; |
|
1237 | - $data['pilot_id'] = $line['pilot_id']; |
|
1238 | - $data['ident'] = trim($line['callsign']); // ident |
|
1239 | - $data['altitude'] = $line['altitude']; // altitude |
|
1240 | - $data['speed'] = $line['gs']; // speed |
|
1241 | - $data['heading'] = $line['heading']; // heading |
|
1242 | - $data['latitude'] = $line['latitude']; // lat |
|
1243 | - $data['longitude'] = $line['longitude']; // long |
|
1244 | - $data['verticalrate'] = ''; // verticale rate |
|
1245 | - $data['squawk'] = ''; // squawk |
|
1246 | - $data['emergency'] = ''; // emergency |
|
1247 | - //$data['datetime'] = $line['lastupdate']; |
|
1248 | - $data['last_update'] = $line['last_update']; |
|
1249 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1250 | - $data['departure_airport_icao'] = $line['departure']; |
|
1251 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1252 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1253 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1254 | - //$data['registration'] = $line['aircraft']; |
|
1255 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1256 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1257 | - $data['id_source'] = $id_source; |
|
1258 | - $data['format_source'] = 'vam'; |
|
1259 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1260 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1261 | - $SI->add($data); |
|
1262 | - unset($data); |
|
1232 | + $data = array(); |
|
1233 | + //$data['id'] = $line['id']; // id not usable |
|
1234 | + $data['id'] = trim($line['flight_id']); |
|
1235 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1236 | + $data['pilot_name'] = $line['pilot_name']; |
|
1237 | + $data['pilot_id'] = $line['pilot_id']; |
|
1238 | + $data['ident'] = trim($line['callsign']); // ident |
|
1239 | + $data['altitude'] = $line['altitude']; // altitude |
|
1240 | + $data['speed'] = $line['gs']; // speed |
|
1241 | + $data['heading'] = $line['heading']; // heading |
|
1242 | + $data['latitude'] = $line['latitude']; // lat |
|
1243 | + $data['longitude'] = $line['longitude']; // long |
|
1244 | + $data['verticalrate'] = ''; // verticale rate |
|
1245 | + $data['squawk'] = ''; // squawk |
|
1246 | + $data['emergency'] = ''; // emergency |
|
1247 | + //$data['datetime'] = $line['lastupdate']; |
|
1248 | + $data['last_update'] = $line['last_update']; |
|
1249 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1250 | + $data['departure_airport_icao'] = $line['departure']; |
|
1251 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1252 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1253 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1254 | + //$data['registration'] = $line['aircraft']; |
|
1255 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1256 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1257 | + $data['id_source'] = $id_source; |
|
1258 | + $data['format_source'] = 'vam'; |
|
1259 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1260 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1261 | + $SI->add($data); |
|
1262 | + unset($data); |
|
1263 | 1263 | } |
1264 | 1264 | if ($globalDebug) echo 'No more data...'."\n"; |
1265 | 1265 | unset($buffer); |
1266 | 1266 | unset($all_data); |
1267 | - } |
|
1268 | - //$last_exec['phpvmacars'] = time(); |
|
1269 | - $last_exec[$id]['last'] = time(); |
|
1267 | + } |
|
1268 | + //$last_exec['phpvmacars'] = time(); |
|
1269 | + $last_exec[$id]['last'] = time(); |
|
1270 | 1270 | } elseif ($value['format'] == 'blitzortung' && |
1271 | - ( |
|
1271 | + ( |
|
1272 | 1272 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1273 | 1273 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1274 | - ) |
|
1274 | + ) |
|
1275 | 1275 | ) { |
1276 | - //$buffer = $Common->getData($hosts[$id]); |
|
1277 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1278 | - $buffer = $Common->getData($value['host']); |
|
1279 | - $all_data = json_decode($buffer,true); |
|
1280 | - if ($buffer != '') { |
|
1276 | + //$buffer = $Common->getData($hosts[$id]); |
|
1277 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1278 | + $buffer = $Common->getData($value['host']); |
|
1279 | + $all_data = json_decode($buffer,true); |
|
1280 | + if ($buffer != '') { |
|
1281 | 1281 | $Source->deleteLocationBySource('blitzortung'); |
1282 | 1282 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1283 | 1283 | $buffer = explode('\n',$buffer); |
1284 | 1284 | foreach ($buffer as $buffer_line) { |
1285 | - $line = json_decode($buffer_line,true); |
|
1286 | - if (isset($line['time'])) { |
|
1285 | + $line = json_decode($buffer_line,true); |
|
1286 | + if (isset($line['time'])) { |
|
1287 | 1287 | $data = array(); |
1288 | 1288 | $data['altitude'] = $line['alt']; // altitude |
1289 | 1289 | $data['latitude'] = $line['lat']; // lat |
@@ -1295,96 +1295,96 @@ discard block |
||
1295 | 1295 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1296 | 1296 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1297 | 1297 | unset($data); |
1298 | - } |
|
1298 | + } |
|
1299 | 1299 | } |
1300 | 1300 | if ($globalDebug) echo 'No more data...'."\n"; |
1301 | 1301 | unset($buffer); |
1302 | - } |
|
1303 | - $last_exec[$id]['last'] = time(); |
|
1302 | + } |
|
1303 | + $last_exec[$id]['last'] = time(); |
|
1304 | 1304 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1305 | 1305 | } 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') { |
1306 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1307 | - //$last_exec[$id]['last'] = time(); |
|
1306 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1307 | + //$last_exec[$id]['last'] = time(); |
|
1308 | 1308 | |
1309 | - //$read = array( $sockets[$id] ); |
|
1310 | - $read = $sockets; |
|
1311 | - $write = NULL; |
|
1312 | - $e = NULL; |
|
1313 | - $n = socket_select($read, $write, $e, $timeout); |
|
1314 | - if ($e != NULL) var_dump($e); |
|
1315 | - if ($n > 0) { |
|
1309 | + //$read = array( $sockets[$id] ); |
|
1310 | + $read = $sockets; |
|
1311 | + $write = NULL; |
|
1312 | + $e = NULL; |
|
1313 | + $n = socket_select($read, $write, $e, $timeout); |
|
1314 | + if ($e != NULL) var_dump($e); |
|
1315 | + if ($n > 0) { |
|
1316 | 1316 | $reset = 0; |
1317 | 1317 | foreach ($read as $nb => $r) { |
1318 | - //$value = $formats[$nb]; |
|
1319 | - $format = $globalSources[$nb]['format']; |
|
1320 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1318 | + //$value = $formats[$nb]; |
|
1319 | + $format = $globalSources[$nb]['format']; |
|
1320 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1321 | 1321 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1322 | - } elseif ($format == 'vrstcp') { |
|
1322 | + } elseif ($format == 'vrstcp') { |
|
1323 | 1323 | $buffer = @socket_read($r, 6000); |
1324 | - } else { |
|
1324 | + } else { |
|
1325 | 1325 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1326 | - } |
|
1327 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1328 | - //echo $buffer."\n"; |
|
1329 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1330 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1331 | - $error = false; |
|
1332 | - //$SI::del(); |
|
1333 | - if ($buffer !== FALSE) { |
|
1326 | + } |
|
1327 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1328 | + //echo $buffer."\n"; |
|
1329 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1330 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1331 | + $error = false; |
|
1332 | + //$SI::del(); |
|
1333 | + if ($buffer !== FALSE) { |
|
1334 | 1334 | if ($format == 'vrstcp') { |
1335 | - $buffer = explode('},{',$buffer); |
|
1335 | + $buffer = explode('},{',$buffer); |
|
1336 | 1336 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
1337 | - } |
|
1338 | - // SBS format is CSV format |
|
1339 | - if ($buffer !== FALSE && $buffer !== '') { |
|
1337 | + } |
|
1338 | + // SBS format is CSV format |
|
1339 | + if ($buffer !== FALSE && $buffer !== '') { |
|
1340 | 1340 | $tt[$format] = 0; |
1341 | 1341 | if ($format == 'acarssbs3') { |
1342 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1343 | - $ACARS->add(trim($buffer)); |
|
1344 | - $ACARS->deleteLiveAcarsData(); |
|
1342 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1343 | + $ACARS->add(trim($buffer)); |
|
1344 | + $ACARS->deleteLiveAcarsData(); |
|
1345 | 1345 | } elseif ($format == 'raw') { |
1346 | - // AVR format |
|
1347 | - $data = $SBS->parse($buffer); |
|
1348 | - if (is_array($data)) { |
|
1346 | + // AVR format |
|
1347 | + $data = $SBS->parse($buffer); |
|
1348 | + if (is_array($data)) { |
|
1349 | 1349 | $data['datetime'] = date('Y-m-d H:i:s'); |
1350 | 1350 | $data['format_source'] = 'raw'; |
1351 | 1351 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1352 | 1352 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1353 | 1353 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1354 | 1354 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1355 | - } |
|
1355 | + } |
|
1356 | 1356 | } elseif ($format == 'ais') { |
1357 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1358 | - $data = array(); |
|
1359 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1360 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1361 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1362 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1363 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1364 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1365 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1366 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1367 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1368 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1369 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1370 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1371 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1372 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1373 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1374 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1357 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1358 | + $data = array(); |
|
1359 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1360 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1361 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1362 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1363 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1364 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1365 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1366 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1367 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1368 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1369 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1370 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1371 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1372 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1373 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1374 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1375 | 1375 | |
1376 | - if (isset($ais_data['timestamp'])) { |
|
1376 | + if (isset($ais_data['timestamp'])) { |
|
1377 | 1377 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1378 | - } else { |
|
1378 | + } else { |
|
1379 | 1379 | $data['datetime'] = date('Y-m-d H:i:s'); |
1380 | - } |
|
1381 | - $data['format_source'] = 'aisnmea'; |
|
1382 | - $data['id_source'] = $id_source; |
|
1383 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1384 | - unset($data); |
|
1385 | - } elseif ($format == 'flightgearsp') { |
|
1386 | - //echo $buffer."\n"; |
|
1387 | - if (strlen($buffer) > 5) { |
|
1380 | + } |
|
1381 | + $data['format_source'] = 'aisnmea'; |
|
1382 | + $data['id_source'] = $id_source; |
|
1383 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1384 | + unset($data); |
|
1385 | + } elseif ($format == 'flightgearsp') { |
|
1386 | + //echo $buffer."\n"; |
|
1387 | + if (strlen($buffer) > 5) { |
|
1388 | 1388 | $line = explode(',',$buffer); |
1389 | 1389 | $data = array(); |
1390 | 1390 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1401,38 +1401,38 @@ discard block |
||
1401 | 1401 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1402 | 1402 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1403 | 1403 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1404 | - } |
|
1405 | - } elseif ($format == 'acars') { |
|
1406 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1407 | - $ACARS->add(trim($buffer)); |
|
1408 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1409 | - $ACARS->deleteLiveAcarsData(); |
|
1404 | + } |
|
1405 | + } elseif ($format == 'acars') { |
|
1406 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1407 | + $ACARS->add(trim($buffer)); |
|
1408 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1409 | + $ACARS->deleteLiveAcarsData(); |
|
1410 | 1410 | } elseif ($format == 'flightgearmp') { |
1411 | - if (substr($buffer,0,1) != '#') { |
|
1411 | + if (substr($buffer,0,1) != '#') { |
|
1412 | 1412 | $data = array(); |
1413 | 1413 | //echo $buffer."\n"; |
1414 | 1414 | $line = explode(' ',$buffer); |
1415 | 1415 | if (count($line) == 11) { |
1416 | - $userserver = explode('@',$line[0]); |
|
1417 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1418 | - $data['ident'] = $userserver[0]; |
|
1419 | - $data['registration'] = $userserver[0]; |
|
1420 | - $data['latitude'] = $line[4]; |
|
1421 | - $data['longitude'] = $line[5]; |
|
1422 | - $data['altitude'] = $line[6]; |
|
1423 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1424 | - $aircraft_type = $line[10]; |
|
1425 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1426 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1427 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1428 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1416 | + $userserver = explode('@',$line[0]); |
|
1417 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1418 | + $data['ident'] = $userserver[0]; |
|
1419 | + $data['registration'] = $userserver[0]; |
|
1420 | + $data['latitude'] = $line[4]; |
|
1421 | + $data['longitude'] = $line[5]; |
|
1422 | + $data['altitude'] = $line[6]; |
|
1423 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1424 | + $aircraft_type = $line[10]; |
|
1425 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1426 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1427 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1428 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1429 | + } |
|
1429 | 1430 | } |
1430 | - } |
|
1431 | 1431 | } elseif ($format == 'beast') { |
1432 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1433 | - die; |
|
1432 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1433 | + die; |
|
1434 | 1434 | } elseif ($format == 'vrstcp') { |
1435 | - foreach($buffer as $all_data) { |
|
1435 | + foreach($buffer as $all_data) { |
|
1436 | 1436 | $line = json_decode('{'.$all_data.'}',true); |
1437 | 1437 | $data = array(); |
1438 | 1438 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1452,153 +1452,153 @@ discard block |
||
1452 | 1452 | */ |
1453 | 1453 | $data['datetime'] = date('Y-m-d H:i:s'); |
1454 | 1454 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1455 | - $data['format_source'] = 'vrstcp'; |
|
1455 | + $data['format_source'] = 'vrstcp'; |
|
1456 | 1456 | $data['id_source'] = $id_source; |
1457 | 1457 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1458 | 1458 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1459 | 1459 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1460 | 1460 | unset($data); |
1461 | - } |
|
1461 | + } |
|
1462 | 1462 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1463 | - $line = explode("\t", $buffer); |
|
1464 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1463 | + $line = explode("\t", $buffer); |
|
1464 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1465 | 1465 | $key = $line[$k]; |
1466 | - $lined[$key] = $line[$k+1]; |
|
1467 | - } |
|
1468 | - if (count($lined) > 3) { |
|
1469 | - $data['hex'] = $lined['hexid']; |
|
1470 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1471 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1472 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1473 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1474 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1475 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1476 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1477 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1478 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1479 | - $data['id_source'] = $id_source; |
|
1480 | - $data['format_source'] = 'tsv'; |
|
1481 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1482 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1466 | + $lined[$key] = $line[$k+1]; |
|
1467 | + } |
|
1468 | + if (count($lined) > 3) { |
|
1469 | + $data['hex'] = $lined['hexid']; |
|
1470 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1471 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1472 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1473 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1474 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1475 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1476 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1477 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1478 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1479 | + $data['id_source'] = $id_source; |
|
1480 | + $data['format_source'] = 'tsv'; |
|
1481 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1482 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1483 | 1483 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1484 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1485 | - unset($lined); |
|
1486 | - unset($data); |
|
1487 | - } else $error = true; |
|
1484 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1485 | + unset($lined); |
|
1486 | + unset($data); |
|
1487 | + } else $error = true; |
|
1488 | 1488 | } elseif ($format == 'aprs' && $use_aprs) { |
1489 | - if ($aprs_connect == 0) { |
|
1489 | + if ($aprs_connect == 0) { |
|
1490 | 1490 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1491 | 1491 | $aprs_connect = 1; |
1492 | - } |
|
1492 | + } |
|
1493 | 1493 | |
1494 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1494 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1495 | 1495 | $aprs_last_tx = time(); |
1496 | 1496 | $data_aprs = "# Keep alive"; |
1497 | 1497 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1498 | - } |
|
1498 | + } |
|
1499 | 1499 | |
1500 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1501 | - //echo 'APRS data : '.$buffer."\n"; |
|
1502 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1503 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1504 | - //echo $buffer."\n"; |
|
1505 | - date_default_timezone_set('UTC'); |
|
1506 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1500 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1501 | + //echo 'APRS data : '.$buffer."\n"; |
|
1502 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1503 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1504 | + //echo $buffer."\n"; |
|
1505 | + date_default_timezone_set('UTC'); |
|
1506 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1507 | 1507 | $line = $APRS->parse($buffer); |
1508 | 1508 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1509 | 1509 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1510 | - $aprs_last_tx = time(); |
|
1511 | - $data = array(); |
|
1512 | - //print_r($line); |
|
1513 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1514 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1515 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1516 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1517 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1518 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1519 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1520 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1521 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1522 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1523 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1524 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1525 | - $data['latitude'] = $line['latitude']; |
|
1526 | - $data['longitude'] = $line['longitude']; |
|
1527 | - //$data['verticalrate'] = $line[16]; |
|
1528 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1529 | - //else $data['speed'] = 0; |
|
1530 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1531 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1532 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1533 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1510 | + $aprs_last_tx = time(); |
|
1511 | + $data = array(); |
|
1512 | + //print_r($line); |
|
1513 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1514 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1515 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1516 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1517 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1518 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1519 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1520 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1521 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1522 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1523 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1524 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1525 | + $data['latitude'] = $line['latitude']; |
|
1526 | + $data['longitude'] = $line['longitude']; |
|
1527 | + //$data['verticalrate'] = $line[16]; |
|
1528 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1529 | + //else $data['speed'] = 0; |
|
1530 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1531 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1532 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1533 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1534 | 1534 | |
1535 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1536 | - //else echo 'No heading...'."\n"; |
|
1537 | - //else $data['heading'] = 0; |
|
1538 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1539 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1540 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1541 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1542 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1543 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1544 | - $data['id_source'] = $id_source; |
|
1545 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1546 | - else $data['format_source'] = 'aprs'; |
|
1547 | - $data['source_name'] = $line['source']; |
|
1548 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1549 | - else $data['source_type'] = 'flarm'; |
|
1550 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1551 | - $currentdate = date('Y-m-d H:i:s'); |
|
1552 | - $aprsdate = strtotime($data['datetime']); |
|
1553 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1554 | - // Accept data if time <= system time + 20s |
|
1555 | - //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'])))) { |
|
1556 | - 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'])))) { |
|
1535 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1536 | + //else echo 'No heading...'."\n"; |
|
1537 | + //else $data['heading'] = 0; |
|
1538 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1539 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1540 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1541 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1542 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1543 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1544 | + $data['id_source'] = $id_source; |
|
1545 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1546 | + else $data['format_source'] = 'aprs'; |
|
1547 | + $data['source_name'] = $line['source']; |
|
1548 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1549 | + else $data['source_type'] = 'flarm'; |
|
1550 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1551 | + $currentdate = date('Y-m-d H:i:s'); |
|
1552 | + $aprsdate = strtotime($data['datetime']); |
|
1553 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1554 | + // Accept data if time <= system time + 20s |
|
1555 | + //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'])))) { |
|
1556 | + 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'])))) { |
|
1557 | 1557 | $send = $SI->add($data); |
1558 | - } elseif ($data['source_type'] == 'ais') { |
|
1558 | + } elseif ($data['source_type'] == 'ais') { |
|
1559 | 1559 | $data['type'] = ''; |
1560 | 1560 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1561 | - } elseif (isset($line['stealth'])) { |
|
1561 | + } elseif (isset($line['stealth'])) { |
|
1562 | 1562 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1563 | 1563 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1564 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1565 | - //$line['symbol'] == 'Balloon' || |
|
1566 | - $line['symbol'] == 'Glider' || |
|
1567 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1568 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1569 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1570 | - $send = $SI->add($data); |
|
1571 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1572 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1573 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
1574 | - $send = $MI->add($data); |
|
1575 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1576 | - $line['symbol'] == 'Car' || |
|
1577 | - $line['symbol'] == 'Ambulance' || |
|
1578 | - $line['symbol'] == 'Van' || |
|
1579 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1580 | - $line['symbol'] == 'Motorcycle' || |
|
1581 | - $line['symbol'] == 'Tractor' || |
|
1582 | - $line['symbol'] == 'Police' || |
|
1583 | - $line['symbol'] == 'Bike' || |
|
1584 | - $line['symbol'] == 'Jogger' || |
|
1585 | - $line['symbol'] == 'Horse' || |
|
1586 | - $line['symbol'] == 'Bus' || |
|
1587 | - $line['symbol'] == 'Jeep' || |
|
1588 | - $line['symbol'] == 'Recreational Vehicle' || |
|
1589 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1590 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
1591 | - $line['symbol'] == 'Firetruck' || |
|
1592 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1593 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1594 | - $line['symbol'] == 'SUV' || |
|
1595 | - $line['symbol'] == 'Snowmobile' || |
|
1596 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
1597 | - //} 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') { |
|
1564 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1565 | + //$line['symbol'] == 'Balloon' || |
|
1566 | + $line['symbol'] == 'Glider' || |
|
1567 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1568 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1569 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1570 | + $send = $SI->add($data); |
|
1571 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1572 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1573 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
1574 | + $send = $MI->add($data); |
|
1575 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1576 | + $line['symbol'] == 'Car' || |
|
1577 | + $line['symbol'] == 'Ambulance' || |
|
1578 | + $line['symbol'] == 'Van' || |
|
1579 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1580 | + $line['symbol'] == 'Motorcycle' || |
|
1581 | + $line['symbol'] == 'Tractor' || |
|
1582 | + $line['symbol'] == 'Police' || |
|
1583 | + $line['symbol'] == 'Bike' || |
|
1584 | + $line['symbol'] == 'Jogger' || |
|
1585 | + $line['symbol'] == 'Horse' || |
|
1586 | + $line['symbol'] == 'Bus' || |
|
1587 | + $line['symbol'] == 'Jeep' || |
|
1588 | + $line['symbol'] == 'Recreational Vehicle' || |
|
1589 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1590 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
1591 | + $line['symbol'] == 'Firetruck' || |
|
1592 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1593 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1594 | + $line['symbol'] == 'SUV' || |
|
1595 | + $line['symbol'] == 'Snowmobile' || |
|
1596 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
1597 | + //} 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') { |
|
1598 | 1598 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $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') { |
1599 | 1599 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1600 | 1600 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1601 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1601 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1602 | 1602 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1603 | 1603 | $Source->deleteOldLocationByType('gs'); |
1604 | 1604 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | } else { |
1607 | 1607 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1608 | 1608 | } |
1609 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1609 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1610 | 1610 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1611 | 1611 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1612 | 1612 | $Source->deleteOldLocationByType('wx'); |
@@ -1616,7 +1616,7 @@ discard block |
||
1616 | 1616 | } else { |
1617 | 1617 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1618 | 1618 | } |
1619 | - } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
|
1619 | + } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
|
1620 | 1620 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1621 | 1621 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1622 | 1622 | $Source->deleteOldLocationByType('lightning'); |
@@ -1625,11 +1625,11 @@ discard block |
||
1625 | 1625 | } else { |
1626 | 1626 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1627 | 1627 | } |
1628 | - } elseif ($globalDebug) { |
|
1629 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1630 | - print_r($line); |
|
1631 | - } |
|
1632 | - unset($data); |
|
1628 | + } elseif ($globalDebug) { |
|
1629 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1630 | + print_r($line); |
|
1631 | + } |
|
1632 | + unset($data); |
|
1633 | 1633 | } |
1634 | 1634 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1635 | 1635 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1648,12 +1648,12 @@ discard block |
||
1648 | 1648 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1649 | 1649 | $globalSources[$nb]['last_weather_clean'] = time(); |
1650 | 1650 | } |
1651 | - } |
|
1651 | + } |
|
1652 | 1652 | } else { |
1653 | - $line = explode(',', $buffer); |
|
1654 | - if (count($line) > 20) { |
|
1655 | - $data['hex'] = $line[4]; |
|
1656 | - /* |
|
1653 | + $line = explode(',', $buffer); |
|
1654 | + if (count($line) > 20) { |
|
1655 | + $data['hex'] = $line[4]; |
|
1656 | + /* |
|
1657 | 1657 | $data['datetime'] = $line[6].' '.$line[7]; |
1658 | 1658 | date_default_timezone_set($globalTimezone); |
1659 | 1659 | $datetime = new DateTime($data['datetime']); |
@@ -1661,30 +1661,30 @@ discard block |
||
1661 | 1661 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1662 | 1662 | date_default_timezone_set('UTC'); |
1663 | 1663 | */ |
1664 | - // Force datetime to current UTC datetime |
|
1665 | - date_default_timezone_set('UTC'); |
|
1666 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1667 | - $data['ident'] = trim($line[10]); |
|
1668 | - $data['latitude'] = $line[14]; |
|
1669 | - $data['longitude'] = $line[15]; |
|
1670 | - $data['verticalrate'] = $line[16]; |
|
1671 | - $data['emergency'] = $line[20]; |
|
1672 | - $data['speed'] = $line[12]; |
|
1673 | - $data['squawk'] = $line[17]; |
|
1674 | - $data['altitude'] = $line[11]; |
|
1675 | - $data['heading'] = $line[13]; |
|
1676 | - $data['ground'] = $line[21]; |
|
1677 | - $data['emergency'] = $line[19]; |
|
1678 | - $data['format_source'] = 'sbs'; |
|
1664 | + // Force datetime to current UTC datetime |
|
1665 | + date_default_timezone_set('UTC'); |
|
1666 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1667 | + $data['ident'] = trim($line[10]); |
|
1668 | + $data['latitude'] = $line[14]; |
|
1669 | + $data['longitude'] = $line[15]; |
|
1670 | + $data['verticalrate'] = $line[16]; |
|
1671 | + $data['emergency'] = $line[20]; |
|
1672 | + $data['speed'] = $line[12]; |
|
1673 | + $data['squawk'] = $line[17]; |
|
1674 | + $data['altitude'] = $line[11]; |
|
1675 | + $data['heading'] = $line[13]; |
|
1676 | + $data['ground'] = $line[21]; |
|
1677 | + $data['emergency'] = $line[19]; |
|
1678 | + $data['format_source'] = 'sbs'; |
|
1679 | 1679 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1680 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1680 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1681 | 1681 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1682 | - $data['id_source'] = $id_source; |
|
1683 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1684 | - else $error = true; |
|
1685 | - unset($data); |
|
1686 | - } else $error = true; |
|
1687 | - if ($error) { |
|
1682 | + $data['id_source'] = $id_source; |
|
1683 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1684 | + else $error = true; |
|
1685 | + unset($data); |
|
1686 | + } else $error = true; |
|
1687 | + if ($error) { |
|
1688 | 1688 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1689 | 1689 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1690 | 1690 | } else { |
@@ -1700,13 +1700,13 @@ discard block |
||
1700 | 1700 | connect_all($sourceer); |
1701 | 1701 | $sourceer = array(); |
1702 | 1702 | } |
1703 | - } |
|
1703 | + } |
|
1704 | 1704 | } |
1705 | 1705 | // Sleep for xxx microseconds |
1706 | 1706 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1707 | - } else { |
|
1707 | + } else { |
|
1708 | 1708 | if ($format == 'flightgearmp') { |
1709 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1709 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1710 | 1710 | //@socket_close($r); |
1711 | 1711 | sleep($globalMinFetch); |
1712 | 1712 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1715,9 +1715,9 @@ discard block |
||
1715 | 1715 | break; |
1716 | 1716 | |
1717 | 1717 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1718 | - if (isset($tt[$format])) $tt[$format]++; |
|
1719 | - else $tt[$format] = 0; |
|
1720 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1718 | + if (isset($tt[$format])) $tt[$format]++; |
|
1719 | + else $tt[$format] = 0; |
|
1720 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1721 | 1721 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1722 | 1722 | //@socket_close($r); |
1723 | 1723 | sleep(2); |
@@ -1728,24 +1728,24 @@ discard block |
||
1728 | 1728 | //connect_all($globalSources); |
1729 | 1729 | $tt[$format]=0; |
1730 | 1730 | break; |
1731 | - } |
|
1732 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1731 | + } |
|
1732 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1733 | + } |
|
1733 | 1734 | } |
1734 | - } |
|
1735 | 1735 | } |
1736 | - } else { |
|
1736 | + } else { |
|
1737 | 1737 | $error = socket_strerror(socket_last_error()); |
1738 | 1738 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1739 | 1739 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1740 | 1740 | if (isset($globalDebug)) echo "Restarting...\n"; |
1741 | 1741 | // Restart the script if possible |
1742 | 1742 | if (is_array($sockets)) { |
1743 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1743 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1744 | 1744 | |
1745 | - foreach ($sockets as $sock) { |
|
1745 | + foreach ($sockets as $sock) { |
|
1746 | 1746 | @socket_shutdown($sock,2); |
1747 | 1747 | @socket_close($sock); |
1748 | - } |
|
1748 | + } |
|
1749 | 1749 | |
1750 | 1750 | } |
1751 | 1751 | if ($globalDebug) echo "Waiting..."; |
@@ -1760,15 +1760,15 @@ discard block |
||
1760 | 1760 | if ($globalDebug) echo "Restart all connections..."; |
1761 | 1761 | connect_all($globalSources); |
1762 | 1762 | } |
1763 | - } |
|
1763 | + } |
|
1764 | 1764 | } |
1765 | 1765 | if ($globalDaemon === false) { |
1766 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1767 | - if (isset($SI)) $SI->checkAll(); |
|
1768 | - if (isset($TI)) $TI->checkAll(); |
|
1769 | - if (isset($MI)) $MI->checkAll(); |
|
1766 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1767 | + if (isset($SI)) $SI->checkAll(); |
|
1768 | + if (isset($TI)) $TI->checkAll(); |
|
1769 | + if (isset($MI)) $MI->checkAll(); |
|
1770 | + } |
|
1770 | 1771 | } |
1771 | - } |
|
1772 | 1772 | } |
1773 | 1773 | |
1774 | 1774 | ?> |
@@ -3,8 +3,8 @@ |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['country'])) { |
6 | - header('Location: '.$globalURL.'/country'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/country'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $country = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING)))); |
@@ -4,8 +4,8 @@ |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['airline'])) { |
7 | - header('Location: '.$globalURL.'/airline'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/airline'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $airline = urldecode(filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING)); |
11 | 11 | $Spotter = new Spotter(); |
@@ -4,8 +4,8 @@ |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['aircraft_manufacturer'])) { |
7 | - header('Location: '.$globalURL.'/manufacturer'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/manufacturer'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $Spotter = new Spotter(); |
11 | 11 | $manufacturer = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)))); |