@@ -5,7 +5,7 @@ |
||
5 | 5 | try { |
6 | 6 | $GeoidHeight = new GeoidHeight(); |
7 | 7 | } catch (Exception $e) { |
8 | - echo $e; |
|
8 | + echo $e; |
|
9 | 9 | } |
10 | 10 | $title = _("Geoid Height Calculator"); |
11 | 11 | require_once('header.php'); |
@@ -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,42 +25,42 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->latest() === false) { |
28 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
29 | - exit(); |
|
28 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if (PHP_SAPI != 'cli') { |
32 | - echo "This script MUST be called from console, not a web browser."; |
|
32 | + echo "This script MUST be called from console, not a web browser."; |
|
33 | 33 | // exit(); |
34 | 34 | } |
35 | 35 | |
36 | 36 | // This is to be compatible with old version of settings.php |
37 | 37 | if (!isset($globalSources)) { |
38 | - if (isset($globalSBS1Hosts)) { |
|
39 | - //$hosts = $globalSBS1Hosts; |
|
40 | - foreach ($globalSBS1Hosts as $host) { |
|
41 | - $globalSources[] = array('host' => $host); |
|
42 | - } |
|
43 | - } else { |
|
44 | - if (!isset($globalSBS1Host)) { |
|
45 | - echo '$globalSources MUST be defined !'; |
|
46 | - die; |
|
38 | + if (isset($globalSBS1Hosts)) { |
|
39 | + //$hosts = $globalSBS1Hosts; |
|
40 | + foreach ($globalSBS1Hosts as $host) { |
|
41 | + $globalSources[] = array('host' => $host); |
|
42 | + } |
|
43 | + } else { |
|
44 | + if (!isset($globalSBS1Host)) { |
|
45 | + echo '$globalSources MUST be defined !'; |
|
46 | + die; |
|
47 | 47 | } |
48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
49 | 49 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
50 | - } |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); |
55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
56 | 56 | if (isset($options['s'])) { |
57 | - $globalSources = array(); |
|
58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
59 | - else $globalSources[] = array('host' => $options['s']); |
|
57 | + $globalSources = array(); |
|
58 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
59 | + else $globalSources[] = array('host' => $options['s']); |
|
60 | 60 | } elseif (isset($options['source'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['source']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['source']); |
|
64 | 64 | } |
65 | 65 | if (isset($options['aprsserverhost'])) { |
66 | 66 | $globalServerAPRS = TRUE; |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
76 | 76 | else $id_source = 1; |
77 | 77 | if (isset($globalServer) && $globalServer) { |
78 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
79 | - $SI=new SpotterServer(); |
|
78 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
79 | + $SI=new SpotterServer(); |
|
80 | 80 | /* |
81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
82 | 82 | $SI = new adsb2aprs(); |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | } else $SI=new SpotterImport($Connection->db); |
86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
87 | 87 | if (isset($globalMarine) && $globalMarine) { |
88 | - $AIS = new AIS(); |
|
89 | - $MI = new MarineImport($Connection->db); |
|
88 | + $AIS = new AIS(); |
|
89 | + $MI = new MarineImport($Connection->db); |
|
90 | 90 | } |
91 | 91 | //$APRS=new APRS($Connection->db); |
92 | 92 | $SBS=new SBS(); |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | //$servertz = system('date +%Z'); |
98 | 98 | // signal handler - playing nice with sockets and dump1090 |
99 | 99 | if (function_exists('pcntl_fork')) { |
100 | - pcntl_signal(SIGINT, function() { |
|
101 | - global $sockets; |
|
102 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
103 | - die("Bye!\n"); |
|
104 | - }); |
|
105 | - pcntl_signal_dispatch(); |
|
100 | + pcntl_signal(SIGINT, function() { |
|
101 | + global $sockets; |
|
102 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
103 | + die("Bye!\n"); |
|
104 | + }); |
|
105 | + pcntl_signal_dispatch(); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // let's try and connect |
@@ -112,36 +112,36 @@ discard block |
||
112 | 112 | $reset = 0; |
113 | 113 | |
114 | 114 | function connect_all($hosts) { |
115 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
117 | - $reset++; |
|
118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
119 | - foreach ($hosts as $id => $value) { |
|
115 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
116 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
117 | + $reset++; |
|
118 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
119 | + foreach ($hosts as $id => $value) { |
|
120 | 120 | $host = $value['host']; |
121 | 121 | $globalSources[$id]['last_exec'] = 0; |
122 | 122 | // Here we check type of source(s) |
123 | 123 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
125 | - //$formats[$id] = 'deltadbtxt'; |
|
126 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
127 | - //$last_exec['deltadbtxt'] = 0; |
|
128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
130 | - //$formats[$id] = 'vatsimtxt'; |
|
131 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
132 | - //$last_exec['vatsimtxt'] = 0; |
|
133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
135 | - //$formats[$id] = 'aircraftlistjson'; |
|
136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
137 | - //$last_exec['aircraftlistjson'] = 0; |
|
138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
139 | - } else if (preg_match('/opensky/i',$host)) { |
|
140 | - //$formats[$id] = 'aircraftlistjson'; |
|
141 | - $globalSources[$id]['format'] = 'opensky'; |
|
142 | - //$last_exec['aircraftlistjson'] = 0; |
|
143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
144 | - /* |
|
124 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
125 | + //$formats[$id] = 'deltadbtxt'; |
|
126 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
127 | + //$last_exec['deltadbtxt'] = 0; |
|
128 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
129 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
130 | + //$formats[$id] = 'vatsimtxt'; |
|
131 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
132 | + //$last_exec['vatsimtxt'] = 0; |
|
133 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
134 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
135 | + //$formats[$id] = 'aircraftlistjson'; |
|
136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
137 | + //$last_exec['aircraftlistjson'] = 0; |
|
138 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
139 | + } else if (preg_match('/opensky/i',$host)) { |
|
140 | + //$formats[$id] = 'aircraftlistjson'; |
|
141 | + $globalSources[$id]['format'] = 'opensky'; |
|
142 | + //$last_exec['aircraftlistjson'] = 0; |
|
143 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
144 | + /* |
|
145 | 145 | // Disabled for now, site change source format |
146 | 146 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
147 | 147 | //$formats[$id] = 'radarvirtueljson'; |
@@ -153,118 +153,118 @@ discard block |
||
153 | 153 | exit(0); |
154 | 154 | } |
155 | 155 | */ |
156 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
157 | - //$formats[$id] = 'planeupdatefaa'; |
|
158 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
159 | - //$last_exec['planeupdatefaa'] = 0; |
|
160 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
161 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
162 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
163 | - exit(0); |
|
164 | - } |
|
165 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
166 | - //$formats[$id] = 'phpvmacars'; |
|
167 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
168 | - //$last_exec['phpvmacars'] = 0; |
|
169 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
170 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
171 | - //$formats[$id] = 'phpvmacars'; |
|
172 | - $globalSources[$id]['format'] = 'vam'; |
|
173 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
174 | - } else if (preg_match('/whazzup/i',$host)) { |
|
175 | - //$formats[$id] = 'whazzup'; |
|
176 | - $globalSources[$id]['format'] = 'whazzup'; |
|
177 | - //$last_exec['whazzup'] = 0; |
|
178 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
179 | - } else if (preg_match('/airwhere/i',$host)) { |
|
180 | - $globalSources[$id]['format'] = 'airwhere'; |
|
181 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
182 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
183 | - //$formats[$id] = 'pirepsjson'; |
|
184 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
185 | - //$last_exec['pirepsjson'] = 0; |
|
186 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
187 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
188 | - //$formats[$id] = 'fr24json'; |
|
189 | - $globalSources[$id]['format'] = 'fr24json'; |
|
190 | - //$last_exec['fr24json'] = 0; |
|
191 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
192 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
193 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
194 | - exit(0); |
|
195 | - } |
|
196 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
197 | - //$formats[$id] = 'fr24json'; |
|
198 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
199 | - //$last_exec['fr24json'] = 0; |
|
200 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
201 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
202 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
203 | - exit(0); |
|
204 | - } |
|
205 | - //} else if (preg_match('/10001/',$host)) { |
|
206 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
207 | - //$formats[$id] = 'tsv'; |
|
208 | - $globalSources[$id]['format'] = 'tsv'; |
|
209 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
210 | - } |
|
211 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
212 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
213 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
214 | - if ($idf !== false) { |
|
215 | - $httpfeeds[$id] = $idf; |
|
216 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
217 | - } |
|
218 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
219 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
220 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
221 | - $hostport = explode(':',$host); |
|
222 | - if (isset($hostport[1])) { |
|
156 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
157 | + //$formats[$id] = 'planeupdatefaa'; |
|
158 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
159 | + //$last_exec['planeupdatefaa'] = 0; |
|
160 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
161 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
162 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
163 | + exit(0); |
|
164 | + } |
|
165 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
166 | + //$formats[$id] = 'phpvmacars'; |
|
167 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
168 | + //$last_exec['phpvmacars'] = 0; |
|
169 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
170 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
171 | + //$formats[$id] = 'phpvmacars'; |
|
172 | + $globalSources[$id]['format'] = 'vam'; |
|
173 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
174 | + } else if (preg_match('/whazzup/i',$host)) { |
|
175 | + //$formats[$id] = 'whazzup'; |
|
176 | + $globalSources[$id]['format'] = 'whazzup'; |
|
177 | + //$last_exec['whazzup'] = 0; |
|
178 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
179 | + } else if (preg_match('/airwhere/i',$host)) { |
|
180 | + $globalSources[$id]['format'] = 'airwhere'; |
|
181 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
182 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
183 | + //$formats[$id] = 'pirepsjson'; |
|
184 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
185 | + //$last_exec['pirepsjson'] = 0; |
|
186 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
187 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
188 | + //$formats[$id] = 'fr24json'; |
|
189 | + $globalSources[$id]['format'] = 'fr24json'; |
|
190 | + //$last_exec['fr24json'] = 0; |
|
191 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
192 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
193 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
194 | + exit(0); |
|
195 | + } |
|
196 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
197 | + //$formats[$id] = 'fr24json'; |
|
198 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
199 | + //$last_exec['fr24json'] = 0; |
|
200 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
201 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
202 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
203 | + exit(0); |
|
204 | + } |
|
205 | + //} else if (preg_match('/10001/',$host)) { |
|
206 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
207 | + //$formats[$id] = 'tsv'; |
|
208 | + $globalSources[$id]['format'] = 'tsv'; |
|
209 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
210 | + } |
|
211 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
212 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
213 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
214 | + if ($idf !== false) { |
|
215 | + $httpfeeds[$id] = $idf; |
|
216 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
217 | + } |
|
218 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
219 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
220 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
221 | + $hostport = explode(':',$host); |
|
222 | + if (isset($hostport[1])) { |
|
223 | 223 | $port = $hostport[1]; |
224 | 224 | $hostn = $hostport[0]; |
225 | - } else { |
|
225 | + } else { |
|
226 | 226 | $port = $globalSources[$id]['port']; |
227 | 227 | $hostn = $globalSources[$id]['host']; |
228 | - } |
|
229 | - $Common = new Common(); |
|
230 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
231 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
232 | - } else { |
|
233 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
234 | - } |
|
235 | - if ($s) { |
|
236 | - $sockets[$id] = $s; |
|
237 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
238 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
228 | + } |
|
229 | + $Common = new Common(); |
|
230 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
231 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
232 | + } else { |
|
233 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
234 | + } |
|
235 | + if ($s) { |
|
236 | + $sockets[$id] = $s; |
|
237 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
238 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
239 | 239 | //$formats[$id] = 'aprs'; |
240 | 240 | $globalSources[$id]['format'] = 'aprs'; |
241 | 241 | //$aprs_connect = 0; |
242 | 242 | //$use_aprs = true; |
243 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
243 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
244 | 244 | $globalSources[$id]['format'] = 'vrstcp'; |
245 | - } elseif ($port == '10001') { |
|
246 | - //$formats[$id] = 'tsv'; |
|
247 | - $globalSources[$id]['format'] = 'tsv'; |
|
248 | - } elseif ($port == '30002') { |
|
249 | - //$formats[$id] = 'raw'; |
|
250 | - $globalSources[$id]['format'] = 'raw'; |
|
251 | - } elseif ($port == '5001') { |
|
252 | - //$formats[$id] = 'raw'; |
|
253 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
254 | - } elseif ($port == '30005') { |
|
245 | + } elseif ($port == '10001') { |
|
246 | + //$formats[$id] = 'tsv'; |
|
247 | + $globalSources[$id]['format'] = 'tsv'; |
|
248 | + } elseif ($port == '30002') { |
|
249 | + //$formats[$id] = 'raw'; |
|
250 | + $globalSources[$id]['format'] = 'raw'; |
|
251 | + } elseif ($port == '5001') { |
|
252 | + //$formats[$id] = 'raw'; |
|
253 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
254 | + } elseif ($port == '30005') { |
|
255 | 255 | // Not yet supported |
256 | - //$formats[$id] = 'beast'; |
|
257 | - $globalSources[$id]['format'] = 'beast'; |
|
258 | - //} else $formats[$id] = 'sbs'; |
|
259 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
260 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
256 | + //$formats[$id] = 'beast'; |
|
257 | + $globalSources[$id]['format'] = 'beast'; |
|
258 | + //} else $formats[$id] = 'sbs'; |
|
259 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
260 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
261 | 261 | } |
262 | 262 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
263 | - } else { |
|
263 | + } else { |
|
264 | 264 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
265 | - } |
|
266 | - } |
|
267 | - } |
|
265 | + } |
|
266 | + } |
|
267 | + } |
|
268 | 268 | } |
269 | 269 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
270 | 270 | |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | //connect_all($globalSources); |
288 | 288 | |
289 | 289 | if (isset($globalProxy) && $globalProxy) { |
290 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
290 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
291 | 291 | } else { |
292 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
292 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | // APRS Configuration |
@@ -298,21 +298,21 @@ discard block |
||
298 | 298 | die; |
299 | 299 | } |
300 | 300 | foreach ($globalSources as $key => $source) { |
301 | - if (!isset($source['format'])) { |
|
302 | - $globalSources[$key]['format'] = 'auto'; |
|
303 | - } |
|
304 | - if (isset($source['callback'])) { |
|
305 | - unset($globalSources[$key]); |
|
306 | - } |
|
301 | + if (!isset($source['format'])) { |
|
302 | + $globalSources[$key]['format'] = 'auto'; |
|
303 | + } |
|
304 | + if (isset($source['callback'])) { |
|
305 | + unset($globalSources[$key]); |
|
306 | + } |
|
307 | 307 | } |
308 | 308 | connect_all($globalSources); |
309 | 309 | foreach ($globalSources as $key => $source) { |
310 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
310 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
311 | 311 | $aprs_connect = 0; |
312 | 312 | $use_aprs = true; |
313 | 313 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
314 | 314 | break; |
315 | - } |
|
315 | + } |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | if ($use_aprs) { |
@@ -353,115 +353,115 @@ discard block |
||
353 | 353 | |
354 | 354 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
355 | 355 | while ($i > 0) { |
356 | - if (!$globalDaemon) $i = $endtime-time(); |
|
357 | - // Delete old ATC |
|
358 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
356 | + if (!$globalDaemon) $i = $endtime-time(); |
|
357 | + // Delete old ATC |
|
358 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
359 | 359 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
360 | - $ATC->deleteOldATC(); |
|
361 | - } |
|
360 | + $ATC->deleteOldATC(); |
|
361 | + } |
|
362 | 362 | |
363 | - if (count($last_exec) == count($globalSources)) { |
|
363 | + if (count($last_exec) == count($globalSources)) { |
|
364 | 364 | $max = $globalMinFetch; |
365 | 365 | foreach ($last_exec as $last) { |
366 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
366 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
367 | 367 | } |
368 | 368 | if ($max != $globalMinFetch) { |
369 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
370 | - sleep($globalMinFetch-$max+2); |
|
369 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
370 | + sleep($globalMinFetch-$max+2); |
|
371 | + } |
|
371 | 372 | } |
372 | - } |
|
373 | 373 | |
374 | 374 | |
375 | - //foreach ($formats as $id => $value) { |
|
376 | - foreach ($globalSources as $id => $value) { |
|
375 | + //foreach ($formats as $id => $value) { |
|
376 | + foreach ($globalSources as $id => $value) { |
|
377 | 377 | date_default_timezone_set('UTC'); |
378 | 378 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
379 | 379 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
380 | - //$buffer = $Common->getData($hosts[$id]); |
|
381 | - $buffer = $Common->getData($value['host']); |
|
382 | - if ($buffer != '') $reset = 0; |
|
383 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
384 | - $buffer = explode('\n',$buffer); |
|
385 | - foreach ($buffer as $line) { |
|
386 | - if ($line != '' && count($line) > 7) { |
|
387 | - $line = explode(',', $line); |
|
388 | - $data = array(); |
|
389 | - $data['hex'] = $line[1]; // hex |
|
390 | - $data['ident'] = $line[2]; // ident |
|
391 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
392 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
393 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
394 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
395 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
396 | - $data['verticalrate'] = ''; // vertical rate |
|
397 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
398 | - $data['emergency'] = ''; // emergency |
|
399 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
400 | - $data['format_source'] = 'deltadbtxt'; |
|
401 | - $data['id_source'] = $id_source; |
|
402 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
403 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
404 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
405 | - $SI->add($data); |
|
406 | - unset($data); |
|
407 | - } |
|
408 | - } |
|
409 | - $last_exec[$id]['last'] = time(); |
|
380 | + //$buffer = $Common->getData($hosts[$id]); |
|
381 | + $buffer = $Common->getData($value['host']); |
|
382 | + if ($buffer != '') $reset = 0; |
|
383 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
384 | + $buffer = explode('\n',$buffer); |
|
385 | + foreach ($buffer as $line) { |
|
386 | + if ($line != '' && count($line) > 7) { |
|
387 | + $line = explode(',', $line); |
|
388 | + $data = array(); |
|
389 | + $data['hex'] = $line[1]; // hex |
|
390 | + $data['ident'] = $line[2]; // ident |
|
391 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
392 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
393 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
394 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
395 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
396 | + $data['verticalrate'] = ''; // vertical rate |
|
397 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
398 | + $data['emergency'] = ''; // emergency |
|
399 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
400 | + $data['format_source'] = 'deltadbtxt'; |
|
401 | + $data['id_source'] = $id_source; |
|
402 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
403 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
404 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
405 | + $SI->add($data); |
|
406 | + unset($data); |
|
407 | + } |
|
408 | + } |
|
409 | + $last_exec[$id]['last'] = time(); |
|
410 | 410 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
411 | - date_default_timezone_set('CET'); |
|
412 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
413 | - date_default_timezone_set('UTC'); |
|
414 | - if ($buffer != '') $reset = 0; |
|
415 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
416 | - $buffer = explode('\n',$buffer); |
|
417 | - foreach ($buffer as $line) { |
|
411 | + date_default_timezone_set('CET'); |
|
412 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
413 | + date_default_timezone_set('UTC'); |
|
414 | + if ($buffer != '') $reset = 0; |
|
415 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
416 | + $buffer = explode('\n',$buffer); |
|
417 | + foreach ($buffer as $line) { |
|
418 | 418 | if ($line != '') { |
419 | - //echo "'".$line."'\n"; |
|
420 | - $add = false; |
|
421 | - $ais_data = $AIS->parse_line(trim($line)); |
|
422 | - $data = array(); |
|
423 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
424 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
425 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
426 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
427 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
428 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
429 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
430 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
431 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
432 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
433 | - if (isset($ais_data['timestamp'])) { |
|
419 | + //echo "'".$line."'\n"; |
|
420 | + $add = false; |
|
421 | + $ais_data = $AIS->parse_line(trim($line)); |
|
422 | + $data = array(); |
|
423 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
424 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
425 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
426 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
427 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
428 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
429 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
430 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
431 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
432 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
433 | + if (isset($ais_data['timestamp'])) { |
|
434 | 434 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
435 | 435 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
436 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
437 | - $add = true; |
|
436 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
437 | + $add = true; |
|
438 | 438 | } |
439 | - } else { |
|
439 | + } else { |
|
440 | 440 | $data['datetime'] = date('Y-m-d H:i:s'); |
441 | 441 | $add = true; |
442 | - } |
|
443 | - $data['format_source'] = 'aisnmeatxt'; |
|
444 | - $data['id_source'] = $id_source; |
|
445 | - //print_r($data); |
|
446 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
447 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
448 | - unset($data); |
|
442 | + } |
|
443 | + $data['format_source'] = 'aisnmeatxt'; |
|
444 | + $data['id_source'] = $id_source; |
|
445 | + //print_r($data); |
|
446 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
447 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
448 | + unset($data); |
|
449 | 449 | } |
450 | - } |
|
451 | - $last_exec[$id]['last'] = time(); |
|
450 | + } |
|
451 | + $last_exec[$id]['last'] = time(); |
|
452 | 452 | } elseif ($value['format'] == 'aisnmeahttp') { |
453 | - $arr = $httpfeeds; |
|
454 | - $w = $e = null; |
|
453 | + $arr = $httpfeeds; |
|
454 | + $w = $e = null; |
|
455 | 455 | |
456 | - if (isset($arr[$id])) { |
|
456 | + if (isset($arr[$id])) { |
|
457 | 457 | $nn = stream_select($arr,$w,$e,$timeout); |
458 | 458 | if ($nn > 0) { |
459 | - foreach ($httpfeeds as $feed) { |
|
459 | + foreach ($httpfeeds as $feed) { |
|
460 | 460 | $buffer = stream_get_line($feed,2000,"\n"); |
461 | 461 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
462 | 462 | $buffer = explode('\n',$buffer); |
463 | 463 | foreach ($buffer as $line) { |
464 | - if ($line != '') { |
|
464 | + if ($line != '') { |
|
465 | 465 | $ais_data = $AIS->parse_line(trim($line)); |
466 | 466 | $data = array(); |
467 | 467 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -479,96 +479,96 @@ discard block |
||
479 | 479 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
480 | 480 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
481 | 481 | if (isset($ais_data['timestamp'])) { |
482 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
482 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
483 | 483 | } else { |
484 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
484 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
485 | 485 | } |
486 | 486 | $data['format_source'] = 'aisnmeahttp'; |
487 | 487 | $data['id_source'] = $id_source; |
488 | 488 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
489 | 489 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
490 | 490 | unset($data); |
491 | - } |
|
491 | + } |
|
492 | + } |
|
492 | 493 | } |
493 | - } |
|
494 | 494 | } else { |
495 | - $format = $value['format']; |
|
496 | - if (isset($tt[$format])) $tt[$format]++; |
|
497 | - else $tt[$format] = 0; |
|
498 | - if ($tt[$format] > 30) { |
|
495 | + $format = $value['format']; |
|
496 | + if (isset($tt[$format])) $tt[$format]++; |
|
497 | + else $tt[$format] = 0; |
|
498 | + if ($tt[$format] > 30) { |
|
499 | 499 | if ($globalDebug) echo 'Reconnect...'."\n"; |
500 | 500 | sleep(2); |
501 | 501 | $sourceeen[] = $value; |
502 | 502 | connect_all($sourceeen); |
503 | 503 | $sourceeen = array(); |
504 | - } |
|
504 | + } |
|
505 | + } |
|
505 | 506 | } |
506 | - } |
|
507 | 507 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
508 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
509 | - if ($buffer != '') { |
|
508 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
509 | + if ($buffer != '') { |
|
510 | 510 | //echo $buffer; |
511 | 511 | $all_data = json_decode($buffer,true); |
512 | 512 | //print_r($all_data); |
513 | 513 | if (isset($all_data[0]['DATA'])) { |
514 | - foreach ($all_data[0]['DATA'] as $line) { |
|
514 | + foreach ($all_data[0]['DATA'] as $line) { |
|
515 | 515 | if ($line != '') { |
516 | - $data = array(); |
|
517 | - $data['ident'] = $line['NAME']; |
|
518 | - $data['mmsi'] = $line['MMSI']; |
|
519 | - $data['speed'] = $line['SOG']; |
|
520 | - $data['heading'] = $line['COG']; |
|
521 | - $data['latitude'] = $line['LAT']; |
|
522 | - $data['longitude'] = $line['LNG']; |
|
523 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
524 | - $data['imo'] = $line['IMO']; |
|
525 | - //$data['arrival_code'] = $ais_data['destination']; |
|
526 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
527 | - $data['format_source'] = 'myshiptracking'; |
|
528 | - $data['id_source'] = $id_source; |
|
529 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
530 | - $MI->add($data); |
|
531 | - unset($data); |
|
516 | + $data = array(); |
|
517 | + $data['ident'] = $line['NAME']; |
|
518 | + $data['mmsi'] = $line['MMSI']; |
|
519 | + $data['speed'] = $line['SOG']; |
|
520 | + $data['heading'] = $line['COG']; |
|
521 | + $data['latitude'] = $line['LAT']; |
|
522 | + $data['longitude'] = $line['LNG']; |
|
523 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
524 | + $data['imo'] = $line['IMO']; |
|
525 | + //$data['arrival_code'] = $ais_data['destination']; |
|
526 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
527 | + $data['format_source'] = 'myshiptracking'; |
|
528 | + $data['id_source'] = $id_source; |
|
529 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
530 | + $MI->add($data); |
|
531 | + unset($data); |
|
532 | + } |
|
532 | 533 | } |
533 | - } |
|
534 | 534 | } |
535 | - } |
|
536 | - $last_exec[$id]['last'] = time(); |
|
535 | + } |
|
536 | + $last_exec[$id]['last'] = time(); |
|
537 | 537 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
538 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
539 | - if ($buffer != '') { |
|
538 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
539 | + if ($buffer != '') { |
|
540 | 540 | $all_data = json_decode($buffer,true); |
541 | 541 | if (isset($all_data[0]['mmsi'])) { |
542 | - foreach ($all_data as $line) { |
|
542 | + foreach ($all_data as $line) { |
|
543 | 543 | if ($line != '') { |
544 | - $data = array(); |
|
545 | - $data['ident'] = $line['shipname']; |
|
546 | - $data['callsign'] = $line['callsign']; |
|
547 | - $data['mmsi'] = $line['mmsi']; |
|
548 | - $data['speed'] = $line['sog']; |
|
549 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
550 | - $data['latitude'] = $line['latitude']; |
|
551 | - $data['longitude'] = $line['longitude']; |
|
552 | - $data['type_id'] = $line['shiptype']; |
|
553 | - $data['arrival_code'] = $line['destination']; |
|
554 | - $data['datetime'] = $line['time']; |
|
555 | - $data['format_source'] = 'boatbeaconapp'; |
|
556 | - $data['id_source'] = $id_source; |
|
557 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
558 | - $MI->add($data); |
|
559 | - unset($data); |
|
544 | + $data = array(); |
|
545 | + $data['ident'] = $line['shipname']; |
|
546 | + $data['callsign'] = $line['callsign']; |
|
547 | + $data['mmsi'] = $line['mmsi']; |
|
548 | + $data['speed'] = $line['sog']; |
|
549 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
550 | + $data['latitude'] = $line['latitude']; |
|
551 | + $data['longitude'] = $line['longitude']; |
|
552 | + $data['type_id'] = $line['shiptype']; |
|
553 | + $data['arrival_code'] = $line['destination']; |
|
554 | + $data['datetime'] = $line['time']; |
|
555 | + $data['format_source'] = 'boatbeaconapp'; |
|
556 | + $data['id_source'] = $id_source; |
|
557 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
558 | + $MI->add($data); |
|
559 | + unset($data); |
|
560 | + } |
|
560 | 561 | } |
561 | - } |
|
562 | 562 | } |
563 | 563 | |
564 | - } |
|
565 | - $last_exec[$id]['last'] = time(); |
|
564 | + } |
|
565 | + $last_exec[$id]['last'] = time(); |
|
566 | 566 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
567 | - $buffer = $Common->getData($value['host']); |
|
568 | - if ($buffer != '') { |
|
567 | + $buffer = $Common->getData($value['host']); |
|
568 | + if ($buffer != '') { |
|
569 | 569 | $all_data = json_decode($buffer,true); |
570 | 570 | if (isset($all_data['features'][0]['id'])) { |
571 | - foreach ($all_data['features'] as $line) { |
|
571 | + foreach ($all_data['features'] as $line) { |
|
572 | 572 | $data = array(); |
573 | 573 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
574 | 574 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -587,59 +587,59 @@ discard block |
||
587 | 587 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
588 | 588 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
589 | 589 | unset($data); |
590 | - } |
|
590 | + } |
|
591 | 591 | } |
592 | 592 | |
593 | - } |
|
594 | - $last_exec[$id]['last'] = time(); |
|
593 | + } |
|
594 | + $last_exec[$id]['last'] = time(); |
|
595 | 595 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
596 | - echo 'download...'; |
|
597 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
598 | - echo 'done !'."\n"; |
|
599 | - if ($buffer != '') $reset = 0; |
|
600 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
601 | - $buffer = explode('\n',$buffer); |
|
602 | - foreach ($buffer as $line) { |
|
596 | + echo 'download...'; |
|
597 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
598 | + echo 'done !'."\n"; |
|
599 | + if ($buffer != '') $reset = 0; |
|
600 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
601 | + $buffer = explode('\n',$buffer); |
|
602 | + foreach ($buffer as $line) { |
|
603 | 603 | if ($line != '') { |
604 | - $data = array(); |
|
605 | - $data['mmsi'] = (int)substr($line,0,9); |
|
606 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
607 | - //$data['status'] = substr($line,21,2); |
|
608 | - //$data['type'] = substr($line,24,3); |
|
609 | - $data['latitude'] = substr($line,29,9); |
|
610 | - $data['longitude'] = substr($line,41,9); |
|
611 | - $data['speed'] = round(substr($line,51,5)); |
|
612 | - //$data['course'] = substr($line,57,5); |
|
613 | - $data['heading'] = round(substr($line,63,3)); |
|
614 | - //$data['draft'] = substr($line,67,4); |
|
615 | - //$data['length'] = substr($line,72,3); |
|
616 | - //$data['beam'] = substr($line,76,2); |
|
617 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
618 | - //$data['callsign'] = trim(substr($line,100,7); |
|
619 | - //$data['dest'] = substr($line,108,20); |
|
620 | - //$data['etaDate'] = substr($line,129,5); |
|
621 | - //$data['etaTime'] = substr($line,135,5); |
|
622 | - $data['format_source'] = 'shipplotter'; |
|
623 | - $data['id_source'] = $id_source; |
|
624 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
625 | - //print_r($data); |
|
626 | - echo 'Add...'."\n"; |
|
627 | - $MI->add($data); |
|
628 | - unset($data); |
|
604 | + $data = array(); |
|
605 | + $data['mmsi'] = (int)substr($line,0,9); |
|
606 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
607 | + //$data['status'] = substr($line,21,2); |
|
608 | + //$data['type'] = substr($line,24,3); |
|
609 | + $data['latitude'] = substr($line,29,9); |
|
610 | + $data['longitude'] = substr($line,41,9); |
|
611 | + $data['speed'] = round(substr($line,51,5)); |
|
612 | + //$data['course'] = substr($line,57,5); |
|
613 | + $data['heading'] = round(substr($line,63,3)); |
|
614 | + //$data['draft'] = substr($line,67,4); |
|
615 | + //$data['length'] = substr($line,72,3); |
|
616 | + //$data['beam'] = substr($line,76,2); |
|
617 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
618 | + //$data['callsign'] = trim(substr($line,100,7); |
|
619 | + //$data['dest'] = substr($line,108,20); |
|
620 | + //$data['etaDate'] = substr($line,129,5); |
|
621 | + //$data['etaTime'] = substr($line,135,5); |
|
622 | + $data['format_source'] = 'shipplotter'; |
|
623 | + $data['id_source'] = $id_source; |
|
624 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
625 | + //print_r($data); |
|
626 | + echo 'Add...'."\n"; |
|
627 | + $MI->add($data); |
|
628 | + unset($data); |
|
629 | 629 | } |
630 | - } |
|
631 | - $last_exec[$id]['last'] = time(); |
|
630 | + } |
|
631 | + $last_exec[$id]['last'] = time(); |
|
632 | 632 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
633 | 633 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
634 | - //$buffer = $Common->getData($hosts[$id]); |
|
635 | - $buffer = $Common->getData($value['host']); |
|
636 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
637 | - $buffer = explode('\n',$buffer); |
|
638 | - $reset = 0; |
|
639 | - foreach ($buffer as $line) { |
|
640 | - if ($line != '') { |
|
641 | - $line = explode(':', $line); |
|
642 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
634 | + //$buffer = $Common->getData($hosts[$id]); |
|
635 | + $buffer = $Common->getData($value['host']); |
|
636 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
637 | + $buffer = explode('\n',$buffer); |
|
638 | + $reset = 0; |
|
639 | + foreach ($buffer as $line) { |
|
640 | + if ($line != '') { |
|
641 | + $line = explode(':', $line); |
|
642 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
643 | 643 | $data = array(); |
644 | 644 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
645 | 645 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -652,37 +652,37 @@ discard block |
||
652 | 652 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
653 | 653 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
654 | 654 | $data['latitude'] = $line[5]; // lat |
655 | - $data['longitude'] = $line[6]; // long |
|
656 | - $data['verticalrate'] = ''; // vertical rate |
|
657 | - $data['squawk'] = ''; // squawk |
|
658 | - $data['emergency'] = ''; // emergency |
|
659 | - $data['waypoints'] = $line[30]; |
|
655 | + $data['longitude'] = $line[6]; // long |
|
656 | + $data['verticalrate'] = ''; // vertical rate |
|
657 | + $data['squawk'] = ''; // squawk |
|
658 | + $data['emergency'] = ''; // emergency |
|
659 | + $data['waypoints'] = $line[30]; |
|
660 | 660 | $data['datetime'] = date('Y-m-d H:i:s'); |
661 | 661 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
662 | 662 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
663 | - $data['departure_airport_icao'] = $line[11]; |
|
664 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
665 | - $data['arrival_airport_icao'] = $line[13]; |
|
663 | + $data['departure_airport_icao'] = $line[11]; |
|
664 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
665 | + $data['arrival_airport_icao'] = $line[13]; |
|
666 | 666 | $data['frequency'] = $line[4]; |
667 | 667 | $data['type'] = $line[18]; |
668 | 668 | $data['range'] = $line[19]; |
669 | 669 | if (isset($line[35])) $data['info'] = $line[35]; |
670 | - $data['id_source'] = $id_source; |
|
671 | - //$data['arrival_airport_time'] = ; |
|
672 | - if ($line[9] != '') { |
|
673 | - $aircraft_data = explode('/',$line[9]); |
|
674 | - if (isset($aircraft_data[1])) { |
|
675 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
676 | - } |
|
677 | - } |
|
678 | - /* |
|
670 | + $data['id_source'] = $id_source; |
|
671 | + //$data['arrival_airport_time'] = ; |
|
672 | + if ($line[9] != '') { |
|
673 | + $aircraft_data = explode('/',$line[9]); |
|
674 | + if (isset($aircraft_data[1])) { |
|
675 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
676 | + } |
|
677 | + } |
|
678 | + /* |
|
679 | 679 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
680 | 680 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
681 | 681 | */ |
682 | - $data['format_source'] = $value['format']; |
|
682 | + $data['format_source'] = $value['format']; |
|
683 | 683 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
684 | 684 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
685 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
685 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
686 | 686 | elseif ($line[3] == 'ATC') { |
687 | 687 | //print_r($data); |
688 | 688 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -703,16 +703,16 @@ discard block |
||
703 | 703 | 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']); |
704 | 704 | } |
705 | 705 | } |
706 | - unset($data); |
|
707 | - } |
|
708 | - } |
|
709 | - } |
|
710 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
711 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
712 | - $last_exec[$id]['last'] = time(); |
|
713 | - } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
714 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
715 | - if ($buffer != '') { |
|
706 | + unset($data); |
|
707 | + } |
|
708 | + } |
|
709 | + } |
|
710 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
711 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
712 | + $last_exec[$id]['last'] = time(); |
|
713 | + } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
714 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
715 | + if ($buffer != '') { |
|
716 | 716 | $all_data = simplexml_load_string($buffer); |
717 | 717 | foreach($all_data->children() as $childdata) { |
718 | 718 | $data = array(); |
@@ -734,10 +734,10 @@ discard block |
||
734 | 734 | $SI->add($data); |
735 | 735 | unset($data); |
736 | 736 | } |
737 | - } |
|
738 | - $Source->deleteOldLocationByType('gs'); |
|
739 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
740 | - if ($buffer != '') { |
|
737 | + } |
|
738 | + $Source->deleteOldLocationByType('gs'); |
|
739 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
740 | + if ($buffer != '') { |
|
741 | 741 | $all_data = simplexml_load_string($buffer); |
742 | 742 | foreach($all_data->children() as $childdata) { |
743 | 743 | $data = array(); |
@@ -755,249 +755,249 @@ discard block |
||
755 | 755 | } |
756 | 756 | unset($data); |
757 | 757 | } |
758 | - } |
|
759 | - $last_exec[$id]['last'] = time(); |
|
758 | + } |
|
759 | + $last_exec[$id]['last'] = time(); |
|
760 | 760 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
761 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
762 | - if ($buffer != '') { |
|
763 | - $all_data = json_decode($buffer,true); |
|
764 | - if (isset($all_data['acList'])) { |
|
761 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
762 | + if ($buffer != '') { |
|
763 | + $all_data = json_decode($buffer,true); |
|
764 | + if (isset($all_data['acList'])) { |
|
765 | 765 | $reset = 0; |
766 | 766 | foreach ($all_data['acList'] as $line) { |
767 | - $data = array(); |
|
768 | - $data['hex'] = $line['Icao']; // hex |
|
769 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
770 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
771 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
772 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
773 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
774 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
775 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
776 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
777 | - $data['emergency'] = ''; // emergency |
|
778 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
767 | + $data = array(); |
|
768 | + $data['hex'] = $line['Icao']; // hex |
|
769 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
770 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
771 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
772 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
773 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
774 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
775 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
776 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
777 | + $data['emergency'] = ''; // emergency |
|
778 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
779 | 779 | |
780 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
781 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
780 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
781 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
782 | 782 | |
783 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
784 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
785 | - $data['format_source'] = 'aircraftlistjson'; |
|
786 | - $data['id_source'] = $id_source; |
|
787 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
788 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
789 | - if (isset($data['latitude'])) $SI->add($data); |
|
790 | - unset($data); |
|
783 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
784 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
785 | + $data['format_source'] = 'aircraftlistjson'; |
|
786 | + $data['id_source'] = $id_source; |
|
787 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
788 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
789 | + if (isset($data['latitude'])) $SI->add($data); |
|
790 | + unset($data); |
|
791 | 791 | } |
792 | - } elseif (is_array($all_data)) { |
|
792 | + } elseif (is_array($all_data)) { |
|
793 | 793 | $reset = 0; |
794 | 794 | foreach ($all_data as $line) { |
795 | - $data = array(); |
|
796 | - $data['hex'] = $line['hex']; // hex |
|
797 | - $data['ident'] = $line['flight']; // ident |
|
798 | - $data['altitude'] = $line['altitude']; // altitude |
|
799 | - $data['speed'] = $line['speed']; // speed |
|
800 | - $data['heading'] = $line['track']; // heading |
|
801 | - $data['latitude'] = $line['lat']; // lat |
|
802 | - $data['longitude'] = $line['lon']; // long |
|
803 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
804 | - $data['squawk'] = $line['squawk']; // squawk |
|
805 | - $data['emergency'] = ''; // emergency |
|
806 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
807 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
808 | - $data['format_source'] = 'aircraftlistjson'; |
|
809 | - $data['id_source'] = $id_source; |
|
810 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
811 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
812 | - $SI->add($data); |
|
813 | - unset($data); |
|
795 | + $data = array(); |
|
796 | + $data['hex'] = $line['hex']; // hex |
|
797 | + $data['ident'] = $line['flight']; // ident |
|
798 | + $data['altitude'] = $line['altitude']; // altitude |
|
799 | + $data['speed'] = $line['speed']; // speed |
|
800 | + $data['heading'] = $line['track']; // heading |
|
801 | + $data['latitude'] = $line['lat']; // lat |
|
802 | + $data['longitude'] = $line['lon']; // long |
|
803 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
804 | + $data['squawk'] = $line['squawk']; // squawk |
|
805 | + $data['emergency'] = ''; // emergency |
|
806 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
807 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
808 | + $data['format_source'] = 'aircraftlistjson'; |
|
809 | + $data['id_source'] = $id_source; |
|
810 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
811 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
812 | + $SI->add($data); |
|
813 | + unset($data); |
|
814 | + } |
|
814 | 815 | } |
815 | - } |
|
816 | - } |
|
817 | - //$last_exec['aircraftlistjson'] = time(); |
|
818 | - $last_exec[$id]['last'] = time(); |
|
819 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
820 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
821 | - $buffer = $Common->getData($value['host']); |
|
822 | - $all_data = json_decode($buffer,true); |
|
823 | - if (isset($all_data['planes'])) { |
|
816 | + } |
|
817 | + //$last_exec['aircraftlistjson'] = time(); |
|
818 | + $last_exec[$id]['last'] = time(); |
|
819 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
820 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
821 | + $buffer = $Common->getData($value['host']); |
|
822 | + $all_data = json_decode($buffer,true); |
|
823 | + if (isset($all_data['planes'])) { |
|
824 | 824 | $reset = 0; |
825 | 825 | foreach ($all_data['planes'] as $key => $line) { |
826 | - $data = array(); |
|
827 | - $data['hex'] = $key; // hex |
|
828 | - $data['ident'] = $line[3]; // ident |
|
829 | - $data['altitude'] = $line[6]; // altitude |
|
830 | - $data['speed'] = $line[8]; // speed |
|
831 | - $data['heading'] = $line[7]; // heading |
|
832 | - $data['latitude'] = $line[4]; // lat |
|
833 | - $data['longitude'] = $line[5]; // long |
|
834 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
835 | - $data['squawk'] = $line[10]; // squawk |
|
836 | - $data['emergency'] = ''; // emergency |
|
837 | - $data['registration'] = $line[2]; |
|
838 | - $data['aircraft_icao'] = $line[0]; |
|
839 | - $deparr = explode('-',$line[1]); |
|
840 | - if (count($deparr) == 2) { |
|
826 | + $data = array(); |
|
827 | + $data['hex'] = $key; // hex |
|
828 | + $data['ident'] = $line[3]; // ident |
|
829 | + $data['altitude'] = $line[6]; // altitude |
|
830 | + $data['speed'] = $line[8]; // speed |
|
831 | + $data['heading'] = $line[7]; // heading |
|
832 | + $data['latitude'] = $line[4]; // lat |
|
833 | + $data['longitude'] = $line[5]; // long |
|
834 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
835 | + $data['squawk'] = $line[10]; // squawk |
|
836 | + $data['emergency'] = ''; // emergency |
|
837 | + $data['registration'] = $line[2]; |
|
838 | + $data['aircraft_icao'] = $line[0]; |
|
839 | + $deparr = explode('-',$line[1]); |
|
840 | + if (count($deparr) == 2) { |
|
841 | 841 | $data['departure_airport_icao'] = $deparr[0]; |
842 | 842 | $data['arrival_airport_icao'] = $deparr[1]; |
843 | - } |
|
844 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
845 | - $data['format_source'] = 'planeupdatefaa'; |
|
846 | - $data['id_source'] = $id_source; |
|
847 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
848 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
849 | - $SI->add($data); |
|
850 | - unset($data); |
|
843 | + } |
|
844 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
845 | + $data['format_source'] = 'planeupdatefaa'; |
|
846 | + $data['id_source'] = $id_source; |
|
847 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
848 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
849 | + $SI->add($data); |
|
850 | + unset($data); |
|
851 | 851 | } |
852 | - } |
|
853 | - //$last_exec['planeupdatefaa'] = time(); |
|
854 | - $last_exec[$id]['last'] = time(); |
|
855 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
856 | - $buffer = $Common->getData($value['host']); |
|
857 | - $all_data = json_decode($buffer,true); |
|
858 | - if (isset($all_data['states'])) { |
|
852 | + } |
|
853 | + //$last_exec['planeupdatefaa'] = time(); |
|
854 | + $last_exec[$id]['last'] = time(); |
|
855 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
856 | + $buffer = $Common->getData($value['host']); |
|
857 | + $all_data = json_decode($buffer,true); |
|
858 | + if (isset($all_data['states'])) { |
|
859 | 859 | $reset = 0; |
860 | 860 | foreach ($all_data['states'] as $key => $line) { |
861 | - $data = array(); |
|
862 | - $data['hex'] = $line[0]; // hex |
|
863 | - $data['ident'] = trim($line[1]); // ident |
|
864 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
865 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
866 | - $data['heading'] = round($line[10]); // heading |
|
867 | - $data['latitude'] = $line[6]; // lat |
|
868 | - $data['longitude'] = $line[5]; // long |
|
869 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
870 | - //$data['squawk'] = $line[10]; // squawk |
|
871 | - //$data['emergency'] = ''; // emergency |
|
872 | - //$data['registration'] = $line[2]; |
|
873 | - //$data['aircraft_icao'] = $line[0]; |
|
874 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
875 | - $data['format_source'] = 'opensky'; |
|
876 | - $data['id_source'] = $id_source; |
|
877 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
878 | - $SI->add($data); |
|
879 | - unset($data); |
|
861 | + $data = array(); |
|
862 | + $data['hex'] = $line[0]; // hex |
|
863 | + $data['ident'] = trim($line[1]); // ident |
|
864 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
865 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
866 | + $data['heading'] = round($line[10]); // heading |
|
867 | + $data['latitude'] = $line[6]; // lat |
|
868 | + $data['longitude'] = $line[5]; // long |
|
869 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
870 | + //$data['squawk'] = $line[10]; // squawk |
|
871 | + //$data['emergency'] = ''; // emergency |
|
872 | + //$data['registration'] = $line[2]; |
|
873 | + //$data['aircraft_icao'] = $line[0]; |
|
874 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
875 | + $data['format_source'] = 'opensky'; |
|
876 | + $data['id_source'] = $id_source; |
|
877 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
878 | + $SI->add($data); |
|
879 | + unset($data); |
|
880 | + } |
|
880 | 881 | } |
881 | - } |
|
882 | - //$last_exec['planeupdatefaa'] = time(); |
|
883 | - $last_exec[$id]['last'] = time(); |
|
884 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
885 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
886 | - //$buffer = $Common->getData($hosts[$id]); |
|
887 | - $buffer = $Common->getData($value['host']); |
|
888 | - $all_data = json_decode($buffer,true); |
|
889 | - if (!empty($all_data)) $reset = 0; |
|
890 | - foreach ($all_data as $key => $line) { |
|
882 | + //$last_exec['planeupdatefaa'] = time(); |
|
883 | + $last_exec[$id]['last'] = time(); |
|
884 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
885 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
886 | + //$buffer = $Common->getData($hosts[$id]); |
|
887 | + $buffer = $Common->getData($value['host']); |
|
888 | + $all_data = json_decode($buffer,true); |
|
889 | + if (!empty($all_data)) $reset = 0; |
|
890 | + foreach ($all_data as $key => $line) { |
|
891 | 891 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
892 | - $data = array(); |
|
893 | - $data['hex'] = $line[0]; |
|
894 | - $data['ident'] = $line[16]; //$line[13] |
|
895 | - $data['altitude'] = $line[4]; // altitude |
|
896 | - $data['speed'] = $line[5]; // speed |
|
897 | - $data['heading'] = $line[3]; // heading |
|
898 | - $data['latitude'] = $line[1]; // lat |
|
899 | - $data['longitude'] = $line[2]; // long |
|
900 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
901 | - $data['squawk'] = $line[6]; // squawk |
|
902 | - $data['aircraft_icao'] = $line[8]; |
|
903 | - $data['registration'] = $line[9]; |
|
904 | - $data['departure_airport_iata'] = $line[11]; |
|
905 | - $data['arrival_airport_iata'] = $line[12]; |
|
906 | - $data['emergency'] = ''; // emergency |
|
907 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
908 | - $data['format_source'] = 'fr24json'; |
|
909 | - $data['id_source'] = $id_source; |
|
910 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
911 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
912 | - $SI->add($data); |
|
913 | - unset($data); |
|
892 | + $data = array(); |
|
893 | + $data['hex'] = $line[0]; |
|
894 | + $data['ident'] = $line[16]; //$line[13] |
|
895 | + $data['altitude'] = $line[4]; // altitude |
|
896 | + $data['speed'] = $line[5]; // speed |
|
897 | + $data['heading'] = $line[3]; // heading |
|
898 | + $data['latitude'] = $line[1]; // lat |
|
899 | + $data['longitude'] = $line[2]; // long |
|
900 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
901 | + $data['squawk'] = $line[6]; // squawk |
|
902 | + $data['aircraft_icao'] = $line[8]; |
|
903 | + $data['registration'] = $line[9]; |
|
904 | + $data['departure_airport_iata'] = $line[11]; |
|
905 | + $data['arrival_airport_iata'] = $line[12]; |
|
906 | + $data['emergency'] = ''; // emergency |
|
907 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
908 | + $data['format_source'] = 'fr24json'; |
|
909 | + $data['id_source'] = $id_source; |
|
910 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
911 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
912 | + $SI->add($data); |
|
913 | + unset($data); |
|
914 | 914 | } |
915 | - } |
|
916 | - //$last_exec['fr24json'] = time(); |
|
917 | - $last_exec[$id]['last'] = time(); |
|
918 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
919 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
920 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
921 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
922 | - //echo $buffer; |
|
923 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
924 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
925 | - $all_data = json_decode($buffer,true); |
|
926 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
915 | + } |
|
916 | + //$last_exec['fr24json'] = time(); |
|
917 | + $last_exec[$id]['last'] = time(); |
|
918 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
919 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
920 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
921 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
922 | + //echo $buffer; |
|
923 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
924 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
925 | + $all_data = json_decode($buffer,true); |
|
926 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
927 | 927 | die(json_last_error_msg()); |
928 | - } |
|
929 | - if (isset($all_data['mrkrs'])) { |
|
928 | + } |
|
929 | + if (isset($all_data['mrkrs'])) { |
|
930 | 930 | $reset = 0; |
931 | 931 | foreach ($all_data['mrkrs'] as $key => $line) { |
932 | - if (isset($line['inf'])) { |
|
932 | + if (isset($line['inf'])) { |
|
933 | 933 | $data = array(); |
934 | 934 | $data['hex'] = $line['inf']['ia']; |
935 | 935 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
936 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
937 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
938 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
939 | - $data['latitude'] = $line['pt'][0]; // lat |
|
940 | - $data['longitude'] = $line['pt'][1]; // long |
|
941 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
942 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
943 | - //$data['aircraft_icao'] = $line[8]; |
|
944 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
936 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
937 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
938 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
939 | + $data['latitude'] = $line['pt'][0]; // lat |
|
940 | + $data['longitude'] = $line['pt'][1]; // long |
|
941 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
942 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
943 | + //$data['aircraft_icao'] = $line[8]; |
|
944 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
945 | 945 | //$data['departure_airport_iata'] = $line[11]; |
946 | 946 | //$data['arrival_airport_iata'] = $line[12]; |
947 | - //$data['emergency'] = ''; // emergency |
|
947 | + //$data['emergency'] = ''; // emergency |
|
948 | 948 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
949 | - $data['format_source'] = 'radarvirtueljson'; |
|
950 | - $data['id_source'] = $id_source; |
|
949 | + $data['format_source'] = 'radarvirtueljson'; |
|
950 | + $data['id_source'] = $id_source; |
|
951 | 951 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
952 | 952 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
953 | 953 | $SI->add($data); |
954 | 954 | unset($data); |
955 | - } |
|
955 | + } |
|
956 | + } |
|
956 | 957 | } |
957 | - } |
|
958 | - //$last_exec['radarvirtueljson'] = time(); |
|
959 | - $last_exec[$id]['last'] = time(); |
|
960 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
961 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
962 | - //$buffer = $Common->getData($hosts[$id]); |
|
963 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
964 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
958 | + //$last_exec['radarvirtueljson'] = time(); |
|
959 | + $last_exec[$id]['last'] = time(); |
|
960 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
961 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
962 | + //$buffer = $Common->getData($hosts[$id]); |
|
963 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
964 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
965 | 965 | |
966 | - if (isset($all_data['pireps'])) { |
|
966 | + if (isset($all_data['pireps'])) { |
|
967 | 967 | $reset = 0; |
968 | - foreach ($all_data['pireps'] as $line) { |
|
969 | - $data = array(); |
|
970 | - $data['id'] = $line['id']; |
|
971 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
972 | - $data['ident'] = $line['callsign']; // ident |
|
973 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
974 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
975 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
976 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
977 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
978 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
979 | - $data['latitude'] = $line['lat']; // lat |
|
980 | - $data['longitude'] = $line['lon']; // long |
|
981 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
982 | - //$data['squawk'] = $line['squawk']; // squawk |
|
983 | - //$data['emergency'] = ''; // emergency |
|
984 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
985 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
986 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
987 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
988 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
989 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
990 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
991 | - else $data['info'] = ''; |
|
992 | - $data['format_source'] = 'pireps'; |
|
993 | - $data['id_source'] = $id_source; |
|
994 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
995 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
996 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
997 | - if ($line['icon'] == 'plane') { |
|
968 | + foreach ($all_data['pireps'] as $line) { |
|
969 | + $data = array(); |
|
970 | + $data['id'] = $line['id']; |
|
971 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
972 | + $data['ident'] = $line['callsign']; // ident |
|
973 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
974 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
975 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
976 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
977 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
978 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
979 | + $data['latitude'] = $line['lat']; // lat |
|
980 | + $data['longitude'] = $line['lon']; // long |
|
981 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
982 | + //$data['squawk'] = $line['squawk']; // squawk |
|
983 | + //$data['emergency'] = ''; // emergency |
|
984 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
985 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
986 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
987 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
988 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
989 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
990 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
991 | + else $data['info'] = ''; |
|
992 | + $data['format_source'] = 'pireps'; |
|
993 | + $data['id_source'] = $id_source; |
|
994 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
995 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
996 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
997 | + if ($line['icon'] == 'plane') { |
|
998 | 998 | $SI->add($data); |
999 | - // print_r($data); |
|
1000 | - } elseif ($line['icon'] == 'ct') { |
|
999 | + // print_r($data); |
|
1000 | + } elseif ($line['icon'] == 'ct') { |
|
1001 | 1001 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1002 | 1002 | $data['info'] = str_replace('&sect;','',$data['info']); |
1003 | 1003 | $typec = substr($data['ident'],-3); |
@@ -1012,203 +1012,203 @@ discard block |
||
1012 | 1012 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1013 | 1013 | else $data['type'] = 'Observer'; |
1014 | 1014 | 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']); |
1015 | - } |
|
1016 | - unset($data); |
|
1015 | + } |
|
1016 | + unset($data); |
|
1017 | + } |
|
1017 | 1018 | } |
1018 | - } |
|
1019 | - //$last_exec['pirepsjson'] = time(); |
|
1020 | - $last_exec[$id]['last'] = time(); |
|
1021 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
1022 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1023 | - //$buffer = $Common->getData($hosts[$id]); |
|
1024 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1025 | - $buffer = $Common->getData($value['host']); |
|
1026 | - $all_data = json_decode($buffer,true); |
|
1027 | - if ($buffer != '' && is_array($all_data)) { |
|
1019 | + //$last_exec['pirepsjson'] = time(); |
|
1020 | + $last_exec[$id]['last'] = time(); |
|
1021 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
1022 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1023 | + //$buffer = $Common->getData($hosts[$id]); |
|
1024 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1025 | + $buffer = $Common->getData($value['host']); |
|
1026 | + $all_data = json_decode($buffer,true); |
|
1027 | + if ($buffer != '' && is_array($all_data)) { |
|
1028 | 1028 | $reset = 0; |
1029 | 1029 | foreach ($all_data as $line) { |
1030 | - $data = array(); |
|
1031 | - //$data['id'] = $line['id']; // id not usable |
|
1032 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1033 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1034 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1035 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1036 | - $data['ident'] = $line['flightnum']; // ident |
|
1037 | - $data['altitude'] = $line['alt']; // altitude |
|
1038 | - $data['speed'] = $line['gs']; // speed |
|
1039 | - $data['heading'] = $line['heading']; // heading |
|
1040 | - $data['latitude'] = $line['lat']; // lat |
|
1041 | - $data['longitude'] = $line['lng']; // long |
|
1042 | - $data['verticalrate'] = ''; // verticale rate |
|
1043 | - $data['squawk'] = ''; // squawk |
|
1044 | - $data['emergency'] = ''; // emergency |
|
1045 | - //$data['datetime'] = $line['lastupdate']; |
|
1046 | - //$data['last_update'] = $line['lastupdate']; |
|
1047 | - if (isset($value['timezone'])) { |
|
1048 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1049 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1050 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1051 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1052 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1053 | - $data['departure_airport_time'] = $line['deptime']; |
|
1054 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1055 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1056 | - $data['registration'] = $line['aircraft']; |
|
1057 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1058 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1059 | - if (isset($line['aircraftname'])) { |
|
1030 | + $data = array(); |
|
1031 | + //$data['id'] = $line['id']; // id not usable |
|
1032 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1033 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1034 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1035 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1036 | + $data['ident'] = $line['flightnum']; // ident |
|
1037 | + $data['altitude'] = $line['alt']; // altitude |
|
1038 | + $data['speed'] = $line['gs']; // speed |
|
1039 | + $data['heading'] = $line['heading']; // heading |
|
1040 | + $data['latitude'] = $line['lat']; // lat |
|
1041 | + $data['longitude'] = $line['lng']; // long |
|
1042 | + $data['verticalrate'] = ''; // verticale rate |
|
1043 | + $data['squawk'] = ''; // squawk |
|
1044 | + $data['emergency'] = ''; // emergency |
|
1045 | + //$data['datetime'] = $line['lastupdate']; |
|
1046 | + //$data['last_update'] = $line['lastupdate']; |
|
1047 | + if (isset($value['timezone'])) { |
|
1048 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1049 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1050 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1051 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1052 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1053 | + $data['departure_airport_time'] = $line['deptime']; |
|
1054 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1055 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1056 | + $data['registration'] = $line['aircraft']; |
|
1057 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1058 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1059 | + if (isset($line['aircraftname'])) { |
|
1060 | 1060 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1061 | 1061 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1062 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1063 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1064 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1065 | - else { |
|
1066 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1067 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1068 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1069 | - } |
|
1070 | - } |
|
1071 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1072 | - $data['id_source'] = $id_source; |
|
1073 | - $data['format_source'] = 'phpvmacars'; |
|
1074 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1075 | - $SI->add($data); |
|
1076 | - unset($data); |
|
1062 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1063 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1064 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1065 | + else { |
|
1066 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1067 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1068 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1069 | + } |
|
1070 | + } |
|
1071 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1072 | + $data['id_source'] = $id_source; |
|
1073 | + $data['format_source'] = 'phpvmacars'; |
|
1074 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1075 | + $SI->add($data); |
|
1076 | + unset($data); |
|
1077 | 1077 | } |
1078 | 1078 | if ($globalDebug) echo 'No more data...'."\n"; |
1079 | 1079 | unset($buffer); |
1080 | 1080 | unset($all_data); |
1081 | - } |
|
1082 | - //$last_exec['phpvmacars'] = time(); |
|
1083 | - $last_exec[$id]['last'] = time(); |
|
1084 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1085 | - //$buffer = $Common->getData($hosts[$id]); |
|
1086 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1087 | - $buffer = $Common->getData($value['host']); |
|
1088 | - $all_data = json_decode($buffer,true); |
|
1089 | - if ($buffer != '' && is_array($all_data)) { |
|
1081 | + } |
|
1082 | + //$last_exec['phpvmacars'] = time(); |
|
1083 | + $last_exec[$id]['last'] = time(); |
|
1084 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1085 | + //$buffer = $Common->getData($hosts[$id]); |
|
1086 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1087 | + $buffer = $Common->getData($value['host']); |
|
1088 | + $all_data = json_decode($buffer,true); |
|
1089 | + if ($buffer != '' && is_array($all_data)) { |
|
1090 | 1090 | $reset = 0; |
1091 | 1091 | foreach ($all_data as $line) { |
1092 | - $data = array(); |
|
1093 | - //$data['id'] = $line['id']; // id not usable |
|
1094 | - $data['id'] = trim($line['flight_id']); |
|
1095 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1096 | - $data['pilot_name'] = $line['pilot_name']; |
|
1097 | - $data['pilot_id'] = $line['pilot_id']; |
|
1098 | - $data['ident'] = trim($line['callsign']); // ident |
|
1099 | - $data['altitude'] = $line['altitude']; // altitude |
|
1100 | - $data['speed'] = $line['gs']; // speed |
|
1101 | - $data['heading'] = $line['heading']; // heading |
|
1102 | - $data['latitude'] = $line['latitude']; // lat |
|
1103 | - $data['longitude'] = $line['longitude']; // long |
|
1104 | - $data['verticalrate'] = ''; // verticale rate |
|
1105 | - $data['squawk'] = ''; // squawk |
|
1106 | - $data['emergency'] = ''; // emergency |
|
1107 | - //$data['datetime'] = $line['lastupdate']; |
|
1108 | - $data['last_update'] = $line['last_update']; |
|
1109 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1110 | - $data['departure_airport_icao'] = $line['departure']; |
|
1111 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1112 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1113 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1114 | - //$data['registration'] = $line['aircraft']; |
|
1115 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1116 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1117 | - $data['id_source'] = $id_source; |
|
1118 | - $data['format_source'] = 'vam'; |
|
1119 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1120 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1121 | - $SI->add($data); |
|
1122 | - unset($data); |
|
1092 | + $data = array(); |
|
1093 | + //$data['id'] = $line['id']; // id not usable |
|
1094 | + $data['id'] = trim($line['flight_id']); |
|
1095 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1096 | + $data['pilot_name'] = $line['pilot_name']; |
|
1097 | + $data['pilot_id'] = $line['pilot_id']; |
|
1098 | + $data['ident'] = trim($line['callsign']); // ident |
|
1099 | + $data['altitude'] = $line['altitude']; // altitude |
|
1100 | + $data['speed'] = $line['gs']; // speed |
|
1101 | + $data['heading'] = $line['heading']; // heading |
|
1102 | + $data['latitude'] = $line['latitude']; // lat |
|
1103 | + $data['longitude'] = $line['longitude']; // long |
|
1104 | + $data['verticalrate'] = ''; // verticale rate |
|
1105 | + $data['squawk'] = ''; // squawk |
|
1106 | + $data['emergency'] = ''; // emergency |
|
1107 | + //$data['datetime'] = $line['lastupdate']; |
|
1108 | + $data['last_update'] = $line['last_update']; |
|
1109 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1110 | + $data['departure_airport_icao'] = $line['departure']; |
|
1111 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1112 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1113 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1114 | + //$data['registration'] = $line['aircraft']; |
|
1115 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1116 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1117 | + $data['id_source'] = $id_source; |
|
1118 | + $data['format_source'] = 'vam'; |
|
1119 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1120 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1121 | + $SI->add($data); |
|
1122 | + unset($data); |
|
1123 | 1123 | } |
1124 | 1124 | if ($globalDebug) echo 'No more data...'."\n"; |
1125 | 1125 | unset($buffer); |
1126 | 1126 | unset($all_data); |
1127 | - } |
|
1128 | - //$last_exec['phpvmacars'] = time(); |
|
1129 | - $last_exec[$id]['last'] = time(); |
|
1127 | + } |
|
1128 | + //$last_exec['phpvmacars'] = time(); |
|
1129 | + $last_exec[$id]['last'] = time(); |
|
1130 | 1130 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1131 | 1131 | } 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') { |
1132 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1133 | - //$last_exec[$id]['last'] = time(); |
|
1132 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1133 | + //$last_exec[$id]['last'] = time(); |
|
1134 | 1134 | |
1135 | - //$read = array( $sockets[$id] ); |
|
1136 | - $read = $sockets; |
|
1137 | - $write = NULL; |
|
1138 | - $e = NULL; |
|
1139 | - $n = socket_select($read, $write, $e, $timeout); |
|
1140 | - if ($e != NULL) var_dump($e); |
|
1141 | - if ($n > 0) { |
|
1135 | + //$read = array( $sockets[$id] ); |
|
1136 | + $read = $sockets; |
|
1137 | + $write = NULL; |
|
1138 | + $e = NULL; |
|
1139 | + $n = socket_select($read, $write, $e, $timeout); |
|
1140 | + if ($e != NULL) var_dump($e); |
|
1141 | + if ($n > 0) { |
|
1142 | 1142 | $reset = 0; |
1143 | 1143 | foreach ($read as $nb => $r) { |
1144 | - //$value = $formats[$nb]; |
|
1145 | - $format = $globalSources[$nb]['format']; |
|
1146 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1144 | + //$value = $formats[$nb]; |
|
1145 | + $format = $globalSources[$nb]['format']; |
|
1146 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1147 | 1147 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1148 | - } elseif ($format == 'vrstcp') { |
|
1148 | + } elseif ($format == 'vrstcp') { |
|
1149 | 1149 | $buffer = @socket_read($r, 6000); |
1150 | - } else { |
|
1150 | + } else { |
|
1151 | 1151 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1152 | - } |
|
1153 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1154 | - //echo $buffer."\n"; |
|
1155 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1156 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1157 | - $error = false; |
|
1158 | - //$SI::del(); |
|
1159 | - if ($format == 'vrstcp') { |
|
1152 | + } |
|
1153 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1154 | + //echo $buffer."\n"; |
|
1155 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1156 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1157 | + $error = false; |
|
1158 | + //$SI::del(); |
|
1159 | + if ($format == 'vrstcp') { |
|
1160 | 1160 | $buffer = explode('},{',$buffer); |
1161 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1162 | - // SBS format is CSV format |
|
1163 | - if ($buffer !== FALSE && $buffer != '') { |
|
1161 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1162 | + // SBS format is CSV format |
|
1163 | + if ($buffer !== FALSE && $buffer != '') { |
|
1164 | 1164 | $tt[$format] = 0; |
1165 | 1165 | if ($format == 'acarssbs3') { |
1166 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1167 | - $ACARS->add(trim($buffer)); |
|
1168 | - $ACARS->deleteLiveAcarsData(); |
|
1166 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1167 | + $ACARS->add(trim($buffer)); |
|
1168 | + $ACARS->deleteLiveAcarsData(); |
|
1169 | 1169 | } elseif ($format == 'raw') { |
1170 | - // AVR format |
|
1171 | - $data = $SBS->parse($buffer); |
|
1172 | - if (is_array($data)) { |
|
1170 | + // AVR format |
|
1171 | + $data = $SBS->parse($buffer); |
|
1172 | + if (is_array($data)) { |
|
1173 | 1173 | $data['datetime'] = date('Y-m-d H:i:s'); |
1174 | 1174 | $data['format_source'] = 'raw'; |
1175 | 1175 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1176 | 1176 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1177 | 1177 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1178 | 1178 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1179 | - } |
|
1179 | + } |
|
1180 | 1180 | } elseif ($format == 'ais') { |
1181 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1182 | - $data = array(); |
|
1183 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1184 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1185 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1186 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1187 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1188 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1189 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1190 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1191 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1192 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1193 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1194 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1195 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1196 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1197 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1198 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1181 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1182 | + $data = array(); |
|
1183 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1184 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1185 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1186 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1187 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1188 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1189 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1190 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1191 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1192 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1193 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1194 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1195 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1196 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1197 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1198 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1199 | 1199 | |
1200 | - if (isset($ais_data['timestamp'])) { |
|
1200 | + if (isset($ais_data['timestamp'])) { |
|
1201 | 1201 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1202 | - } else { |
|
1202 | + } else { |
|
1203 | 1203 | $data['datetime'] = date('Y-m-d H:i:s'); |
1204 | - } |
|
1205 | - $data['format_source'] = 'aisnmea'; |
|
1206 | - $data['id_source'] = $id_source; |
|
1207 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1208 | - unset($data); |
|
1209 | - } elseif ($format == 'flightgearsp') { |
|
1210 | - //echo $buffer."\n"; |
|
1211 | - if (strlen($buffer) > 5) { |
|
1204 | + } |
|
1205 | + $data['format_source'] = 'aisnmea'; |
|
1206 | + $data['id_source'] = $id_source; |
|
1207 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1208 | + unset($data); |
|
1209 | + } elseif ($format == 'flightgearsp') { |
|
1210 | + //echo $buffer."\n"; |
|
1211 | + if (strlen($buffer) > 5) { |
|
1212 | 1212 | $line = explode(',',$buffer); |
1213 | 1213 | $data = array(); |
1214 | 1214 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1225,38 +1225,38 @@ discard block |
||
1225 | 1225 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1226 | 1226 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1227 | 1227 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1228 | - } |
|
1229 | - } elseif ($format == 'acars') { |
|
1230 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1231 | - $ACARS->add(trim($buffer)); |
|
1232 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1233 | - $ACARS->deleteLiveAcarsData(); |
|
1228 | + } |
|
1229 | + } elseif ($format == 'acars') { |
|
1230 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1231 | + $ACARS->add(trim($buffer)); |
|
1232 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1233 | + $ACARS->deleteLiveAcarsData(); |
|
1234 | 1234 | } elseif ($format == 'flightgearmp') { |
1235 | - if (substr($buffer,0,1) != '#') { |
|
1235 | + if (substr($buffer,0,1) != '#') { |
|
1236 | 1236 | $data = array(); |
1237 | 1237 | //echo $buffer."\n"; |
1238 | 1238 | $line = explode(' ',$buffer); |
1239 | 1239 | if (count($line) == 11) { |
1240 | - $userserver = explode('@',$line[0]); |
|
1241 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1242 | - $data['ident'] = $userserver[0]; |
|
1243 | - $data['registration'] = $userserver[0]; |
|
1244 | - $data['latitude'] = $line[4]; |
|
1245 | - $data['longitude'] = $line[5]; |
|
1246 | - $data['altitude'] = $line[6]; |
|
1247 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1248 | - $aircraft_type = $line[10]; |
|
1249 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1250 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1251 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1252 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1240 | + $userserver = explode('@',$line[0]); |
|
1241 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1242 | + $data['ident'] = $userserver[0]; |
|
1243 | + $data['registration'] = $userserver[0]; |
|
1244 | + $data['latitude'] = $line[4]; |
|
1245 | + $data['longitude'] = $line[5]; |
|
1246 | + $data['altitude'] = $line[6]; |
|
1247 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1248 | + $aircraft_type = $line[10]; |
|
1249 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1250 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1251 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1252 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1253 | + } |
|
1253 | 1254 | } |
1254 | - } |
|
1255 | 1255 | } elseif ($format == 'beast') { |
1256 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1257 | - die; |
|
1256 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1257 | + die; |
|
1258 | 1258 | } elseif ($format == 'vrstcp') { |
1259 | - foreach($buffer as $all_data) { |
|
1259 | + foreach($buffer as $all_data) { |
|
1260 | 1260 | $line = json_decode('{'.$all_data.'}',true); |
1261 | 1261 | $data = array(); |
1262 | 1262 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1276,145 +1276,145 @@ discard block |
||
1276 | 1276 | */ |
1277 | 1277 | $data['datetime'] = date('Y-m-d H:i:s'); |
1278 | 1278 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1279 | - $data['format_source'] = 'vrstcp'; |
|
1279 | + $data['format_source'] = 'vrstcp'; |
|
1280 | 1280 | $data['id_source'] = $id_source; |
1281 | 1281 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1282 | 1282 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1283 | 1283 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1284 | 1284 | unset($data); |
1285 | - } |
|
1285 | + } |
|
1286 | 1286 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1287 | - $line = explode("\t", $buffer); |
|
1288 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1287 | + $line = explode("\t", $buffer); |
|
1288 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1289 | 1289 | $key = $line[$k]; |
1290 | - $lined[$key] = $line[$k+1]; |
|
1291 | - } |
|
1292 | - if (count($lined) > 3) { |
|
1293 | - $data['hex'] = $lined['hexid']; |
|
1294 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1295 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1296 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1297 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1298 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1299 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1300 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1301 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1302 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1303 | - $data['id_source'] = $id_source; |
|
1304 | - $data['format_source'] = 'tsv'; |
|
1305 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1306 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1290 | + $lined[$key] = $line[$k+1]; |
|
1291 | + } |
|
1292 | + if (count($lined) > 3) { |
|
1293 | + $data['hex'] = $lined['hexid']; |
|
1294 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1295 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1296 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1297 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1298 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1299 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1300 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1301 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1302 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1303 | + $data['id_source'] = $id_source; |
|
1304 | + $data['format_source'] = 'tsv'; |
|
1305 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1306 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1307 | 1307 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1308 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1309 | - unset($lined); |
|
1310 | - unset($data); |
|
1311 | - } else $error = true; |
|
1308 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1309 | + unset($lined); |
|
1310 | + unset($data); |
|
1311 | + } else $error = true; |
|
1312 | 1312 | } elseif ($format == 'aprs' && $use_aprs) { |
1313 | - if ($aprs_connect == 0) { |
|
1313 | + if ($aprs_connect == 0) { |
|
1314 | 1314 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1315 | 1315 | $aprs_connect = 1; |
1316 | - } |
|
1316 | + } |
|
1317 | 1317 | |
1318 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1318 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1319 | 1319 | $aprs_last_tx = time(); |
1320 | 1320 | $data_aprs = "# Keep alive"; |
1321 | 1321 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1322 | - } |
|
1322 | + } |
|
1323 | 1323 | |
1324 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1325 | - //echo 'APRS data : '.$buffer."\n"; |
|
1326 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1327 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1328 | - //echo $buffer."\n"; |
|
1329 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1324 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1325 | + //echo 'APRS data : '.$buffer."\n"; |
|
1326 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1327 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1328 | + //echo $buffer."\n"; |
|
1329 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1330 | 1330 | $line = $APRS->parse($buffer); |
1331 | 1331 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1332 | 1332 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1333 | - $aprs_last_tx = time(); |
|
1334 | - $data = array(); |
|
1335 | - //print_r($line); |
|
1336 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1337 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1338 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1339 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1340 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1341 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1342 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1343 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1344 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1345 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1346 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1347 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1348 | - $data['latitude'] = $line['latitude']; |
|
1349 | - $data['longitude'] = $line['longitude']; |
|
1350 | - //$data['verticalrate'] = $line[16]; |
|
1351 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1352 | - //else $data['speed'] = 0; |
|
1353 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1354 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1355 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1356 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1357 | - //else $data['heading'] = 0; |
|
1358 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1359 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1360 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1361 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1362 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1363 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1364 | - $data['id_source'] = $id_source; |
|
1365 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1366 | - else $data['format_source'] = 'aprs'; |
|
1367 | - $data['source_name'] = $line['source']; |
|
1368 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1369 | - else $data['source_type'] = 'flarm'; |
|
1370 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1371 | - $currentdate = date('Y-m-d H:i:s'); |
|
1372 | - $aprsdate = strtotime($data['datetime']); |
|
1373 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1374 | - // Accept data if time <= system time + 20s |
|
1375 | - //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'])))) { |
|
1376 | - 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'])))) { |
|
1333 | + $aprs_last_tx = time(); |
|
1334 | + $data = array(); |
|
1335 | + //print_r($line); |
|
1336 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1337 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1338 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1339 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1340 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1341 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1342 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1343 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1344 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1345 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1346 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1347 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1348 | + $data['latitude'] = $line['latitude']; |
|
1349 | + $data['longitude'] = $line['longitude']; |
|
1350 | + //$data['verticalrate'] = $line[16]; |
|
1351 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1352 | + //else $data['speed'] = 0; |
|
1353 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1354 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1355 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1356 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1357 | + //else $data['heading'] = 0; |
|
1358 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1359 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1360 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1361 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1362 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1363 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1364 | + $data['id_source'] = $id_source; |
|
1365 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1366 | + else $data['format_source'] = 'aprs'; |
|
1367 | + $data['source_name'] = $line['source']; |
|
1368 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1369 | + else $data['source_type'] = 'flarm'; |
|
1370 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1371 | + $currentdate = date('Y-m-d H:i:s'); |
|
1372 | + $aprsdate = strtotime($data['datetime']); |
|
1373 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1374 | + // Accept data if time <= system time + 20s |
|
1375 | + //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'])))) { |
|
1376 | + 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'])))) { |
|
1377 | 1377 | $send = $SI->add($data); |
1378 | - } elseif ($data['source_type'] == 'ais') { |
|
1378 | + } elseif ($data['source_type'] == 'ais') { |
|
1379 | 1379 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1380 | - } elseif (isset($line['stealth'])) { |
|
1380 | + } elseif (isset($line['stealth'])) { |
|
1381 | 1381 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1382 | 1382 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1383 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1384 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1385 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1386 | - $send = $SI->add($data); |
|
1387 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1388 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1389 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
1390 | - $send = $MI->add($data); |
|
1391 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1392 | - $line['symbol'] == 'Car' || |
|
1393 | - $line['symbol'] == 'Ambulance' || |
|
1394 | - $line['symbol'] == 'Van' || |
|
1395 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1396 | - $line['symbol'] == 'Motorcycle' || |
|
1397 | - $line['symbol'] == 'Tractor' || |
|
1398 | - $line['symbol'] == 'Police' || |
|
1399 | - $line['symbol'] == 'Bike' || |
|
1400 | - $line['symbol'] == 'Jogger' || |
|
1401 | - $line['symbol'] == 'Horse' || |
|
1402 | - $line['symbol'] == 'Bus' || |
|
1403 | - $line['symbol'] == 'Jeep' || |
|
1404 | - $line['symbol'] == 'Recreational Vehicle' || |
|
1405 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1406 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
1407 | - $line['symbol'] == 'Firetruck' || |
|
1408 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1409 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1410 | - $line['symbol'] == 'SUV' || |
|
1411 | - $line['symbol'] == 'Snowmobile' || |
|
1412 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
1413 | - //} 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') { |
|
1383 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1384 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1385 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1386 | + $send = $SI->add($data); |
|
1387 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1388 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1389 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
1390 | + $send = $MI->add($data); |
|
1391 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1392 | + $line['symbol'] == 'Car' || |
|
1393 | + $line['symbol'] == 'Ambulance' || |
|
1394 | + $line['symbol'] == 'Van' || |
|
1395 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1396 | + $line['symbol'] == 'Motorcycle' || |
|
1397 | + $line['symbol'] == 'Tractor' || |
|
1398 | + $line['symbol'] == 'Police' || |
|
1399 | + $line['symbol'] == 'Bike' || |
|
1400 | + $line['symbol'] == 'Jogger' || |
|
1401 | + $line['symbol'] == 'Horse' || |
|
1402 | + $line['symbol'] == 'Bus' || |
|
1403 | + $line['symbol'] == 'Jeep' || |
|
1404 | + $line['symbol'] == 'Recreational Vehicle' || |
|
1405 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1406 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
1407 | + $line['symbol'] == 'Firetruck' || |
|
1408 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1409 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1410 | + $line['symbol'] == 'SUV' || |
|
1411 | + $line['symbol'] == 'Snowmobile' || |
|
1412 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
1413 | + //} 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') { |
|
1414 | 1414 | // } 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') { |
1415 | 1415 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1416 | 1416 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1417 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1417 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1418 | 1418 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1419 | 1419 | $Source->deleteOldLocationByType('gs'); |
1420 | 1420 | if (count($Source->getLocationInfoByName($data['ident'])) > 0) { |
@@ -1422,11 +1422,11 @@ discard block |
||
1422 | 1422 | } else { |
1423 | 1423 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1424 | 1424 | } |
1425 | - } else { |
|
1426 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1427 | - print_r($line); |
|
1428 | - } |
|
1429 | - unset($data); |
|
1425 | + } else { |
|
1426 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1427 | + print_r($line); |
|
1428 | + } |
|
1429 | + unset($data); |
|
1430 | 1430 | } |
1431 | 1431 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1432 | 1432 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1442,12 +1442,12 @@ discard block |
||
1442 | 1442 | */ |
1443 | 1443 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1444 | 1444 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1445 | - } |
|
1445 | + } |
|
1446 | 1446 | } else { |
1447 | - $line = explode(',', $buffer); |
|
1448 | - if (count($line) > 20) { |
|
1449 | - $data['hex'] = $line[4]; |
|
1450 | - /* |
|
1447 | + $line = explode(',', $buffer); |
|
1448 | + if (count($line) > 20) { |
|
1449 | + $data['hex'] = $line[4]; |
|
1450 | + /* |
|
1451 | 1451 | $data['datetime'] = $line[6].' '.$line[7]; |
1452 | 1452 | date_default_timezone_set($globalTimezone); |
1453 | 1453 | $datetime = new DateTime($data['datetime']); |
@@ -1455,30 +1455,30 @@ discard block |
||
1455 | 1455 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1456 | 1456 | date_default_timezone_set('UTC'); |
1457 | 1457 | */ |
1458 | - // Force datetime to current UTC datetime |
|
1459 | - date_default_timezone_set('UTC'); |
|
1460 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1461 | - $data['ident'] = trim($line[10]); |
|
1462 | - $data['latitude'] = $line[14]; |
|
1463 | - $data['longitude'] = $line[15]; |
|
1464 | - $data['verticalrate'] = $line[16]; |
|
1465 | - $data['emergency'] = $line[20]; |
|
1466 | - $data['speed'] = $line[12]; |
|
1467 | - $data['squawk'] = $line[17]; |
|
1468 | - $data['altitude'] = $line[11]; |
|
1469 | - $data['heading'] = $line[13]; |
|
1470 | - $data['ground'] = $line[21]; |
|
1471 | - $data['emergency'] = $line[19]; |
|
1472 | - $data['format_source'] = 'sbs'; |
|
1458 | + // Force datetime to current UTC datetime |
|
1459 | + date_default_timezone_set('UTC'); |
|
1460 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1461 | + $data['ident'] = trim($line[10]); |
|
1462 | + $data['latitude'] = $line[14]; |
|
1463 | + $data['longitude'] = $line[15]; |
|
1464 | + $data['verticalrate'] = $line[16]; |
|
1465 | + $data['emergency'] = $line[20]; |
|
1466 | + $data['speed'] = $line[12]; |
|
1467 | + $data['squawk'] = $line[17]; |
|
1468 | + $data['altitude'] = $line[11]; |
|
1469 | + $data['heading'] = $line[13]; |
|
1470 | + $data['ground'] = $line[21]; |
|
1471 | + $data['emergency'] = $line[19]; |
|
1472 | + $data['format_source'] = 'sbs'; |
|
1473 | 1473 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1474 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1474 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1475 | 1475 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1476 | - $data['id_source'] = $id_source; |
|
1477 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1478 | - else $error = true; |
|
1479 | - unset($data); |
|
1480 | - } else $error = true; |
|
1481 | - if ($error) { |
|
1476 | + $data['id_source'] = $id_source; |
|
1477 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1478 | + else $error = true; |
|
1479 | + unset($data); |
|
1480 | + } else $error = true; |
|
1481 | + if ($error) { |
|
1482 | 1482 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1483 | 1483 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1484 | 1484 | } else { |
@@ -1494,13 +1494,13 @@ discard block |
||
1494 | 1494 | connect_all($sourceer); |
1495 | 1495 | $sourceer = array(); |
1496 | 1496 | } |
1497 | - } |
|
1497 | + } |
|
1498 | 1498 | } |
1499 | 1499 | // Sleep for xxx microseconds |
1500 | 1500 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1501 | - } else { |
|
1501 | + } else { |
|
1502 | 1502 | if ($format == 'flightgearmp') { |
1503 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1503 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1504 | 1504 | //@socket_close($r); |
1505 | 1505 | sleep($globalMinFetch); |
1506 | 1506 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1509,9 +1509,9 @@ discard block |
||
1509 | 1509 | break; |
1510 | 1510 | |
1511 | 1511 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1512 | - if (isset($tt[$format])) $tt[$format]++; |
|
1513 | - else $tt[$format] = 0; |
|
1514 | - if ($tt[$format] > 30) { |
|
1512 | + if (isset($tt[$format])) $tt[$format]++; |
|
1513 | + else $tt[$format] = 0; |
|
1514 | + if ($tt[$format] > 30) { |
|
1515 | 1515 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1516 | 1516 | //@socket_close($r); |
1517 | 1517 | sleep(2); |
@@ -1522,23 +1522,23 @@ discard block |
||
1522 | 1522 | //connect_all($globalSources); |
1523 | 1523 | $tt[$format]=0; |
1524 | 1524 | break; |
1525 | - } |
|
1525 | + } |
|
1526 | + } |
|
1526 | 1527 | } |
1527 | - } |
|
1528 | 1528 | } |
1529 | - } else { |
|
1529 | + } else { |
|
1530 | 1530 | $error = socket_strerror(socket_last_error()); |
1531 | 1531 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1532 | 1532 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1533 | 1533 | if (isset($globalDebug)) echo "Restarting...\n"; |
1534 | 1534 | // Restart the script if possible |
1535 | 1535 | if (is_array($sockets)) { |
1536 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1536 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1537 | 1537 | |
1538 | - foreach ($sockets as $sock) { |
|
1538 | + foreach ($sockets as $sock) { |
|
1539 | 1539 | @socket_shutdown($sock,2); |
1540 | 1540 | @socket_close($sock); |
1541 | - } |
|
1541 | + } |
|
1542 | 1542 | |
1543 | 1543 | } |
1544 | 1544 | if ($globalDebug) echo "Waiting..."; |
@@ -1553,15 +1553,15 @@ discard block |
||
1553 | 1553 | if ($globalDebug) echo "Restart all connections..."; |
1554 | 1554 | connect_all($globalSources); |
1555 | 1555 | } |
1556 | - } |
|
1556 | + } |
|
1557 | 1557 | } |
1558 | 1558 | if ($globalDaemon === false) { |
1559 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1560 | - if (isset($SI)) $SI->checkAll(); |
|
1561 | - if (isset($TI)) $TI->checkAll(); |
|
1562 | - if (isset($MI)) $MI->checkAll(); |
|
1559 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1560 | + if (isset($SI)) $SI->checkAll(); |
|
1561 | + if (isset($TI)) $TI->checkAll(); |
|
1562 | + if (isset($MI)) $MI->checkAll(); |
|
1563 | + } |
|
1563 | 1564 | } |
1564 | - } |
|
1565 | 1565 | } |
1566 | 1566 | |
1567 | 1567 | ?> |
@@ -76,38 +76,38 @@ discard block |
||
76 | 76 | try { |
77 | 77 | //$Connection = new Connection(); |
78 | 78 | $sth = $Connection->db->prepare($query); |
79 | - $sth->execute(array(':source' => $database_file)); |
|
80 | - } catch(PDOException $e) { |
|
81 | - return "error : ".$e->getMessage(); |
|
82 | - } |
|
79 | + $sth->execute(array(':source' => $database_file)); |
|
80 | + } catch(PDOException $e) { |
|
81 | + return "error : ".$e->getMessage(); |
|
82 | + } |
|
83 | 83 | |
84 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
85 | - update_db::connect_sqlite($database_file); |
|
84 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
85 | + update_db::connect_sqlite($database_file); |
|
86 | 86 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
87 | 87 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
88 | 88 | try { |
89 | - $sth = update_db::$db_sqlite->prepare($query); |
|
90 | - $sth->execute(); |
|
91 | - } catch(PDOException $e) { |
|
92 | - return "error : ".$e->getMessage(); |
|
93 | - } |
|
89 | + $sth = update_db::$db_sqlite->prepare($query); |
|
90 | + $sth->execute(); |
|
91 | + } catch(PDOException $e) { |
|
92 | + return "error : ".$e->getMessage(); |
|
93 | + } |
|
94 | 94 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
95 | 95 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
96 | 96 | $Connection = new Connection(); |
97 | 97 | $sth_dest = $Connection->db->prepare($query_dest); |
98 | 98 | try { |
99 | 99 | if ($globalTransaction) $Connection->db->beginTransaction(); |
100 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
100 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
101 | 101 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
102 | 102 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
103 | 103 | $sth_dest->execute($query_dest_values); |
104 | - } |
|
104 | + } |
|
105 | 105 | if ($globalTransaction) $Connection->db->commit(); |
106 | 106 | } catch(PDOException $e) { |
107 | 107 | if ($globalTransaction) $Connection->db->rollBack(); |
108 | 108 | return "error : ".$e->getMessage(); |
109 | 109 | } |
110 | - return ''; |
|
110 | + return ''; |
|
111 | 111 | } |
112 | 112 | public static function retrieve_route_oneworld($database_file) { |
113 | 113 | global $globalDebug, $globalTransaction; |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | try { |
119 | 119 | //$Connection = new Connection(); |
120 | 120 | $sth = $Connection->db->prepare($query); |
121 | - $sth->execute(array(':source' => 'oneworld')); |
|
122 | - } catch(PDOException $e) { |
|
123 | - return "error : ".$e->getMessage(); |
|
124 | - } |
|
121 | + $sth->execute(array(':source' => 'oneworld')); |
|
122 | + } catch(PDOException $e) { |
|
123 | + return "error : ".$e->getMessage(); |
|
124 | + } |
|
125 | 125 | |
126 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
126 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
127 | 127 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
128 | 128 | $Spotter = new Spotter(); |
129 | 129 | if ($fh = fopen($database_file,"r")) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | if ($globalTransaction) $Connection->db->commit(); |
149 | 149 | } |
150 | - return ''; |
|
150 | + return ''; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | public static function retrieve_route_skyteam($database_file) { |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | try { |
160 | 160 | //$Connection = new Connection(); |
161 | 161 | $sth = $Connection->db->prepare($query); |
162 | - $sth->execute(array(':source' => 'skyteam')); |
|
163 | - } catch(PDOException $e) { |
|
164 | - return "error : ".$e->getMessage(); |
|
165 | - } |
|
162 | + $sth->execute(array(':source' => 'skyteam')); |
|
163 | + } catch(PDOException $e) { |
|
164 | + return "error : ".$e->getMessage(); |
|
165 | + } |
|
166 | 166 | |
167 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
167 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
168 | 168 | |
169 | 169 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
170 | 170 | $Spotter = new Spotter(); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | return "error : ".$e->getMessage(); |
191 | 191 | } |
192 | 192 | } |
193 | - return ''; |
|
193 | + return ''; |
|
194 | 194 | } |
195 | 195 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
196 | 196 | global $globalTransaction; |
@@ -199,27 +199,27 @@ discard block |
||
199 | 199 | try { |
200 | 200 | $Connection = new Connection(); |
201 | 201 | $sth = $Connection->db->prepare($query); |
202 | - $sth->execute(array(':source' => $database_file)); |
|
203 | - } catch(PDOException $e) { |
|
204 | - return "error : ".$e->getMessage(); |
|
205 | - } |
|
202 | + $sth->execute(array(':source' => $database_file)); |
|
203 | + } catch(PDOException $e) { |
|
204 | + return "error : ".$e->getMessage(); |
|
205 | + } |
|
206 | 206 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
207 | 207 | try { |
208 | 208 | $Connection = new Connection(); |
209 | 209 | $sth = $Connection->db->prepare($query); |
210 | - $sth->execute(array(':source' => $database_file)); |
|
211 | - } catch(PDOException $e) { |
|
212 | - return "error : ".$e->getMessage(); |
|
213 | - } |
|
210 | + $sth->execute(array(':source' => $database_file)); |
|
211 | + } catch(PDOException $e) { |
|
212 | + return "error : ".$e->getMessage(); |
|
213 | + } |
|
214 | 214 | |
215 | - update_db::connect_sqlite($database_file); |
|
215 | + update_db::connect_sqlite($database_file); |
|
216 | 216 | $query = 'select * from Aircraft'; |
217 | 217 | try { |
218 | - $sth = update_db::$db_sqlite->prepare($query); |
|
219 | - $sth->execute(); |
|
220 | - } catch(PDOException $e) { |
|
221 | - return "error : ".$e->getMessage(); |
|
222 | - } |
|
218 | + $sth = update_db::$db_sqlite->prepare($query); |
|
219 | + $sth->execute(); |
|
220 | + } catch(PDOException $e) { |
|
221 | + return "error : ".$e->getMessage(); |
|
222 | + } |
|
223 | 223 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
224 | 224 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
225 | 225 | |
@@ -230,17 +230,17 @@ discard block |
||
230 | 230 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
231 | 231 | try { |
232 | 232 | if ($globalTransaction) $Connection->db->beginTransaction(); |
233 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
233 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
234 | 234 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
235 | 235 | if ($values['UserString4'] == 'M') $type = 'military'; |
236 | 236 | else $type = null; |
237 | 237 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
238 | 238 | $sth_dest->execute($query_dest_values); |
239 | 239 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
240 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
241 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
240 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
241 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
242 | 242 | } |
243 | - } |
|
243 | + } |
|
244 | 244 | if ($globalTransaction) $Connection->db->commit(); |
245 | 245 | } catch(PDOException $e) { |
246 | 246 | return "error : ".$e->getMessage(); |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | try { |
252 | 252 | $Connection = new Connection(); |
253 | 253 | $sth = $Connection->db->prepare($query); |
254 | - $sth->execute(array(':source' => $database_file)); |
|
255 | - } catch(PDOException $e) { |
|
256 | - return "error : ".$e->getMessage(); |
|
257 | - } |
|
254 | + $sth->execute(array(':source' => $database_file)); |
|
255 | + } catch(PDOException $e) { |
|
256 | + return "error : ".$e->getMessage(); |
|
257 | + } |
|
258 | 258 | return ''; |
259 | 259 | } |
260 | 260 | |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | try { |
267 | 267 | $Connection = new Connection(); |
268 | 268 | $sth = $Connection->db->prepare($query); |
269 | - $sth->execute(array(':source' => $database_file)); |
|
270 | - } catch(PDOException $e) { |
|
271 | - return "error : ".$e->getMessage(); |
|
272 | - } |
|
269 | + $sth->execute(array(':source' => $database_file)); |
|
270 | + } catch(PDOException $e) { |
|
271 | + return "error : ".$e->getMessage(); |
|
272 | + } |
|
273 | 273 | |
274 | 274 | if ($fh = fopen($database_file,"r")) { |
275 | 275 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -279,26 +279,26 @@ discard block |
||
279 | 279 | $sth_dest = $Connection->db->prepare($query_dest); |
280 | 280 | try { |
281 | 281 | if ($globalTransaction) $Connection->db->beginTransaction(); |
282 | - while (!feof($fh)) { |
|
283 | - $values = array(); |
|
284 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
282 | + while (!feof($fh)) { |
|
283 | + $values = array(); |
|
284 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
285 | 285 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
286 | - $values['ModeS'] = substr($line,0,6); |
|
287 | - $values['Registration'] = trim(substr($line,69,6)); |
|
288 | - $aircraft_name = trim(substr($line,48,6)); |
|
289 | - // Check if we can find ICAO, else set it to GLID |
|
290 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
291 | - $search_more = ''; |
|
292 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
293 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
294 | - $sth_search = $Connection->db->prepare($query_search); |
|
286 | + $values['ModeS'] = substr($line,0,6); |
|
287 | + $values['Registration'] = trim(substr($line,69,6)); |
|
288 | + $aircraft_name = trim(substr($line,48,6)); |
|
289 | + // Check if we can find ICAO, else set it to GLID |
|
290 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
291 | + $search_more = ''; |
|
292 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
293 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
294 | + $sth_search = $Connection->db->prepare($query_search); |
|
295 | 295 | try { |
296 | - $sth_search->execute(); |
|
297 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
298 | - //if (count($result) > 0) { |
|
299 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
300 | - $values['ICAOTypeCode'] = $result['icao']; |
|
301 | - } |
|
296 | + $sth_search->execute(); |
|
297 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
298 | + //if (count($result) > 0) { |
|
299 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
300 | + $values['ICAOTypeCode'] = $result['icao']; |
|
301 | + } |
|
302 | 302 | } catch(PDOException $e) { |
303 | 303 | return "error : ".$e->getMessage(); |
304 | 304 | } |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | try { |
322 | 322 | $Connection = new Connection(); |
323 | 323 | $sth = $Connection->db->prepare($query); |
324 | - $sth->execute(array(':source' => $database_file)); |
|
325 | - } catch(PDOException $e) { |
|
326 | - return "error : ".$e->getMessage(); |
|
327 | - } |
|
324 | + $sth->execute(array(':source' => $database_file)); |
|
325 | + } catch(PDOException $e) { |
|
326 | + return "error : ".$e->getMessage(); |
|
327 | + } |
|
328 | 328 | return ''; |
329 | 329 | } |
330 | 330 | |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | try { |
336 | 336 | $Connection = new Connection(); |
337 | 337 | $sth = $Connection->db->prepare($query); |
338 | - $sth->execute(array(':source' => $database_file)); |
|
339 | - } catch(PDOException $e) { |
|
340 | - return "error : ".$e->getMessage(); |
|
341 | - } |
|
338 | + $sth->execute(array(':source' => $database_file)); |
|
339 | + } catch(PDOException $e) { |
|
340 | + return "error : ".$e->getMessage(); |
|
341 | + } |
|
342 | 342 | |
343 | 343 | if ($fh = fopen($database_file,"r")) { |
344 | 344 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -349,25 +349,25 @@ discard block |
||
349 | 349 | try { |
350 | 350 | if ($globalTransaction) $Connection->db->beginTransaction(); |
351 | 351 | $tmp = fgetcsv($fh,9999,',',"'"); |
352 | - while (!feof($fh)) { |
|
353 | - $line = fgetcsv($fh,9999,',',"'"); |
|
352 | + while (!feof($fh)) { |
|
353 | + $line = fgetcsv($fh,9999,',',"'"); |
|
354 | 354 | |
355 | 355 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
356 | 356 | //print_r($line); |
357 | - $values['ModeS'] = $line[1]; |
|
358 | - $values['Registration'] = $line[3]; |
|
359 | - $values['ICAOTypeCode'] = ''; |
|
360 | - $aircraft_name = $line[2]; |
|
361 | - // Check if we can find ICAO, else set it to GLID |
|
362 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
363 | - $search_more = ''; |
|
364 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
365 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
366 | - $sth_search = $Connection->db->prepare($query_search); |
|
357 | + $values['ModeS'] = $line[1]; |
|
358 | + $values['Registration'] = $line[3]; |
|
359 | + $values['ICAOTypeCode'] = ''; |
|
360 | + $aircraft_name = $line[2]; |
|
361 | + // Check if we can find ICAO, else set it to GLID |
|
362 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
363 | + $search_more = ''; |
|
364 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
365 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
366 | + $sth_search = $Connection->db->prepare($query_search); |
|
367 | 367 | try { |
368 | - $sth_search->execute(); |
|
369 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
370 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
368 | + $sth_search->execute(); |
|
369 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
370 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
371 | 371 | } catch(PDOException $e) { |
372 | 372 | return "error : ".$e->getMessage(); |
373 | 373 | } |
@@ -390,10 +390,10 @@ discard block |
||
390 | 390 | try { |
391 | 391 | $Connection = new Connection(); |
392 | 392 | $sth = $Connection->db->prepare($query); |
393 | - $sth->execute(array(':source' => $database_file)); |
|
394 | - } catch(PDOException $e) { |
|
395 | - return "error : ".$e->getMessage(); |
|
396 | - } |
|
393 | + $sth->execute(array(':source' => $database_file)); |
|
394 | + } catch(PDOException $e) { |
|
395 | + return "error : ".$e->getMessage(); |
|
396 | + } |
|
397 | 397 | return ''; |
398 | 398 | } |
399 | 399 | |
@@ -404,16 +404,16 @@ discard block |
||
404 | 404 | try { |
405 | 405 | $Connection = new Connection(); |
406 | 406 | $sth = $Connection->db->prepare($query); |
407 | - $sth->execute(array(':source' => $database_file)); |
|
408 | - } catch(PDOException $e) { |
|
409 | - return "error : ".$e->getMessage(); |
|
410 | - } |
|
407 | + $sth->execute(array(':source' => $database_file)); |
|
408 | + } catch(PDOException $e) { |
|
409 | + return "error : ".$e->getMessage(); |
|
410 | + } |
|
411 | 411 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
412 | 412 | $Spotter = new Spotter(); |
413 | 413 | if ($fh = fopen($database_file,"r")) { |
414 | 414 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
415 | 415 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
416 | - $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
416 | + $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
417 | 417 | |
418 | 418 | $Connection = new Connection(); |
419 | 419 | $sth_dest = $Connection->db->prepare($query_dest); |
@@ -421,126 +421,126 @@ discard block |
||
421 | 421 | try { |
422 | 422 | if ($globalTransaction) $Connection->db->beginTransaction(); |
423 | 423 | $tmp = fgetcsv($fh,9999,',','"'); |
424 | - while (!feof($fh)) { |
|
425 | - $line = fgetcsv($fh,9999,',','"'); |
|
426 | - $values = array(); |
|
427 | - //print_r($line); |
|
428 | - if ($country == 'F') { |
|
429 | - $values['registration'] = $line[0]; |
|
430 | - $values['base'] = $line[4]; |
|
431 | - $values['owner'] = $line[5]; |
|
432 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
434 | - $values['cancel'] = $line[7]; |
|
424 | + while (!feof($fh)) { |
|
425 | + $line = fgetcsv($fh,9999,',','"'); |
|
426 | + $values = array(); |
|
427 | + //print_r($line); |
|
428 | + if ($country == 'F') { |
|
429 | + $values['registration'] = $line[0]; |
|
430 | + $values['base'] = $line[4]; |
|
431 | + $values['owner'] = $line[5]; |
|
432 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
433 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
434 | + $values['cancel'] = $line[7]; |
|
435 | 435 | } elseif ($country == 'EI') { |
436 | - // TODO : add modeS & reg to aircraft_modes |
|
437 | - $values['registration'] = $line[0]; |
|
438 | - $values['base'] = $line[3]; |
|
439 | - $values['owner'] = $line[2]; |
|
440 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
442 | - $values['cancel'] = ''; |
|
443 | - $values['modes'] = $line[7]; |
|
444 | - $values['icao'] = $line[8]; |
|
436 | + // TODO : add modeS & reg to aircraft_modes |
|
437 | + $values['registration'] = $line[0]; |
|
438 | + $values['base'] = $line[3]; |
|
439 | + $values['owner'] = $line[2]; |
|
440 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
441 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
442 | + $values['cancel'] = ''; |
|
443 | + $values['modes'] = $line[7]; |
|
444 | + $values['icao'] = $line[8]; |
|
445 | 445 | |
446 | 446 | } elseif ($country == 'HB') { |
447 | - // TODO : add modeS & reg to aircraft_modes |
|
448 | - $values['registration'] = $line[0]; |
|
449 | - $values['base'] = null; |
|
450 | - $values['owner'] = $line[5]; |
|
451 | - $values['date_first_reg'] = null; |
|
452 | - $values['cancel'] = ''; |
|
453 | - $values['modes'] = $line[4]; |
|
454 | - $values['icao'] = $line[7]; |
|
447 | + // TODO : add modeS & reg to aircraft_modes |
|
448 | + $values['registration'] = $line[0]; |
|
449 | + $values['base'] = null; |
|
450 | + $values['owner'] = $line[5]; |
|
451 | + $values['date_first_reg'] = null; |
|
452 | + $values['cancel'] = ''; |
|
453 | + $values['modes'] = $line[4]; |
|
454 | + $values['icao'] = $line[7]; |
|
455 | 455 | } elseif ($country == 'OK') { |
456 | - // TODO : add modeS & reg to aircraft_modes |
|
457 | - $values['registration'] = $line[3]; |
|
458 | - $values['base'] = null; |
|
459 | - $values['owner'] = $line[5]; |
|
460 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
462 | - $values['cancel'] = ''; |
|
456 | + // TODO : add modeS & reg to aircraft_modes |
|
457 | + $values['registration'] = $line[3]; |
|
458 | + $values['base'] = null; |
|
459 | + $values['owner'] = $line[5]; |
|
460 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
461 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
462 | + $values['cancel'] = ''; |
|
463 | 463 | } elseif ($country == 'VH') { |
464 | - // TODO : add modeS & reg to aircraft_modes |
|
465 | - $values['registration'] = $line[0]; |
|
466 | - $values['base'] = null; |
|
467 | - $values['owner'] = $line[12]; |
|
468 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
470 | - |
|
471 | - $values['cancel'] = $line[39]; |
|
464 | + // TODO : add modeS & reg to aircraft_modes |
|
465 | + $values['registration'] = $line[0]; |
|
466 | + $values['base'] = null; |
|
467 | + $values['owner'] = $line[12]; |
|
468 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
469 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
470 | + |
|
471 | + $values['cancel'] = $line[39]; |
|
472 | 472 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
473 | - $values['registration'] = $line[0]; |
|
474 | - $values['base'] = null; |
|
475 | - $values['owner'] = $line[4]; |
|
476 | - $values['date_first_reg'] = null; |
|
477 | - $values['cancel'] = ''; |
|
473 | + $values['registration'] = $line[0]; |
|
474 | + $values['base'] = null; |
|
475 | + $values['owner'] = $line[4]; |
|
476 | + $values['date_first_reg'] = null; |
|
477 | + $values['cancel'] = ''; |
|
478 | 478 | } elseif ($country == 'CC') { |
479 | - $values['registration'] = $line[0]; |
|
480 | - $values['base'] = null; |
|
481 | - $values['owner'] = $line[6]; |
|
482 | - $values['date_first_reg'] = null; |
|
483 | - $values['cancel'] = ''; |
|
479 | + $values['registration'] = $line[0]; |
|
480 | + $values['base'] = null; |
|
481 | + $values['owner'] = $line[6]; |
|
482 | + $values['date_first_reg'] = null; |
|
483 | + $values['cancel'] = ''; |
|
484 | 484 | } elseif ($country == 'HJ') { |
485 | - $values['registration'] = $line[0]; |
|
486 | - $values['base'] = null; |
|
487 | - $values['owner'] = $line[8]; |
|
488 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
490 | - $values['cancel'] = ''; |
|
485 | + $values['registration'] = $line[0]; |
|
486 | + $values['base'] = null; |
|
487 | + $values['owner'] = $line[8]; |
|
488 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
489 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
490 | + $values['cancel'] = ''; |
|
491 | 491 | } elseif ($country == 'PP') { |
492 | - $values['registration'] = $line[0]; |
|
493 | - $values['base'] = null; |
|
494 | - $values['owner'] = $line[4]; |
|
495 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
497 | - $values['cancel'] = $line[7]; |
|
492 | + $values['registration'] = $line[0]; |
|
493 | + $values['base'] = null; |
|
494 | + $values['owner'] = $line[4]; |
|
495 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
496 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
497 | + $values['cancel'] = $line[7]; |
|
498 | 498 | } elseif ($country == 'E7') { |
499 | - $values['registration'] = $line[0]; |
|
500 | - $values['base'] = null; |
|
501 | - $values['owner'] = $line[4]; |
|
502 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
504 | - $values['cancel'] = ''; |
|
499 | + $values['registration'] = $line[0]; |
|
500 | + $values['base'] = null; |
|
501 | + $values['owner'] = $line[4]; |
|
502 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
503 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
504 | + $values['cancel'] = ''; |
|
505 | 505 | } elseif ($country == '8Q') { |
506 | - $values['registration'] = $line[0]; |
|
507 | - $values['base'] = null; |
|
508 | - $values['owner'] = $line[3]; |
|
509 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
511 | - $values['cancel'] = ''; |
|
506 | + $values['registration'] = $line[0]; |
|
507 | + $values['base'] = null; |
|
508 | + $values['owner'] = $line[3]; |
|
509 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
510 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
511 | + $values['cancel'] = ''; |
|
512 | 512 | } elseif ($country == 'ZK') { |
513 | - $values['registration'] = $line[0]; |
|
514 | - $values['base'] = null; |
|
515 | - $values['owner'] = $line[3]; |
|
516 | - $values['date_first_reg'] = null; |
|
517 | - $values['cancel'] = ''; |
|
518 | - $values['modes'] = $line[5]; |
|
519 | - $values['icao'] = $line[9]; |
|
513 | + $values['registration'] = $line[0]; |
|
514 | + $values['base'] = null; |
|
515 | + $values['owner'] = $line[3]; |
|
516 | + $values['date_first_reg'] = null; |
|
517 | + $values['cancel'] = ''; |
|
518 | + $values['modes'] = $line[5]; |
|
519 | + $values['icao'] = $line[9]; |
|
520 | 520 | } elseif ($country == 'M') { |
521 | - $values['registration'] = $line[0]; |
|
522 | - $values['base'] = null; |
|
523 | - $values['owner'] = $line[6]; |
|
524 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
525 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
526 | - $values['modes'] = $line[4]; |
|
527 | - $values['icao'] = $line[10]; |
|
521 | + $values['registration'] = $line[0]; |
|
522 | + $values['base'] = null; |
|
523 | + $values['owner'] = $line[6]; |
|
524 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
525 | + $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
526 | + $values['modes'] = $line[4]; |
|
527 | + $values['icao'] = $line[10]; |
|
528 | 528 | } elseif ($country == 'OY') { |
529 | - $values['registration'] = $line[0]; |
|
530 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
531 | - $values['modes'] = $line[5]; |
|
532 | - $values['icao'] = $line[6]; |
|
529 | + $values['registration'] = $line[0]; |
|
530 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
531 | + $values['modes'] = $line[5]; |
|
532 | + $values['icao'] = $line[6]; |
|
533 | 533 | } elseif ($country == 'PH') { |
534 | - $values['registration'] = $line[0]; |
|
535 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
536 | - $values['modes'] = $line[4]; |
|
537 | - $values['icao'] = $line[5]; |
|
534 | + $values['registration'] = $line[0]; |
|
535 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
536 | + $values['modes'] = $line[4]; |
|
537 | + $values['icao'] = $line[5]; |
|
538 | 538 | } elseif ($country == 'OM' || $country == 'TF') { |
539 | - $values['registration'] = $line[0]; |
|
540 | - $values['base'] = null; |
|
541 | - $values['owner'] = $line[3]; |
|
542 | - $values['date_first_reg'] = null; |
|
543 | - $values['cancel'] = ''; |
|
539 | + $values['registration'] = $line[0]; |
|
540 | + $values['base'] = null; |
|
541 | + $values['owner'] = $line[3]; |
|
542 | + $values['date_first_reg'] = null; |
|
543 | + $values['cancel'] = ''; |
|
544 | 544 | } |
545 | 545 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
546 | 546 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | return "error : ".$e->getMessage(); |
674 | 674 | } |
675 | 675 | */ |
676 | - /* |
|
676 | + /* |
|
677 | 677 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
678 | 678 | try { |
679 | 679 | $Connection = new Connection(); |
@@ -918,10 +918,10 @@ discard block |
||
918 | 918 | try { |
919 | 919 | $Connection = new Connection(); |
920 | 920 | $sth = $Connection->db->prepare($query); |
921 | - $sth->execute(array(':source' => 'translation.csv')); |
|
922 | - } catch(PDOException $e) { |
|
923 | - return "error : ".$e->getMessage(); |
|
924 | - } |
|
921 | + $sth->execute(array(':source' => 'translation.csv')); |
|
922 | + } catch(PDOException $e) { |
|
923 | + return "error : ".$e->getMessage(); |
|
924 | + } |
|
925 | 925 | |
926 | 926 | |
927 | 927 | //update_db::unzip($out_file); |
@@ -940,21 +940,21 @@ discard block |
||
940 | 940 | $data = $row; |
941 | 941 | $operator = $data[2]; |
942 | 942 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
943 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
944 | - //echo substr($operator, 0, 2)."\n";; |
|
945 | - if (count($airline_array) > 0) { |
|
943 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
944 | + //echo substr($operator, 0, 2)."\n";; |
|
945 | + if (count($airline_array) > 0) { |
|
946 | 946 | //print_r($airline_array); |
947 | 947 | $operator = $airline_array[0]['icao'].substr($operator,2); |
948 | - } |
|
949 | - } |
|
948 | + } |
|
949 | + } |
|
950 | 950 | |
951 | 951 | $operator_correct = $data[3]; |
952 | 952 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
953 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
954 | - if (count($airline_array) > 0) { |
|
955 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
956 | - } |
|
957 | - } |
|
953 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
954 | + if (count($airline_array) > 0) { |
|
955 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
956 | + } |
|
957 | + } |
|
958 | 958 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
959 | 959 | try { |
960 | 960 | $sth = $Connection->db->prepare($query); |
@@ -968,7 +968,7 @@ discard block |
||
968 | 968 | //$Connection->db->commit(); |
969 | 969 | } |
970 | 970 | return ''; |
971 | - } |
|
971 | + } |
|
972 | 972 | |
973 | 973 | public static function translation_fam() { |
974 | 974 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -978,10 +978,10 @@ discard block |
||
978 | 978 | try { |
979 | 979 | $Connection = new Connection(); |
980 | 980 | $sth = $Connection->db->prepare($query); |
981 | - $sth->execute(array(':source' => 'website_fam')); |
|
982 | - } catch(PDOException $e) { |
|
983 | - return "error : ".$e->getMessage(); |
|
984 | - } |
|
981 | + $sth->execute(array(':source' => 'website_fam')); |
|
982 | + } catch(PDOException $e) { |
|
983 | + return "error : ".$e->getMessage(); |
|
984 | + } |
|
985 | 985 | |
986 | 986 | |
987 | 987 | //update_db::unzip($out_file); |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | //$Connection->db->commit(); |
1011 | 1011 | } |
1012 | 1012 | return ''; |
1013 | - } |
|
1013 | + } |
|
1014 | 1014 | |
1015 | 1015 | /* |
1016 | 1016 | * This function use FAA public data. |
@@ -1022,19 +1022,19 @@ discard block |
||
1022 | 1022 | try { |
1023 | 1023 | $Connection = new Connection(); |
1024 | 1024 | $sth = $Connection->db->prepare($query); |
1025 | - $sth->execute(array(':source' => 'website_faa')); |
|
1026 | - } catch(PDOException $e) { |
|
1027 | - return "error : ".$e->getMessage(); |
|
1028 | - } |
|
1025 | + $sth->execute(array(':source' => 'website_faa')); |
|
1026 | + } catch(PDOException $e) { |
|
1027 | + return "error : ".$e->getMessage(); |
|
1028 | + } |
|
1029 | 1029 | |
1030 | 1030 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
1031 | 1031 | try { |
1032 | 1032 | $Connection = new Connection(); |
1033 | 1033 | $sth = $Connection->db->prepare($query); |
1034 | - $sth->execute(array(':source' => 'website_faa')); |
|
1035 | - } catch(PDOException $e) { |
|
1036 | - return "error : ".$e->getMessage(); |
|
1037 | - } |
|
1034 | + $sth->execute(array(':source' => 'website_faa')); |
|
1035 | + } catch(PDOException $e) { |
|
1036 | + return "error : ".$e->getMessage(); |
|
1037 | + } |
|
1038 | 1038 | |
1039 | 1039 | $delimiter = ","; |
1040 | 1040 | $mfr = array(); |
@@ -1110,17 +1110,17 @@ discard block |
||
1110 | 1110 | } |
1111 | 1111 | print_r($mfr); |
1112 | 1112 | return ''; |
1113 | - } |
|
1113 | + } |
|
1114 | 1114 | public static function modes_fam() { |
1115 | 1115 | global $tmp_dir, $globalTransaction; |
1116 | 1116 | $query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source"; |
1117 | 1117 | try { |
1118 | 1118 | $Connection = new Connection(); |
1119 | 1119 | $sth = $Connection->db->prepare($query); |
1120 | - $sth->execute(array(':source' => 'website_fam')); |
|
1121 | - } catch(PDOException $e) { |
|
1122 | - return "error : ".$e->getMessage(); |
|
1123 | - } |
|
1120 | + $sth->execute(array(':source' => 'website_fam')); |
|
1121 | + } catch(PDOException $e) { |
|
1122 | + return "error : ".$e->getMessage(); |
|
1123 | + } |
|
1124 | 1124 | |
1125 | 1125 | |
1126 | 1126 | //update_db::unzip($out_file); |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | if ($globalTransaction) $Connection->db->commit(); |
1151 | 1151 | } |
1152 | 1152 | return ''; |
1153 | - } |
|
1153 | + } |
|
1154 | 1154 | |
1155 | 1155 | public static function owner_fam() { |
1156 | 1156 | global $tmp_dir, $globalTransaction; |
@@ -1158,10 +1158,10 @@ discard block |
||
1158 | 1158 | try { |
1159 | 1159 | $Connection = new Connection(); |
1160 | 1160 | $sth = $Connection->db->prepare($query); |
1161 | - $sth->execute(array(':source' => 'website_fam')); |
|
1162 | - } catch(PDOException $e) { |
|
1163 | - return "error : ".$e->getMessage(); |
|
1164 | - } |
|
1161 | + $sth->execute(array(':source' => 'website_fam')); |
|
1162 | + } catch(PDOException $e) { |
|
1163 | + return "error : ".$e->getMessage(); |
|
1164 | + } |
|
1165 | 1165 | |
1166 | 1166 | $delimiter = "\t"; |
1167 | 1167 | $Connection = new Connection(); |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | if ($globalTransaction) $Connection->db->commit(); |
1188 | 1188 | } |
1189 | 1189 | return ''; |
1190 | - } |
|
1190 | + } |
|
1191 | 1191 | |
1192 | 1192 | public static function routes_fam() { |
1193 | 1193 | global $tmp_dir, $globalTransaction, $globalDebug; |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | if ($globalTransaction) $Connection->db->commit(); |
1223 | 1223 | } |
1224 | 1224 | return ''; |
1225 | - } |
|
1225 | + } |
|
1226 | 1226 | |
1227 | 1227 | public static function marine_identity_fam() { |
1228 | 1228 | global $tmp_dir, $globalTransaction; |
@@ -1230,10 +1230,10 @@ discard block |
||
1230 | 1230 | try { |
1231 | 1231 | $Connection = new Connection(); |
1232 | 1232 | $sth = $Connection->db->prepare($query); |
1233 | - $sth->execute(); |
|
1234 | - } catch(PDOException $e) { |
|
1235 | - return "error : ".$e->getMessage(); |
|
1236 | - } |
|
1233 | + $sth->execute(); |
|
1234 | + } catch(PDOException $e) { |
|
1235 | + return "error : ".$e->getMessage(); |
|
1236 | + } |
|
1237 | 1237 | |
1238 | 1238 | |
1239 | 1239 | //update_db::unzip($out_file); |
@@ -1263,7 +1263,7 @@ discard block |
||
1263 | 1263 | if ($globalTransaction) $Connection->db->commit(); |
1264 | 1264 | } |
1265 | 1265 | return ''; |
1266 | - } |
|
1266 | + } |
|
1267 | 1267 | |
1268 | 1268 | public static function banned_fam() { |
1269 | 1269 | global $tmp_dir, $globalTransaction; |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | if ($globalTransaction) $Connection->db->commit(); |
1298 | 1298 | } |
1299 | 1299 | return ''; |
1300 | - } |
|
1300 | + } |
|
1301 | 1301 | |
1302 | 1302 | public static function tle($filename,$tletype) { |
1303 | 1303 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1308,10 +1308,10 @@ discard block |
||
1308 | 1308 | try { |
1309 | 1309 | $Connection = new Connection(); |
1310 | 1310 | $sth = $Connection->db->prepare($query); |
1311 | - $sth->execute(array(':source' => $filename)); |
|
1312 | - } catch(PDOException $e) { |
|
1313 | - return "error : ".$e->getMessage(); |
|
1314 | - } |
|
1311 | + $sth->execute(array(':source' => $filename)); |
|
1312 | + } catch(PDOException $e) { |
|
1313 | + return "error : ".$e->getMessage(); |
|
1314 | + } |
|
1315 | 1315 | |
1316 | 1316 | $Connection = new Connection(); |
1317 | 1317 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1346,54 +1346,54 @@ discard block |
||
1346 | 1346 | //$Connection->db->commit(); |
1347 | 1347 | } |
1348 | 1348 | return ''; |
1349 | - } |
|
1349 | + } |
|
1350 | 1350 | |
1351 | 1351 | /** |
1352 | - * Convert a HTML table to an array |
|
1353 | - * @param String $data HTML page |
|
1354 | - * @return Array array of the tables in HTML page |
|
1355 | - */ |
|
1356 | - private static function table2array($data) { |
|
1357 | - $html = str_get_html($data); |
|
1358 | - $tabledata=array(); |
|
1359 | - foreach($html->find('tr') as $element) |
|
1360 | - { |
|
1361 | - $td = array(); |
|
1362 | - foreach( $element->find('th') as $row) |
|
1363 | - { |
|
1364 | - $td [] = trim($row->plaintext); |
|
1365 | - } |
|
1366 | - $td=array_filter($td); |
|
1367 | - $tabledata[] = $td; |
|
1368 | - |
|
1369 | - $td = array(); |
|
1370 | - $tdi = array(); |
|
1371 | - foreach( $element->find('td') as $row) |
|
1372 | - { |
|
1373 | - $td [] = trim($row->plaintext); |
|
1374 | - $tdi [] = trim($row->innertext); |
|
1375 | - } |
|
1376 | - $td=array_filter($td); |
|
1377 | - $tdi=array_filter($tdi); |
|
1378 | - // $tabledata[]=array_merge($td,$tdi); |
|
1379 | - $tabledata[]=$td; |
|
1380 | - } |
|
1381 | - return(array_filter($tabledata)); |
|
1382 | - } |
|
1383 | - |
|
1384 | - /** |
|
1385 | - * Get data from form result |
|
1386 | - * @param String $url form URL |
|
1387 | - * @return String the result |
|
1388 | - */ |
|
1389 | - private static function getData($url) { |
|
1390 | - $ch = curl_init(); |
|
1391 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
1392 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1393 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1394 | - curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
|
1395 | - return curl_exec($ch); |
|
1396 | - } |
|
1352 | + * Convert a HTML table to an array |
|
1353 | + * @param String $data HTML page |
|
1354 | + * @return Array array of the tables in HTML page |
|
1355 | + */ |
|
1356 | + private static function table2array($data) { |
|
1357 | + $html = str_get_html($data); |
|
1358 | + $tabledata=array(); |
|
1359 | + foreach($html->find('tr') as $element) |
|
1360 | + { |
|
1361 | + $td = array(); |
|
1362 | + foreach( $element->find('th') as $row) |
|
1363 | + { |
|
1364 | + $td [] = trim($row->plaintext); |
|
1365 | + } |
|
1366 | + $td=array_filter($td); |
|
1367 | + $tabledata[] = $td; |
|
1368 | + |
|
1369 | + $td = array(); |
|
1370 | + $tdi = array(); |
|
1371 | + foreach( $element->find('td') as $row) |
|
1372 | + { |
|
1373 | + $td [] = trim($row->plaintext); |
|
1374 | + $tdi [] = trim($row->innertext); |
|
1375 | + } |
|
1376 | + $td=array_filter($td); |
|
1377 | + $tdi=array_filter($tdi); |
|
1378 | + // $tabledata[]=array_merge($td,$tdi); |
|
1379 | + $tabledata[]=$td; |
|
1380 | + } |
|
1381 | + return(array_filter($tabledata)); |
|
1382 | + } |
|
1383 | + |
|
1384 | + /** |
|
1385 | + * Get data from form result |
|
1386 | + * @param String $url form URL |
|
1387 | + * @return String the result |
|
1388 | + */ |
|
1389 | + private static function getData($url) { |
|
1390 | + $ch = curl_init(); |
|
1391 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
1392 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1393 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1394 | + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
|
1395 | + return curl_exec($ch); |
|
1396 | + } |
|
1397 | 1397 | /* |
1398 | 1398 | public static function waypoints() { |
1399 | 1399 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -1476,7 +1476,7 @@ discard block |
||
1476 | 1476 | if ($globalTransaction) $Connection->db->commit(); |
1477 | 1477 | } |
1478 | 1478 | return ''; |
1479 | - } |
|
1479 | + } |
|
1480 | 1480 | |
1481 | 1481 | public static function ivao_airlines($filename) { |
1482 | 1482 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1486,10 +1486,10 @@ discard block |
||
1486 | 1486 | try { |
1487 | 1487 | $Connection = new Connection(); |
1488 | 1488 | $sth = $Connection->db->prepare($query); |
1489 | - $sth->execute(); |
|
1490 | - } catch(PDOException $e) { |
|
1491 | - return "error : ".$e->getMessage(); |
|
1492 | - } |
|
1489 | + $sth->execute(); |
|
1490 | + } catch(PDOException $e) { |
|
1491 | + return "error : ".$e->getMessage(); |
|
1492 | + } |
|
1493 | 1493 | |
1494 | 1494 | $header = NULL; |
1495 | 1495 | $delimiter = ':'; |
@@ -1513,7 +1513,7 @@ discard block |
||
1513 | 1513 | if ($globalTransaction) $Connection->db->commit(); |
1514 | 1514 | } |
1515 | 1515 | return ''; |
1516 | - } |
|
1516 | + } |
|
1517 | 1517 | |
1518 | 1518 | public static function update_airspace() { |
1519 | 1519 | global $tmp_dir, $globalDBdriver; |
@@ -1523,11 +1523,11 @@ discard block |
||
1523 | 1523 | $query = 'DROP TABLE airspace'; |
1524 | 1524 | try { |
1525 | 1525 | $sth = $Connection->db->prepare($query); |
1526 | - $sth->execute(); |
|
1527 | - } catch(PDOException $e) { |
|
1526 | + $sth->execute(); |
|
1527 | + } catch(PDOException $e) { |
|
1528 | 1528 | return "error : ".$e->getMessage(); |
1529 | - } |
|
1530 | - } |
|
1529 | + } |
|
1530 | + } |
|
1531 | 1531 | |
1532 | 1532 | |
1533 | 1533 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1582,10 +1582,10 @@ discard block |
||
1582 | 1582 | $query = 'DROP TABLE countries'; |
1583 | 1583 | try { |
1584 | 1584 | $sth = $Connection->db->prepare($query); |
1585 | - $sth->execute(); |
|
1586 | - } catch(PDOException $e) { |
|
1587 | - echo "error : ".$e->getMessage(); |
|
1588 | - } |
|
1585 | + $sth->execute(); |
|
1586 | + } catch(PDOException $e) { |
|
1587 | + echo "error : ".$e->getMessage(); |
|
1588 | + } |
|
1589 | 1589 | } |
1590 | 1590 | if ($globalDBdriver == 'mysql') { |
1591 | 1591 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -2114,11 +2114,11 @@ discard block |
||
2114 | 2114 | $query = 'DROP TABLE airspace'; |
2115 | 2115 | try { |
2116 | 2116 | $sth = $Connection->db->prepare($query); |
2117 | - $sth->execute(); |
|
2118 | - } catch(PDOException $e) { |
|
2117 | + $sth->execute(); |
|
2118 | + } catch(PDOException $e) { |
|
2119 | 2119 | return "error : ".$e->getMessage(); |
2120 | - } |
|
2121 | - } |
|
2120 | + } |
|
2121 | + } |
|
2122 | 2122 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2123 | 2123 | update_db::insert_airspace_version($airspace_md5); |
2124 | 2124 | } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
@@ -2300,12 +2300,12 @@ discard block |
||
2300 | 2300 | echo $data; |
2301 | 2301 | */ |
2302 | 2302 | if (file_exists($tmp_dir.'aircrafts.html')) { |
2303 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2304 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2305 | - $result = fread($fh,100000000); |
|
2306 | - //echo $result; |
|
2307 | - //var_dump(str_get_html($result)); |
|
2308 | - //print_r(self::table2array($result)); |
|
2303 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2304 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2305 | + $result = fread($fh,100000000); |
|
2306 | + //echo $result; |
|
2307 | + //var_dump(str_get_html($result)); |
|
2308 | + //print_r(self::table2array($result)); |
|
2309 | 2309 | } |
2310 | 2310 | |
2311 | 2311 | } |
@@ -2319,10 +2319,10 @@ discard block |
||
2319 | 2319 | try { |
2320 | 2320 | $Connection = new Connection(); |
2321 | 2321 | $sth = $Connection->db->prepare($query); |
2322 | - $sth->execute(); |
|
2323 | - } catch(PDOException $e) { |
|
2324 | - return "error : ".$e->getMessage(); |
|
2325 | - } |
|
2322 | + $sth->execute(); |
|
2323 | + } catch(PDOException $e) { |
|
2324 | + return "error : ".$e->getMessage(); |
|
2325 | + } |
|
2326 | 2326 | |
2327 | 2327 | $error = ''; |
2328 | 2328 | if ($globalDebug) echo "Notam : Download..."; |
@@ -2378,8 +2378,8 @@ discard block |
||
2378 | 2378 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
2379 | 2379 | $data['permanent'] = 0; |
2380 | 2380 | } else { |
2381 | - $data['date_end'] = NULL; |
|
2382 | - $data['permanent'] = 1; |
|
2381 | + $data['date_end'] = NULL; |
|
2382 | + $data['permanent'] = 1; |
|
2383 | 2383 | } |
2384 | 2384 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
2385 | 2385 | $NOTAM = new NOTAM(); |
@@ -2453,13 +2453,13 @@ discard block |
||
2453 | 2453 | try { |
2454 | 2454 | $Connection = new Connection(); |
2455 | 2455 | $sth = $Connection->db->prepare($query); |
2456 | - $sth->execute(); |
|
2457 | - } catch(PDOException $e) { |
|
2458 | - return "error : ".$e->getMessage(); |
|
2459 | - } |
|
2460 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2461 | - if ($row['nb'] > 0) return false; |
|
2462 | - else return true; |
|
2456 | + $sth->execute(); |
|
2457 | + } catch(PDOException $e) { |
|
2458 | + return "error : ".$e->getMessage(); |
|
2459 | + } |
|
2460 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2461 | + if ($row['nb'] > 0) return false; |
|
2462 | + else return true; |
|
2463 | 2463 | } |
2464 | 2464 | |
2465 | 2465 | public static function insert_last_update() { |
@@ -2468,10 +2468,10 @@ discard block |
||
2468 | 2468 | try { |
2469 | 2469 | $Connection = new Connection(); |
2470 | 2470 | $sth = $Connection->db->prepare($query); |
2471 | - $sth->execute(); |
|
2472 | - } catch(PDOException $e) { |
|
2473 | - return "error : ".$e->getMessage(); |
|
2474 | - } |
|
2471 | + $sth->execute(); |
|
2472 | + } catch(PDOException $e) { |
|
2473 | + return "error : ".$e->getMessage(); |
|
2474 | + } |
|
2475 | 2475 | } |
2476 | 2476 | |
2477 | 2477 | public static function check_airspace_version($version) { |
@@ -2479,13 +2479,13 @@ discard block |
||
2479 | 2479 | try { |
2480 | 2480 | $Connection = new Connection(); |
2481 | 2481 | $sth = $Connection->db->prepare($query); |
2482 | - $sth->execute(array(':version' => $version)); |
|
2483 | - } catch(PDOException $e) { |
|
2484 | - return "error : ".$e->getMessage(); |
|
2485 | - } |
|
2486 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2487 | - if ($row['nb'] > 0) return true; |
|
2488 | - else return false; |
|
2482 | + $sth->execute(array(':version' => $version)); |
|
2483 | + } catch(PDOException $e) { |
|
2484 | + return "error : ".$e->getMessage(); |
|
2485 | + } |
|
2486 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2487 | + if ($row['nb'] > 0) return true; |
|
2488 | + else return false; |
|
2489 | 2489 | } |
2490 | 2490 | |
2491 | 2491 | public static function check_geoid_version($version) { |
@@ -2493,13 +2493,13 @@ discard block |
||
2493 | 2493 | try { |
2494 | 2494 | $Connection = new Connection(); |
2495 | 2495 | $sth = $Connection->db->prepare($query); |
2496 | - $sth->execute(array(':version' => $version)); |
|
2497 | - } catch(PDOException $e) { |
|
2498 | - return "error : ".$e->getMessage(); |
|
2499 | - } |
|
2500 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2501 | - if ($row['nb'] > 0) return true; |
|
2502 | - else return false; |
|
2496 | + $sth->execute(array(':version' => $version)); |
|
2497 | + } catch(PDOException $e) { |
|
2498 | + return "error : ".$e->getMessage(); |
|
2499 | + } |
|
2500 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2501 | + if ($row['nb'] > 0) return true; |
|
2502 | + else return false; |
|
2503 | 2503 | } |
2504 | 2504 | |
2505 | 2505 | public static function check_marine_identity_version($version) { |
@@ -2507,13 +2507,13 @@ discard block |
||
2507 | 2507 | try { |
2508 | 2508 | $Connection = new Connection(); |
2509 | 2509 | $sth = $Connection->db->prepare($query); |
2510 | - $sth->execute(array(':version' => $version)); |
|
2511 | - } catch(PDOException $e) { |
|
2512 | - return "error : ".$e->getMessage(); |
|
2513 | - } |
|
2514 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2515 | - if ($row['nb'] > 0) return true; |
|
2516 | - else return false; |
|
2510 | + $sth->execute(array(':version' => $version)); |
|
2511 | + } catch(PDOException $e) { |
|
2512 | + return "error : ".$e->getMessage(); |
|
2513 | + } |
|
2514 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2515 | + if ($row['nb'] > 0) return true; |
|
2516 | + else return false; |
|
2517 | 2517 | } |
2518 | 2518 | |
2519 | 2519 | |
@@ -2535,10 +2535,10 @@ discard block |
||
2535 | 2535 | try { |
2536 | 2536 | $Connection = new Connection(); |
2537 | 2537 | $sth = $Connection->db->prepare($query); |
2538 | - $sth->execute(array(':version' => $version)); |
|
2539 | - } catch(PDOException $e) { |
|
2540 | - return "error : ".$e->getMessage(); |
|
2541 | - } |
|
2538 | + $sth->execute(array(':version' => $version)); |
|
2539 | + } catch(PDOException $e) { |
|
2540 | + return "error : ".$e->getMessage(); |
|
2541 | + } |
|
2542 | 2542 | } |
2543 | 2543 | |
2544 | 2544 | public static function insert_marine_identity_version($version) { |
@@ -2547,10 +2547,10 @@ discard block |
||
2547 | 2547 | try { |
2548 | 2548 | $Connection = new Connection(); |
2549 | 2549 | $sth = $Connection->db->prepare($query); |
2550 | - $sth->execute(array(':version' => $version)); |
|
2551 | - } catch(PDOException $e) { |
|
2552 | - return "error : ".$e->getMessage(); |
|
2553 | - } |
|
2550 | + $sth->execute(array(':version' => $version)); |
|
2551 | + } catch(PDOException $e) { |
|
2552 | + return "error : ".$e->getMessage(); |
|
2553 | + } |
|
2554 | 2554 | } |
2555 | 2555 | |
2556 | 2556 | public static function check_last_notam_update() { |
@@ -2563,13 +2563,13 @@ discard block |
||
2563 | 2563 | try { |
2564 | 2564 | $Connection = new Connection(); |
2565 | 2565 | $sth = $Connection->db->prepare($query); |
2566 | - $sth->execute(); |
|
2567 | - } catch(PDOException $e) { |
|
2568 | - return "error : ".$e->getMessage(); |
|
2569 | - } |
|
2570 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2571 | - if ($row['nb'] > 0) return false; |
|
2572 | - else return true; |
|
2566 | + $sth->execute(); |
|
2567 | + } catch(PDOException $e) { |
|
2568 | + return "error : ".$e->getMessage(); |
|
2569 | + } |
|
2570 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2571 | + if ($row['nb'] > 0) return false; |
|
2572 | + else return true; |
|
2573 | 2573 | } |
2574 | 2574 | |
2575 | 2575 | public static function insert_last_notam_update() { |
@@ -2578,10 +2578,10 @@ discard block |
||
2578 | 2578 | try { |
2579 | 2579 | $Connection = new Connection(); |
2580 | 2580 | $sth = $Connection->db->prepare($query); |
2581 | - $sth->execute(); |
|
2582 | - } catch(PDOException $e) { |
|
2583 | - return "error : ".$e->getMessage(); |
|
2584 | - } |
|
2581 | + $sth->execute(); |
|
2582 | + } catch(PDOException $e) { |
|
2583 | + return "error : ".$e->getMessage(); |
|
2584 | + } |
|
2585 | 2585 | } |
2586 | 2586 | |
2587 | 2587 | public static function check_last_airspace_update() { |
@@ -2594,13 +2594,13 @@ discard block |
||
2594 | 2594 | try { |
2595 | 2595 | $Connection = new Connection(); |
2596 | 2596 | $sth = $Connection->db->prepare($query); |
2597 | - $sth->execute(); |
|
2598 | - } catch(PDOException $e) { |
|
2599 | - return "error : ".$e->getMessage(); |
|
2600 | - } |
|
2601 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2602 | - if ($row['nb'] > 0) return false; |
|
2603 | - else return true; |
|
2597 | + $sth->execute(); |
|
2598 | + } catch(PDOException $e) { |
|
2599 | + return "error : ".$e->getMessage(); |
|
2600 | + } |
|
2601 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2602 | + if ($row['nb'] > 0) return false; |
|
2603 | + else return true; |
|
2604 | 2604 | } |
2605 | 2605 | |
2606 | 2606 | public static function insert_last_airspace_update() { |
@@ -2609,10 +2609,10 @@ discard block |
||
2609 | 2609 | try { |
2610 | 2610 | $Connection = new Connection(); |
2611 | 2611 | $sth = $Connection->db->prepare($query); |
2612 | - $sth->execute(); |
|
2613 | - } catch(PDOException $e) { |
|
2614 | - return "error : ".$e->getMessage(); |
|
2615 | - } |
|
2612 | + $sth->execute(); |
|
2613 | + } catch(PDOException $e) { |
|
2614 | + return "error : ".$e->getMessage(); |
|
2615 | + } |
|
2616 | 2616 | } |
2617 | 2617 | |
2618 | 2618 | public static function check_last_geoid_update() { |
@@ -2625,13 +2625,13 @@ discard block |
||
2625 | 2625 | try { |
2626 | 2626 | $Connection = new Connection(); |
2627 | 2627 | $sth = $Connection->db->prepare($query); |
2628 | - $sth->execute(); |
|
2629 | - } catch(PDOException $e) { |
|
2630 | - return "error : ".$e->getMessage(); |
|
2631 | - } |
|
2632 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2633 | - if ($row['nb'] > 0) return false; |
|
2634 | - else return true; |
|
2628 | + $sth->execute(); |
|
2629 | + } catch(PDOException $e) { |
|
2630 | + return "error : ".$e->getMessage(); |
|
2631 | + } |
|
2632 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2633 | + if ($row['nb'] > 0) return false; |
|
2634 | + else return true; |
|
2635 | 2635 | } |
2636 | 2636 | |
2637 | 2637 | public static function insert_last_geoid_update() { |
@@ -2640,10 +2640,10 @@ discard block |
||
2640 | 2640 | try { |
2641 | 2641 | $Connection = new Connection(); |
2642 | 2642 | $sth = $Connection->db->prepare($query); |
2643 | - $sth->execute(); |
|
2644 | - } catch(PDOException $e) { |
|
2645 | - return "error : ".$e->getMessage(); |
|
2646 | - } |
|
2643 | + $sth->execute(); |
|
2644 | + } catch(PDOException $e) { |
|
2645 | + return "error : ".$e->getMessage(); |
|
2646 | + } |
|
2647 | 2647 | } |
2648 | 2648 | |
2649 | 2649 | public static function check_last_owner_update() { |
@@ -2656,13 +2656,13 @@ discard block |
||
2656 | 2656 | try { |
2657 | 2657 | $Connection = new Connection(); |
2658 | 2658 | $sth = $Connection->db->prepare($query); |
2659 | - $sth->execute(); |
|
2660 | - } catch(PDOException $e) { |
|
2661 | - return "error : ".$e->getMessage(); |
|
2662 | - } |
|
2663 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2664 | - if ($row['nb'] > 0) return false; |
|
2665 | - else return true; |
|
2659 | + $sth->execute(); |
|
2660 | + } catch(PDOException $e) { |
|
2661 | + return "error : ".$e->getMessage(); |
|
2662 | + } |
|
2663 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2664 | + if ($row['nb'] > 0) return false; |
|
2665 | + else return true; |
|
2666 | 2666 | } |
2667 | 2667 | |
2668 | 2668 | public static function insert_last_owner_update() { |
@@ -2671,10 +2671,10 @@ discard block |
||
2671 | 2671 | try { |
2672 | 2672 | $Connection = new Connection(); |
2673 | 2673 | $sth = $Connection->db->prepare($query); |
2674 | - $sth->execute(); |
|
2675 | - } catch(PDOException $e) { |
|
2676 | - return "error : ".$e->getMessage(); |
|
2677 | - } |
|
2674 | + $sth->execute(); |
|
2675 | + } catch(PDOException $e) { |
|
2676 | + return "error : ".$e->getMessage(); |
|
2677 | + } |
|
2678 | 2678 | } |
2679 | 2679 | public static function check_last_schedules_update() { |
2680 | 2680 | global $globalDBdriver; |
@@ -2686,13 +2686,13 @@ discard block |
||
2686 | 2686 | try { |
2687 | 2687 | $Connection = new Connection(); |
2688 | 2688 | $sth = $Connection->db->prepare($query); |
2689 | - $sth->execute(); |
|
2690 | - } catch(PDOException $e) { |
|
2691 | - return "error : ".$e->getMessage(); |
|
2692 | - } |
|
2693 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2694 | - if ($row['nb'] > 0) return false; |
|
2695 | - else return true; |
|
2689 | + $sth->execute(); |
|
2690 | + } catch(PDOException $e) { |
|
2691 | + return "error : ".$e->getMessage(); |
|
2692 | + } |
|
2693 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2694 | + if ($row['nb'] > 0) return false; |
|
2695 | + else return true; |
|
2696 | 2696 | } |
2697 | 2697 | |
2698 | 2698 | public static function insert_last_schedules_update() { |
@@ -2701,10 +2701,10 @@ discard block |
||
2701 | 2701 | try { |
2702 | 2702 | $Connection = new Connection(); |
2703 | 2703 | $sth = $Connection->db->prepare($query); |
2704 | - $sth->execute(); |
|
2705 | - } catch(PDOException $e) { |
|
2706 | - return "error : ".$e->getMessage(); |
|
2707 | - } |
|
2704 | + $sth->execute(); |
|
2705 | + } catch(PDOException $e) { |
|
2706 | + return "error : ".$e->getMessage(); |
|
2707 | + } |
|
2708 | 2708 | } |
2709 | 2709 | public static function check_last_tle_update() { |
2710 | 2710 | global $globalDBdriver; |
@@ -2716,13 +2716,13 @@ discard block |
||
2716 | 2716 | try { |
2717 | 2717 | $Connection = new Connection(); |
2718 | 2718 | $sth = $Connection->db->prepare($query); |
2719 | - $sth->execute(); |
|
2720 | - } catch(PDOException $e) { |
|
2721 | - return "error : ".$e->getMessage(); |
|
2722 | - } |
|
2723 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2724 | - if ($row['nb'] > 0) return false; |
|
2725 | - else return true; |
|
2719 | + $sth->execute(); |
|
2720 | + } catch(PDOException $e) { |
|
2721 | + return "error : ".$e->getMessage(); |
|
2722 | + } |
|
2723 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2724 | + if ($row['nb'] > 0) return false; |
|
2725 | + else return true; |
|
2726 | 2726 | } |
2727 | 2727 | |
2728 | 2728 | public static function insert_last_tle_update() { |
@@ -2731,10 +2731,10 @@ discard block |
||
2731 | 2731 | try { |
2732 | 2732 | $Connection = new Connection(); |
2733 | 2733 | $sth = $Connection->db->prepare($query); |
2734 | - $sth->execute(); |
|
2735 | - } catch(PDOException $e) { |
|
2736 | - return "error : ".$e->getMessage(); |
|
2737 | - } |
|
2734 | + $sth->execute(); |
|
2735 | + } catch(PDOException $e) { |
|
2736 | + return "error : ".$e->getMessage(); |
|
2737 | + } |
|
2738 | 2738 | } |
2739 | 2739 | public static function check_last_marine_identity_update() { |
2740 | 2740 | global $globalDBdriver; |
@@ -2746,13 +2746,13 @@ discard block |
||
2746 | 2746 | try { |
2747 | 2747 | $Connection = new Connection(); |
2748 | 2748 | $sth = $Connection->db->prepare($query); |
2749 | - $sth->execute(); |
|
2750 | - } catch(PDOException $e) { |
|
2751 | - return "error : ".$e->getMessage(); |
|
2752 | - } |
|
2753 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2754 | - if ($row['nb'] > 0) return false; |
|
2755 | - else return true; |
|
2749 | + $sth->execute(); |
|
2750 | + } catch(PDOException $e) { |
|
2751 | + return "error : ".$e->getMessage(); |
|
2752 | + } |
|
2753 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2754 | + if ($row['nb'] > 0) return false; |
|
2755 | + else return true; |
|
2756 | 2756 | } |
2757 | 2757 | |
2758 | 2758 | public static function insert_last_marine_identity_update() { |
@@ -2761,10 +2761,10 @@ discard block |
||
2761 | 2761 | try { |
2762 | 2762 | $Connection = new Connection(); |
2763 | 2763 | $sth = $Connection->db->prepare($query); |
2764 | - $sth->execute(); |
|
2765 | - } catch(PDOException $e) { |
|
2766 | - return "error : ".$e->getMessage(); |
|
2767 | - } |
|
2764 | + $sth->execute(); |
|
2765 | + } catch(PDOException $e) { |
|
2766 | + return "error : ".$e->getMessage(); |
|
2767 | + } |
|
2768 | 2768 | } |
2769 | 2769 | public static function delete_duplicatemodes() { |
2770 | 2770 | global $globalDBdriver; |
@@ -2776,10 +2776,10 @@ discard block |
||
2776 | 2776 | try { |
2777 | 2777 | $Connection = new Connection(); |
2778 | 2778 | $sth = $Connection->db->prepare($query); |
2779 | - $sth->execute(); |
|
2780 | - } catch(PDOException $e) { |
|
2781 | - return "error : ".$e->getMessage(); |
|
2782 | - } |
|
2779 | + $sth->execute(); |
|
2780 | + } catch(PDOException $e) { |
|
2781 | + return "error : ".$e->getMessage(); |
|
2782 | + } |
|
2783 | 2783 | } |
2784 | 2784 | public static function delete_duplicateowner() { |
2785 | 2785 | global $globalDBdriver; |
@@ -2791,10 +2791,10 @@ discard block |
||
2791 | 2791 | try { |
2792 | 2792 | $Connection = new Connection(); |
2793 | 2793 | $sth = $Connection->db->prepare($query); |
2794 | - $sth->execute(); |
|
2795 | - } catch(PDOException $e) { |
|
2796 | - return "error : ".$e->getMessage(); |
|
2797 | - } |
|
2794 | + $sth->execute(); |
|
2795 | + } catch(PDOException $e) { |
|
2796 | + return "error : ".$e->getMessage(); |
|
2797 | + } |
|
2798 | 2798 | } |
2799 | 2799 | |
2800 | 2800 | public static function update_all() { |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | $this->SI = new SpotterImport($this->db); |
17 | 17 | } |
18 | 18 | /** |
19 | - * Change IATA to ICAO value for ident |
|
20 | - * |
|
21 | - * @param String $ident ident |
|
22 | - * @return String the icao |
|
23 | - */ |
|
19 | + * Change IATA to ICAO value for ident |
|
20 | + * |
|
21 | + * @param String $ident ident |
|
22 | + * @return String the icao |
|
23 | + */ |
|
24 | 24 | public function ident2icao($ident) { |
25 | 25 | if (substr($ident,0,2) == 'AF') { |
26 | 26 | if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | - * Deletes all info in the live table |
|
40 | - * |
|
41 | - * @return String success or false |
|
42 | - * |
|
43 | - */ |
|
39 | + * Deletes all info in the live table |
|
40 | + * |
|
41 | + * @return String success or false |
|
42 | + * |
|
43 | + */ |
|
44 | 44 | public function deleteLiveAcarsData() |
45 | 45 | { |
46 | 46 | global $globalDBdriver; |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | - * Deletes all info in the archive table |
|
64 | - * |
|
65 | - * @return String success or false |
|
66 | - * |
|
67 | - */ |
|
63 | + * Deletes all info in the archive table |
|
64 | + * |
|
65 | + * @return String success or false |
|
66 | + * |
|
67 | + */ |
|
68 | 68 | public function deleteArchiveAcarsData() |
69 | 69 | { |
70 | 70 | global $globalACARSArchiveKeepMonths, $globalDBdriver; |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | |
86 | 86 | |
87 | 87 | /** |
88 | - * Parse ACARS data |
|
89 | - * |
|
90 | - * @param String ACARS data in acarsdec data |
|
91 | - * |
|
92 | - */ |
|
88 | + * Parse ACARS data |
|
89 | + * |
|
90 | + * @param String ACARS data in acarsdec data |
|
91 | + * |
|
92 | + */ |
|
93 | 93 | public function parse($data) { |
94 | 94 | global $globalDebug, $globalACARSArchive; |
95 | 95 | //$Image = new Image($this->db); |
@@ -719,11 +719,11 @@ discard block |
||
719 | 719 | } |
720 | 720 | |
721 | 721 | /** |
722 | - * Add ACARS data |
|
723 | - * |
|
724 | - * @param String ACARS data in acarsdec data |
|
725 | - * |
|
726 | - */ |
|
722 | + * Add ACARS data |
|
723 | + * |
|
724 | + * @param String ACARS data in acarsdec data |
|
725 | + * |
|
726 | + */ |
|
727 | 727 | function add($data) { |
728 | 728 | global $globalDebug, $globalACARSArchive; |
729 | 729 | $Image = new Image($this->db); |
@@ -770,15 +770,15 @@ discard block |
||
770 | 770 | } |
771 | 771 | |
772 | 772 | /** |
773 | - * Add Live ACARS data in DB |
|
774 | - * |
|
775 | - * @param String $ident ident |
|
776 | - * @param String $registration Registration of the aircraft |
|
777 | - * @param String $label Label of the ACARS message |
|
778 | - * @param String $block_id Block id of the ACARS message |
|
779 | - * @param String $msg_no Number of the ACARS message |
|
780 | - * @param String $message ACARS message |
|
781 | - */ |
|
773 | + * Add Live ACARS data in DB |
|
774 | + * |
|
775 | + * @param String $ident ident |
|
776 | + * @param String $registration Registration of the aircraft |
|
777 | + * @param String $label Label of the ACARS message |
|
778 | + * @param String $block_id Block id of the ACARS message |
|
779 | + * @param String $msg_no Number of the ACARS message |
|
780 | + * @param String $message ACARS message |
|
781 | + */ |
|
782 | 782 | public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
783 | 783 | global $globalDebug; |
784 | 784 | date_default_timezone_set('UTC'); |
@@ -814,15 +814,15 @@ discard block |
||
814 | 814 | } |
815 | 815 | |
816 | 816 | /** |
817 | - * Add Archive ACARS data in DB |
|
818 | - * |
|
819 | - * @param String $ident ident |
|
820 | - * @param String $registration Registration of the aircraft |
|
821 | - * @param String $label Label of the ACARS message |
|
822 | - * @param String $block_id Block id of the ACARS message |
|
823 | - * @param String $msg_no Number of the ACARS message |
|
824 | - * @param String $message ACARS message |
|
825 | - */ |
|
817 | + * Add Archive ACARS data in DB |
|
818 | + * |
|
819 | + * @param String $ident ident |
|
820 | + * @param String $registration Registration of the aircraft |
|
821 | + * @param String $label Label of the ACARS message |
|
822 | + * @param String $block_id Block id of the ACARS message |
|
823 | + * @param String $msg_no Number of the ACARS message |
|
824 | + * @param String $message ACARS message |
|
825 | + */ |
|
826 | 826 | public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
827 | 827 | global $globalDebug; |
828 | 828 | date_default_timezone_set('UTC'); |
@@ -853,11 +853,11 @@ discard block |
||
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
856 | - * Get Message title from label from DB |
|
857 | - * |
|
858 | - * @param String $label |
|
859 | - * @return String Return ACARS title |
|
860 | - */ |
|
856 | + * Get Message title from label from DB |
|
857 | + * |
|
858 | + * @param String $label |
|
859 | + * @return String Return ACARS title |
|
860 | + */ |
|
861 | 861 | public function getTitlefromLabel($label) { |
862 | 862 | $Connection = new Connection($this->db); |
863 | 863 | $this->db = $Connection->db; |
@@ -876,10 +876,10 @@ discard block |
||
876 | 876 | } |
877 | 877 | |
878 | 878 | /** |
879 | - * List all Message title & label from DB |
|
880 | - * |
|
881 | - * @return Array Return ACARS data in array |
|
882 | - */ |
|
879 | + * List all Message title & label from DB |
|
880 | + * |
|
881 | + * @return Array Return ACARS data in array |
|
882 | + */ |
|
883 | 883 | public function getAllTitleLabel() { |
884 | 884 | $query = "SELECT * FROM acars_label ORDER BY title"; |
885 | 885 | $query_values = array(); |
@@ -896,11 +896,11 @@ discard block |
||
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
899 | - * Get Live ACARS data from DB |
|
900 | - * |
|
901 | - * @param String $ident |
|
902 | - * @return Array Return ACARS data in array |
|
903 | - */ |
|
899 | + * Get Live ACARS data from DB |
|
900 | + * |
|
901 | + * @param String $ident |
|
902 | + * @return Array Return ACARS data in array |
|
903 | + */ |
|
904 | 904 | public function getLiveAcarsData($ident) { |
905 | 905 | $query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC"; |
906 | 906 | $query_values = array(':ident' => $ident); |
@@ -917,10 +917,10 @@ discard block |
||
917 | 917 | } |
918 | 918 | |
919 | 919 | /** |
920 | - * Get Latest ACARS data from DB |
|
921 | - * |
|
922 | - * @return Array Return ACARS data in array |
|
923 | - */ |
|
920 | + * Get Latest ACARS data from DB |
|
921 | + * |
|
922 | + * @return Array Return ACARS data in array |
|
923 | + */ |
|
924 | 924 | public function getLatestAcarsData($limit = '',$label = '') { |
925 | 925 | global $globalURL, $globalDBdriver; |
926 | 926 | $Image = new Image($this->db); |
@@ -1008,10 +1008,10 @@ discard block |
||
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | /** |
1011 | - * Get Archive ACARS data from DB |
|
1012 | - * |
|
1013 | - * @return Array Return ACARS data in array |
|
1014 | - */ |
|
1011 | + * Get Archive ACARS data from DB |
|
1012 | + * |
|
1013 | + * @return Array Return ACARS data in array |
|
1014 | + */ |
|
1015 | 1015 | public function getArchiveAcarsData($limit = '',$label = '') { |
1016 | 1016 | global $globalURL, $globalDBdriver; |
1017 | 1017 | $Image = new Image($this->db); |
@@ -1099,13 +1099,13 @@ discard block |
||
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | /** |
1102 | - * Add ModeS data to DB |
|
1103 | - * |
|
1104 | - * @param String $ident ident |
|
1105 | - * @param String $registration Registration of the aircraft |
|
1106 | - * @param String $icao |
|
1107 | - * @param String $ICAOTypeCode |
|
1108 | - */ |
|
1102 | + * Add ModeS data to DB |
|
1103 | + * |
|
1104 | + * @param String $ident ident |
|
1105 | + * @param String $registration Registration of the aircraft |
|
1106 | + * @param String $icao |
|
1107 | + * @param String $ICAOTypeCode |
|
1108 | + */ |
|
1109 | 1109 | public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
1110 | 1110 | global $globalDebug, $globalDBdriver; |
1111 | 1111 | $ident = trim($ident); |
@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | require_once(dirname(__FILE__).'/class.Common.php'); |
4 | 4 | class aprs { |
5 | - private $socket; |
|
6 | - private $connected = false; |
|
5 | + private $socket; |
|
6 | + private $connected = false; |
|
7 | 7 | |
8 | - protected $symbols = array('/!' => 'Police', |
|
8 | + protected $symbols = array('/!' => 'Police', |
|
9 | 9 | '/#' => 'DIGI', |
10 | 10 | '/$' => 'Phone', |
11 | 11 | '/%' => 'DX Cluster', |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | '\~' => 'TNC Stream SW'); |
166 | 166 | |
167 | 167 | |
168 | - private function urshift($n, $s) { |
|
168 | + private function urshift($n, $s) { |
|
169 | 169 | return ($n >= 0) ? ($n >> $s) : |
170 | - (($n & 0x7fffffff) >> $s) | |
|
170 | + (($n & 0x7fffffff) >> $s) | |
|
171 | 171 | (0x40000000 >> ($s - 1)); |
172 | - } |
|
172 | + } |
|
173 | 173 | |
174 | - public function parse($input) { |
|
174 | + public function parse($input) { |
|
175 | 175 | global $globalDebug; |
176 | 176 | $debug = false; |
177 | 177 | $result = array(); |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | |
184 | 184 | /* Check that end was found and body has at least one byte. */ |
185 | 185 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
186 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
187 | - return false; |
|
186 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
187 | + return false; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | if ($debug) echo 'input : '.$input."\n"; |
@@ -198,34 +198,34 @@ discard block |
||
198 | 198 | /* Parse source, target and path. */ |
199 | 199 | //FLRDF0A52>APRS,qAS,LSTB |
200 | 200 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
201 | - $ident = $matches[1]; |
|
202 | - $all_elements = $matches[2]; |
|
203 | - if ($ident == 'AIRCRAFT') { |
|
201 | + $ident = $matches[1]; |
|
202 | + $all_elements = $matches[2]; |
|
203 | + if ($ident == 'AIRCRAFT') { |
|
204 | 204 | $result['format_source'] = 'famaprs'; |
205 | 205 | $result['source_type'] = 'modes'; |
206 | - } elseif ($ident == 'MARINE') { |
|
206 | + } elseif ($ident == 'MARINE') { |
|
207 | 207 | $result['format_source'] = 'famaprs'; |
208 | 208 | $result['source_type'] = 'ais'; |
209 | - } else { |
|
209 | + } else { |
|
210 | 210 | if ($debug) echo 'ident : '.$ident."\n"; |
211 | 211 | $result['ident'] = $ident; |
212 | - } |
|
212 | + } |
|
213 | 213 | } else { |
214 | - if ($debug) 'No ident'."\n"; |
|
215 | - return false; |
|
214 | + if ($debug) 'No ident'."\n"; |
|
215 | + return false; |
|
216 | 216 | } |
217 | 217 | $elements = explode(',',$all_elements); |
218 | 218 | $source = end($elements); |
219 | 219 | $result['source'] = $source; |
220 | 220 | foreach ($elements as $element) { |
221 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
222 | - //echo "ok"; |
|
223 | - //if ($element == 'TCPIP*') return false; |
|
224 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
221 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
222 | + //echo "ok"; |
|
223 | + //if ($element == 'TCPIP*') return false; |
|
224 | + } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
225 | 225 | if ($debug) echo 'element : '.$element."\n"; |
226 | 226 | return false; |
227 | - } |
|
228 | - /* |
|
227 | + } |
|
228 | + /* |
|
229 | 229 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
230 | 230 | //echo "ok"; |
231 | 231 | } else { |
@@ -252,49 +252,49 @@ discard block |
||
252 | 252 | $body_parse = substr($body,1); |
253 | 253 | //echo 'Body : '.$body."\n"; |
254 | 254 | if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
255 | - $body_parse = substr($body_parse,10); |
|
256 | - $find = true; |
|
257 | - //echo $body_parse."\n"; |
|
255 | + $body_parse = substr($body_parse,10); |
|
256 | + $find = true; |
|
257 | + //echo $body_parse."\n"; |
|
258 | 258 | } |
259 | 259 | if (preg_match('/^`(.*)\//',$body,$matches)) { |
260 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
261 | - $find = true; |
|
262 | - //echo $body_parse."\n"; |
|
260 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
261 | + $find = true; |
|
262 | + //echo $body_parse."\n"; |
|
263 | 263 | } |
264 | 264 | if (preg_match("/^'(.*)\//",$body,$matches)) { |
265 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
266 | - $find = true; |
|
267 | - //echo $body_parse."\n"; |
|
265 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
266 | + $find = true; |
|
267 | + //echo $body_parse."\n"; |
|
268 | 268 | } |
269 | 269 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
270 | - $find = true; |
|
271 | - //print_r($matches); |
|
272 | - $timestamp = $matches[0]; |
|
273 | - if ($matches[4] == 'h') { |
|
270 | + $find = true; |
|
271 | + //print_r($matches); |
|
272 | + $timestamp = $matches[0]; |
|
273 | + if ($matches[4] == 'h') { |
|
274 | 274 | $timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]); |
275 | 275 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
276 | 276 | /* |
277 | 277 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
278 | 278 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
279 | 279 | */ |
280 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
280 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
281 | 281 | // This work or not ? |
282 | 282 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
283 | - } |
|
284 | - $body_parse = substr($body_parse,7); |
|
285 | - $result['timestamp'] = $timestamp; |
|
286 | - //echo date('Ymd H:i:s',$timestamp); |
|
283 | + } |
|
284 | + $body_parse = substr($body_parse,7); |
|
285 | + $result['timestamp'] = $timestamp; |
|
286 | + //echo date('Ymd H:i:s',$timestamp); |
|
287 | 287 | } |
288 | 288 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
289 | - $find = true; |
|
290 | - $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
291 | - $body_parse = substr($body_parse,8); |
|
292 | - $result['timestamp'] = $timestamp; |
|
293 | - //echo date('Ymd H:i:s',$timestamp); |
|
289 | + $find = true; |
|
290 | + $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
291 | + $body_parse = substr($body_parse,8); |
|
292 | + $result['timestamp'] = $timestamp; |
|
293 | + //echo date('Ymd H:i:s',$timestamp); |
|
294 | 294 | } |
295 | 295 | //if (strlen($body_parse) > 19) { |
296 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
297 | - $find = true; |
|
296 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
297 | + $find = true; |
|
298 | 298 | // 4658.70N/00707.78Ez |
299 | 299 | //print_r(str_split($body_parse)); |
300 | 300 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $lon = intval($lon_deg); |
313 | 313 | if ($lat > 89 || $lon > 179) return false; |
314 | 314 | |
315 | - /* |
|
315 | + /* |
|
316 | 316 | $tmp_5b = str_replace('.','',$lat_min); |
317 | 317 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
318 | 318 | print_r($matches); |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | $result['longitude'] = $longitude; |
327 | 327 | $body_parse = substr($body_parse,18); |
328 | 328 | $body_parse_len = strlen($body_parse); |
329 | - } |
|
330 | - $body_parse_len = strlen($body_parse); |
|
331 | - if ($body_parse_len > 0) { |
|
329 | + } |
|
330 | + $body_parse_len = strlen($body_parse); |
|
331 | + if ($body_parse_len > 0) { |
|
332 | 332 | /* |
333 | 333 | if (!isset($result['timestamp']) && !isset($result['latitude'])) { |
334 | 334 | $body_split = str_split($body); |
@@ -360,95 +360,95 @@ discard block |
||
360 | 360 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
361 | 361 | if ($symbol_code != '_') { |
362 | 362 | } |
363 | - //$body_parse = substr($body_parse,1); |
|
364 | - //$body_parse = trim($body_parse); |
|
365 | - //$body_parse_len = strlen($body_parse); |
|
366 | - if ($body_parse_len >= 7) { |
|
363 | + //$body_parse = substr($body_parse,1); |
|
364 | + //$body_parse = trim($body_parse); |
|
365 | + //$body_parse_len = strlen($body_parse); |
|
366 | + if ($body_parse_len >= 7) { |
|
367 | 367 | |
368 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
369 | - $course = substr($body_parse,0,3); |
|
370 | - $tmp_s = intval($course); |
|
371 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
372 | - $speed = substr($body_parse,4,3); |
|
373 | - if ($speed != '...') { |
|
374 | - //$result['speed'] = round($speed*1.852); |
|
375 | - $result['speed'] = intval($speed); |
|
376 | - } |
|
377 | - $body_parse = substr($body_parse,7); |
|
378 | - } |
|
379 | - // Check PHGR, PHG, RNG |
|
380 | - } |
|
381 | - /* |
|
368 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
369 | + $course = substr($body_parse,0,3); |
|
370 | + $tmp_s = intval($course); |
|
371 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
372 | + $speed = substr($body_parse,4,3); |
|
373 | + if ($speed != '...') { |
|
374 | + //$result['speed'] = round($speed*1.852); |
|
375 | + $result['speed'] = intval($speed); |
|
376 | + } |
|
377 | + $body_parse = substr($body_parse,7); |
|
378 | + } |
|
379 | + // Check PHGR, PHG, RNG |
|
380 | + } |
|
381 | + /* |
|
382 | 382 | else if ($body_parse_len > 0) { |
383 | 383 | $rest = $body_parse; |
384 | 384 | } |
385 | 385 | */ |
386 | - if (strlen($body_parse) > 0) { |
|
387 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
388 | - $altitude = intval($matches[1]); |
|
389 | - //$result['altitude'] = round($altitude*0.3048); |
|
390 | - $result['altitude'] = $altitude; |
|
391 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
392 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
393 | - } |
|
394 | - } |
|
386 | + if (strlen($body_parse) > 0) { |
|
387 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
388 | + $altitude = intval($matches[1]); |
|
389 | + //$result['altitude'] = round($altitude*0.3048); |
|
390 | + $result['altitude'] = $altitude; |
|
391 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
392 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
393 | + } |
|
394 | + } |
|
395 | 395 | |
396 | - // Telemetry |
|
397 | - /* |
|
396 | + // Telemetry |
|
397 | + /* |
|
398 | 398 | if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { |
399 | 399 | // Nothing yet... |
400 | 400 | } |
401 | 401 | */ |
402 | - // DAO |
|
402 | + // DAO |
|
403 | 403 | |
404 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
404 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
405 | 405 | |
406 | - $dao = $matches[1]; |
|
407 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
406 | + $dao = $matches[1]; |
|
407 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
408 | 408 | $dao_split = str_split($dao); |
409 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
410 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
409 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
410 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
411 | 411 | |
412 | 412 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
413 | 413 | else $result['latitude'] += $lat_off; |
414 | 414 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
415 | 415 | else $result['longitude'] += $lon_off; |
416 | - } |
|
416 | + } |
|
417 | 417 | |
418 | - $body_parse = substr($body_parse,6); |
|
419 | - } |
|
418 | + $body_parse = substr($body_parse,6); |
|
419 | + } |
|
420 | 420 | |
421 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
421 | + if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
422 | 422 | $result['ident'] = str_replace('_',' ',$matches[1]); |
423 | - } |
|
424 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
423 | + } |
|
424 | + if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
425 | 425 | $result['squawk'] = $matches[1]; |
426 | - } |
|
427 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
426 | + } |
|
427 | + if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
428 | 428 | $result['aircraft_icao'] = $matches[1]; |
429 | - } |
|
430 | - if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
429 | + } |
|
430 | + if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
431 | 431 | $result['verticalrate'] = $matches[1]; |
432 | - } |
|
433 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
432 | + } |
|
433 | + if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
434 | 434 | $result['typeid'] = $matches[1]; |
435 | - } |
|
436 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
435 | + } |
|
436 | + if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
437 | 437 | $result['statusid'] = $matches[1]; |
438 | - } |
|
439 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
438 | + } |
|
439 | + if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
440 | 440 | $result['imo'] = $matches[1]; |
441 | - } |
|
442 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
441 | + } |
|
442 | + if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
443 | 443 | $result['arrival_date'] = $matches[1]; |
444 | - } |
|
445 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
444 | + } |
|
445 | + if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
446 | 446 | $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
447 | - } |
|
448 | - // OGN comment |
|
447 | + } |
|
448 | + // OGN comment |
|
449 | 449 | // echo "Before OGN : ".$body_parse."\n"; |
450 | - //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
451 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
450 | + //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
451 | + if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
452 | 452 | $id = $matches[1]; |
453 | 453 | //$mode = substr($id,0,2); |
454 | 454 | $address = substr($id,2); |
@@ -478,53 +478,53 @@ discard block |
||
478 | 478 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
479 | 479 | $result['stealth'] = $stealth; |
480 | 480 | $result['address'] = $address; |
481 | - } |
|
481 | + } |
|
482 | 482 | |
483 | - //Comment |
|
484 | - $result['comment'] = trim($body_parse); |
|
483 | + //Comment |
|
484 | + $result['comment'] = trim($body_parse); |
|
485 | 485 | } else { |
486 | - // parse weather |
|
487 | - //$body_parse = substr($body_parse,1); |
|
488 | - //$body_parse_len = strlen($body_parse); |
|
486 | + // parse weather |
|
487 | + //$body_parse = substr($body_parse,1); |
|
488 | + //$body_parse_len = strlen($body_parse); |
|
489 | 489 | |
490 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
491 | - $result['wind_dir'] = intval($matches[1]); |
|
492 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
493 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
494 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
495 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
496 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
490 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
491 | + $result['wind_dir'] = intval($matches[1]); |
|
492 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
493 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
494 | + $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
495 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
496 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
497 | 497 | $result['wind_dir'] = intval($matches[1]); |
498 | 498 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
499 | 499 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
500 | 500 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
501 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
502 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
501 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
502 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
503 | 503 | $result['wind_dir'] = intval($matches[1]); |
504 | 504 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
505 | 505 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
506 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
507 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
506 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
507 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
508 | 508 | $result['wind_dir'] = intval($matches[1]); |
509 | 509 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
510 | 510 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
511 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
512 | - } |
|
513 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
511 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
512 | + } |
|
513 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
514 | 514 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
515 | - } |
|
515 | + } |
|
516 | 516 | } |
517 | 517 | } else $result['comment'] = trim($body_parse); |
518 | 518 | |
519 | - } |
|
519 | + } |
|
520 | 520 | //} |
521 | 521 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
522 | 522 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
523 | 523 | if ($debug) print_r($result); |
524 | 524 | return $result; |
525 | - } |
|
525 | + } |
|
526 | 526 | |
527 | - public function connect() { |
|
527 | + public function connect() { |
|
528 | 528 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
529 | 529 | $aprs_connect = 0; |
530 | 530 | $aprs_keep = 120; |
@@ -548,24 +548,24 @@ discard block |
||
548 | 548 | socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); |
549 | 549 | while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
550 | 550 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
551 | - echo 'APRS user verified !'."\n"; |
|
552 | - $this->connected = true; |
|
553 | - return true; |
|
554 | - break; |
|
551 | + echo 'APRS user verified !'."\n"; |
|
552 | + $this->connected = true; |
|
553 | + return true; |
|
554 | + break; |
|
555 | 555 | } |
556 | 556 | if (time()-$authstart > 5) { |
557 | - echo 'APRS timeout'."\n"; |
|
558 | - break; |
|
557 | + echo 'APRS timeout'."\n"; |
|
558 | + break; |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | } |
562 | - } |
|
562 | + } |
|
563 | 563 | |
564 | - public function disconnect() { |
|
564 | + public function disconnect() { |
|
565 | 565 | socket_close($this->socket); |
566 | - } |
|
566 | + } |
|
567 | 567 | |
568 | - public function send($data) { |
|
568 | + public function send($data) { |
|
569 | 569 | global $globalDebug; |
570 | 570 | if ($this->connected === false) $this->connect(); |
571 | 571 | $send = socket_send( $this->socket , $data , strlen($data),0); |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | socket_close($this->socket); |
575 | 575 | $this->connect(); |
576 | 576 | } |
577 | - } |
|
577 | + } |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | class APRSSpotter extends APRS { |
@@ -10,10 +10,10 @@ |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
13 | - * Get SQL query part for filter used |
|
14 | - * @param Array $filter the filter |
|
15 | - * @return Array the SQL part |
|
16 | - */ |
|
13 | + * Get SQL query part for filter used |
|
14 | + * @param Array $filter the filter |
|
15 | + * @return Array the SQL part |
|
16 | + */ |
|
17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -9,20 +9,20 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.GeoidHeight.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 SpotterImport { |
16 | - private $all_flights = 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_flights = 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, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid; |
27 | 27 | if (!(isset($globalNoDB) && $globalNoDB)) { |
28 | 28 | $Connection = new Connection($dbc); |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | $currentdate = date('Y-m-d'); |
35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
36 | 36 | if (!empty($sourcestat)) { |
37 | - foreach($sourcestat as $srcst) { |
|
38 | - $type = $srcst['stats_type']; |
|
37 | + foreach($sourcestat as $srcst) { |
|
38 | + $type = $srcst['stats_type']; |
|
39 | 39 | if ($type == 'polar' || $type == 'hist') { |
40 | - $source = $srcst['source_name']; |
|
41 | - $data = $srcst['source_data']; |
|
42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
43 | - } |
|
44 | - } |
|
40 | + $source = $srcst['source_name']; |
|
41 | + $data = $srcst['source_data']; |
|
42 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | $GeoidClass = FALSE; |
57 | 57 | } |
58 | 58 | } |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | - public function get_Schedule($id,$ident) { |
|
61 | + public function get_Schedule($id,$ident) { |
|
62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
63 | 63 | // Get schedule here, so it's done only one time |
64 | 64 | |
@@ -78,42 +78,42 @@ discard block |
||
78 | 78 | $operator = $Spotter->getOperator($ident); |
79 | 79 | $scheduleexist = false; |
80 | 80 | if ($Schedule->checkSchedule($operator) == 0) { |
81 | - $operator = $Translation->checkTranslation($ident); |
|
82 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
81 | + $operator = $Translation->checkTranslation($ident); |
|
82 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | - // Should also check if route schedule = route from DB |
|
89 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
85 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | + // Should also check if route schedule = route from DB |
|
89 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
91 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
92 | - if (trim($airport_icao) != '') { |
|
91 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
92 | + if (trim($airport_icao) != '') { |
|
93 | 93 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
94 | 94 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
95 | - } |
|
95 | + } |
|
96 | + } |
|
96 | 97 | } |
97 | - } |
|
98 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
98 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
99 | 99 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
100 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
101 | - if (trim($airport_icao) != '') { |
|
100 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
101 | + if (trim($airport_icao) != '') { |
|
102 | 102 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
103 | 103 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
104 | - } |
|
104 | + } |
|
105 | 105 | } |
106 | - } |
|
107 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
106 | + } |
|
107 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
108 | 108 | } |
109 | - } else $scheduleexist = true; |
|
109 | + } else $scheduleexist = true; |
|
110 | 110 | } else $scheduleexist = true; |
111 | 111 | // close connection, at least one way will work ? |
112 | - if ($scheduleexist) { |
|
112 | + if ($scheduleexist) { |
|
113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
114 | - $sch = $Schedule->getSchedule($operator); |
|
114 | + $sch = $Schedule->getSchedule($operator); |
|
115 | 115 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
116 | - } |
|
116 | + } |
|
117 | 117 | $Spotter->db = null; |
118 | 118 | $Schedule->db = null; |
119 | 119 | $Translation->db = null; |
@@ -128,78 +128,78 @@ discard block |
||
128 | 128 | } |
129 | 129 | */ |
130 | 130 | } |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | - public function checkAll() { |
|
133 | + public function checkAll() { |
|
134 | 134 | global $globalDebug, $globalNoImport; |
135 | 135 | if ($globalDebug) echo "Update last seen flights data...\n"; |
136 | 136 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
137 | - foreach ($this->all_flights as $key => $flight) { |
|
137 | + foreach ($this->all_flights as $key => $flight) { |
|
138 | 138 | if (isset($this->all_flights[$key]['id'])) { |
139 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
140 | - $Spotter = new Spotter($this->db); |
|
141 | - $real_arrival = $this->arrival($key); |
|
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
143 | - } |
|
144 | - } |
|
139 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
140 | + $Spotter = new Spotter($this->db); |
|
141 | + $real_arrival = $this->arrival($key); |
|
142 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
143 | + } |
|
144 | + } |
|
145 | + } |
|
145 | 146 | } |
146 | - } |
|
147 | 147 | |
148 | - public function arrival($key) { |
|
148 | + public function arrival($key) { |
|
149 | 149 | global $globalClosestMinDist, $globalDebug; |
150 | 150 | if ($globalDebug) echo 'Update arrival...'."\n"; |
151 | 151 | $Spotter = new Spotter($this->db); |
152 | - $airport_icao = ''; |
|
153 | - $airport_time = ''; |
|
154 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
152 | + $airport_icao = ''; |
|
153 | + $airport_time = ''; |
|
154 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
155 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
157 | - if (isset($closestAirports[0])) { |
|
158 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
159 | - $airport_icao = $closestAirports[0]['icao']; |
|
160 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
161 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
162 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
163 | - foreach ($closestAirports as $airport) { |
|
164 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
165 | - $airport_icao = $airport['icao']; |
|
166 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
167 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
168 | - break; |
|
169 | - } |
|
170 | - } |
|
171 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
172 | - $airport_icao = $closestAirports[0]['icao']; |
|
173 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
174 | - } else { |
|
175 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
176 | - } |
|
177 | - } else { |
|
178 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
179 | - } |
|
156 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
157 | + if (isset($closestAirports[0])) { |
|
158 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
159 | + $airport_icao = $closestAirports[0]['icao']; |
|
160 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
161 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
162 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
163 | + foreach ($closestAirports as $airport) { |
|
164 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
165 | + $airport_icao = $airport['icao']; |
|
166 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
167 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
168 | + break; |
|
169 | + } |
|
170 | + } |
|
171 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
172 | + $airport_icao = $closestAirports[0]['icao']; |
|
173 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
174 | + } else { |
|
175 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
176 | + } |
|
177 | + } else { |
|
178 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
179 | + } |
|
180 | 180 | |
181 | - } else { |
|
182 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
183 | - } |
|
184 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
185 | - } |
|
181 | + } else { |
|
182 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
183 | + } |
|
184 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
185 | + } |
|
186 | 186 | |
187 | 187 | |
188 | 188 | |
189 | - public function del() { |
|
189 | + public function del() { |
|
190 | 190 | global $globalDebug, $globalNoImport, $globalNoDB; |
191 | 191 | // Delete old infos |
192 | 192 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
193 | 193 | foreach ($this->all_flights as $key => $flight) { |
194 | - if (isset($flight['lastupdate'])) { |
|
194 | + if (isset($flight['lastupdate'])) { |
|
195 | 195 | if ($flight['lastupdate'] < (time()-5900)) { |
196 | - $this->delKey($key); |
|
196 | + $this->delKey($key); |
|
197 | 197 | } |
198 | - } |
|
198 | + } |
|
199 | + } |
|
199 | 200 | } |
200 | - } |
|
201 | 201 | |
202 | - public function delKey($key) { |
|
202 | + public function delKey($key) { |
|
203 | 203 | global $globalDebug, $globalNoImport, $globalNoDB; |
204 | 204 | // Delete old infos |
205 | 205 | if (isset($this->all_flights[$key]['id'])) { |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | } |
215 | 215 | } |
216 | 216 | unset($this->all_flights[$key]); |
217 | - } |
|
217 | + } |
|
218 | 218 | |
219 | - public function add($line) { |
|
219 | + public function add($line) { |
|
220 | 220 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass; |
221 | 221 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
222 | 222 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
@@ -242,20 +242,20 @@ discard block |
||
242 | 242 | |
243 | 243 | // SBS format is CSV format |
244 | 244 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
245 | - //print_r($line); |
|
246 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
247 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
245 | + //print_r($line); |
|
246 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
247 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
248 | 248 | |
249 | 249 | // Increment message number |
250 | 250 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
251 | - $current_date = date('Y-m-d'); |
|
252 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
253 | - else $source = ''; |
|
254 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
255 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
256 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
257 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
258 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
251 | + $current_date = date('Y-m-d'); |
|
252 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
253 | + else $source = ''; |
|
254 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
255 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
256 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
257 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
258 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /* |
@@ -271,54 +271,54 @@ discard block |
||
271 | 271 | //$this->db = $dbc; |
272 | 272 | |
273 | 273 | //$hex = trim($line['hex']); |
274 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | - else $id = trim($line['id']); |
|
274 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | + else $id = trim($line['id']); |
|
276 | 276 | |
277 | 277 | if (!isset($this->all_flights[$id])) { |
278 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
279 | - $this->all_flights[$id] = array(); |
|
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
283 | - if (!isset($line['id'])) { |
|
278 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
279 | + $this->all_flights[$id] = array(); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
283 | + if (!isset($line['id'])) { |
|
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
286 | 286 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | 287 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
288 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
288 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
289 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
291 | 291 | } |
292 | 292 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | //print_r($this->all_flights); |
297 | 297 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
298 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
299 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
298 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
299 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
300 | 300 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
301 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
302 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
301 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
302 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
303 | 303 | $timeelapsed = microtime(true); |
304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
305 | - $Spotter = new Spotter($this->db); |
|
306 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
305 | + $Spotter = new Spotter($this->db); |
|
306 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
307 | 307 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
308 | - } else { |
|
308 | + } else { |
|
309 | 309 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | - } |
|
311 | - $Spotter->db = null; |
|
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
310 | + } |
|
311 | + $Spotter->db = null; |
|
312 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
314 | 314 | } |
315 | - } |
|
316 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
315 | + } |
|
316 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
318 | 318 | } |
319 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
321 | - } |
|
319 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
321 | + } |
|
322 | 322 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
323 | 323 | $icao = $line['aircraft_icao']; |
324 | 324 | $Spotter = new Spotter($this->db); |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | } |
348 | 348 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
349 | 349 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
350 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
350 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
351 | 351 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
352 | - } else { |
|
352 | + } else { |
|
353 | 353 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
354 | 354 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
355 | 355 | /* |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | print_r($line); |
359 | 359 | */ |
360 | 360 | return ''; |
361 | - } |
|
361 | + } |
|
362 | 362 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
363 | 363 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
364 | 364 | return ''; |
@@ -374,21 +374,21 @@ discard block |
||
374 | 374 | } |
375 | 375 | |
376 | 376 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
377 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
377 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
378 | 378 | } |
379 | 379 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
380 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
380 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
381 | 381 | } |
382 | 382 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
383 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
383 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
384 | 384 | } |
385 | 385 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
386 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
386 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
390 | 390 | |
391 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
391 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
392 | 392 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
393 | 393 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
394 | 394 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -397,23 +397,23 @@ discard block |
||
397 | 397 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
398 | 398 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
399 | 399 | } else { |
400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
401 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
401 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
402 | 402 | $timeelapsed = microtime(true); |
403 | - $Spotter = new Spotter($this->db); |
|
404 | - $fromsource = NULL; |
|
405 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
406 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
403 | + $Spotter = new Spotter($this->db); |
|
404 | + $fromsource = NULL; |
|
405 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
406 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
407 | 407 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
408 | 408 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
409 | 409 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
410 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
410 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
411 | 411 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
412 | 412 | $Spotter->db = null; |
413 | 413 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
414 | - } |
|
414 | + } |
|
415 | 415 | } |
416 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
416 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
417 | 417 | |
418 | 418 | /* |
419 | 419 | if (!isset($line['id'])) { |
@@ -423,63 +423,63 @@ discard block |
||
423 | 423 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
424 | 424 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
425 | 425 | */ |
426 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
426 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
427 | 427 | |
428 | - //$putinarchive = true; |
|
429 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
428 | + //$putinarchive = true; |
|
429 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
430 | 430 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
431 | - } |
|
432 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
431 | + } |
|
432 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
433 | 433 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
434 | - } |
|
435 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
436 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
437 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
434 | + } |
|
435 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
436 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
437 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
438 | 438 | $timeelapsed = microtime(true); |
439 | 439 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
440 | 440 | $Spotter = new Spotter($this->db); |
441 | 441 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
442 | 442 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
443 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
443 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
444 | 444 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
445 | - } |
|
446 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
445 | + } |
|
446 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
447 | 447 | $timeelapsed = microtime(true); |
448 | 448 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
449 | - $Spotter = new Spotter($this->db); |
|
450 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
451 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
449 | + $Spotter = new Spotter($this->db); |
|
450 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
451 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
452 | 452 | $Translation = new Translation($this->db); |
453 | 453 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
454 | 454 | $route = $Spotter->getRouteInfo($ident); |
455 | 455 | $Translation->db = null; |
456 | - } |
|
457 | - $Spotter->db = null; |
|
458 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
459 | - } |
|
456 | + } |
|
457 | + $Spotter->db = null; |
|
458 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
459 | + } |
|
460 | 460 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
461 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
462 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
461 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
462 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
463 | 463 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
464 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
465 | - } |
|
464 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
465 | + } |
|
466 | 466 | } |
467 | 467 | if (!isset($globalFork)) $globalFork = TRUE; |
468 | 468 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
469 | 469 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
470 | 470 | } |
471 | - } |
|
471 | + } |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
475 | 475 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
476 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
477 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
478 | - //$dataFound = true; |
|
476 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
477 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
478 | + //$dataFound = true; |
|
479 | 479 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
480 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
481 | - if ($distance > 1000 && $distance < 10000) { |
|
482 | - // use datetime |
|
480 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
481 | + if ($distance > 1000 && $distance < 10000) { |
|
482 | + // use datetime |
|
483 | 483 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
484 | 484 | $speed = $speed*3.6; |
485 | 485 | if ($speed < 1000) { |
@@ -488,48 +488,48 @@ discard block |
||
488 | 488 | } else { |
489 | 489 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
490 | 490 | } |
491 | - } |
|
491 | + } |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | |
495 | 495 | |
496 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
497 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
498 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
499 | - return false; |
|
500 | - } |
|
501 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
502 | - else unset($timediff); |
|
503 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
504 | - else unset($timediff_archive); |
|
505 | - if ($this->tmd > 5 |
|
506 | - || (isset($line['format_source']) |
|
507 | - && $line['format_source'] == 'airwhere' |
|
508 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
509 | - || !isset($this->all_flights[$id]['longitude'])) |
|
510 | - || (isset($this->all_flights[$id]['latitude']) |
|
511 | - && isset($this->all_flights[$id]['longitude']) |
|
512 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
513 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
514 | - ) |
|
515 | - ) |
|
516 | - ) |
|
517 | - || (isset($globalVA) && $globalVA) |
|
518 | - || (isset($globalIVAO) && $globalIVAO) |
|
519 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
520 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
521 | - || (isset($globalVAM) && $globalVAM) |
|
522 | - || !isset($timediff) |
|
523 | - || $timediff > $globalLiveInterval |
|
524 | - || ($timediff > 30 |
|
525 | - && isset($this->all_flights[$id]['latitude']) |
|
526 | - && isset($this->all_flights[$id]['longitude']) |
|
527 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
528 | - ) |
|
529 | - ) { |
|
496 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
497 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
498 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
499 | + return false; |
|
500 | + } |
|
501 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
502 | + else unset($timediff); |
|
503 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
504 | + else unset($timediff_archive); |
|
505 | + if ($this->tmd > 5 |
|
506 | + || (isset($line['format_source']) |
|
507 | + && $line['format_source'] == 'airwhere' |
|
508 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
509 | + || !isset($this->all_flights[$id]['longitude'])) |
|
510 | + || (isset($this->all_flights[$id]['latitude']) |
|
511 | + && isset($this->all_flights[$id]['longitude']) |
|
512 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
513 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
514 | + ) |
|
515 | + ) |
|
516 | + ) |
|
517 | + || (isset($globalVA) && $globalVA) |
|
518 | + || (isset($globalIVAO) && $globalIVAO) |
|
519 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
520 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
521 | + || (isset($globalVAM) && $globalVAM) |
|
522 | + || !isset($timediff) |
|
523 | + || $timediff > $globalLiveInterval |
|
524 | + || ($timediff > 30 |
|
525 | + && isset($this->all_flights[$id]['latitude']) |
|
526 | + && isset($this->all_flights[$id]['longitude']) |
|
527 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
528 | + ) |
|
529 | + ) { |
|
530 | 530 | |
531 | 531 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
532 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
532 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
533 | 533 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
534 | 534 | || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
535 | 535 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -537,9 +537,9 @@ discard block |
||
537 | 537 | $this->all_flights[$id]['putinarchive'] = true; |
538 | 538 | $this->tmd = 0; |
539 | 539 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
540 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
541 | - $timeelapsed = microtime(true); |
|
542 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
540 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
541 | + $timeelapsed = microtime(true); |
|
542 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
543 | 543 | $Spotter = new Spotter($this->db); |
544 | 544 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
545 | 545 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -547,11 +547,11 @@ discard block |
||
547 | 547 | $Spotter->db = null; |
548 | 548 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
549 | 549 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
550 | - } |
|
550 | + } |
|
551 | 551 | } |
552 | 552 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
553 | - } |
|
554 | - /* |
|
553 | + } |
|
554 | + /* |
|
555 | 555 | else { |
556 | 556 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
557 | 557 | else { |
@@ -565,16 +565,16 @@ discard block |
||
565 | 565 | } |
566 | 566 | |
567 | 567 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
568 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
568 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
569 | 569 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
570 | 570 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
571 | 571 | $this->all_flights[$id]['time_last_coord'] = time(); |
572 | 572 | } |
573 | 573 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
574 | 574 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
575 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
576 | - $dataFound = true; |
|
577 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
575 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
576 | + $dataFound = true; |
|
577 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
578 | 578 | } |
579 | 579 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
580 | 580 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -585,24 +585,24 @@ discard block |
||
585 | 585 | //$putinarchive = true; |
586 | 586 | } |
587 | 587 | */ |
588 | - /* |
|
588 | + /* |
|
589 | 589 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
590 | 590 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
591 | 591 | } |
592 | 592 | */ |
593 | 593 | } |
594 | 594 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
595 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
596 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
595 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
596 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
597 | 597 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
598 | 598 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
599 | 599 | $this->all_flights[$id]['time_last_coord'] = time(); |
600 | 600 | } |
601 | 601 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
602 | 602 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
603 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
604 | - $dataFound = true; |
|
605 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
603 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
604 | + $dataFound = true; |
|
605 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
606 | 606 | } |
607 | 607 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
608 | 608 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -620,67 +620,67 @@ discard block |
||
620 | 620 | */ |
621 | 621 | } |
622 | 622 | |
623 | - } else if ($globalDebug && $timediff > 30) { |
|
623 | + } else if ($globalDebug && $timediff > 30) { |
|
624 | 624 | $this->tmd = $this->tmd + 1; |
625 | 625 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
626 | 626 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
627 | 627 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
628 | 628 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
629 | - } |
|
629 | + } |
|
630 | 630 | } |
631 | 631 | if (isset($line['last_update']) && $line['last_update'] != '') { |
632 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
633 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
632 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
633 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
634 | 634 | } |
635 | 635 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
636 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
637 | - //$dataFound = true; |
|
636 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
637 | + //$dataFound = true; |
|
638 | 638 | } |
639 | 639 | if (isset($line['format_source']) && $line['format_source'] != '') { |
640 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
640 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
641 | 641 | } |
642 | 642 | if (isset($line['source_name']) && $line['source_name'] != '') { |
643 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
643 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
644 | 644 | } |
645 | 645 | if (isset($line['emergency']) && $line['emergency'] != '') { |
646 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
647 | - //$dataFound = true; |
|
646 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
647 | + //$dataFound = true; |
|
648 | 648 | } |
649 | 649 | if (isset($line['ground']) && $line['ground'] != '') { |
650 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
650 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
651 | 651 | // Here we force archive of flight because after ground it's a new one (or should be) |
652 | 652 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
653 | 653 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
654 | 654 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
655 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
655 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
656 | 656 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
657 | - } |
|
658 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
659 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
660 | - //$dataFound = true; |
|
657 | + } |
|
658 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
659 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
660 | + //$dataFound = true; |
|
661 | 661 | } |
662 | 662 | if (isset($line['squawk']) && $line['squawk'] != '') { |
663 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
664 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
665 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
666 | - $highlight = ''; |
|
667 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
668 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
669 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
670 | - if ($highlight != '') { |
|
663 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
664 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
665 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
666 | + $highlight = ''; |
|
667 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
668 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
669 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
670 | + if ($highlight != '') { |
|
671 | 671 | $timeelapsed = microtime(true); |
672 | 672 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
673 | - $Spotter = new Spotter($this->db); |
|
674 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
675 | - $Spotter->db = null; |
|
676 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
673 | + $Spotter = new Spotter($this->db); |
|
674 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
675 | + $Spotter->db = null; |
|
676 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
677 | 677 | } |
678 | 678 | //$putinarchive = true; |
679 | 679 | //$highlight = ''; |
680 | - } |
|
680 | + } |
|
681 | 681 | |
682 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
683 | - //$dataFound = true; |
|
682 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
683 | + //$dataFound = true; |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | if (isset($line['altitude']) && $line['altitude'] != '') { |
@@ -691,13 +691,13 @@ discard block |
||
691 | 691 | $line['altitude'] = $line['altitude'] - $geoid; |
692 | 692 | } |
693 | 693 | } |
694 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
694 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
695 | 695 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
696 | 696 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
697 | 697 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
698 | 698 | //$dataFound = true; |
699 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
700 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
699 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
700 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
701 | 701 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
702 | 702 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
703 | 703 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -706,27 +706,27 @@ discard block |
||
706 | 706 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
707 | 707 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
708 | 708 | } |
709 | - } |
|
710 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
709 | + } |
|
710 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
714 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
714 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | if (isset($line['heading']) && $line['heading'] != '') { |
718 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
719 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
720 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
721 | - //$dataFound = true; |
|
718 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
719 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
720 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
721 | + //$dataFound = true; |
|
722 | 722 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
723 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
724 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
725 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
726 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
723 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
724 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
725 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
726 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
727 | 727 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
728 | - // If not enough messages and ACARS set heading to 0 |
|
729 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
728 | + // If not enough messages and ACARS set heading to 0 |
|
729 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
730 | 730 | } |
731 | 731 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
732 | 732 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -739,125 +739,125 @@ discard block |
||
739 | 739 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
740 | 740 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
741 | 741 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
742 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
743 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
744 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
745 | - //print_r($this->all_flights); |
|
746 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
747 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
748 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
742 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
743 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
744 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
745 | + //print_r($this->all_flights); |
|
746 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
747 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
748 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
749 | 749 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
750 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
751 | - $timeelapsed = microtime(true); |
|
752 | - $SpotterLive = new SpotterLive($this->db); |
|
753 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
750 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
751 | + $timeelapsed = microtime(true); |
|
752 | + $SpotterLive = new SpotterLive($this->db); |
|
753 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
754 | 754 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
755 | 755 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
756 | - } elseif (isset($line['id'])) { |
|
756 | + } elseif (isset($line['id'])) { |
|
757 | 757 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
758 | 758 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
759 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
759 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
760 | 760 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
761 | 761 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
762 | - } else $recent_ident = ''; |
|
763 | - $SpotterLive->db=null; |
|
764 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
765 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
762 | + } else $recent_ident = ''; |
|
763 | + $SpotterLive->db=null; |
|
764 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
765 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
766 | 766 | } else $recent_ident = ''; |
767 | - } else { |
|
767 | + } else { |
|
768 | 768 | $recent_ident = ''; |
769 | 769 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
770 | - } |
|
771 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
772 | - if($recent_ident == "") |
|
773 | - { |
|
770 | + } |
|
771 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
772 | + if($recent_ident == "") |
|
773 | + { |
|
774 | 774 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
775 | 775 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
776 | 776 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
777 | 777 | //adds the spotter data for the archive |
778 | 778 | $ignoreImport = false; |
779 | 779 | foreach($globalAirportIgnore as $airportIgnore) { |
780 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
780 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
781 | 781 | $ignoreImport = true; |
782 | - } |
|
782 | + } |
|
783 | 783 | } |
784 | 784 | if (count($globalAirportAccept) > 0) { |
785 | - $ignoreImport = true; |
|
786 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
785 | + $ignoreImport = true; |
|
786 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
787 | 787 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
788 | - $ignoreImport = false; |
|
788 | + $ignoreImport = false; |
|
789 | + } |
|
789 | 790 | } |
790 | - } |
|
791 | 791 | } |
792 | 792 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
793 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
793 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
794 | 794 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
795 | - $ignoreImport = true; |
|
795 | + $ignoreImport = true; |
|
796 | + } |
|
796 | 797 | } |
797 | - } |
|
798 | 798 | } |
799 | 799 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
800 | - $ignoreImport = true; |
|
801 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
800 | + $ignoreImport = true; |
|
801 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
802 | 802 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
803 | - $ignoreImport = false; |
|
803 | + $ignoreImport = false; |
|
804 | + } |
|
804 | 805 | } |
805 | - } |
|
806 | 806 | } |
807 | 807 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
808 | - $ignoreImport = true; |
|
809 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
808 | + $ignoreImport = true; |
|
809 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
810 | 810 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
811 | - $ignoreImport = false; |
|
811 | + $ignoreImport = false; |
|
812 | + } |
|
812 | 813 | } |
813 | - } |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | if (!$ignoreImport) { |
817 | - $highlight = ''; |
|
818 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
819 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
820 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
821 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
822 | - $timeelapsed = microtime(true); |
|
823 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
817 | + $highlight = ''; |
|
818 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
819 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
820 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
821 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
822 | + $timeelapsed = microtime(true); |
|
823 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
824 | 824 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
825 | - $Spotter = new Spotter($this->db); |
|
826 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
827 | - $Spotter->db = null; |
|
828 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
825 | + $Spotter = new Spotter($this->db); |
|
826 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
827 | + $Spotter->db = null; |
|
828 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
829 | 829 | } |
830 | - } |
|
831 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
832 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
830 | + } |
|
831 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
832 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
833 | 833 | |
834 | - // Add source stat in DB |
|
835 | - $Stats = new Stats($this->db); |
|
836 | - if (!empty($this->stats)) { |
|
834 | + // Add source stat in DB |
|
835 | + $Stats = new Stats($this->db); |
|
836 | + if (!empty($this->stats)) { |
|
837 | 837 | if ($globalDebug) echo 'Add source stats : '; |
838 | - foreach($this->stats as $date => $data) { |
|
839 | - foreach($data as $source => $sourced) { |
|
840 | - //print_r($sourced); |
|
841 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
842 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
843 | - if (isset($sourced['msg'])) { |
|
844 | - if (time() - $sourced['msg']['date'] > 10) { |
|
845 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
846 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
847 | - unset($this->stats[$date][$source]['msg']); |
|
848 | - } |
|
849 | - } |
|
850 | - } |
|
851 | - if ($date != date('Y-m-d')) { |
|
852 | - unset($this->stats[$date]); |
|
853 | - } |
|
854 | - } |
|
855 | - if ($globalDebug) echo 'Done'."\n"; |
|
838 | + foreach($this->stats as $date => $data) { |
|
839 | + foreach($data as $source => $sourced) { |
|
840 | + //print_r($sourced); |
|
841 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
842 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
843 | + if (isset($sourced['msg'])) { |
|
844 | + if (time() - $sourced['msg']['date'] > 10) { |
|
845 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
846 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
847 | + unset($this->stats[$date][$source]['msg']); |
|
848 | + } |
|
849 | + } |
|
850 | + } |
|
851 | + if ($date != date('Y-m-d')) { |
|
852 | + unset($this->stats[$date]); |
|
853 | + } |
|
854 | + } |
|
855 | + if ($globalDebug) echo 'Done'."\n"; |
|
856 | 856 | |
857 | - } |
|
858 | - $Stats->db = null; |
|
859 | - } |
|
860 | - $this->del(); |
|
857 | + } |
|
858 | + $Stats->db = null; |
|
859 | + } |
|
860 | + $this->del(); |
|
861 | 861 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
862 | 862 | //$ignoreImport = false; |
863 | 863 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -875,41 +875,41 @@ discard block |
||
875 | 875 | */ |
876 | 876 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
877 | 877 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
878 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
879 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
880 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
878 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
879 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
880 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
881 | 881 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
882 | - $SpotterLive = new SpotterLive($this->db); |
|
883 | - $SpotterLive->deleteLiveSpotterData(); |
|
884 | - $SpotterLive->db=null; |
|
882 | + $SpotterLive = new SpotterLive($this->db); |
|
883 | + $SpotterLive->deleteLiveSpotterData(); |
|
884 | + $SpotterLive->db=null; |
|
885 | 885 | } |
886 | - } |
|
887 | - if ($globalDebug) echo " Done\n"; |
|
888 | - $this->last_delete = time(); |
|
886 | + } |
|
887 | + if ($globalDebug) echo " Done\n"; |
|
888 | + $this->last_delete = time(); |
|
889 | 889 | } |
890 | - } else { |
|
890 | + } else { |
|
891 | 891 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
892 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
893 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
892 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
893 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
894 | 894 | } |
895 | 895 | if (isset($globalDaemon) && !$globalDaemon) { |
896 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
896 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
897 | 897 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
898 | - $Spotter = new Spotter($this->db); |
|
899 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
900 | - $Spotter->db = null; |
|
898 | + $Spotter = new Spotter($this->db); |
|
899 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
900 | + $Spotter->db = null; |
|
901 | + } |
|
901 | 902 | } |
902 | - } |
|
903 | 903 | } |
904 | 904 | |
905 | - } |
|
905 | + } |
|
906 | 906 | } |
907 | - } |
|
908 | - //adds the spotter LIVE data |
|
909 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
910 | - //echo "\nAdd in Live !! \n"; |
|
911 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
912 | - if ($globalDebug) { |
|
907 | + } |
|
908 | + //adds the spotter LIVE data |
|
909 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
910 | + //echo "\nAdd in Live !! \n"; |
|
911 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
912 | + if ($globalDebug) { |
|
913 | 913 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
914 | 914 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
915 | 915 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -917,60 +917,60 @@ discard block |
||
917 | 917 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
918 | 918 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
919 | 919 | } |
920 | - } |
|
921 | - $ignoreImport = false; |
|
922 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
923 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
920 | + } |
|
921 | + $ignoreImport = false; |
|
922 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
923 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
924 | 924 | |
925 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
926 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
927 | - $ignoreImport = true; |
|
925 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
926 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
927 | + $ignoreImport = true; |
|
928 | + } |
|
928 | 929 | } |
929 | - } |
|
930 | - if (count($globalAirportAccept) > 0) { |
|
931 | - $ignoreImport = true; |
|
932 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
933 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
930 | + if (count($globalAirportAccept) > 0) { |
|
931 | + $ignoreImport = true; |
|
932 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
933 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
934 | 934 | $ignoreImport = false; |
935 | - } |
|
935 | + } |
|
936 | 936 | } |
937 | - } |
|
938 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
937 | + } |
|
938 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
939 | 939 | foreach($globalAirlineIgnore as $airlineIgnore) { |
940 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
940 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
941 | 941 | $ignoreImport = true; |
942 | - } |
|
942 | + } |
|
943 | 943 | } |
944 | - } |
|
945 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
944 | + } |
|
945 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
946 | 946 | $ignoreImport = true; |
947 | 947 | foreach($globalAirlineAccept as $airlineAccept) { |
948 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
948 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
949 | 949 | $ignoreImport = false; |
950 | - } |
|
950 | + } |
|
951 | + } |
|
951 | 952 | } |
952 | - } |
|
953 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
953 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
954 | 954 | $ignoreImport = true; |
955 | 955 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
956 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
957 | - $ignoreImport = false; |
|
958 | - } |
|
956 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
957 | + $ignoreImport = false; |
|
958 | + } |
|
959 | + } |
|
959 | 960 | } |
960 | - } |
|
961 | 961 | |
962 | - if (!$ignoreImport) { |
|
962 | + if (!$ignoreImport) { |
|
963 | 963 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
964 | 964 | if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
965 | 965 | $timeelapsed = microtime(true); |
966 | 966 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
967 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
967 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
968 | 968 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
969 | 969 | $SpotterLive = new SpotterLive($this->db); |
970 | 970 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
971 | 971 | $SpotterLive->db = null; |
972 | 972 | if ($globalDebug) echo $result."\n"; |
973 | - } |
|
973 | + } |
|
974 | 974 | } |
975 | 975 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
976 | 976 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | //if ($line['format_source'] != 'aprs') { |
983 | 983 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
984 | 984 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
985 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
985 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
986 | 986 | $source = $this->all_flights[$id]['source_name']; |
987 | 987 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
988 | 988 | if (!isset($this->source_location[$source])) { |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | if ($stats_heading == 16) $stats_heading = 0; |
1009 | 1009 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1010 | 1010 | for ($i=0;$i<=15;$i++) { |
1011 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1011 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1012 | 1012 | } |
1013 | 1013 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
1014 | 1014 | } else { |
@@ -1021,17 +1021,17 @@ discard block |
||
1021 | 1021 | //var_dump($this->stats); |
1022 | 1022 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1023 | 1023 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1024 | - end($this->stats[$current_date][$source]['hist']); |
|
1025 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1024 | + end($this->stats[$current_date][$source]['hist']); |
|
1025 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1026 | 1026 | } else $mini = 0; |
1027 | 1027 | for ($i=$mini;$i<=$distance;$i+=10) { |
1028 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1028 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1029 | 1029 | } |
1030 | 1030 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
1031 | 1031 | } else { |
1032 | 1032 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
1033 | 1033 | } |
1034 | - } |
|
1034 | + } |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1041,7 +1041,7 @@ discard block |
||
1041 | 1041 | //$this->del(); |
1042 | 1042 | |
1043 | 1043 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1044 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1044 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1045 | 1045 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
1046 | 1046 | $SpotterLive = new SpotterLive($this->db); |
1047 | 1047 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1049,19 +1049,19 @@ discard block |
||
1049 | 1049 | //SpotterLive->deleteLiveSpotterData(); |
1050 | 1050 | if ($globalDebug) echo " Done\n"; |
1051 | 1051 | $this->last_delete_hourly = time(); |
1052 | - } else { |
|
1052 | + } else { |
|
1053 | 1053 | $this->del(); |
1054 | 1054 | $this->last_delete_hourly = time(); |
1055 | - } |
|
1055 | + } |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | - } |
|
1059 | - //$ignoreImport = false; |
|
1058 | + } |
|
1059 | + //$ignoreImport = false; |
|
1060 | 1060 | } |
1061 | 1061 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1062 | 1062 | if ($send) return $this->all_flights[$id]; |
1063 | - } |
|
1063 | + } |
|
1064 | + } |
|
1064 | 1065 | } |
1065 | - } |
|
1066 | 1066 | } |
1067 | 1067 | ?> |
@@ -7,35 +7,35 @@ discard block |
||
7 | 7 | public $db; |
8 | 8 | |
9 | 9 | protected $texts = Array( |
10 | - 'MI' => 'Shallow', |
|
11 | - 'PR' => 'Partial', |
|
12 | - 'BC' => 'Low drifting', |
|
13 | - 'BL' => 'Blowing', |
|
14 | - 'SH' => 'Showers', |
|
15 | - 'TS' => 'Thunderstorm', |
|
16 | - 'FZ' => 'Freezing', |
|
17 | - 'DZ' => 'Drizzle', |
|
18 | - 'RA' => 'Rain', |
|
19 | - 'SN' => 'Snow', |
|
20 | - 'SG' => 'Snow Grains', |
|
21 | - 'IC' => 'Ice crystals', |
|
22 | - 'PL' => 'Ice pellets', |
|
23 | - 'GR' => 'Hail', |
|
24 | - 'GS' => 'Small hail', |
|
25 | - 'UP' => 'Unknown', |
|
26 | - 'BR' => 'Mist', |
|
27 | - 'FG' => 'Fog', |
|
28 | - 'FU' => 'Smoke', |
|
29 | - 'VA' => 'Volcanic ash', |
|
30 | - 'DU' => 'Widespread dust', |
|
31 | - 'SA' => 'Sand', |
|
32 | - 'HZ' => 'Haze', |
|
33 | - 'PY' => 'Spray', |
|
34 | - 'PO' => 'Well developed dust / sand whirls', |
|
35 | - 'SQ' => 'Squalls', |
|
36 | - 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
37 | - 'SS' => 'Sandstorm', |
|
38 | - 'DS' => 'Duststorm' |
|
10 | + 'MI' => 'Shallow', |
|
11 | + 'PR' => 'Partial', |
|
12 | + 'BC' => 'Low drifting', |
|
13 | + 'BL' => 'Blowing', |
|
14 | + 'SH' => 'Showers', |
|
15 | + 'TS' => 'Thunderstorm', |
|
16 | + 'FZ' => 'Freezing', |
|
17 | + 'DZ' => 'Drizzle', |
|
18 | + 'RA' => 'Rain', |
|
19 | + 'SN' => 'Snow', |
|
20 | + 'SG' => 'Snow Grains', |
|
21 | + 'IC' => 'Ice crystals', |
|
22 | + 'PL' => 'Ice pellets', |
|
23 | + 'GR' => 'Hail', |
|
24 | + 'GS' => 'Small hail', |
|
25 | + 'UP' => 'Unknown', |
|
26 | + 'BR' => 'Mist', |
|
27 | + 'FG' => 'Fog', |
|
28 | + 'FU' => 'Smoke', |
|
29 | + 'VA' => 'Volcanic ash', |
|
30 | + 'DU' => 'Widespread dust', |
|
31 | + 'SA' => 'Sand', |
|
32 | + 'HZ' => 'Haze', |
|
33 | + 'PY' => 'Spray', |
|
34 | + 'PO' => 'Well developed dust / sand whirls', |
|
35 | + 'SQ' => 'Squalls', |
|
36 | + 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
37 | + 'SS' => 'Sandstorm', |
|
38 | + 'DS' => 'Duststorm' |
|
39 | 39 | ); |
40 | 40 | |
41 | 41 | public function __construct($dbc = null) { |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg'; |
154 | 154 | */ |
155 | 155 | } |
156 | - /* |
|
156 | + /* |
|
157 | 157 | // Wind Direction |
158 | 158 | if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) { |
159 | 159 | $result['wind_direction'] = $matches[1]; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $result['speed_variable'] = $matches[1]; |
165 | 165 | } |
166 | 166 | */ |
167 | - // Visibility |
|
167 | + // Visibility |
|
168 | 168 | if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
169 | 169 | if (isset($matches[3]) && strlen($matches[3]) > 0) { |
170 | 170 | $result['visibility'] = (float)$matches[3] * 1609.34; |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
223 | 223 | if (isset($matches[3])) { |
224 | 224 | $range = Array( |
225 | - 'from' => (float)$matches[2], |
|
226 | - 'to' => (float)$matches[4], |
|
227 | - 'unit' => $matches[5] ? 'FT' : 'M' |
|
225 | + 'from' => (float)$matches[2], |
|
226 | + 'to' => (float)$matches[4], |
|
227 | + 'unit' => $matches[5] ? 'FT' : 'M' |
|
228 | 228 | ); |
229 | 229 | } |
230 | 230 | $result['RVR'] = $matches[1]; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | } |
258 | 258 | } |
259 | 259 | return $result; |
260 | - } |
|
260 | + } |
|
261 | 261 | |
262 | 262 | public function getMETAR($icao) { |
263 | 263 | global $globalMETARcycle, $globalDBdriver; |