@@ -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,18 +298,18 @@ 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 | - } |
|
301 | + if (!isset($source['format'])) { |
|
302 | + $globalSources[$key]['format'] = 'auto'; |
|
303 | + } |
|
304 | 304 | } |
305 | 305 | connect_all($globalSources); |
306 | 306 | foreach ($globalSources as $key => $source) { |
307 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
307 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
308 | 308 | $aprs_connect = 0; |
309 | 309 | $use_aprs = true; |
310 | 310 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
311 | 311 | break; |
312 | - } |
|
312 | + } |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | if ($use_aprs) { |
@@ -350,115 +350,115 @@ discard block |
||
350 | 350 | |
351 | 351 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
352 | 352 | while ($i > 0) { |
353 | - if (!$globalDaemon) $i = $endtime-time(); |
|
354 | - // Delete old ATC |
|
355 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
353 | + if (!$globalDaemon) $i = $endtime-time(); |
|
354 | + // Delete old ATC |
|
355 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
356 | 356 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
357 | - $ATC->deleteOldATC(); |
|
358 | - } |
|
357 | + $ATC->deleteOldATC(); |
|
358 | + } |
|
359 | 359 | |
360 | - if (count($last_exec) == count($globalSources)) { |
|
360 | + if (count($last_exec) == count($globalSources)) { |
|
361 | 361 | $max = $globalMinFetch; |
362 | 362 | foreach ($last_exec as $last) { |
363 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
363 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
364 | 364 | } |
365 | 365 | if ($max != $globalMinFetch) { |
366 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
367 | - sleep($globalMinFetch-$max+2); |
|
366 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
367 | + sleep($globalMinFetch-$max+2); |
|
368 | + } |
|
368 | 369 | } |
369 | - } |
|
370 | 370 | |
371 | 371 | |
372 | - //foreach ($formats as $id => $value) { |
|
373 | - foreach ($globalSources as $id => $value) { |
|
372 | + //foreach ($formats as $id => $value) { |
|
373 | + foreach ($globalSources as $id => $value) { |
|
374 | 374 | date_default_timezone_set('UTC'); |
375 | 375 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
376 | 376 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
377 | - //$buffer = $Common->getData($hosts[$id]); |
|
378 | - $buffer = $Common->getData($value['host']); |
|
379 | - if ($buffer != '') $reset = 0; |
|
380 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
381 | - $buffer = explode('\n',$buffer); |
|
382 | - foreach ($buffer as $line) { |
|
383 | - if ($line != '' && count($line) > 7) { |
|
384 | - $line = explode(',', $line); |
|
385 | - $data = array(); |
|
386 | - $data['hex'] = $line[1]; // hex |
|
387 | - $data['ident'] = $line[2]; // ident |
|
388 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
389 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
390 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
391 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
392 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
393 | - $data['verticalrate'] = ''; // vertical rate |
|
394 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
395 | - $data['emergency'] = ''; // emergency |
|
396 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
397 | - $data['format_source'] = 'deltadbtxt'; |
|
398 | - $data['id_source'] = $id_source; |
|
399 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
400 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
401 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
402 | - $SI->add($data); |
|
403 | - unset($data); |
|
404 | - } |
|
405 | - } |
|
406 | - $last_exec[$id]['last'] = time(); |
|
377 | + //$buffer = $Common->getData($hosts[$id]); |
|
378 | + $buffer = $Common->getData($value['host']); |
|
379 | + if ($buffer != '') $reset = 0; |
|
380 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
381 | + $buffer = explode('\n',$buffer); |
|
382 | + foreach ($buffer as $line) { |
|
383 | + if ($line != '' && count($line) > 7) { |
|
384 | + $line = explode(',', $line); |
|
385 | + $data = array(); |
|
386 | + $data['hex'] = $line[1]; // hex |
|
387 | + $data['ident'] = $line[2]; // ident |
|
388 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
389 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
390 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
391 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
392 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
393 | + $data['verticalrate'] = ''; // vertical rate |
|
394 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
395 | + $data['emergency'] = ''; // emergency |
|
396 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
397 | + $data['format_source'] = 'deltadbtxt'; |
|
398 | + $data['id_source'] = $id_source; |
|
399 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
400 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
401 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
402 | + $SI->add($data); |
|
403 | + unset($data); |
|
404 | + } |
|
405 | + } |
|
406 | + $last_exec[$id]['last'] = time(); |
|
407 | 407 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
408 | - date_default_timezone_set('CET'); |
|
409 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
410 | - date_default_timezone_set('UTC'); |
|
411 | - if ($buffer != '') $reset = 0; |
|
412 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
413 | - $buffer = explode('\n',$buffer); |
|
414 | - foreach ($buffer as $line) { |
|
408 | + date_default_timezone_set('CET'); |
|
409 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
410 | + date_default_timezone_set('UTC'); |
|
411 | + if ($buffer != '') $reset = 0; |
|
412 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
413 | + $buffer = explode('\n',$buffer); |
|
414 | + foreach ($buffer as $line) { |
|
415 | 415 | if ($line != '') { |
416 | - //echo "'".$line."'\n"; |
|
417 | - $add = false; |
|
418 | - $ais_data = $AIS->parse_line(trim($line)); |
|
419 | - $data = array(); |
|
420 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
421 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
422 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
423 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
424 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
425 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
426 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
427 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
428 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
429 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
430 | - if (isset($ais_data['timestamp'])) { |
|
416 | + //echo "'".$line."'\n"; |
|
417 | + $add = false; |
|
418 | + $ais_data = $AIS->parse_line(trim($line)); |
|
419 | + $data = array(); |
|
420 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
421 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
422 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
423 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
424 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
425 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
426 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
427 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
428 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
429 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
430 | + if (isset($ais_data['timestamp'])) { |
|
431 | 431 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
432 | 432 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
433 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
434 | - $add = true; |
|
433 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
434 | + $add = true; |
|
435 | 435 | } |
436 | - } else { |
|
436 | + } else { |
|
437 | 437 | $data['datetime'] = date('Y-m-d H:i:s'); |
438 | 438 | $add = true; |
439 | - } |
|
440 | - $data['format_source'] = 'aisnmeatxt'; |
|
441 | - $data['id_source'] = $id_source; |
|
442 | - //print_r($data); |
|
443 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
444 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
445 | - unset($data); |
|
439 | + } |
|
440 | + $data['format_source'] = 'aisnmeatxt'; |
|
441 | + $data['id_source'] = $id_source; |
|
442 | + //print_r($data); |
|
443 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
444 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
445 | + unset($data); |
|
446 | 446 | } |
447 | - } |
|
448 | - $last_exec[$id]['last'] = time(); |
|
447 | + } |
|
448 | + $last_exec[$id]['last'] = time(); |
|
449 | 449 | } elseif ($value['format'] == 'aisnmeahttp') { |
450 | - $arr = $httpfeeds; |
|
451 | - $w = $e = null; |
|
450 | + $arr = $httpfeeds; |
|
451 | + $w = $e = null; |
|
452 | 452 | |
453 | - if (isset($arr[$id])) { |
|
453 | + if (isset($arr[$id])) { |
|
454 | 454 | $nn = stream_select($arr,$w,$e,$timeout); |
455 | 455 | if ($nn > 0) { |
456 | - foreach ($httpfeeds as $feed) { |
|
456 | + foreach ($httpfeeds as $feed) { |
|
457 | 457 | $buffer = stream_get_line($feed,2000,"\n"); |
458 | 458 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
459 | 459 | $buffer = explode('\n',$buffer); |
460 | 460 | foreach ($buffer as $line) { |
461 | - if ($line != '') { |
|
461 | + if ($line != '') { |
|
462 | 462 | $ais_data = $AIS->parse_line(trim($line)); |
463 | 463 | $data = array(); |
464 | 464 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -476,96 +476,96 @@ discard block |
||
476 | 476 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
477 | 477 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
478 | 478 | if (isset($ais_data['timestamp'])) { |
479 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
479 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
480 | 480 | } else { |
481 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
481 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
482 | 482 | } |
483 | 483 | $data['format_source'] = 'aisnmeahttp'; |
484 | 484 | $data['id_source'] = $id_source; |
485 | 485 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
486 | 486 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
487 | 487 | unset($data); |
488 | - } |
|
488 | + } |
|
489 | + } |
|
489 | 490 | } |
490 | - } |
|
491 | 491 | } else { |
492 | - $format = $value['format']; |
|
493 | - if (isset($tt[$format])) $tt[$format]++; |
|
494 | - else $tt[$format] = 0; |
|
495 | - if ($tt[$format] > 30) { |
|
492 | + $format = $value['format']; |
|
493 | + if (isset($tt[$format])) $tt[$format]++; |
|
494 | + else $tt[$format] = 0; |
|
495 | + if ($tt[$format] > 30) { |
|
496 | 496 | if ($globalDebug) echo 'Reconnect...'."\n"; |
497 | 497 | sleep(2); |
498 | 498 | $sourceeen[] = $value; |
499 | 499 | connect_all($sourceeen); |
500 | 500 | $sourceeen = array(); |
501 | - } |
|
501 | + } |
|
502 | + } |
|
502 | 503 | } |
503 | - } |
|
504 | 504 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
505 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
506 | - if ($buffer != '') { |
|
505 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
506 | + if ($buffer != '') { |
|
507 | 507 | //echo $buffer; |
508 | 508 | $all_data = json_decode($buffer,true); |
509 | 509 | //print_r($all_data); |
510 | 510 | if (isset($all_data[0]['DATA'])) { |
511 | - foreach ($all_data[0]['DATA'] as $line) { |
|
511 | + foreach ($all_data[0]['DATA'] as $line) { |
|
512 | 512 | if ($line != '') { |
513 | - $data = array(); |
|
514 | - $data['ident'] = $line['NAME']; |
|
515 | - $data['mmsi'] = $line['MMSI']; |
|
516 | - $data['speed'] = $line['SOG']; |
|
517 | - $data['heading'] = $line['COG']; |
|
518 | - $data['latitude'] = $line['LAT']; |
|
519 | - $data['longitude'] = $line['LNG']; |
|
520 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
521 | - $data['imo'] = $line['IMO']; |
|
522 | - //$data['arrival_code'] = $ais_data['destination']; |
|
523 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
524 | - $data['format_source'] = 'myshiptracking'; |
|
525 | - $data['id_source'] = $id_source; |
|
526 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
527 | - $MI->add($data); |
|
528 | - unset($data); |
|
513 | + $data = array(); |
|
514 | + $data['ident'] = $line['NAME']; |
|
515 | + $data['mmsi'] = $line['MMSI']; |
|
516 | + $data['speed'] = $line['SOG']; |
|
517 | + $data['heading'] = $line['COG']; |
|
518 | + $data['latitude'] = $line['LAT']; |
|
519 | + $data['longitude'] = $line['LNG']; |
|
520 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
521 | + $data['imo'] = $line['IMO']; |
|
522 | + //$data['arrival_code'] = $ais_data['destination']; |
|
523 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
524 | + $data['format_source'] = 'myshiptracking'; |
|
525 | + $data['id_source'] = $id_source; |
|
526 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
527 | + $MI->add($data); |
|
528 | + unset($data); |
|
529 | + } |
|
529 | 530 | } |
530 | - } |
|
531 | 531 | } |
532 | - } |
|
533 | - $last_exec[$id]['last'] = time(); |
|
532 | + } |
|
533 | + $last_exec[$id]['last'] = time(); |
|
534 | 534 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
535 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
536 | - if ($buffer != '') { |
|
535 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
536 | + if ($buffer != '') { |
|
537 | 537 | $all_data = json_decode($buffer,true); |
538 | 538 | if (isset($all_data[0]['mmsi'])) { |
539 | - foreach ($all_data as $line) { |
|
539 | + foreach ($all_data as $line) { |
|
540 | 540 | if ($line != '') { |
541 | - $data = array(); |
|
542 | - $data['ident'] = $line['shipname']; |
|
543 | - $data['callsign'] = $line['callsign']; |
|
544 | - $data['mmsi'] = $line['mmsi']; |
|
545 | - $data['speed'] = $line['sog']; |
|
546 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
547 | - $data['latitude'] = $line['latitude']; |
|
548 | - $data['longitude'] = $line['longitude']; |
|
549 | - $data['type_id'] = $line['shiptype']; |
|
550 | - $data['arrival_code'] = $line['destination']; |
|
551 | - $data['datetime'] = $line['time']; |
|
552 | - $data['format_source'] = 'boatbeaconapp'; |
|
553 | - $data['id_source'] = $id_source; |
|
554 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
555 | - $MI->add($data); |
|
556 | - unset($data); |
|
541 | + $data = array(); |
|
542 | + $data['ident'] = $line['shipname']; |
|
543 | + $data['callsign'] = $line['callsign']; |
|
544 | + $data['mmsi'] = $line['mmsi']; |
|
545 | + $data['speed'] = $line['sog']; |
|
546 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
547 | + $data['latitude'] = $line['latitude']; |
|
548 | + $data['longitude'] = $line['longitude']; |
|
549 | + $data['type_id'] = $line['shiptype']; |
|
550 | + $data['arrival_code'] = $line['destination']; |
|
551 | + $data['datetime'] = $line['time']; |
|
552 | + $data['format_source'] = 'boatbeaconapp'; |
|
553 | + $data['id_source'] = $id_source; |
|
554 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
555 | + $MI->add($data); |
|
556 | + unset($data); |
|
557 | + } |
|
557 | 558 | } |
558 | - } |
|
559 | 559 | } |
560 | 560 | |
561 | - } |
|
562 | - $last_exec[$id]['last'] = time(); |
|
561 | + } |
|
562 | + $last_exec[$id]['last'] = time(); |
|
563 | 563 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
564 | - $buffer = $Common->getData($value['host']); |
|
565 | - if ($buffer != '') { |
|
564 | + $buffer = $Common->getData($value['host']); |
|
565 | + if ($buffer != '') { |
|
566 | 566 | $all_data = json_decode($buffer,true); |
567 | 567 | if (isset($all_data['features'][0]['id'])) { |
568 | - foreach ($all_data['features'] as $line) { |
|
568 | + foreach ($all_data['features'] as $line) { |
|
569 | 569 | $data = array(); |
570 | 570 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
571 | 571 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -584,59 +584,59 @@ discard block |
||
584 | 584 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
585 | 585 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
586 | 586 | unset($data); |
587 | - } |
|
587 | + } |
|
588 | 588 | } |
589 | 589 | |
590 | - } |
|
591 | - $last_exec[$id]['last'] = time(); |
|
590 | + } |
|
591 | + $last_exec[$id]['last'] = time(); |
|
592 | 592 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
593 | - echo 'download...'; |
|
594 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
595 | - echo 'done !'."\n"; |
|
596 | - if ($buffer != '') $reset = 0; |
|
597 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
598 | - $buffer = explode('\n',$buffer); |
|
599 | - foreach ($buffer as $line) { |
|
593 | + echo 'download...'; |
|
594 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
595 | + echo 'done !'."\n"; |
|
596 | + if ($buffer != '') $reset = 0; |
|
597 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
598 | + $buffer = explode('\n',$buffer); |
|
599 | + foreach ($buffer as $line) { |
|
600 | 600 | if ($line != '') { |
601 | - $data = array(); |
|
602 | - $data['mmsi'] = (int)substr($line,0,9); |
|
603 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
604 | - //$data['status'] = substr($line,21,2); |
|
605 | - //$data['type'] = substr($line,24,3); |
|
606 | - $data['latitude'] = substr($line,29,9); |
|
607 | - $data['longitude'] = substr($line,41,9); |
|
608 | - $data['speed'] = round(substr($line,51,5)); |
|
609 | - //$data['course'] = substr($line,57,5); |
|
610 | - $data['heading'] = round(substr($line,63,3)); |
|
611 | - //$data['draft'] = substr($line,67,4); |
|
612 | - //$data['length'] = substr($line,72,3); |
|
613 | - //$data['beam'] = substr($line,76,2); |
|
614 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
615 | - //$data['callsign'] = trim(substr($line,100,7); |
|
616 | - //$data['dest'] = substr($line,108,20); |
|
617 | - //$data['etaDate'] = substr($line,129,5); |
|
618 | - //$data['etaTime'] = substr($line,135,5); |
|
619 | - $data['format_source'] = 'shipplotter'; |
|
620 | - $data['id_source'] = $id_source; |
|
621 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
622 | - //print_r($data); |
|
623 | - echo 'Add...'."\n"; |
|
624 | - $MI->add($data); |
|
625 | - unset($data); |
|
601 | + $data = array(); |
|
602 | + $data['mmsi'] = (int)substr($line,0,9); |
|
603 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
604 | + //$data['status'] = substr($line,21,2); |
|
605 | + //$data['type'] = substr($line,24,3); |
|
606 | + $data['latitude'] = substr($line,29,9); |
|
607 | + $data['longitude'] = substr($line,41,9); |
|
608 | + $data['speed'] = round(substr($line,51,5)); |
|
609 | + //$data['course'] = substr($line,57,5); |
|
610 | + $data['heading'] = round(substr($line,63,3)); |
|
611 | + //$data['draft'] = substr($line,67,4); |
|
612 | + //$data['length'] = substr($line,72,3); |
|
613 | + //$data['beam'] = substr($line,76,2); |
|
614 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
615 | + //$data['callsign'] = trim(substr($line,100,7); |
|
616 | + //$data['dest'] = substr($line,108,20); |
|
617 | + //$data['etaDate'] = substr($line,129,5); |
|
618 | + //$data['etaTime'] = substr($line,135,5); |
|
619 | + $data['format_source'] = 'shipplotter'; |
|
620 | + $data['id_source'] = $id_source; |
|
621 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
622 | + //print_r($data); |
|
623 | + echo 'Add...'."\n"; |
|
624 | + $MI->add($data); |
|
625 | + unset($data); |
|
626 | 626 | } |
627 | - } |
|
628 | - $last_exec[$id]['last'] = time(); |
|
627 | + } |
|
628 | + $last_exec[$id]['last'] = time(); |
|
629 | 629 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
630 | 630 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
631 | - //$buffer = $Common->getData($hosts[$id]); |
|
632 | - $buffer = $Common->getData($value['host']); |
|
633 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
634 | - $buffer = explode('\n',$buffer); |
|
635 | - $reset = 0; |
|
636 | - foreach ($buffer as $line) { |
|
637 | - if ($line != '') { |
|
638 | - $line = explode(':', $line); |
|
639 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
631 | + //$buffer = $Common->getData($hosts[$id]); |
|
632 | + $buffer = $Common->getData($value['host']); |
|
633 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
634 | + $buffer = explode('\n',$buffer); |
|
635 | + $reset = 0; |
|
636 | + foreach ($buffer as $line) { |
|
637 | + if ($line != '') { |
|
638 | + $line = explode(':', $line); |
|
639 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
640 | 640 | $data = array(); |
641 | 641 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
642 | 642 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -649,37 +649,37 @@ discard block |
||
649 | 649 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
650 | 650 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
651 | 651 | $data['latitude'] = $line[5]; // lat |
652 | - $data['longitude'] = $line[6]; // long |
|
653 | - $data['verticalrate'] = ''; // vertical rate |
|
654 | - $data['squawk'] = ''; // squawk |
|
655 | - $data['emergency'] = ''; // emergency |
|
656 | - $data['waypoints'] = $line[30]; |
|
652 | + $data['longitude'] = $line[6]; // long |
|
653 | + $data['verticalrate'] = ''; // vertical rate |
|
654 | + $data['squawk'] = ''; // squawk |
|
655 | + $data['emergency'] = ''; // emergency |
|
656 | + $data['waypoints'] = $line[30]; |
|
657 | 657 | $data['datetime'] = date('Y-m-d H:i:s'); |
658 | 658 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
659 | 659 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
660 | - $data['departure_airport_icao'] = $line[11]; |
|
661 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
662 | - $data['arrival_airport_icao'] = $line[13]; |
|
660 | + $data['departure_airport_icao'] = $line[11]; |
|
661 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
662 | + $data['arrival_airport_icao'] = $line[13]; |
|
663 | 663 | $data['frequency'] = $line[4]; |
664 | 664 | $data['type'] = $line[18]; |
665 | 665 | $data['range'] = $line[19]; |
666 | 666 | if (isset($line[35])) $data['info'] = $line[35]; |
667 | - $data['id_source'] = $id_source; |
|
668 | - //$data['arrival_airport_time'] = ; |
|
669 | - if ($line[9] != '') { |
|
670 | - $aircraft_data = explode('/',$line[9]); |
|
671 | - if (isset($aircraft_data[1])) { |
|
672 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
673 | - } |
|
674 | - } |
|
675 | - /* |
|
667 | + $data['id_source'] = $id_source; |
|
668 | + //$data['arrival_airport_time'] = ; |
|
669 | + if ($line[9] != '') { |
|
670 | + $aircraft_data = explode('/',$line[9]); |
|
671 | + if (isset($aircraft_data[1])) { |
|
672 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
673 | + } |
|
674 | + } |
|
675 | + /* |
|
676 | 676 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
677 | 677 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
678 | 678 | */ |
679 | - $data['format_source'] = $value['format']; |
|
679 | + $data['format_source'] = $value['format']; |
|
680 | 680 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
681 | 681 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
682 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
682 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
683 | 683 | elseif ($line[3] == 'ATC') { |
684 | 684 | //print_r($data); |
685 | 685 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -700,16 +700,16 @@ discard block |
||
700 | 700 | 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']); |
701 | 701 | } |
702 | 702 | } |
703 | - unset($data); |
|
704 | - } |
|
705 | - } |
|
706 | - } |
|
707 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
708 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
709 | - $last_exec[$id]['last'] = time(); |
|
710 | - } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
711 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
712 | - if ($buffer != '') { |
|
703 | + unset($data); |
|
704 | + } |
|
705 | + } |
|
706 | + } |
|
707 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
708 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
709 | + $last_exec[$id]['last'] = time(); |
|
710 | + } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
711 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
712 | + if ($buffer != '') { |
|
713 | 713 | $all_data = simplexml_load_string($buffer); |
714 | 714 | foreach($all_data->children() as $childdata) { |
715 | 715 | $data = array(); |
@@ -731,10 +731,10 @@ discard block |
||
731 | 731 | $SI->add($data); |
732 | 732 | unset($data); |
733 | 733 | } |
734 | - } |
|
735 | - $Source->deleteOldLocationByType('gs'); |
|
736 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
737 | - if ($buffer != '') { |
|
734 | + } |
|
735 | + $Source->deleteOldLocationByType('gs'); |
|
736 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
737 | + if ($buffer != '') { |
|
738 | 738 | $all_data = simplexml_load_string($buffer); |
739 | 739 | foreach($all_data->children() as $childdata) { |
740 | 740 | $data = array(); |
@@ -752,249 +752,249 @@ discard block |
||
752 | 752 | } |
753 | 753 | unset($data); |
754 | 754 | } |
755 | - } |
|
756 | - $last_exec[$id]['last'] = time(); |
|
755 | + } |
|
756 | + $last_exec[$id]['last'] = time(); |
|
757 | 757 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
758 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
759 | - if ($buffer != '') { |
|
760 | - $all_data = json_decode($buffer,true); |
|
761 | - if (isset($all_data['acList'])) { |
|
758 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
759 | + if ($buffer != '') { |
|
760 | + $all_data = json_decode($buffer,true); |
|
761 | + if (isset($all_data['acList'])) { |
|
762 | 762 | $reset = 0; |
763 | 763 | foreach ($all_data['acList'] as $line) { |
764 | - $data = array(); |
|
765 | - $data['hex'] = $line['Icao']; // hex |
|
766 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
767 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
768 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
769 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
770 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
771 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
772 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
773 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
774 | - $data['emergency'] = ''; // emergency |
|
775 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
764 | + $data = array(); |
|
765 | + $data['hex'] = $line['Icao']; // hex |
|
766 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
767 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
768 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
769 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
770 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
771 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
772 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
773 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
774 | + $data['emergency'] = ''; // emergency |
|
775 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
776 | 776 | |
777 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
778 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
777 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
778 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
779 | 779 | |
780 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
781 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
782 | - $data['format_source'] = 'aircraftlistjson'; |
|
783 | - $data['id_source'] = $id_source; |
|
784 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
785 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
786 | - if (isset($data['latitude'])) $SI->add($data); |
|
787 | - unset($data); |
|
780 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
781 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
782 | + $data['format_source'] = 'aircraftlistjson'; |
|
783 | + $data['id_source'] = $id_source; |
|
784 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
785 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
786 | + if (isset($data['latitude'])) $SI->add($data); |
|
787 | + unset($data); |
|
788 | 788 | } |
789 | - } elseif (is_array($all_data)) { |
|
789 | + } elseif (is_array($all_data)) { |
|
790 | 790 | $reset = 0; |
791 | 791 | foreach ($all_data as $line) { |
792 | - $data = array(); |
|
793 | - $data['hex'] = $line['hex']; // hex |
|
794 | - $data['ident'] = $line['flight']; // ident |
|
795 | - $data['altitude'] = $line['altitude']; // altitude |
|
796 | - $data['speed'] = $line['speed']; // speed |
|
797 | - $data['heading'] = $line['track']; // heading |
|
798 | - $data['latitude'] = $line['lat']; // lat |
|
799 | - $data['longitude'] = $line['lon']; // long |
|
800 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
801 | - $data['squawk'] = $line['squawk']; // squawk |
|
802 | - $data['emergency'] = ''; // emergency |
|
803 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
804 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
805 | - $data['format_source'] = 'aircraftlistjson'; |
|
806 | - $data['id_source'] = $id_source; |
|
807 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
808 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
809 | - $SI->add($data); |
|
810 | - unset($data); |
|
792 | + $data = array(); |
|
793 | + $data['hex'] = $line['hex']; // hex |
|
794 | + $data['ident'] = $line['flight']; // ident |
|
795 | + $data['altitude'] = $line['altitude']; // altitude |
|
796 | + $data['speed'] = $line['speed']; // speed |
|
797 | + $data['heading'] = $line['track']; // heading |
|
798 | + $data['latitude'] = $line['lat']; // lat |
|
799 | + $data['longitude'] = $line['lon']; // long |
|
800 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
801 | + $data['squawk'] = $line['squawk']; // squawk |
|
802 | + $data['emergency'] = ''; // emergency |
|
803 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
804 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
805 | + $data['format_source'] = 'aircraftlistjson'; |
|
806 | + $data['id_source'] = $id_source; |
|
807 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
808 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
809 | + $SI->add($data); |
|
810 | + unset($data); |
|
811 | + } |
|
811 | 812 | } |
812 | - } |
|
813 | - } |
|
814 | - //$last_exec['aircraftlistjson'] = time(); |
|
815 | - $last_exec[$id]['last'] = time(); |
|
816 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
817 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
818 | - $buffer = $Common->getData($value['host']); |
|
819 | - $all_data = json_decode($buffer,true); |
|
820 | - if (isset($all_data['planes'])) { |
|
813 | + } |
|
814 | + //$last_exec['aircraftlistjson'] = time(); |
|
815 | + $last_exec[$id]['last'] = time(); |
|
816 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
817 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
818 | + $buffer = $Common->getData($value['host']); |
|
819 | + $all_data = json_decode($buffer,true); |
|
820 | + if (isset($all_data['planes'])) { |
|
821 | 821 | $reset = 0; |
822 | 822 | foreach ($all_data['planes'] as $key => $line) { |
823 | - $data = array(); |
|
824 | - $data['hex'] = $key; // hex |
|
825 | - $data['ident'] = $line[3]; // ident |
|
826 | - $data['altitude'] = $line[6]; // altitude |
|
827 | - $data['speed'] = $line[8]; // speed |
|
828 | - $data['heading'] = $line[7]; // heading |
|
829 | - $data['latitude'] = $line[4]; // lat |
|
830 | - $data['longitude'] = $line[5]; // long |
|
831 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
832 | - $data['squawk'] = $line[10]; // squawk |
|
833 | - $data['emergency'] = ''; // emergency |
|
834 | - $data['registration'] = $line[2]; |
|
835 | - $data['aircraft_icao'] = $line[0]; |
|
836 | - $deparr = explode('-',$line[1]); |
|
837 | - if (count($deparr) == 2) { |
|
823 | + $data = array(); |
|
824 | + $data['hex'] = $key; // hex |
|
825 | + $data['ident'] = $line[3]; // ident |
|
826 | + $data['altitude'] = $line[6]; // altitude |
|
827 | + $data['speed'] = $line[8]; // speed |
|
828 | + $data['heading'] = $line[7]; // heading |
|
829 | + $data['latitude'] = $line[4]; // lat |
|
830 | + $data['longitude'] = $line[5]; // long |
|
831 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
832 | + $data['squawk'] = $line[10]; // squawk |
|
833 | + $data['emergency'] = ''; // emergency |
|
834 | + $data['registration'] = $line[2]; |
|
835 | + $data['aircraft_icao'] = $line[0]; |
|
836 | + $deparr = explode('-',$line[1]); |
|
837 | + if (count($deparr) == 2) { |
|
838 | 838 | $data['departure_airport_icao'] = $deparr[0]; |
839 | 839 | $data['arrival_airport_icao'] = $deparr[1]; |
840 | - } |
|
841 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
842 | - $data['format_source'] = 'planeupdatefaa'; |
|
843 | - $data['id_source'] = $id_source; |
|
844 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
845 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
846 | - $SI->add($data); |
|
847 | - unset($data); |
|
840 | + } |
|
841 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
842 | + $data['format_source'] = 'planeupdatefaa'; |
|
843 | + $data['id_source'] = $id_source; |
|
844 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
845 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
846 | + $SI->add($data); |
|
847 | + unset($data); |
|
848 | 848 | } |
849 | - } |
|
850 | - //$last_exec['planeupdatefaa'] = time(); |
|
851 | - $last_exec[$id]['last'] = time(); |
|
852 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
853 | - $buffer = $Common->getData($value['host']); |
|
854 | - $all_data = json_decode($buffer,true); |
|
855 | - if (isset($all_data['states'])) { |
|
849 | + } |
|
850 | + //$last_exec['planeupdatefaa'] = time(); |
|
851 | + $last_exec[$id]['last'] = time(); |
|
852 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
853 | + $buffer = $Common->getData($value['host']); |
|
854 | + $all_data = json_decode($buffer,true); |
|
855 | + if (isset($all_data['states'])) { |
|
856 | 856 | $reset = 0; |
857 | 857 | foreach ($all_data['states'] as $key => $line) { |
858 | - $data = array(); |
|
859 | - $data['hex'] = $line[0]; // hex |
|
860 | - $data['ident'] = trim($line[1]); // ident |
|
861 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
862 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
863 | - $data['heading'] = round($line[10]); // heading |
|
864 | - $data['latitude'] = $line[6]; // lat |
|
865 | - $data['longitude'] = $line[5]; // long |
|
866 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
867 | - //$data['squawk'] = $line[10]; // squawk |
|
868 | - //$data['emergency'] = ''; // emergency |
|
869 | - //$data['registration'] = $line[2]; |
|
870 | - //$data['aircraft_icao'] = $line[0]; |
|
871 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
872 | - $data['format_source'] = 'opensky'; |
|
873 | - $data['id_source'] = $id_source; |
|
874 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
875 | - $SI->add($data); |
|
876 | - unset($data); |
|
858 | + $data = array(); |
|
859 | + $data['hex'] = $line[0]; // hex |
|
860 | + $data['ident'] = trim($line[1]); // ident |
|
861 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
862 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
863 | + $data['heading'] = round($line[10]); // heading |
|
864 | + $data['latitude'] = $line[6]; // lat |
|
865 | + $data['longitude'] = $line[5]; // long |
|
866 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
867 | + //$data['squawk'] = $line[10]; // squawk |
|
868 | + //$data['emergency'] = ''; // emergency |
|
869 | + //$data['registration'] = $line[2]; |
|
870 | + //$data['aircraft_icao'] = $line[0]; |
|
871 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
872 | + $data['format_source'] = 'opensky'; |
|
873 | + $data['id_source'] = $id_source; |
|
874 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
875 | + $SI->add($data); |
|
876 | + unset($data); |
|
877 | + } |
|
877 | 878 | } |
878 | - } |
|
879 | - //$last_exec['planeupdatefaa'] = time(); |
|
880 | - $last_exec[$id]['last'] = time(); |
|
881 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
882 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
883 | - //$buffer = $Common->getData($hosts[$id]); |
|
884 | - $buffer = $Common->getData($value['host']); |
|
885 | - $all_data = json_decode($buffer,true); |
|
886 | - if (!empty($all_data)) $reset = 0; |
|
887 | - foreach ($all_data as $key => $line) { |
|
879 | + //$last_exec['planeupdatefaa'] = time(); |
|
880 | + $last_exec[$id]['last'] = time(); |
|
881 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
882 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
883 | + //$buffer = $Common->getData($hosts[$id]); |
|
884 | + $buffer = $Common->getData($value['host']); |
|
885 | + $all_data = json_decode($buffer,true); |
|
886 | + if (!empty($all_data)) $reset = 0; |
|
887 | + foreach ($all_data as $key => $line) { |
|
888 | 888 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
889 | - $data = array(); |
|
890 | - $data['hex'] = $line[0]; |
|
891 | - $data['ident'] = $line[16]; //$line[13] |
|
892 | - $data['altitude'] = $line[4]; // altitude |
|
893 | - $data['speed'] = $line[5]; // speed |
|
894 | - $data['heading'] = $line[3]; // heading |
|
895 | - $data['latitude'] = $line[1]; // lat |
|
896 | - $data['longitude'] = $line[2]; // long |
|
897 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
898 | - $data['squawk'] = $line[6]; // squawk |
|
899 | - $data['aircraft_icao'] = $line[8]; |
|
900 | - $data['registration'] = $line[9]; |
|
901 | - $data['departure_airport_iata'] = $line[11]; |
|
902 | - $data['arrival_airport_iata'] = $line[12]; |
|
903 | - $data['emergency'] = ''; // emergency |
|
904 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
905 | - $data['format_source'] = 'fr24json'; |
|
906 | - $data['id_source'] = $id_source; |
|
907 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
908 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
909 | - $SI->add($data); |
|
910 | - unset($data); |
|
889 | + $data = array(); |
|
890 | + $data['hex'] = $line[0]; |
|
891 | + $data['ident'] = $line[16]; //$line[13] |
|
892 | + $data['altitude'] = $line[4]; // altitude |
|
893 | + $data['speed'] = $line[5]; // speed |
|
894 | + $data['heading'] = $line[3]; // heading |
|
895 | + $data['latitude'] = $line[1]; // lat |
|
896 | + $data['longitude'] = $line[2]; // long |
|
897 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
898 | + $data['squawk'] = $line[6]; // squawk |
|
899 | + $data['aircraft_icao'] = $line[8]; |
|
900 | + $data['registration'] = $line[9]; |
|
901 | + $data['departure_airport_iata'] = $line[11]; |
|
902 | + $data['arrival_airport_iata'] = $line[12]; |
|
903 | + $data['emergency'] = ''; // emergency |
|
904 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
905 | + $data['format_source'] = 'fr24json'; |
|
906 | + $data['id_source'] = $id_source; |
|
907 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
908 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
909 | + $SI->add($data); |
|
910 | + unset($data); |
|
911 | 911 | } |
912 | - } |
|
913 | - //$last_exec['fr24json'] = time(); |
|
914 | - $last_exec[$id]['last'] = time(); |
|
915 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
916 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
917 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
918 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
919 | - //echo $buffer; |
|
920 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
921 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
922 | - $all_data = json_decode($buffer,true); |
|
923 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
912 | + } |
|
913 | + //$last_exec['fr24json'] = time(); |
|
914 | + $last_exec[$id]['last'] = time(); |
|
915 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
916 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
917 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
918 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
919 | + //echo $buffer; |
|
920 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
921 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
922 | + $all_data = json_decode($buffer,true); |
|
923 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
924 | 924 | die(json_last_error_msg()); |
925 | - } |
|
926 | - if (isset($all_data['mrkrs'])) { |
|
925 | + } |
|
926 | + if (isset($all_data['mrkrs'])) { |
|
927 | 927 | $reset = 0; |
928 | 928 | foreach ($all_data['mrkrs'] as $key => $line) { |
929 | - if (isset($line['inf'])) { |
|
929 | + if (isset($line['inf'])) { |
|
930 | 930 | $data = array(); |
931 | 931 | $data['hex'] = $line['inf']['ia']; |
932 | 932 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
933 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
934 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
935 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
936 | - $data['latitude'] = $line['pt'][0]; // lat |
|
937 | - $data['longitude'] = $line['pt'][1]; // long |
|
938 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
939 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
940 | - //$data['aircraft_icao'] = $line[8]; |
|
941 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
933 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
934 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
935 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
936 | + $data['latitude'] = $line['pt'][0]; // lat |
|
937 | + $data['longitude'] = $line['pt'][1]; // long |
|
938 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
939 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
940 | + //$data['aircraft_icao'] = $line[8]; |
|
941 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
942 | 942 | //$data['departure_airport_iata'] = $line[11]; |
943 | 943 | //$data['arrival_airport_iata'] = $line[12]; |
944 | - //$data['emergency'] = ''; // emergency |
|
944 | + //$data['emergency'] = ''; // emergency |
|
945 | 945 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
946 | - $data['format_source'] = 'radarvirtueljson'; |
|
947 | - $data['id_source'] = $id_source; |
|
946 | + $data['format_source'] = 'radarvirtueljson'; |
|
947 | + $data['id_source'] = $id_source; |
|
948 | 948 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
949 | 949 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
950 | 950 | $SI->add($data); |
951 | 951 | unset($data); |
952 | - } |
|
952 | + } |
|
953 | + } |
|
953 | 954 | } |
954 | - } |
|
955 | - //$last_exec['radarvirtueljson'] = time(); |
|
956 | - $last_exec[$id]['last'] = time(); |
|
957 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
958 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
959 | - //$buffer = $Common->getData($hosts[$id]); |
|
960 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
961 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
955 | + //$last_exec['radarvirtueljson'] = time(); |
|
956 | + $last_exec[$id]['last'] = time(); |
|
957 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
958 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
959 | + //$buffer = $Common->getData($hosts[$id]); |
|
960 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
961 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
962 | 962 | |
963 | - if (isset($all_data['pireps'])) { |
|
963 | + if (isset($all_data['pireps'])) { |
|
964 | 964 | $reset = 0; |
965 | - foreach ($all_data['pireps'] as $line) { |
|
966 | - $data = array(); |
|
967 | - $data['id'] = $line['id']; |
|
968 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
969 | - $data['ident'] = $line['callsign']; // ident |
|
970 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
971 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
972 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
973 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
974 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
975 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
976 | - $data['latitude'] = $line['lat']; // lat |
|
977 | - $data['longitude'] = $line['lon']; // long |
|
978 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
979 | - //$data['squawk'] = $line['squawk']; // squawk |
|
980 | - //$data['emergency'] = ''; // emergency |
|
981 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
982 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
983 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
984 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
985 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
986 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
987 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
988 | - else $data['info'] = ''; |
|
989 | - $data['format_source'] = 'pireps'; |
|
990 | - $data['id_source'] = $id_source; |
|
991 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
992 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
993 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
994 | - if ($line['icon'] == 'plane') { |
|
965 | + foreach ($all_data['pireps'] as $line) { |
|
966 | + $data = array(); |
|
967 | + $data['id'] = $line['id']; |
|
968 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
969 | + $data['ident'] = $line['callsign']; // ident |
|
970 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
971 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
972 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
973 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
974 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
975 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
976 | + $data['latitude'] = $line['lat']; // lat |
|
977 | + $data['longitude'] = $line['lon']; // long |
|
978 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
979 | + //$data['squawk'] = $line['squawk']; // squawk |
|
980 | + //$data['emergency'] = ''; // emergency |
|
981 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
982 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
983 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
984 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
985 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
986 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
987 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
988 | + else $data['info'] = ''; |
|
989 | + $data['format_source'] = 'pireps'; |
|
990 | + $data['id_source'] = $id_source; |
|
991 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
992 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
993 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
994 | + if ($line['icon'] == 'plane') { |
|
995 | 995 | $SI->add($data); |
996 | - // print_r($data); |
|
997 | - } elseif ($line['icon'] == 'ct') { |
|
996 | + // print_r($data); |
|
997 | + } elseif ($line['icon'] == 'ct') { |
|
998 | 998 | $data['info'] = str_replace('^§','<br />',$data['info']); |
999 | 999 | $data['info'] = str_replace('&sect;','',$data['info']); |
1000 | 1000 | $typec = substr($data['ident'],-3); |
@@ -1009,203 +1009,203 @@ discard block |
||
1009 | 1009 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1010 | 1010 | else $data['type'] = 'Observer'; |
1011 | 1011 | 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']); |
1012 | - } |
|
1013 | - unset($data); |
|
1012 | + } |
|
1013 | + unset($data); |
|
1014 | + } |
|
1014 | 1015 | } |
1015 | - } |
|
1016 | - //$last_exec['pirepsjson'] = time(); |
|
1017 | - $last_exec[$id]['last'] = time(); |
|
1018 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
1019 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1020 | - //$buffer = $Common->getData($hosts[$id]); |
|
1021 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1022 | - $buffer = $Common->getData($value['host']); |
|
1023 | - $all_data = json_decode($buffer,true); |
|
1024 | - if ($buffer != '' && is_array($all_data)) { |
|
1016 | + //$last_exec['pirepsjson'] = time(); |
|
1017 | + $last_exec[$id]['last'] = time(); |
|
1018 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
1019 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1020 | + //$buffer = $Common->getData($hosts[$id]); |
|
1021 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1022 | + $buffer = $Common->getData($value['host']); |
|
1023 | + $all_data = json_decode($buffer,true); |
|
1024 | + if ($buffer != '' && is_array($all_data)) { |
|
1025 | 1025 | $reset = 0; |
1026 | 1026 | foreach ($all_data as $line) { |
1027 | - $data = array(); |
|
1028 | - //$data['id'] = $line['id']; // id not usable |
|
1029 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1030 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1031 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1032 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1033 | - $data['ident'] = $line['flightnum']; // ident |
|
1034 | - $data['altitude'] = $line['alt']; // altitude |
|
1035 | - $data['speed'] = $line['gs']; // speed |
|
1036 | - $data['heading'] = $line['heading']; // heading |
|
1037 | - $data['latitude'] = $line['lat']; // lat |
|
1038 | - $data['longitude'] = $line['lng']; // long |
|
1039 | - $data['verticalrate'] = ''; // verticale rate |
|
1040 | - $data['squawk'] = ''; // squawk |
|
1041 | - $data['emergency'] = ''; // emergency |
|
1042 | - //$data['datetime'] = $line['lastupdate']; |
|
1043 | - //$data['last_update'] = $line['lastupdate']; |
|
1044 | - if (isset($value['timezone'])) { |
|
1045 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1046 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1047 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1048 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1049 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1050 | - $data['departure_airport_time'] = $line['deptime']; |
|
1051 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1052 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1053 | - $data['registration'] = $line['aircraft']; |
|
1054 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1055 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1056 | - if (isset($line['aircraftname'])) { |
|
1027 | + $data = array(); |
|
1028 | + //$data['id'] = $line['id']; // id not usable |
|
1029 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1030 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1031 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1032 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1033 | + $data['ident'] = $line['flightnum']; // ident |
|
1034 | + $data['altitude'] = $line['alt']; // altitude |
|
1035 | + $data['speed'] = $line['gs']; // speed |
|
1036 | + $data['heading'] = $line['heading']; // heading |
|
1037 | + $data['latitude'] = $line['lat']; // lat |
|
1038 | + $data['longitude'] = $line['lng']; // long |
|
1039 | + $data['verticalrate'] = ''; // verticale rate |
|
1040 | + $data['squawk'] = ''; // squawk |
|
1041 | + $data['emergency'] = ''; // emergency |
|
1042 | + //$data['datetime'] = $line['lastupdate']; |
|
1043 | + //$data['last_update'] = $line['lastupdate']; |
|
1044 | + if (isset($value['timezone'])) { |
|
1045 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1046 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1047 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1048 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1049 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1050 | + $data['departure_airport_time'] = $line['deptime']; |
|
1051 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1052 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1053 | + $data['registration'] = $line['aircraft']; |
|
1054 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1055 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1056 | + if (isset($line['aircraftname'])) { |
|
1057 | 1057 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1058 | 1058 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1059 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1060 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1061 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1062 | - else { |
|
1063 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1064 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1065 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1066 | - } |
|
1067 | - } |
|
1068 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1069 | - $data['id_source'] = $id_source; |
|
1070 | - $data['format_source'] = 'phpvmacars'; |
|
1071 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1072 | - $SI->add($data); |
|
1073 | - unset($data); |
|
1059 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1060 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1061 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1062 | + else { |
|
1063 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1064 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1065 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1066 | + } |
|
1067 | + } |
|
1068 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1069 | + $data['id_source'] = $id_source; |
|
1070 | + $data['format_source'] = 'phpvmacars'; |
|
1071 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1072 | + $SI->add($data); |
|
1073 | + unset($data); |
|
1074 | 1074 | } |
1075 | 1075 | if ($globalDebug) echo 'No more data...'."\n"; |
1076 | 1076 | unset($buffer); |
1077 | 1077 | unset($all_data); |
1078 | - } |
|
1079 | - //$last_exec['phpvmacars'] = time(); |
|
1080 | - $last_exec[$id]['last'] = time(); |
|
1081 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1082 | - //$buffer = $Common->getData($hosts[$id]); |
|
1083 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1084 | - $buffer = $Common->getData($value['host']); |
|
1085 | - $all_data = json_decode($buffer,true); |
|
1086 | - if ($buffer != '' && is_array($all_data)) { |
|
1078 | + } |
|
1079 | + //$last_exec['phpvmacars'] = time(); |
|
1080 | + $last_exec[$id]['last'] = time(); |
|
1081 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1082 | + //$buffer = $Common->getData($hosts[$id]); |
|
1083 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1084 | + $buffer = $Common->getData($value['host']); |
|
1085 | + $all_data = json_decode($buffer,true); |
|
1086 | + if ($buffer != '' && is_array($all_data)) { |
|
1087 | 1087 | $reset = 0; |
1088 | 1088 | foreach ($all_data as $line) { |
1089 | - $data = array(); |
|
1090 | - //$data['id'] = $line['id']; // id not usable |
|
1091 | - $data['id'] = trim($line['flight_id']); |
|
1092 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1093 | - $data['pilot_name'] = $line['pilot_name']; |
|
1094 | - $data['pilot_id'] = $line['pilot_id']; |
|
1095 | - $data['ident'] = trim($line['callsign']); // ident |
|
1096 | - $data['altitude'] = $line['altitude']; // altitude |
|
1097 | - $data['speed'] = $line['gs']; // speed |
|
1098 | - $data['heading'] = $line['heading']; // heading |
|
1099 | - $data['latitude'] = $line['latitude']; // lat |
|
1100 | - $data['longitude'] = $line['longitude']; // long |
|
1101 | - $data['verticalrate'] = ''; // verticale rate |
|
1102 | - $data['squawk'] = ''; // squawk |
|
1103 | - $data['emergency'] = ''; // emergency |
|
1104 | - //$data['datetime'] = $line['lastupdate']; |
|
1105 | - $data['last_update'] = $line['last_update']; |
|
1106 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1107 | - $data['departure_airport_icao'] = $line['departure']; |
|
1108 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1109 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1110 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1111 | - //$data['registration'] = $line['aircraft']; |
|
1112 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1113 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1114 | - $data['id_source'] = $id_source; |
|
1115 | - $data['format_source'] = 'vam'; |
|
1116 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1117 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1118 | - $SI->add($data); |
|
1119 | - unset($data); |
|
1089 | + $data = array(); |
|
1090 | + //$data['id'] = $line['id']; // id not usable |
|
1091 | + $data['id'] = trim($line['flight_id']); |
|
1092 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1093 | + $data['pilot_name'] = $line['pilot_name']; |
|
1094 | + $data['pilot_id'] = $line['pilot_id']; |
|
1095 | + $data['ident'] = trim($line['callsign']); // ident |
|
1096 | + $data['altitude'] = $line['altitude']; // altitude |
|
1097 | + $data['speed'] = $line['gs']; // speed |
|
1098 | + $data['heading'] = $line['heading']; // heading |
|
1099 | + $data['latitude'] = $line['latitude']; // lat |
|
1100 | + $data['longitude'] = $line['longitude']; // long |
|
1101 | + $data['verticalrate'] = ''; // verticale rate |
|
1102 | + $data['squawk'] = ''; // squawk |
|
1103 | + $data['emergency'] = ''; // emergency |
|
1104 | + //$data['datetime'] = $line['lastupdate']; |
|
1105 | + $data['last_update'] = $line['last_update']; |
|
1106 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1107 | + $data['departure_airport_icao'] = $line['departure']; |
|
1108 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1109 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1110 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1111 | + //$data['registration'] = $line['aircraft']; |
|
1112 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1113 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1114 | + $data['id_source'] = $id_source; |
|
1115 | + $data['format_source'] = 'vam'; |
|
1116 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1117 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1118 | + $SI->add($data); |
|
1119 | + unset($data); |
|
1120 | 1120 | } |
1121 | 1121 | if ($globalDebug) echo 'No more data...'."\n"; |
1122 | 1122 | unset($buffer); |
1123 | 1123 | unset($all_data); |
1124 | - } |
|
1125 | - //$last_exec['phpvmacars'] = time(); |
|
1126 | - $last_exec[$id]['last'] = time(); |
|
1124 | + } |
|
1125 | + //$last_exec['phpvmacars'] = time(); |
|
1126 | + $last_exec[$id]['last'] = time(); |
|
1127 | 1127 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1128 | 1128 | } 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') { |
1129 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1130 | - //$last_exec[$id]['last'] = time(); |
|
1129 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1130 | + //$last_exec[$id]['last'] = time(); |
|
1131 | 1131 | |
1132 | - //$read = array( $sockets[$id] ); |
|
1133 | - $read = $sockets; |
|
1134 | - $write = NULL; |
|
1135 | - $e = NULL; |
|
1136 | - $n = socket_select($read, $write, $e, $timeout); |
|
1137 | - if ($e != NULL) var_dump($e); |
|
1138 | - if ($n > 0) { |
|
1132 | + //$read = array( $sockets[$id] ); |
|
1133 | + $read = $sockets; |
|
1134 | + $write = NULL; |
|
1135 | + $e = NULL; |
|
1136 | + $n = socket_select($read, $write, $e, $timeout); |
|
1137 | + if ($e != NULL) var_dump($e); |
|
1138 | + if ($n > 0) { |
|
1139 | 1139 | $reset = 0; |
1140 | 1140 | foreach ($read as $nb => $r) { |
1141 | - //$value = $formats[$nb]; |
|
1142 | - $format = $globalSources[$nb]['format']; |
|
1143 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1141 | + //$value = $formats[$nb]; |
|
1142 | + $format = $globalSources[$nb]['format']; |
|
1143 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1144 | 1144 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1145 | - } elseif ($format == 'vrstcp') { |
|
1145 | + } elseif ($format == 'vrstcp') { |
|
1146 | 1146 | $buffer = @socket_read($r, 6000); |
1147 | - } else { |
|
1147 | + } else { |
|
1148 | 1148 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1149 | - } |
|
1150 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1151 | - //echo $buffer."\n"; |
|
1152 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1153 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1154 | - $error = false; |
|
1155 | - //$SI::del(); |
|
1156 | - if ($format == 'vrstcp') { |
|
1149 | + } |
|
1150 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1151 | + //echo $buffer."\n"; |
|
1152 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1153 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1154 | + $error = false; |
|
1155 | + //$SI::del(); |
|
1156 | + if ($format == 'vrstcp') { |
|
1157 | 1157 | $buffer = explode('},{',$buffer); |
1158 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1159 | - // SBS format is CSV format |
|
1160 | - if ($buffer !== FALSE && $buffer != '') { |
|
1158 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1159 | + // SBS format is CSV format |
|
1160 | + if ($buffer !== FALSE && $buffer != '') { |
|
1161 | 1161 | $tt[$format] = 0; |
1162 | 1162 | if ($format == 'acarssbs3') { |
1163 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1164 | - $ACARS->add(trim($buffer)); |
|
1165 | - $ACARS->deleteLiveAcarsData(); |
|
1163 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1164 | + $ACARS->add(trim($buffer)); |
|
1165 | + $ACARS->deleteLiveAcarsData(); |
|
1166 | 1166 | } elseif ($format == 'raw') { |
1167 | - // AVR format |
|
1168 | - $data = $SBS->parse($buffer); |
|
1169 | - if (is_array($data)) { |
|
1167 | + // AVR format |
|
1168 | + $data = $SBS->parse($buffer); |
|
1169 | + if (is_array($data)) { |
|
1170 | 1170 | $data['datetime'] = date('Y-m-d H:i:s'); |
1171 | 1171 | $data['format_source'] = 'raw'; |
1172 | 1172 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1173 | 1173 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1174 | 1174 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1175 | 1175 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1176 | - } |
|
1176 | + } |
|
1177 | 1177 | } elseif ($format == 'ais') { |
1178 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1179 | - $data = array(); |
|
1180 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1181 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1182 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1183 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1184 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1185 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1186 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1187 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1188 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1189 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1190 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1191 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1192 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1193 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1194 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1195 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1178 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1179 | + $data = array(); |
|
1180 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1181 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1182 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1183 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1184 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1185 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1186 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1187 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1188 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1189 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1190 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1191 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1192 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1193 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1194 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1195 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1196 | 1196 | |
1197 | - if (isset($ais_data['timestamp'])) { |
|
1197 | + if (isset($ais_data['timestamp'])) { |
|
1198 | 1198 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1199 | - } else { |
|
1199 | + } else { |
|
1200 | 1200 | $data['datetime'] = date('Y-m-d H:i:s'); |
1201 | - } |
|
1202 | - $data['format_source'] = 'aisnmea'; |
|
1203 | - $data['id_source'] = $id_source; |
|
1204 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1205 | - unset($data); |
|
1206 | - } elseif ($format == 'flightgearsp') { |
|
1207 | - //echo $buffer."\n"; |
|
1208 | - if (strlen($buffer) > 5) { |
|
1201 | + } |
|
1202 | + $data['format_source'] = 'aisnmea'; |
|
1203 | + $data['id_source'] = $id_source; |
|
1204 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1205 | + unset($data); |
|
1206 | + } elseif ($format == 'flightgearsp') { |
|
1207 | + //echo $buffer."\n"; |
|
1208 | + if (strlen($buffer) > 5) { |
|
1209 | 1209 | $line = explode(',',$buffer); |
1210 | 1210 | $data = array(); |
1211 | 1211 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1222,38 +1222,38 @@ discard block |
||
1222 | 1222 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1223 | 1223 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1224 | 1224 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1225 | - } |
|
1226 | - } elseif ($format == 'acars') { |
|
1227 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1228 | - $ACARS->add(trim($buffer)); |
|
1229 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1230 | - $ACARS->deleteLiveAcarsData(); |
|
1225 | + } |
|
1226 | + } elseif ($format == 'acars') { |
|
1227 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1228 | + $ACARS->add(trim($buffer)); |
|
1229 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1230 | + $ACARS->deleteLiveAcarsData(); |
|
1231 | 1231 | } elseif ($format == 'flightgearmp') { |
1232 | - if (substr($buffer,0,1) != '#') { |
|
1232 | + if (substr($buffer,0,1) != '#') { |
|
1233 | 1233 | $data = array(); |
1234 | 1234 | //echo $buffer."\n"; |
1235 | 1235 | $line = explode(' ',$buffer); |
1236 | 1236 | if (count($line) == 11) { |
1237 | - $userserver = explode('@',$line[0]); |
|
1238 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1239 | - $data['ident'] = $userserver[0]; |
|
1240 | - $data['registration'] = $userserver[0]; |
|
1241 | - $data['latitude'] = $line[4]; |
|
1242 | - $data['longitude'] = $line[5]; |
|
1243 | - $data['altitude'] = $line[6]; |
|
1244 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1245 | - $aircraft_type = $line[10]; |
|
1246 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1247 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1248 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1249 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1237 | + $userserver = explode('@',$line[0]); |
|
1238 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1239 | + $data['ident'] = $userserver[0]; |
|
1240 | + $data['registration'] = $userserver[0]; |
|
1241 | + $data['latitude'] = $line[4]; |
|
1242 | + $data['longitude'] = $line[5]; |
|
1243 | + $data['altitude'] = $line[6]; |
|
1244 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1245 | + $aircraft_type = $line[10]; |
|
1246 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1247 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1248 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1249 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1250 | + } |
|
1250 | 1251 | } |
1251 | - } |
|
1252 | 1252 | } elseif ($format == 'beast') { |
1253 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1254 | - die; |
|
1253 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1254 | + die; |
|
1255 | 1255 | } elseif ($format == 'vrstcp') { |
1256 | - foreach($buffer as $all_data) { |
|
1256 | + foreach($buffer as $all_data) { |
|
1257 | 1257 | $line = json_decode('{'.$all_data.'}',true); |
1258 | 1258 | $data = array(); |
1259 | 1259 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1273,116 +1273,116 @@ discard block |
||
1273 | 1273 | */ |
1274 | 1274 | $data['datetime'] = date('Y-m-d H:i:s'); |
1275 | 1275 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1276 | - $data['format_source'] = 'vrstcp'; |
|
1276 | + $data['format_source'] = 'vrstcp'; |
|
1277 | 1277 | $data['id_source'] = $id_source; |
1278 | 1278 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1279 | 1279 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1280 | 1280 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1281 | 1281 | unset($data); |
1282 | - } |
|
1282 | + } |
|
1283 | 1283 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1284 | - $line = explode("\t", $buffer); |
|
1285 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1284 | + $line = explode("\t", $buffer); |
|
1285 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1286 | 1286 | $key = $line[$k]; |
1287 | - $lined[$key] = $line[$k+1]; |
|
1288 | - } |
|
1289 | - if (count($lined) > 3) { |
|
1290 | - $data['hex'] = $lined['hexid']; |
|
1291 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1292 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1293 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1294 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1295 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1296 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1297 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1298 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1299 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1300 | - $data['id_source'] = $id_source; |
|
1301 | - $data['format_source'] = 'tsv'; |
|
1302 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1303 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1287 | + $lined[$key] = $line[$k+1]; |
|
1288 | + } |
|
1289 | + if (count($lined) > 3) { |
|
1290 | + $data['hex'] = $lined['hexid']; |
|
1291 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1292 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1293 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1294 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1295 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1296 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1297 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1298 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1299 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1300 | + $data['id_source'] = $id_source; |
|
1301 | + $data['format_source'] = 'tsv'; |
|
1302 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1303 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1304 | 1304 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1305 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1306 | - unset($lined); |
|
1307 | - unset($data); |
|
1308 | - } else $error = true; |
|
1305 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1306 | + unset($lined); |
|
1307 | + unset($data); |
|
1308 | + } else $error = true; |
|
1309 | 1309 | } elseif ($format == 'aprs' && $use_aprs) { |
1310 | - if ($aprs_connect == 0) { |
|
1310 | + if ($aprs_connect == 0) { |
|
1311 | 1311 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1312 | 1312 | $aprs_connect = 1; |
1313 | - } |
|
1313 | + } |
|
1314 | 1314 | |
1315 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1315 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1316 | 1316 | $aprs_last_tx = time(); |
1317 | 1317 | $data_aprs = "# Keep alive"; |
1318 | 1318 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1319 | - } |
|
1319 | + } |
|
1320 | 1320 | |
1321 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1322 | - //echo 'APRS data : '.$buffer."\n"; |
|
1323 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1324 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1325 | - //echo $buffer."\n"; |
|
1326 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1321 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1322 | + //echo 'APRS data : '.$buffer."\n"; |
|
1323 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1324 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1325 | + //echo $buffer."\n"; |
|
1326 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1327 | 1327 | $line = $APRS->parse($buffer); |
1328 | 1328 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1329 | 1329 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1330 | - $aprs_last_tx = time(); |
|
1331 | - $data = array(); |
|
1332 | - //print_r($line); |
|
1333 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1334 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1335 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1336 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1337 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1338 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1339 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1340 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1341 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1342 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1343 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1344 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1345 | - $data['latitude'] = $line['latitude']; |
|
1346 | - $data['longitude'] = $line['longitude']; |
|
1347 | - //$data['verticalrate'] = $line[16]; |
|
1348 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1349 | - //else $data['speed'] = 0; |
|
1350 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1351 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1352 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1353 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1354 | - //else $data['heading'] = 0; |
|
1355 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1356 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1357 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1358 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1359 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1360 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1361 | - $data['id_source'] = $id_source; |
|
1362 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1363 | - else $data['format_source'] = 'aprs'; |
|
1364 | - $data['source_name'] = $line['source']; |
|
1365 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1366 | - else $data['source_type'] = 'flarm'; |
|
1367 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1368 | - $currentdate = date('Y-m-d H:i:s'); |
|
1369 | - $aprsdate = strtotime($data['datetime']); |
|
1370 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1371 | - // Accept data if time <= system time + 20s |
|
1372 | - //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'])))) { |
|
1373 | - 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'])))) { |
|
1330 | + $aprs_last_tx = time(); |
|
1331 | + $data = array(); |
|
1332 | + //print_r($line); |
|
1333 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1334 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1335 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1336 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1337 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1338 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1339 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1340 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1341 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1342 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1343 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1344 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1345 | + $data['latitude'] = $line['latitude']; |
|
1346 | + $data['longitude'] = $line['longitude']; |
|
1347 | + //$data['verticalrate'] = $line[16]; |
|
1348 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1349 | + //else $data['speed'] = 0; |
|
1350 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1351 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1352 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1353 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1354 | + //else $data['heading'] = 0; |
|
1355 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1356 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1357 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1358 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1359 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1360 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1361 | + $data['id_source'] = $id_source; |
|
1362 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1363 | + else $data['format_source'] = 'aprs'; |
|
1364 | + $data['source_name'] = $line['source']; |
|
1365 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1366 | + else $data['source_type'] = 'flarm'; |
|
1367 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1368 | + $currentdate = date('Y-m-d H:i:s'); |
|
1369 | + $aprsdate = strtotime($data['datetime']); |
|
1370 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1371 | + // Accept data if time <= system time + 20s |
|
1372 | + //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'])))) { |
|
1373 | + 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'])))) { |
|
1374 | 1374 | $send = $SI->add($data); |
1375 | - } elseif ($data['source_type'] == 'ais') { |
|
1375 | + } elseif ($data['source_type'] == 'ais') { |
|
1376 | 1376 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1377 | - } elseif (isset($line['stealth'])) { |
|
1377 | + } elseif (isset($line['stealth'])) { |
|
1378 | 1378 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1379 | 1379 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1380 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1381 | - //} 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') { |
|
1382 | - } 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') { |
|
1380 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1381 | + //} 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') { |
|
1382 | + } 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') { |
|
1383 | 1383 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1384 | 1384 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1385 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1385 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1386 | 1386 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1387 | 1387 | $Source->deleteOldLocationByType('gs'); |
1388 | 1388 | if (count($Source->getLocationInfoByName($data['ident'])) > 0) { |
@@ -1390,11 +1390,11 @@ discard block |
||
1390 | 1390 | } else { |
1391 | 1391 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1392 | 1392 | } |
1393 | - } else { |
|
1394 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1395 | - print_r($line); |
|
1396 | - } |
|
1397 | - unset($data); |
|
1393 | + } else { |
|
1394 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1395 | + print_r($line); |
|
1396 | + } |
|
1397 | + unset($data); |
|
1398 | 1398 | } |
1399 | 1399 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1400 | 1400 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1410,12 +1410,12 @@ discard block |
||
1410 | 1410 | */ |
1411 | 1411 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1412 | 1412 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1413 | - } |
|
1413 | + } |
|
1414 | 1414 | } else { |
1415 | - $line = explode(',', $buffer); |
|
1416 | - if (count($line) > 20) { |
|
1417 | - $data['hex'] = $line[4]; |
|
1418 | - /* |
|
1415 | + $line = explode(',', $buffer); |
|
1416 | + if (count($line) > 20) { |
|
1417 | + $data['hex'] = $line[4]; |
|
1418 | + /* |
|
1419 | 1419 | $data['datetime'] = $line[6].' '.$line[7]; |
1420 | 1420 | date_default_timezone_set($globalTimezone); |
1421 | 1421 | $datetime = new DateTime($data['datetime']); |
@@ -1423,30 +1423,30 @@ discard block |
||
1423 | 1423 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1424 | 1424 | date_default_timezone_set('UTC'); |
1425 | 1425 | */ |
1426 | - // Force datetime to current UTC datetime |
|
1427 | - date_default_timezone_set('UTC'); |
|
1428 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1429 | - $data['ident'] = trim($line[10]); |
|
1430 | - $data['latitude'] = $line[14]; |
|
1431 | - $data['longitude'] = $line[15]; |
|
1432 | - $data['verticalrate'] = $line[16]; |
|
1433 | - $data['emergency'] = $line[20]; |
|
1434 | - $data['speed'] = $line[12]; |
|
1435 | - $data['squawk'] = $line[17]; |
|
1436 | - $data['altitude'] = $line[11]; |
|
1437 | - $data['heading'] = $line[13]; |
|
1438 | - $data['ground'] = $line[21]; |
|
1439 | - $data['emergency'] = $line[19]; |
|
1440 | - $data['format_source'] = 'sbs'; |
|
1426 | + // Force datetime to current UTC datetime |
|
1427 | + date_default_timezone_set('UTC'); |
|
1428 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1429 | + $data['ident'] = trim($line[10]); |
|
1430 | + $data['latitude'] = $line[14]; |
|
1431 | + $data['longitude'] = $line[15]; |
|
1432 | + $data['verticalrate'] = $line[16]; |
|
1433 | + $data['emergency'] = $line[20]; |
|
1434 | + $data['speed'] = $line[12]; |
|
1435 | + $data['squawk'] = $line[17]; |
|
1436 | + $data['altitude'] = $line[11]; |
|
1437 | + $data['heading'] = $line[13]; |
|
1438 | + $data['ground'] = $line[21]; |
|
1439 | + $data['emergency'] = $line[19]; |
|
1440 | + $data['format_source'] = 'sbs'; |
|
1441 | 1441 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1442 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1442 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1443 | 1443 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1444 | - $data['id_source'] = $id_source; |
|
1445 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1446 | - else $error = true; |
|
1447 | - unset($data); |
|
1448 | - } else $error = true; |
|
1449 | - if ($error) { |
|
1444 | + $data['id_source'] = $id_source; |
|
1445 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1446 | + else $error = true; |
|
1447 | + unset($data); |
|
1448 | + } else $error = true; |
|
1449 | + if ($error) { |
|
1450 | 1450 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1451 | 1451 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1452 | 1452 | } else { |
@@ -1462,13 +1462,13 @@ discard block |
||
1462 | 1462 | connect_all($sourceer); |
1463 | 1463 | $sourceer = array(); |
1464 | 1464 | } |
1465 | - } |
|
1465 | + } |
|
1466 | 1466 | } |
1467 | 1467 | // Sleep for xxx microseconds |
1468 | 1468 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1469 | - } else { |
|
1469 | + } else { |
|
1470 | 1470 | if ($format == 'flightgearmp') { |
1471 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1471 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1472 | 1472 | //@socket_close($r); |
1473 | 1473 | sleep($globalMinFetch); |
1474 | 1474 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1477,9 +1477,9 @@ discard block |
||
1477 | 1477 | break; |
1478 | 1478 | |
1479 | 1479 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1480 | - if (isset($tt[$format])) $tt[$format]++; |
|
1481 | - else $tt[$format] = 0; |
|
1482 | - if ($tt[$format] > 30) { |
|
1480 | + if (isset($tt[$format])) $tt[$format]++; |
|
1481 | + else $tt[$format] = 0; |
|
1482 | + if ($tt[$format] > 30) { |
|
1483 | 1483 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1484 | 1484 | //@socket_close($r); |
1485 | 1485 | sleep(2); |
@@ -1490,23 +1490,23 @@ discard block |
||
1490 | 1490 | //connect_all($globalSources); |
1491 | 1491 | $tt[$format]=0; |
1492 | 1492 | break; |
1493 | - } |
|
1493 | + } |
|
1494 | + } |
|
1494 | 1495 | } |
1495 | - } |
|
1496 | 1496 | } |
1497 | - } else { |
|
1497 | + } else { |
|
1498 | 1498 | $error = socket_strerror(socket_last_error()); |
1499 | 1499 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1500 | 1500 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1501 | 1501 | if (isset($globalDebug)) echo "Restarting...\n"; |
1502 | 1502 | // Restart the script if possible |
1503 | 1503 | if (is_array($sockets)) { |
1504 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1504 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1505 | 1505 | |
1506 | - foreach ($sockets as $sock) { |
|
1506 | + foreach ($sockets as $sock) { |
|
1507 | 1507 | @socket_shutdown($sock,2); |
1508 | 1508 | @socket_close($sock); |
1509 | - } |
|
1509 | + } |
|
1510 | 1510 | |
1511 | 1511 | } |
1512 | 1512 | if ($globalDebug) echo "Waiting..."; |
@@ -1521,13 +1521,13 @@ discard block |
||
1521 | 1521 | if ($globalDebug) echo "Restart all connections..."; |
1522 | 1522 | connect_all($globalSources); |
1523 | 1523 | } |
1524 | - } |
|
1524 | + } |
|
1525 | 1525 | } |
1526 | 1526 | if ($globalDaemon === false) { |
1527 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1528 | - $SI->checkAll(); |
|
1527 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1528 | + $SI->checkAll(); |
|
1529 | + } |
|
1529 | 1530 | } |
1530 | - } |
|
1531 | 1531 | } |
1532 | 1532 | |
1533 | 1533 | ?> |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | </tr> |
318 | 318 | <!-- |
319 | 319 | <?php |
320 | - require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
321 | - $Connection = new Connection(); |
|
320 | + require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
321 | + $Connection = new Connection(); |
|
322 | 322 | ?> |
323 | 323 | --> |
324 | 324 | <?php |
325 | - if ($Connection->db != NULL) { |
|
325 | + if ($Connection->db != NULL) { |
|
326 | 326 | if ($Connection->tableExists('source_location')) { |
327 | - require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
328 | - $Source = new Source(); |
|
329 | - //$alllocations = $Source->getAllLocationInfo(); |
|
330 | - $alllocations = $Source->getLocationInfobyType(''); |
|
331 | - foreach ($alllocations as $location) { |
|
327 | + require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
328 | + $Source = new Source(); |
|
329 | + //$alllocations = $Source->getAllLocationInfo(); |
|
330 | + $alllocations = $Source->getLocationInfobyType(''); |
|
331 | + foreach ($alllocations as $location) { |
|
332 | 332 | ?> |
333 | 333 | <tr> |
334 | 334 | <input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" /> |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | </tr> |
343 | 343 | |
344 | 344 | <?php |
345 | - } |
|
345 | + } |
|
346 | + } |
|
346 | 347 | } |
347 | - } |
|
348 | 348 | ?> |
349 | 349 | |
350 | 350 | <tr> |
@@ -452,12 +452,12 @@ discard block |
||
452 | 452 | ?> |
453 | 453 | <tr> |
454 | 454 | <?php |
455 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
455 | + if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
456 | 456 | ?> |
457 | 457 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
458 | 458 | <td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
459 | 459 | <?php |
460 | - } else { |
|
460 | + } else { |
|
461 | 461 | $hostport = explode(':',$source['host']); |
462 | 462 | if (isset($hostport[1])) { |
463 | 463 | $host = $hostport[0]; |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | <td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td> |
471 | 471 | <td><input type="number" name="port[]" id="port" class="col-xs-2" value="<?php print $port; ?>" /></td> |
472 | 472 | <?php |
473 | - } |
|
473 | + } |
|
474 | 474 | ?> |
475 | 475 | <td> |
476 | 476 | <select name="format[]" id="format"> |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | <br /> |
877 | 877 | <p> |
878 | 878 | <?php |
879 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
879 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
880 | 880 | ?> |
881 | 881 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
882 | 882 | <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
@@ -886,11 +886,11 @@ discard block |
||
886 | 886 | <b>The directory cache is not writable, aircraft icon will not be cached</b> |
887 | 887 | <?php |
888 | 888 | } |
889 | - } else { |
|
889 | + } else { |
|
890 | 890 | ?> |
891 | 891 | <b>PHP GD is not installed, you can't change color of aircraft icon on map</b> |
892 | 892 | <?php |
893 | - } |
|
893 | + } |
|
894 | 894 | ?> |
895 | 895 | </p> |
896 | 896 | <br /> |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | </p> |
915 | 915 | <?php |
916 | 916 | require('../footer.php'); |
917 | - exit; |
|
917 | + exit; |
|
918 | 918 | } |
919 | 919 | |
920 | 920 | $settings = array(); |
@@ -1005,8 +1005,8 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | $sources = array(); |
1007 | 1007 | foreach ($source_name as $keys => $name) { |
1008 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1009 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1008 | + if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1009 | + else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1010 | 1010 | } |
1011 | 1011 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
1012 | 1012 | |
@@ -1384,14 +1384,14 @@ discard block |
||
1384 | 1384 | |
1385 | 1385 | // Set some defaults values... |
1386 | 1386 | if (!isset($globalAircraftImageSources)) { |
1387 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1388 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1387 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1388 | + $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1389 | 1389 | } |
1390 | 1390 | |
1391 | 1391 | if (!isset($globalSchedulesSources)) { |
1392 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1393 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1394 | - } |
|
1392 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1393 | + $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1394 | + } |
|
1395 | 1395 | |
1396 | 1396 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
1397 | 1397 | |
@@ -1443,21 +1443,21 @@ discard block |
||
1443 | 1443 | $popi = false; |
1444 | 1444 | $popw = false; |
1445 | 1445 | foreach ($_SESSION['done'] as $done) { |
1446 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1447 | - if ($done == 'Create database') $pop = true; |
|
1448 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1449 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1450 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1446 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1447 | + if ($done == 'Create database') $pop = true; |
|
1448 | + if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1449 | + if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1450 | + if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1451 | 1451 | } |
1452 | 1452 | if ($pop) { |
1453 | - sleep(5); |
|
1454 | - print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1453 | + sleep(5); |
|
1454 | + print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1455 | 1455 | } else if ($popi) { |
1456 | - sleep(5); |
|
1457 | - print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1456 | + sleep(5); |
|
1457 | + print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1458 | 1458 | } else if ($popw) { |
1459 | - sleep(5); |
|
1460 | - print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1459 | + sleep(5); |
|
1460 | + print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1461 | 1461 | } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
1462 | 1462 | print '</div></ul>'; |
1463 | 1463 | print '<div id="error"></div>'; |
@@ -1520,7 +1520,7 @@ discard block |
||
1520 | 1520 | unset($_COOKIE['install']); |
1521 | 1521 | print '<div class="info column"><ul>'; |
1522 | 1522 | foreach ($_SESSION['done'] as $done) { |
1523 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1523 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1524 | 1524 | } |
1525 | 1525 | print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>'; |
1526 | 1526 | print '</ul></div>'; |
@@ -7,16 +7,16 @@ discard block |
||
7 | 7 | require_once(dirname(__FILE__).'/class.Source.php'); |
8 | 8 | |
9 | 9 | class TrackerImport { |
10 | - private $all_tracked = array(); |
|
11 | - private $last_delete_hourly = 0; |
|
12 | - private $last_delete = 0; |
|
13 | - private $stats = array(); |
|
14 | - private $tmd = 0; |
|
15 | - private $source_location = array(); |
|
16 | - public $db = null; |
|
17 | - public $nb = 0; |
|
10 | + private $all_tracked = array(); |
|
11 | + private $last_delete_hourly = 0; |
|
12 | + private $last_delete = 0; |
|
13 | + private $stats = array(); |
|
14 | + private $tmd = 0; |
|
15 | + private $source_location = array(); |
|
16 | + public $db = null; |
|
17 | + public $nb = 0; |
|
18 | 18 | |
19 | - public function __construct($dbc = null) { |
|
19 | + public function __construct($dbc = null) { |
|
20 | 20 | global $globalBeta; |
21 | 21 | $Connection = new Connection($dbc); |
22 | 22 | $this->db = $Connection->db(); |
@@ -38,50 +38,50 @@ discard block |
||
38 | 38 | } |
39 | 39 | } |
40 | 40 | */ |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - public function checkAll() { |
|
43 | + public function checkAll() { |
|
44 | 44 | global $globalDebug; |
45 | 45 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
46 | 46 | foreach ($this->all_tracked as $key => $flight) { |
47 | - if (isset($this->all_tracked[$key]['id'])) { |
|
47 | + if (isset($this->all_tracked[$key]['id'])) { |
|
48 | 48 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
49 | - $Tracker = new Tracker($this->db); |
|
50 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
51 | - } |
|
49 | + $Tracker = new Tracker($this->db); |
|
50 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
51 | + } |
|
52 | + } |
|
52 | 53 | } |
53 | - } |
|
54 | 54 | |
55 | - public function del() { |
|
55 | + public function del() { |
|
56 | 56 | global $globalDebug; |
57 | 57 | // Delete old infos |
58 | 58 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
59 | 59 | foreach ($this->all_tracked as $key => $flight) { |
60 | - if (isset($flight['lastupdate'])) { |
|
61 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
62 | - if (isset($this->all_tracked[$key]['id'])) { |
|
63 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
60 | + if (isset($flight['lastupdate'])) { |
|
61 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
62 | + if (isset($this->all_tracked[$key]['id'])) { |
|
63 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
64 | 64 | /* |
65 | 65 | $TrackerLive = new TrackerLive(); |
66 | 66 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
67 | 67 | $TrackerLive->db = null; |
68 | 68 | */ |
69 | - //$real_arrival = $this->arrival($key); |
|
70 | - $Tracker = new Tracker($this->db); |
|
71 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
69 | + //$real_arrival = $this->arrival($key); |
|
70 | + $Tracker = new Tracker($this->db); |
|
71 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
72 | 72 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
73 | 73 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
74 | 74 | } |
75 | 75 | // Put in archive |
76 | 76 | // $Tracker->db = null; |
77 | - } |
|
78 | - unset($this->all_tracked[$key]); |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
82 | - } |
|
77 | + } |
|
78 | + unset($this->all_tracked[$key]); |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - public function add($line) { |
|
84 | + public function add($line) { |
|
85 | 85 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
86 | 86 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
87 | 87 | date_default_timezone_set('UTC'); |
@@ -90,47 +90,47 @@ discard block |
||
90 | 90 | |
91 | 91 | // SBS format is CSV format |
92 | 92 | if(is_array($line) && isset($line['ident'])) { |
93 | - //print_r($line); |
|
94 | - if (isset($line['ident'])) { |
|
93 | + //print_r($line); |
|
94 | + if (isset($line['ident'])) { |
|
95 | 95 | |
96 | 96 | |
97 | 97 | // Increment message number |
98 | 98 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
99 | - $current_date = date('Y-m-d'); |
|
100 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
101 | - else $source = ''; |
|
102 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
103 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
104 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
105 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
106 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
99 | + $current_date = date('Y-m-d'); |
|
100 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
101 | + else $source = ''; |
|
102 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
103 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
104 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
105 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
106 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
110 | 110 | $Common = new Common(); |
111 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
112 | - else $id = trim($line['id']); |
|
111 | + if (!isset($line['id'])) $id = trim($line['ident']); |
|
112 | + else $id = trim($line['id']); |
|
113 | 113 | |
114 | 114 | if (!isset($this->all_tracked[$id])) { |
115 | - $this->all_tracked[$id] = array(); |
|
116 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
119 | - if (!isset($line['id'])) { |
|
115 | + $this->all_tracked[$id] = array(); |
|
116 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
119 | + if (!isset($line['id'])) { |
|
120 | 120 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
121 | 121 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
122 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
123 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
122 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
123 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
127 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
127 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
128 | 128 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
129 | - } else { |
|
129 | + } else { |
|
130 | 130 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
131 | 131 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
132 | 132 | return ''; |
133 | - } |
|
133 | + } |
|
134 | 134 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
135 | 135 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
136 | 136 | return ''; |
@@ -147,38 +147,38 @@ discard block |
||
147 | 147 | |
148 | 148 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
149 | 149 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
151 | - if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
151 | + if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
152 | 152 | $timeelapsed = microtime(true); |
153 | - $Tracker = new Tracker($this->db); |
|
154 | - $fromsource = NULL; |
|
155 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
153 | + $Tracker = new Tracker($this->db); |
|
154 | + $fromsource = NULL; |
|
155 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
156 | 156 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
157 | 157 | $Tracker->db = null; |
158 | 158 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
159 | - } |
|
160 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
159 | + } |
|
160 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | if (isset($line['speed']) && $line['speed'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
166 | 166 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
167 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
168 | - if ($distance > 100 && $distance < 10000) { |
|
167 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
168 | + if ($distance > 100 && $distance < 10000) { |
|
169 | 169 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
170 | 170 | $speed = $speed*3.6; |
171 | 171 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
172 | 172 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
173 | - } |
|
173 | + } |
|
174 | 174 | } |
175 | 175 | |
176 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
177 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
178 | - else unset($timediff); |
|
179 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
176 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
177 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
178 | + else unset($timediff); |
|
179 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
180 | 180 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
181 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
181 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
182 | 182 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
183 | 183 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
184 | 184 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -192,30 +192,30 @@ discard block |
||
192 | 192 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
193 | 193 | $this->tmd = 0; |
194 | 194 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
195 | - } |
|
195 | + } |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
199 | 199 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
200 | 200 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
201 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
202 | - $dataFound = true; |
|
203 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
201 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
202 | + $dataFound = true; |
|
203 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
204 | 204 | } |
205 | 205 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
206 | 206 | } |
207 | 207 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
208 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
208 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
209 | 209 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
210 | 210 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
211 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
212 | - $dataFound = true; |
|
213 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
211 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
212 | + $dataFound = true; |
|
213 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
214 | 214 | } |
215 | 215 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
216 | 216 | } |
217 | 217 | |
218 | - } else if ($globalDebug && $timediff > 20) { |
|
218 | + } else if ($globalDebug && $timediff > 20) { |
|
219 | 219 | $this->tmd = $this->tmd + 1; |
220 | 220 | if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) { |
221 | 221 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
@@ -223,131 +223,131 @@ discard block |
||
223 | 223 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
224 | 224 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
225 | 225 | } |
226 | - } |
|
226 | + } |
|
227 | 227 | } |
228 | 228 | if (isset($line['last_update']) && $line['last_update'] != '') { |
229 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
229 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
231 | 231 | } |
232 | 232 | if (isset($line['format_source']) && $line['format_source'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
234 | 234 | } |
235 | 235 | if (isset($line['source_name']) && $line['source_name'] != '') { |
236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
237 | 237 | } |
238 | 238 | if (isset($line['comment']) && $line['comment'] != '') { |
239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
240 | - //$dataFound = true; |
|
239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
240 | + //$dataFound = true; |
|
241 | 241 | } |
242 | 242 | if (isset($line['type']) && $line['type'] != '') { |
243 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
244 | - //$dataFound = true; |
|
243 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
244 | + //$dataFound = true; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | if (isset($line['altitude']) && $line['altitude'] != '') { |
248 | - //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
248 | + //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
249 | 249 | if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
250 | 250 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
251 | 251 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
252 | 252 | //$dataFound = true; |
253 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
253 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | if (isset($line['heading']) && $line['heading'] != '') { |
261 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
263 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
264 | - //$dataFound = true; |
|
261 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
263 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
264 | + //$dataFound = true; |
|
265 | 265 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
266 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
267 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
268 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
269 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
266 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
267 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
268 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
269 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
270 | 270 | } |
271 | 271 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
272 | 272 | |
273 | 273 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
274 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
275 | - if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
276 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
277 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
274 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
275 | + if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
276 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
277 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
278 | 278 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
279 | 279 | $timeelapsed = microtime(true); |
280 | 280 | $TrackerLive = new TrackerLive($this->db); |
281 | 281 | if (isset($line['id'])) { |
282 | - $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
282 | + $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
283 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
284 | 284 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
285 | - $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
285 | + $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
286 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
287 | 287 | } else $recent_ident = ''; |
288 | 288 | $TrackerLive->db=null; |
289 | 289 | |
290 | 290 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
291 | 291 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
292 | - } else { |
|
292 | + } else { |
|
293 | 293 | $recent_ident = ''; |
294 | 294 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
295 | - } |
|
296 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
297 | - if($recent_ident == "") |
|
298 | - { |
|
295 | + } |
|
296 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
297 | + if($recent_ident == "") |
|
298 | + { |
|
299 | 299 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
300 | 300 | //adds the spotter data for the archive |
301 | - $highlight = ''; |
|
302 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
303 | - $timeelapsed = microtime(true); |
|
304 | - $Tracker = new Tracker($this->db); |
|
305 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
306 | - $Tracker->db = null; |
|
307 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
301 | + $highlight = ''; |
|
302 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
303 | + $timeelapsed = microtime(true); |
|
304 | + $Tracker = new Tracker($this->db); |
|
305 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
306 | + $Tracker->db = null; |
|
307 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
308 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
309 | 309 | |
310 | 310 | |
311 | - // Add source stat in DB |
|
312 | - $Stats = new Stats($this->db); |
|
313 | - if (!empty($this->stats)) { |
|
311 | + // Add source stat in DB |
|
312 | + $Stats = new Stats($this->db); |
|
313 | + if (!empty($this->stats)) { |
|
314 | 314 | if ($globalDebug) echo 'Add source stats : '; |
315 | - foreach($this->stats as $date => $data) { |
|
316 | - foreach($data as $source => $sourced) { |
|
317 | - //print_r($sourced); |
|
318 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
319 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
320 | - if (isset($sourced['msg'])) { |
|
321 | - if (time() - $sourced['msg']['date'] > 10) { |
|
322 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
323 | - echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date); |
|
324 | - unset($this->stats[$date][$source]['msg']); |
|
325 | - } |
|
326 | - } |
|
327 | - } |
|
328 | - if ($date != date('Y-m-d')) { |
|
329 | - unset($this->stats[$date]); |
|
330 | - } |
|
331 | - } |
|
332 | - if ($globalDebug) echo 'Done'."\n"; |
|
315 | + foreach($this->stats as $date => $data) { |
|
316 | + foreach($data as $source => $sourced) { |
|
317 | + //print_r($sourced); |
|
318 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
319 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
320 | + if (isset($sourced['msg'])) { |
|
321 | + if (time() - $sourced['msg']['date'] > 10) { |
|
322 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
323 | + echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date); |
|
324 | + unset($this->stats[$date][$source]['msg']); |
|
325 | + } |
|
326 | + } |
|
327 | + } |
|
328 | + if ($date != date('Y-m-d')) { |
|
329 | + unset($this->stats[$date]); |
|
330 | + } |
|
331 | + } |
|
332 | + if ($globalDebug) echo 'Done'."\n"; |
|
333 | 333 | |
334 | - } |
|
335 | - $Stats->db = null; |
|
334 | + } |
|
335 | + $Stats->db = null; |
|
336 | 336 | |
337 | - $this->del(); |
|
337 | + $this->del(); |
|
338 | 338 | //$ignoreImport = false; |
339 | 339 | $this->all_tracked[$id]['addedTracker'] = 1; |
340 | 340 | //print_r($this->all_tracked[$id]); |
341 | 341 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
342 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
343 | - //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
344 | - $TrackerLive = new TrackerLive($this->db); |
|
345 | - $TrackerLive->deleteLiveTrackerData(); |
|
346 | - $TrackerLive->db=null; |
|
347 | - if ($globalDebug) echo " Done\n"; |
|
348 | - $this->last_delete = time(); |
|
342 | + if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
343 | + //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
344 | + $TrackerLive = new TrackerLive($this->db); |
|
345 | + $TrackerLive->deleteLiveTrackerData(); |
|
346 | + $TrackerLive->db=null; |
|
347 | + if ($globalDebug) echo " Done\n"; |
|
348 | + $this->last_delete = time(); |
|
349 | 349 | } |
350 | - } else { |
|
350 | + } else { |
|
351 | 351 | $this->all_tracked[$id]['id'] = $recent_ident; |
352 | 352 | $this->all_tracked[$id]['addedTracker'] = 1; |
353 | 353 | if (isset($globalDaemon) && !$globalDaemon) { |
@@ -356,16 +356,16 @@ discard block |
||
356 | 356 | $Tracker->db = null; |
357 | 357 | } |
358 | 358 | |
359 | - } |
|
359 | + } |
|
360 | 360 | } |
361 | - } |
|
362 | - //adds the spotter LIVE data |
|
363 | - if ($globalDebug) { |
|
361 | + } |
|
362 | + //adds the spotter LIVE data |
|
363 | + if ($globalDebug) { |
|
364 | 364 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
365 | - } |
|
366 | - $ignoreImport = false; |
|
365 | + } |
|
366 | + $ignoreImport = false; |
|
367 | 367 | |
368 | - if (!$ignoreImport) { |
|
368 | + if (!$ignoreImport) { |
|
369 | 369 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
370 | 370 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
371 | 371 | $timeelapsed = microtime(true); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | if ($stats_heading == 16) $stats_heading = 0; |
404 | 404 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
405 | 405 | for ($i=0;$i<=15;$i++) { |
406 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
406 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
407 | 407 | } |
408 | 408 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
409 | 409 | } else { |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | //var_dump($this->stats); |
417 | 417 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
418 | 418 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
419 | - end($this->stats[$current_date][$source]['hist']); |
|
420 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
419 | + end($this->stats[$current_date][$source]['hist']); |
|
420 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
421 | 421 | } else $mini = 0; |
422 | 422 | for ($i=$mini;$i<=$distance;$i+=10) { |
423 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
423 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
424 | 424 | } |
425 | 425 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
426 | 426 | } else { |
@@ -436,22 +436,22 @@ discard block |
||
436 | 436 | |
437 | 437 | |
438 | 438 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
440 | - $TrackerLive = new TrackerLive($this->db); |
|
441 | - $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
442 | - $TrackerLive->db = null; |
|
443 | - //TrackerLive->deleteLiveTrackerData(); |
|
444 | - if ($globalDebug) echo " Done\n"; |
|
445 | - $this->last_delete_hourly = time(); |
|
439 | + if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
440 | + $TrackerLive = new TrackerLive($this->db); |
|
441 | + $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
442 | + $TrackerLive->db = null; |
|
443 | + //TrackerLive->deleteLiveTrackerData(); |
|
444 | + if ($globalDebug) echo " Done\n"; |
|
445 | + $this->last_delete_hourly = time(); |
|
446 | 446 | } |
447 | 447 | |
448 | - } |
|
449 | - //$ignoreImport = false; |
|
448 | + } |
|
449 | + //$ignoreImport = false; |
|
450 | 450 | } |
451 | 451 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
452 | 452 | if ($send) return $this->all_tracked[$id]; |
453 | - } |
|
453 | + } |
|
454 | + } |
|
454 | 455 | } |
455 | - } |
|
456 | 456 | } |
457 | 457 | ?> |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Gets all the spotter information based on the latest data entry |
|
90 | - * |
|
91 | - * @return Array the spotter information |
|
92 | - * |
|
93 | - */ |
|
89 | + * Gets all the spotter information based on the latest data entry |
|
90 | + * |
|
91 | + * @return Array the spotter information |
|
92 | + * |
|
93 | + */ |
|
94 | 94 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
95 | 95 | { |
96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Gets Minimal Live Spotter data |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
135 | + * Gets Minimal Live Spotter data |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | 140 | public function getMinLiveTrackerData($filter = array()) |
141 | 141 | { |
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | - * Gets Minimal Live Spotter data since xx seconds |
|
174 | - * |
|
175 | - * @return Array the spotter information |
|
176 | - * |
|
177 | - */ |
|
173 | + * Gets Minimal Live Spotter data since xx seconds |
|
174 | + * |
|
175 | + * @return Array the spotter information |
|
176 | + * |
|
177 | + */ |
|
178 | 178 | public function getMinLastLiveTrackerData($filter = array()) |
179 | 179 | { |
180 | 180 | global $globalDBdriver, $globalLiveInterval; |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
188 | 188 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
189 | 189 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
190 | - } else { |
|
190 | + } else { |
|
191 | 191 | $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
192 | 192 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
193 | 193 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
194 | 194 | } |
195 | 195 | |
196 | - try { |
|
196 | + try { |
|
197 | 197 | $sth = $this->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | 199 | } catch(PDOException $e) { |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
208 | - * Gets number of latest data entry |
|
209 | - * |
|
210 | - * @return String number of entry |
|
211 | - * |
|
212 | - */ |
|
208 | + * Gets number of latest data entry |
|
209 | + * |
|
210 | + * @return String number of entry |
|
211 | + * |
|
212 | + */ |
|
213 | 213 | public function getLiveTrackerCount($filter = array()) |
214 | 214 | { |
215 | 215 | global $globalDBdriver, $globalLiveInterval; |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
237 | - * Gets all the spotter information based on the latest data entry and coord |
|
238 | - * |
|
239 | - * @return Array the spotter information |
|
240 | - * |
|
241 | - */ |
|
237 | + * Gets all the spotter information based on the latest data entry and coord |
|
238 | + * |
|
239 | + * @return Array the spotter information |
|
240 | + * |
|
241 | + */ |
|
242 | 242 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
243 | 243 | { |
244 | 244 | global $globalDBdriver, $globalLiveInterval; |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | - * Gets all the spotter information based on the latest data entry and coord |
|
266 | - * |
|
267 | - * @return Array the spotter information |
|
268 | - * |
|
269 | - */ |
|
265 | + * Gets all the spotter information based on the latest data entry and coord |
|
266 | + * |
|
267 | + * @return Array the spotter information |
|
268 | + * |
|
269 | + */ |
|
270 | 270 | public function getMinLiveTrackerDatabyCoord($coord, $filter = array()) |
271 | 271 | { |
272 | 272 | global $globalDBdriver, $globalLiveInterval; |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
296 | - * Gets all the spotter information based on a user's latitude and longitude |
|
297 | - * |
|
298 | - * @return Array the spotter information |
|
299 | - * |
|
300 | - */ |
|
296 | + * Gets all the spotter information based on a user's latitude and longitude |
|
297 | + * |
|
298 | + * @return Array the spotter information |
|
299 | + * |
|
300 | + */ |
|
301 | 301 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
302 | 302 | { |
303 | 303 | $Tracker = new Tracker($this->db); |
@@ -310,142 +310,142 @@ discard block |
||
310 | 310 | if ($lng != '') |
311 | 311 | { |
312 | 312 | if (!is_numeric($lng)) |
313 | - { |
|
314 | - return false; |
|
315 | - } |
|
316 | - } |
|
317 | - |
|
318 | - if ($radius != '') |
|
319 | - { |
|
320 | - if (!is_numeric($radius)) |
|
321 | - { |
|
322 | - return false; |
|
323 | - } |
|
324 | - } |
|
313 | + { |
|
314 | + return false; |
|
315 | + } |
|
316 | + } |
|
317 | + |
|
318 | + if ($radius != '') |
|
319 | + { |
|
320 | + if (!is_numeric($radius)) |
|
321 | + { |
|
322 | + return false; |
|
323 | + } |
|
324 | + } |
|
325 | 325 | $additional_query = ''; |
326 | 326 | if ($interval != '') |
327 | - { |
|
328 | - if (!is_string($interval)) |
|
329 | - { |
|
330 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
331 | - return false; |
|
332 | - } else { |
|
333 | - if ($interval == '1m') |
|
334 | - { |
|
335 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
336 | - } else if ($interval == '15m'){ |
|
337 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
338 | - } |
|
339 | - } |
|
340 | - } else { |
|
341 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
342 | - } |
|
343 | - |
|
344 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
327 | + { |
|
328 | + if (!is_string($interval)) |
|
329 | + { |
|
330 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
331 | + return false; |
|
332 | + } else { |
|
333 | + if ($interval == '1m') |
|
334 | + { |
|
335 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
336 | + } else if ($interval == '15m'){ |
|
337 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
338 | + } |
|
339 | + } |
|
340 | + } else { |
|
341 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
342 | + } |
|
343 | + |
|
344 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
345 | 345 | WHERE tracker_live.latitude <> '' |
346 | 346 | AND tracker_live.longitude <> '' |
347 | 347 | ".$additional_query." |
348 | 348 | HAVING distance < :radius |
349 | 349 | ORDER BY distance"; |
350 | 350 | |
351 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
351 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
352 | 352 | |
353 | - return $spotter_array; |
|
354 | - } |
|
353 | + return $spotter_array; |
|
354 | + } |
|
355 | 355 | |
356 | 356 | |
357 | - /** |
|
358 | - * Gets all the spotter information based on a particular callsign |
|
359 | - * |
|
360 | - * @return Array the spotter information |
|
361 | - * |
|
362 | - */ |
|
357 | + /** |
|
358 | + * Gets all the spotter information based on a particular callsign |
|
359 | + * |
|
360 | + * @return Array the spotter information |
|
361 | + * |
|
362 | + */ |
|
363 | 363 | public function getLastLiveTrackerDataByIdent($ident) |
364 | 364 | { |
365 | 365 | $Tracker = new Tracker($this->db); |
366 | 366 | date_default_timezone_set('UTC'); |
367 | 367 | |
368 | 368 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
369 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
369 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
370 | 370 | |
371 | 371 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
372 | 372 | |
373 | 373 | return $spotter_array; |
374 | 374 | } |
375 | 375 | |
376 | - /** |
|
377 | - * Gets all the spotter information based on a particular callsign |
|
378 | - * |
|
379 | - * @return Array the spotter information |
|
380 | - * |
|
381 | - */ |
|
376 | + /** |
|
377 | + * Gets all the spotter information based on a particular callsign |
|
378 | + * |
|
379 | + * @return Array the spotter information |
|
380 | + * |
|
381 | + */ |
|
382 | 382 | public function getDateLiveTrackerDataByIdent($ident,$date) |
383 | 383 | { |
384 | 384 | $Tracker = new Tracker($this->db); |
385 | 385 | date_default_timezone_set('UTC'); |
386 | 386 | |
387 | 387 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
388 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
388 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
389 | 389 | |
390 | - $date = date('c',$date); |
|
390 | + $date = date('c',$date); |
|
391 | 391 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
392 | 392 | |
393 | 393 | return $spotter_array; |
394 | 394 | } |
395 | 395 | |
396 | - /** |
|
397 | - * Gets last spotter information based on a particular callsign |
|
398 | - * |
|
399 | - * @return Array the spotter information |
|
400 | - * |
|
401 | - */ |
|
396 | + /** |
|
397 | + * Gets last spotter information based on a particular callsign |
|
398 | + * |
|
399 | + * @return Array the spotter information |
|
400 | + * |
|
401 | + */ |
|
402 | 402 | public function getLastLiveTrackerDataById($id) |
403 | 403 | { |
404 | 404 | $Tracker = new Tracker($this->db); |
405 | 405 | date_default_timezone_set('UTC'); |
406 | 406 | |
407 | 407 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
408 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
408 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
409 | 409 | |
410 | 410 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
411 | 411 | |
412 | 412 | return $spotter_array; |
413 | 413 | } |
414 | 414 | |
415 | - /** |
|
416 | - * Gets last spotter information based on a particular callsign |
|
417 | - * |
|
418 | - * @return Array the spotter information |
|
419 | - * |
|
420 | - */ |
|
415 | + /** |
|
416 | + * Gets last spotter information based on a particular callsign |
|
417 | + * |
|
418 | + * @return Array the spotter information |
|
419 | + * |
|
420 | + */ |
|
421 | 421 | public function getDateLiveTrackerDataById($id,$date) |
422 | 422 | { |
423 | 423 | $Tracker = new Tracker($this->db); |
424 | 424 | date_default_timezone_set('UTC'); |
425 | 425 | |
426 | 426 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
427 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
428 | - $date = date('c',$date); |
|
427 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
428 | + $date = date('c',$date); |
|
429 | 429 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
430 | 430 | |
431 | 431 | return $spotter_array; |
432 | 432 | } |
433 | 433 | |
434 | - /** |
|
435 | - * Gets altitude information based on a particular callsign |
|
436 | - * |
|
437 | - * @return Array the spotter information |
|
438 | - * |
|
439 | - */ |
|
434 | + /** |
|
435 | + * Gets altitude information based on a particular callsign |
|
436 | + * |
|
437 | + * @return Array the spotter information |
|
438 | + * |
|
439 | + */ |
|
440 | 440 | public function getAltitudeLiveTrackerDataByIdent($ident) |
441 | 441 | { |
442 | 442 | |
443 | 443 | date_default_timezone_set('UTC'); |
444 | 444 | |
445 | 445 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
446 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
446 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
447 | 447 | |
448 | - try { |
|
448 | + try { |
|
449 | 449 | |
450 | 450 | $sth = $this->db->prepare($query); |
451 | 451 | $sth->execute(array(':ident' => $ident)); |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | return $spotter_array; |
459 | 459 | } |
460 | 460 | |
461 | - /** |
|
462 | - * Gets all the spotter information based on a particular id |
|
463 | - * |
|
464 | - * @return Array the spotter information |
|
465 | - * |
|
466 | - */ |
|
461 | + /** |
|
462 | + * Gets all the spotter information based on a particular id |
|
463 | + * |
|
464 | + * @return Array the spotter information |
|
465 | + * |
|
466 | + */ |
|
467 | 467 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
468 | 468 | { |
469 | 469 | global $globalDBdriver, $globalLiveInterval; |
@@ -491,18 +491,18 @@ discard block |
||
491 | 491 | return $spotter_array; |
492 | 492 | } |
493 | 493 | |
494 | - /** |
|
495 | - * Gets all the spotter information based on a particular ident |
|
496 | - * |
|
497 | - * @return Array the spotter information |
|
498 | - * |
|
499 | - */ |
|
494 | + /** |
|
495 | + * Gets all the spotter information based on a particular ident |
|
496 | + * |
|
497 | + * @return Array the spotter information |
|
498 | + * |
|
499 | + */ |
|
500 | 500 | public function getAllLiveTrackerDataByIdent($ident) |
501 | 501 | { |
502 | 502 | date_default_timezone_set('UTC'); |
503 | 503 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
504 | 504 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
505 | - try { |
|
505 | + try { |
|
506 | 506 | |
507 | 507 | $sth = $this->db->prepare($query); |
508 | 508 | $sth->execute(array(':ident' => $ident)); |
@@ -516,23 +516,23 @@ discard block |
||
516 | 516 | |
517 | 517 | |
518 | 518 | /** |
519 | - * Deletes all info in the table |
|
520 | - * |
|
521 | - * @return String success or false |
|
522 | - * |
|
523 | - */ |
|
519 | + * Deletes all info in the table |
|
520 | + * |
|
521 | + * @return String success or false |
|
522 | + * |
|
523 | + */ |
|
524 | 524 | public function deleteLiveTrackerData() |
525 | 525 | { |
526 | 526 | global $globalDBdriver; |
527 | 527 | if ($globalDBdriver == 'mysql') { |
528 | 528 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
529 | 529 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
530 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
530 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
531 | 531 | } else { |
532 | 532 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
533 | 533 | } |
534 | 534 | |
535 | - try { |
|
535 | + try { |
|
536 | 536 | |
537 | 537 | $sth = $this->db->prepare($query); |
538 | 538 | $sth->execute(); |
@@ -544,18 +544,18 @@ discard block |
||
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
547 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
548 | - * |
|
549 | - * @return String success or false |
|
550 | - * |
|
551 | - */ |
|
547 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
548 | + * |
|
549 | + * @return String success or false |
|
550 | + * |
|
551 | + */ |
|
552 | 552 | public function deleteLiveTrackerDataNotUpdated() |
553 | 553 | { |
554 | 554 | global $globalDBdriver, $globalDebug; |
555 | 555 | if ($globalDBdriver == 'mysql') { |
556 | 556 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
557 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
558 | - try { |
|
557 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
558 | + try { |
|
559 | 559 | |
560 | 560 | $sth = $this->db->prepare($query); |
561 | 561 | $sth->execute(); |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | return "error"; |
564 | 564 | } |
565 | 565 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
566 | - $i = 0; |
|
567 | - $j =0; |
|
566 | + $i = 0; |
|
567 | + $j =0; |
|
568 | 568 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
569 | 569 | foreach($all as $row) |
570 | 570 | { |
@@ -572,20 +572,20 @@ discard block |
||
572 | 572 | $j++; |
573 | 573 | if ($j == 30) { |
574 | 574 | if ($globalDebug) echo "."; |
575 | - try { |
|
575 | + try { |
|
576 | 576 | |
577 | 577 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
578 | 578 | $sth->execute(); |
579 | 579 | } catch(PDOException $e) { |
580 | 580 | return "error"; |
581 | 581 | } |
582 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
583 | - $j = 0; |
|
582 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
583 | + $j = 0; |
|
584 | 584 | } |
585 | 585 | $query_delete .= "'".$row['famtrackid']."',"; |
586 | 586 | } |
587 | 587 | if ($i > 0) { |
588 | - try { |
|
588 | + try { |
|
589 | 589 | |
590 | 590 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
591 | 591 | $sth->execute(); |
@@ -596,9 +596,9 @@ discard block |
||
596 | 596 | return "success"; |
597 | 597 | } elseif ($globalDBdriver == 'pgsql') { |
598 | 598 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
599 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
600 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
601 | - try { |
|
599 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
600 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
601 | + try { |
|
602 | 602 | |
603 | 603 | $sth = $this->db->prepare($query); |
604 | 604 | $sth->execute(); |
@@ -642,17 +642,17 @@ discard block |
||
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
645 | - * Deletes all info in the table for an ident |
|
646 | - * |
|
647 | - * @return String success or false |
|
648 | - * |
|
649 | - */ |
|
645 | + * Deletes all info in the table for an ident |
|
646 | + * |
|
647 | + * @return String success or false |
|
648 | + * |
|
649 | + */ |
|
650 | 650 | public function deleteLiveTrackerDataByIdent($ident) |
651 | 651 | { |
652 | 652 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
653 | 653 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
654 | 654 | |
655 | - try { |
|
655 | + try { |
|
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(array(':ident' => $ident)); |
@@ -664,17 +664,17 @@ discard block |
||
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
667 | - * Deletes all info in the table for an id |
|
668 | - * |
|
669 | - * @return String success or false |
|
670 | - * |
|
671 | - */ |
|
667 | + * Deletes all info in the table for an id |
|
668 | + * |
|
669 | + * @return String success or false |
|
670 | + * |
|
671 | + */ |
|
672 | 672 | public function deleteLiveTrackerDataById($id) |
673 | 673 | { |
674 | 674 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
675 | 675 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
676 | 676 | |
677 | - try { |
|
677 | + try { |
|
678 | 678 | |
679 | 679 | $sth = $this->db->prepare($query); |
680 | 680 | $sth->execute(array(':id' => $id)); |
@@ -687,11 +687,11 @@ discard block |
||
687 | 687 | |
688 | 688 | |
689 | 689 | /** |
690 | - * Gets the aircraft ident within the last hour |
|
691 | - * |
|
692 | - * @return String the ident |
|
693 | - * |
|
694 | - */ |
|
690 | + * Gets the aircraft ident within the last hour |
|
691 | + * |
|
692 | + * @return String the ident |
|
693 | + * |
|
694 | + */ |
|
695 | 695 | public function getIdentFromLastHour($ident) |
696 | 696 | { |
697 | 697 | global $globalDBdriver, $globalTimezone; |
@@ -717,14 +717,14 @@ discard block |
||
717 | 717 | $ident_result = $row['ident']; |
718 | 718 | } |
719 | 719 | return $ident_result; |
720 | - } |
|
720 | + } |
|
721 | 721 | |
722 | 722 | /** |
723 | - * Check recent aircraft |
|
724 | - * |
|
725 | - * @return String the ident |
|
726 | - * |
|
727 | - */ |
|
723 | + * Check recent aircraft |
|
724 | + * |
|
725 | + * @return String the ident |
|
726 | + * |
|
727 | + */ |
|
728 | 728 | public function checkIdentRecent($ident) |
729 | 729 | { |
730 | 730 | global $globalDBdriver, $globalTimezone; |
@@ -750,14 +750,14 @@ discard block |
||
750 | 750 | $ident_result = $row['famtrackid']; |
751 | 751 | } |
752 | 752 | return $ident_result; |
753 | - } |
|
753 | + } |
|
754 | 754 | |
755 | 755 | /** |
756 | - * Check recent aircraft by id |
|
757 | - * |
|
758 | - * @return String the ident |
|
759 | - * |
|
760 | - */ |
|
756 | + * Check recent aircraft by id |
|
757 | + * |
|
758 | + * @return String the ident |
|
759 | + * |
|
760 | + */ |
|
761 | 761 | public function checkIdRecent($id) |
762 | 762 | { |
763 | 763 | global $globalDBdriver, $globalTimezone; |
@@ -783,19 +783,19 @@ discard block |
||
783 | 783 | $ident_result = $row['famtrackid']; |
784 | 784 | } |
785 | 785 | return $ident_result; |
786 | - } |
|
786 | + } |
|
787 | 787 | |
788 | 788 | /** |
789 | - * Adds a new spotter data |
|
790 | - * |
|
791 | - * @param String $famtrackid the ID from flightaware |
|
792 | - * @param String $ident the flight ident |
|
793 | - * @param String $aircraft_icao the aircraft type |
|
794 | - * @param String $departure_airport_icao the departure airport |
|
795 | - * @param String $arrival_airport_icao the arrival airport |
|
796 | - * @return String success or false |
|
797 | - * |
|
798 | - */ |
|
789 | + * Adds a new spotter data |
|
790 | + * |
|
791 | + * @param String $famtrackid the ID from flightaware |
|
792 | + * @param String $ident the flight ident |
|
793 | + * @param String $aircraft_icao the aircraft type |
|
794 | + * @param String $departure_airport_icao the departure airport |
|
795 | + * @param String $arrival_airport_icao the arrival airport |
|
796 | + * @return String success or false |
|
797 | + * |
|
798 | + */ |
|
799 | 799 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
800 | 800 | { |
801 | 801 | global $globalURL, $globalArchive, $globalDebug; |
@@ -868,8 +868,8 @@ discard block |
||
868 | 868 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
869 | 869 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
870 | 870 | |
871 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
872 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
871 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
872 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
873 | 873 | |
874 | 874 | $query = ''; |
875 | 875 | if ($globalArchive) { |
@@ -884,18 +884,18 @@ discard block |
||
884 | 884 | |
885 | 885 | $sth = $this->db->prepare($query); |
886 | 886 | $sth->execute($query_values); |
887 | - } catch(PDOException $e) { |
|
888 | - return "error : ".$e->getMessage(); |
|
889 | - } |
|
890 | - /* |
|
887 | + } catch(PDOException $e) { |
|
888 | + return "error : ".$e->getMessage(); |
|
889 | + } |
|
890 | + /* |
|
891 | 891 | echo 'putinarchive : '.$putinarchive."\n"; |
892 | 892 | echo 'noarchive : '.$noarchive."\n"; |
893 | 893 | */ |
894 | 894 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
895 | - if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
896 | - $TrackerArchive = new TrackerArchive($this->db); |
|
897 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
898 | - if ($globalDebug) echo $result.')'; |
|
895 | + if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
896 | + $TrackerArchive = new TrackerArchive($this->db); |
|
897 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
898 | + if ($globalDebug) echo $result.')'; |
|
899 | 899 | } |
900 | 900 | |
901 | 901 | return "success"; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | <?php }; if (isset($globalTracker) && $globalTracker) { ?><td><div id="ibxtracker"><h4><?php echo _("Trackers Detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?> |
46 | 46 | </tr></table></div> |
47 | 47 | <?php |
48 | - if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
48 | + if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
49 | 49 | |
50 | 50 | ?> |
51 | 51 | <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script> |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script> |
66 | 66 | <?php |
67 | 67 | } |
68 | - } |
|
68 | + } |
|
69 | 69 | ?> |
70 | 70 | |
71 | 71 | <div id="sidebar" class="sidebar collapsed"> |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | <li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li> |
77 | 77 | <li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li> |
78 | 78 | <?php |
79 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
79 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
80 | 80 | if (isset($globalArchive) && $globalArchive == TRUE) { |
81 | 81 | ?> |
82 | 82 | <li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li> |
83 | 83 | <?php |
84 | 84 | } |
85 | - } |
|
85 | + } |
|
86 | 86 | ?> |
87 | 87 | <li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li> |
88 | 88 | <li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li> |
89 | 89 | <li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li> |
90 | 90 | <?php |
91 | - if (isset($globalMap3D) && $globalMap3D) { |
|
91 | + if (isset($globalMap3D) && $globalMap3D) { |
|
92 | 92 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
93 | 93 | ?> |
94 | 94 | <li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li> |
95 | 95 | <?php |
96 | - } else { |
|
97 | - if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
96 | + } else { |
|
97 | + if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
98 | 98 | ?> |
99 | 99 | <li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li> |
100 | 100 | <?php |
101 | - } |
|
101 | + } |
|
102 | 102 | ?> |
103 | 103 | <li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li> |
104 | 104 | <?php |
105 | 105 | } |
106 | - } |
|
106 | + } |
|
107 | 107 | ?> |
108 | 108 | </ul> |
109 | 109 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | ?> |
179 | 179 | </div> |
180 | 180 | <?php |
181 | - if (isset($globalArchive) && $globalArchive == TRUE) { |
|
181 | + if (isset($globalArchive) && $globalArchive == TRUE) { |
|
182 | 182 | ?> |
183 | 183 | <div class="sidebar-pane" id="archive"> |
184 | 184 | <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | </form> |
239 | 239 | </div> |
240 | 240 | <?php |
241 | - } |
|
241 | + } |
|
242 | 242 | ?> |
243 | 243 | <div class="sidebar-pane" id="settings"> |
244 | 244 | <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -249,56 +249,56 @@ discard block |
||
249 | 249 | <?php |
250 | 250 | if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
251 | 251 | else $MapType = $_COOKIE['MapType']; |
252 | - ?> |
|
252 | + ?> |
|
253 | 253 | <?php |
254 | 254 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
255 | - ?> |
|
255 | + ?> |
|
256 | 256 | <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
257 | 257 | <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
258 | 258 | <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
259 | 259 | <?php |
260 | 260 | } |
261 | - ?> |
|
261 | + ?> |
|
262 | 262 | <?php |
263 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
264 | - ?> |
|
263 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
264 | + ?> |
|
265 | 265 | <?php |
266 | - if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
267 | - ?> |
|
266 | + if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
267 | + ?> |
|
268 | 268 | <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
269 | 269 | <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
270 | 270 | <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
271 | 271 | <?php |
272 | - } |
|
273 | - ?> |
|
272 | + } |
|
273 | + ?> |
|
274 | 274 | <?php |
275 | - if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
276 | - ?> |
|
275 | + if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
276 | + ?> |
|
277 | 277 | <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
278 | 278 | <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
279 | 279 | <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
280 | 280 | <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
281 | 281 | <?php |
282 | - } |
|
283 | - ?> |
|
282 | + } |
|
283 | + ?> |
|
284 | 284 | <?php |
285 | - if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
286 | - ?> |
|
285 | + if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
286 | + ?> |
|
287 | 287 | <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
288 | 288 | <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
289 | 289 | <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
290 | 290 | <?php |
291 | - } |
|
292 | - ?> |
|
291 | + } |
|
292 | + ?> |
|
293 | 293 | <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
294 | 294 | <?php |
295 | 295 | } |
296 | - ?> |
|
296 | + ?> |
|
297 | 297 | <?php |
298 | - if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
298 | + if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
299 | 299 | if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
300 | 300 | else $MapBoxId = $_COOKIE['MapTypeId']; |
301 | - ?> |
|
301 | + ?> |
|
302 | 302 | <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
303 | 303 | <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
304 | 304 | <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
@@ -312,13 +312,13 @@ discard block |
||
312 | 312 | <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
313 | 313 | <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
314 | 314 | <?php |
315 | - } |
|
316 | - ?> |
|
315 | + } |
|
316 | + ?> |
|
317 | 317 | <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
318 | 318 | </select> |
319 | 319 | </li> |
320 | 320 | <?php |
321 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
321 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
322 | 322 | ?> |
323 | 323 | <li><?php echo _("Type of Terrain:"); ?> |
324 | 324 | <select class="selectpicker" onchange="terrainType(this);"> |
@@ -328,10 +328,10 @@ discard block |
||
328 | 328 | </select> |
329 | 329 | </li> |
330 | 330 | <?php |
331 | - } |
|
331 | + } |
|
332 | 332 | ?> |
333 | 333 | <?php |
334 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
334 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
335 | 335 | ?> |
336 | 336 | |
337 | 337 | <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
@@ -340,76 +340,76 @@ discard block |
||
340 | 340 | <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || !isset($_COOKIE['MapRemainingRoute']) || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) print 'checked'; ?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li> |
341 | 341 | <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
342 | 342 | <?php |
343 | - } |
|
343 | + } |
|
344 | 344 | ?> |
345 | 345 | <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
346 | 346 | <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li> |
347 | 347 | <?php |
348 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
348 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
349 | 349 | ?> |
350 | 350 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
351 | 351 | <?php |
352 | - } |
|
353 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
352 | + } |
|
353 | + if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
354 | 354 | ?> |
355 | 355 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
356 | 356 | <?php |
357 | - } |
|
357 | + } |
|
358 | 358 | ?> |
359 | 359 | |
360 | 360 | <?php |
361 | 361 | if (function_exists('array_column')) { |
362 | - if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
363 | - ?> |
|
362 | + if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
363 | + ?> |
|
364 | 364 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
365 | 365 | <?php |
366 | - } |
|
366 | + } |
|
367 | 367 | } elseif (isset($globalSources)) { |
368 | - $dispolar = false; |
|
369 | - foreach ($globalSources as $testsource) { |
|
370 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
371 | - } |
|
372 | - if ($dispolar) { |
|
373 | - ?> |
|
368 | + $dispolar = false; |
|
369 | + foreach ($globalSources as $testsource) { |
|
370 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
371 | + } |
|
372 | + if ($dispolar) { |
|
373 | + ?> |
|
374 | 374 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
375 | 375 | <?php |
376 | - } |
|
377 | - } |
|
378 | - ?> |
|
376 | + } |
|
377 | + } |
|
378 | + ?> |
|
379 | 379 | <?php |
380 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
380 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
381 | 381 | ?> |
382 | 382 | |
383 | 383 | <?php |
384 | 384 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
385 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
386 | - ?> |
|
385 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
386 | + ?> |
|
387 | 387 | <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
388 | 388 | <?php |
389 | 389 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
390 | - ?> |
|
390 | + ?> |
|
391 | 391 | <li><?php echo _("Aircraft icon color:"); ?> |
392 | 392 | <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
393 | 393 | </li> |
394 | 394 | <?php |
395 | 395 | } |
396 | - } |
|
397 | - } |
|
398 | - ?> |
|
396 | + } |
|
397 | + } |
|
398 | + ?> |
|
399 | 399 | <?php |
400 | 400 | if (isset($globalMarine) && $globalMarine === TRUE) { |
401 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
402 | - ?> |
|
401 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
402 | + ?> |
|
403 | 403 | <li><?php echo _("Marine icon color:"); ?> |
404 | 404 | <input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>"> |
405 | 405 | </li> |
406 | 406 | <?php |
407 | - } |
|
408 | - } |
|
409 | - ?> |
|
407 | + } |
|
408 | + } |
|
409 | + ?> |
|
410 | 410 | <?php |
411 | 411 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
412 | - ?> |
|
412 | + ?> |
|
413 | 413 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
414 | 414 | <div class="range"> |
415 | 415 | <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | </li> |
419 | 419 | <?php |
420 | 420 | } |
421 | - ?> |
|
421 | + ?> |
|
422 | 422 | <?php |
423 | - } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
423 | + } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
424 | 424 | ?> |
425 | 425 | <?php |
426 | 426 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | </li> |
442 | 442 | <?php |
443 | 443 | } |
444 | - } |
|
444 | + } |
|
445 | 445 | ?> |
446 | 446 | <li><?php echo _("Distance unit:"); ?> |
447 | 447 | <select class="selectpicker" onchange="unitdistance(this);"> |
@@ -474,19 +474,19 @@ discard block |
||
474 | 474 | <ul> |
475 | 475 | <?php |
476 | 476 | if (!isset($globalAircraft) || $globalAircraft) { |
477 | - ?> |
|
477 | + ?> |
|
478 | 478 | <?php |
479 | 479 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
480 | - ?> |
|
480 | + ?> |
|
481 | 481 | <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
482 | 482 | <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
483 | 483 | <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
484 | 484 | <?php |
485 | 485 | } |
486 | - ?> |
|
486 | + ?> |
|
487 | 487 | <?php |
488 | 488 | if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
489 | - ?> |
|
489 | + ?> |
|
490 | 490 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
491 | 491 | <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
492 | 492 | <?php } ?> |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | <?php } ?> |
496 | 496 | <?php |
497 | 497 | } |
498 | - ?> |
|
498 | + ?> |
|
499 | 499 | <li><?php echo _("Display airlines:"); ?> |
500 | 500 | <br/> |
501 | 501 | <select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines"> |
@@ -515,14 +515,14 @@ discard block |
||
515 | 515 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
516 | 516 | } |
517 | 517 | } |
518 | - ?> |
|
518 | + ?> |
|
519 | 519 | </select> |
520 | 520 | </li> |
521 | 521 | <?php |
522 | 522 | $Spotter = new Spotter(); |
523 | 523 | $allalliancenames = $Spotter->getAllAllianceNames(); |
524 | 524 | if (!empty($allalliancenames)) { |
525 | - ?> |
|
525 | + ?> |
|
526 | 526 | <li><?php echo _("Display alliance:"); ?> |
527 | 527 | <br/> |
528 | 528 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
@@ -536,18 +536,18 @@ discard block |
||
536 | 536 | echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>'; |
537 | 537 | } |
538 | 538 | } |
539 | - ?> |
|
539 | + ?> |
|
540 | 540 | </select> |
541 | 541 | </li> |
542 | 542 | <?php |
543 | 543 | } |
544 | - ?> |
|
544 | + ?> |
|
545 | 545 | <?php |
546 | 546 | } |
547 | - ?> |
|
547 | + ?> |
|
548 | 548 | <?php |
549 | 549 | if (isset($globalAPRS) && $globalAPRS) { |
550 | - ?> |
|
550 | + ?> |
|
551 | 551 | <li><?php echo _("Display APRS sources name:"); ?> |
552 | 552 | <select class="selectpicker" multiple onchange="sources(this);"> |
553 | 553 | <?php |
@@ -559,18 +559,18 @@ discard block |
||
559 | 559 | echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>'; |
560 | 560 | } |
561 | 561 | } |
562 | - ?> |
|
562 | + ?> |
|
563 | 563 | </select> |
564 | 564 | </li> |
565 | 565 | <?php |
566 | 566 | } |
567 | - ?> |
|
567 | + ?> |
|
568 | 568 | <?php |
569 | 569 | if (!isset($globalAircraft) && $globalAircraft) { |
570 | - ?> |
|
570 | + ?> |
|
571 | 571 | <?php |
572 | 572 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
573 | - ?> |
|
573 | + ?> |
|
574 | 574 | <li><?php echo _("Display airlines of type:"); ?><br/> |
575 | 575 | <select class="selectpicker" onchange="airlinestype(this);"> |
576 | 576 | <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
@@ -581,14 +581,14 @@ discard block |
||
581 | 581 | </li> |
582 | 582 | <?php |
583 | 583 | } |
584 | - ?> |
|
584 | + ?> |
|
585 | 585 | <li> |
586 | 586 | <?php echo _("Display flight with ident:"); ?> |
587 | 587 | <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
588 | 588 | </li> |
589 | 589 | <?php |
590 | 590 | } |
591 | - ?> |
|
591 | + ?> |
|
592 | 592 | </ul> |
593 | 593 | </form> |
594 | 594 | <form method="post"> |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | </form> |
598 | 598 | </div> |
599 | 599 | <?php |
600 | - if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
600 | + if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
601 | 601 | ?> |
602 | 602 | <div class="sidebar-pane" id="satellites"> |
603 | 603 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -637,14 +637,14 @@ discard block |
||
637 | 637 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
638 | 638 | } |
639 | 639 | } |
640 | - ?> |
|
640 | + ?> |
|
641 | 641 | </select> |
642 | 642 | </li> |
643 | 643 | </ul> |
644 | 644 | </form> |
645 | 645 | </div> |
646 | 646 | <?php |
647 | - } |
|
647 | + } |
|
648 | 648 | ?> |
649 | 649 | </div> |
650 | 650 | </div> |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | class update_schema { |
9 | 9 | |
10 | 10 | public static function update_schedule() { |
11 | - $Connection = new Connection(); |
|
12 | - $Schedule = new Schedule(); |
|
13 | - $query = "SELECT * FROM schedule"; |
|
14 | - try { |
|
15 | - $sth = $Connection->db->prepare($query); |
|
11 | + $Connection = new Connection(); |
|
12 | + $Schedule = new Schedule(); |
|
13 | + $query = "SELECT * FROM schedule"; |
|
14 | + try { |
|
15 | + $sth = $Connection->db->prepare($query); |
|
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch(PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | - } |
|
20 | - while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | - } |
|
19 | + } |
|
20 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | + $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | /* |
@@ -43,198 +43,198 @@ discard block |
||
43 | 43 | } |
44 | 44 | */ |
45 | 45 | private static function update_from_1() { |
46 | - $Connection = new Connection(); |
|
47 | - // Add new column to routes table |
|
48 | - //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
46 | + $Connection = new Connection(); |
|
47 | + // Add new column to routes table |
|
48 | + //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
49 | 49 | $query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL"; |
50 | - try { |
|
51 | - $sth = $Connection->db->prepare($query); |
|
52 | - $sth->execute(); |
|
53 | - } catch(PDOException $e) { |
|
54 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | - } |
|
56 | - // Copy schedules data to routes table |
|
57 | - self::update_schedule(); |
|
58 | - // Delete schedule table |
|
50 | + try { |
|
51 | + $sth = $Connection->db->prepare($query); |
|
52 | + $sth->execute(); |
|
53 | + } catch(PDOException $e) { |
|
54 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | + } |
|
56 | + // Copy schedules data to routes table |
|
57 | + self::update_schedule(); |
|
58 | + // Delete schedule table |
|
59 | 59 | $query = "DROP TABLE `schedule`"; |
60 | - try { |
|
61 | - $sth = $Connection->db->prepare($query); |
|
62 | - $sth->execute(); |
|
63 | - } catch(PDOException $e) { |
|
64 | - return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | - } |
|
66 | - // Add source column |
|
67 | - $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | - try { |
|
69 | - $sth = $Connection->db->prepare($query); |
|
70 | - $sth->execute(); |
|
71 | - } catch(PDOException $e) { |
|
72 | - return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | - } |
|
60 | + try { |
|
61 | + $sth = $Connection->db->prepare($query); |
|
62 | + $sth->execute(); |
|
63 | + } catch(PDOException $e) { |
|
64 | + return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | + } |
|
66 | + // Add source column |
|
67 | + $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | + try { |
|
69 | + $sth = $Connection->db->prepare($query); |
|
70 | + $sth->execute(); |
|
71 | + } catch(PDOException $e) { |
|
72 | + return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | + } |
|
74 | 74 | // Delete unused column |
75 | 75 | $query = "ALTER TABLE `aircraft_modes` DROP `SerialNo`, DROP `OperatorFlagCode`, DROP `Manufacturer`, DROP `Type`, DROP `FirstRegDate`, DROP `CurrentRegDate`, DROP `Country`, DROP `PreviousID`, DROP `DeRegDate`, DROP `Status`, DROP `PopularName`, DROP `GenericName`, DROP `AircraftClass`, DROP `Engines`, DROP `OwnershipStatus`, DROP `RegisteredOwners`, DROP `MTOW`, DROP `TotalHours`, DROP `YearBuilt`, DROP `CofACategory`, DROP `CofAExpiry`, DROP `UserNotes`, DROP `Interested`, DROP `UserTag`, DROP `InfoUrl`, DROP `PictureUrl1`, DROP `PictureUrl2`, DROP `PictureUrl3`, DROP `UserBool1`, DROP `UserBool2`, DROP `UserBool3`, DROP `UserBool4`, DROP `UserBool5`, DROP `UserString1`, DROP `UserString2`, DROP `UserString3`, DROP `UserString4`, DROP `UserString5`, DROP `UserInt1`, DROP `UserInt2`, DROP `UserInt3`, DROP `UserInt4`, DROP `UserInt5`"; |
76 | - try { |
|
77 | - $sth = $Connection->db->prepare($query); |
|
78 | - $sth->execute(); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | - } |
|
76 | + try { |
|
77 | + $sth = $Connection->db->prepare($query); |
|
78 | + $sth->execute(); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | + } |
|
82 | 82 | // Add ModeS column |
83 | 83 | $query = "ALTER TABLE `spotter_output` ADD `ModeS` VARCHAR(255) NULL"; |
84 | - try { |
|
85 | - $sth = $Connection->db->prepare($query); |
|
86 | - $sth->execute(); |
|
87 | - } catch(PDOException $e) { |
|
88 | - return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | - } |
|
84 | + try { |
|
85 | + $sth = $Connection->db->prepare($query); |
|
86 | + $sth->execute(); |
|
87 | + } catch(PDOException $e) { |
|
88 | + return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | + } |
|
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | - try { |
|
92 | - $sth = $Connection->db->prepare($query); |
|
93 | - $sth->execute(); |
|
94 | - } catch(PDOException $e) { |
|
95 | - return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | - } |
|
97 | - // Add auto_increment for aircraft_modes |
|
98 | - $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | - try { |
|
100 | - $sth = $Connection->db->prepare($query); |
|
101 | - $sth->execute(); |
|
102 | - } catch(PDOException $e) { |
|
103 | - return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | - } |
|
105 | - $error = ''; |
|
91 | + try { |
|
92 | + $sth = $Connection->db->prepare($query); |
|
93 | + $sth->execute(); |
|
94 | + } catch(PDOException $e) { |
|
95 | + return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | + } |
|
97 | + // Add auto_increment for aircraft_modes |
|
98 | + $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | + try { |
|
100 | + $sth = $Connection->db->prepare($query); |
|
101 | + $sth->execute(); |
|
102 | + } catch(PDOException $e) { |
|
103 | + return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | + } |
|
105 | + $error = ''; |
|
106 | 106 | $error .= create_db::import_file('../db/acars_live.sql'); |
107 | 107 | $error .= create_db::import_file('../db/config.sql'); |
108 | 108 | // Update schema_version to 2 |
109 | 109 | $query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'"; |
110 | - try { |
|
111 | - $sth = $Connection->db->prepare($query); |
|
112 | - $sth->execute(); |
|
113 | - } catch(PDOException $e) { |
|
114 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | - } |
|
110 | + try { |
|
111 | + $sth = $Connection->db->prepare($query); |
|
112 | + $sth->execute(); |
|
113 | + } catch(PDOException $e) { |
|
114 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | + } |
|
116 | 116 | return $error; |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | 119 | private static function update_from_2() { |
120 | - $Connection = new Connection(); |
|
121 | - // Add new column decode to acars_live table |
|
120 | + $Connection = new Connection(); |
|
121 | + // Add new column decode to acars_live table |
|
122 | 122 | $query = "ALTER TABLE `acars_live` ADD `decode` TEXT"; |
123 | - try { |
|
124 | - $sth = $Connection->db->prepare($query); |
|
125 | - $sth->execute(); |
|
126 | - } catch(PDOException $e) { |
|
127 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | - } |
|
129 | - $error = ''; |
|
130 | - // Create table acars_archive |
|
123 | + try { |
|
124 | + $sth = $Connection->db->prepare($query); |
|
125 | + $sth->execute(); |
|
126 | + } catch(PDOException $e) { |
|
127 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | + } |
|
129 | + $error = ''; |
|
130 | + // Create table acars_archive |
|
131 | 131 | $error .= create_db::import_file('../db/acars_archive.sql'); |
132 | 132 | // Update schema_version to 3 |
133 | 133 | $query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'"; |
134 | - try { |
|
135 | - $sth = $Connection->db->prepare($query); |
|
136 | - $sth->execute(); |
|
137 | - } catch(PDOException $e) { |
|
138 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | - } |
|
134 | + try { |
|
135 | + $sth = $Connection->db->prepare($query); |
|
136 | + $sth->execute(); |
|
137 | + } catch(PDOException $e) { |
|
138 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | + } |
|
140 | 140 | return $error; |
141 | 141 | } |
142 | 142 | |
143 | 143 | private static function update_from_3() { |
144 | - $Connection = new Connection(); |
|
145 | - // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
144 | + $Connection = new Connection(); |
|
145 | + // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
146 | 146 | $query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP"; |
147 | - try { |
|
148 | - $sth = $Connection->db->prepare($query); |
|
149 | - $sth->execute(); |
|
150 | - } catch(PDOException $e) { |
|
151 | - return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | - } |
|
153 | - // Add image_source_website column to spotter_image |
|
147 | + try { |
|
148 | + $sth = $Connection->db->prepare($query); |
|
149 | + $sth->execute(); |
|
150 | + } catch(PDOException $e) { |
|
151 | + return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | + } |
|
153 | + // Add image_source_website column to spotter_image |
|
154 | 154 | $query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL"; |
155 | - try { |
|
156 | - $sth = $Connection->db->prepare($query); |
|
157 | - $sth->execute(); |
|
158 | - } catch(PDOException $e) { |
|
159 | - return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | - } |
|
161 | - $error = ''; |
|
155 | + try { |
|
156 | + $sth = $Connection->db->prepare($query); |
|
157 | + $sth->execute(); |
|
158 | + } catch(PDOException $e) { |
|
159 | + return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | + } |
|
161 | + $error = ''; |
|
162 | 162 | // Update schema_version to 4 |
163 | 163 | $query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'"; |
164 | - try { |
|
165 | - $sth = $Connection->db->prepare($query); |
|
166 | - $sth->execute(); |
|
167 | - } catch(PDOException $e) { |
|
168 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | - } |
|
164 | + try { |
|
165 | + $sth = $Connection->db->prepare($query); |
|
166 | + $sth->execute(); |
|
167 | + } catch(PDOException $e) { |
|
168 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | + } |
|
170 | 170 | return $error; |
171 | 171 | } |
172 | 172 | |
173 | 173 | private static function update_from_4() { |
174 | - $Connection = new Connection(); |
|
174 | + $Connection = new Connection(); |
|
175 | 175 | |
176 | - $error = ''; |
|
177 | - // Create table acars_label |
|
176 | + $error = ''; |
|
177 | + // Create table acars_label |
|
178 | 178 | $error .= create_db::import_file('../db/acars_label.sql'); |
179 | 179 | if ($error == '') { |
180 | - // Update schema_version to 5 |
|
181 | - $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | - try { |
|
183 | - $sth = $Connection->db->prepare($query); |
|
180 | + // Update schema_version to 5 |
|
181 | + $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | + try { |
|
183 | + $sth = $Connection->db->prepare($query); |
|
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch(PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | - } |
|
188 | - } |
|
187 | + } |
|
188 | + } |
|
189 | 189 | return $error; |
190 | 190 | } |
191 | 191 | |
192 | 192 | private static function update_from_5() { |
193 | - $Connection = new Connection(); |
|
194 | - // Add columns to translation |
|
193 | + $Connection = new Connection(); |
|
194 | + // Add columns to translation |
|
195 | 195 | $query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;"; |
196 | - try { |
|
197 | - $sth = $Connection->db->prepare($query); |
|
198 | - $sth->execute(); |
|
199 | - } catch(PDOException $e) { |
|
200 | - return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | - } |
|
202 | - // Add aircraft_shadow column to aircraft |
|
203 | - $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | - try { |
|
205 | - $sth = $Connection->db->prepare($query); |
|
206 | - $sth->execute(); |
|
207 | - } catch(PDOException $e) { |
|
208 | - return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | - } |
|
210 | - // Add aircraft_shadow column to spotter_live |
|
211 | - $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | - try { |
|
213 | - $sth = $Connection->db->prepare($query); |
|
214 | - $sth->execute(); |
|
215 | - } catch(PDOException $e) { |
|
216 | - return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | - } |
|
218 | - $error = ''; |
|
219 | - // Update table aircraft |
|
196 | + try { |
|
197 | + $sth = $Connection->db->prepare($query); |
|
198 | + $sth->execute(); |
|
199 | + } catch(PDOException $e) { |
|
200 | + return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | + } |
|
202 | + // Add aircraft_shadow column to aircraft |
|
203 | + $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | + try { |
|
205 | + $sth = $Connection->db->prepare($query); |
|
206 | + $sth->execute(); |
|
207 | + } catch(PDOException $e) { |
|
208 | + return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | + } |
|
210 | + // Add aircraft_shadow column to spotter_live |
|
211 | + $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | + try { |
|
213 | + $sth = $Connection->db->prepare($query); |
|
214 | + $sth->execute(); |
|
215 | + } catch(PDOException $e) { |
|
216 | + return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | + } |
|
218 | + $error = ''; |
|
219 | + // Update table aircraft |
|
220 | 220 | $error .= create_db::import_file('../db/aircraft.sql'); |
221 | 221 | $error .= create_db::import_file('../db/spotter_archive.sql'); |
222 | 222 | |
223 | 223 | // Update schema_version to 6 |
224 | 224 | $query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'"; |
225 | - try { |
|
226 | - $sth = $Connection->db->prepare($query); |
|
227 | - $sth->execute(); |
|
228 | - } catch(PDOException $e) { |
|
229 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | - } |
|
225 | + try { |
|
226 | + $sth = $Connection->db->prepare($query); |
|
227 | + $sth->execute(); |
|
228 | + } catch(PDOException $e) { |
|
229 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | + } |
|
231 | 231 | return $error; |
232 | 232 | } |
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | - $Connection = new Connection(); |
|
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | - $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
235 | + $Connection = new Connection(); |
|
236 | + if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | + $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
240 | 240 | ALTER TABLE spotter_live ADD INDEX(flightaware_id); |
@@ -247,147 +247,147 @@ discard block |
||
247 | 247 | ALTER TABLE aircraft ADD INDEX(icao); |
248 | 248 | ALTER TABLE airport ADD INDEX(icao); |
249 | 249 | ALTER TABLE translation ADD INDEX(Operator);"; |
250 | - try { |
|
251 | - $sth = $Connection->db->prepare($query); |
|
250 | + try { |
|
251 | + $sth = $Connection->db->prepare($query); |
|
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch(PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | - } |
|
256 | - } |
|
257 | - $error = ''; |
|
258 | - // Update table countries |
|
259 | - if ($Connection->tableExists('airspace')) { |
|
260 | - $error .= update_db::update_countries(); |
|
261 | - if ($error != '') return $error; |
|
255 | + } |
|
256 | + } |
|
257 | + $error = ''; |
|
258 | + // Update table countries |
|
259 | + if ($Connection->tableExists('airspace')) { |
|
260 | + $error .= update_db::update_countries(); |
|
261 | + if ($error != '') return $error; |
|
262 | 262 | } |
263 | 263 | // Update schema_version to 7 |
264 | 264 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
265 | - try { |
|
266 | - $sth = $Connection->db->prepare($query); |
|
267 | - $sth->execute(); |
|
268 | - } catch(PDOException $e) { |
|
269 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | - } |
|
265 | + try { |
|
266 | + $sth = $Connection->db->prepare($query); |
|
267 | + $sth->execute(); |
|
268 | + } catch(PDOException $e) { |
|
269 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | + } |
|
271 | 271 | return $error; |
272 | - } |
|
272 | + } |
|
273 | 273 | |
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | - $Connection = new Connection(); |
|
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
276 | + $Connection = new Connection(); |
|
277 | + $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | - try { |
|
280 | - $sth = $Connection->db->prepare($query); |
|
281 | - $sth->execute(); |
|
282 | - } catch(PDOException $e) { |
|
283 | - return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | - } |
|
285 | - if ($globalDBdriver == 'mysql') { |
|
286 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | - try { |
|
288 | - $sth = $Connection->db->prepare($query); |
|
289 | - $sth->execute(); |
|
290 | - } catch(PDOException $e) { |
|
279 | + try { |
|
280 | + $sth = $Connection->db->prepare($query); |
|
281 | + $sth->execute(); |
|
282 | + } catch(PDOException $e) { |
|
283 | + return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | + } |
|
285 | + if ($globalDBdriver == 'mysql') { |
|
286 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | + try { |
|
288 | + $sth = $Connection->db->prepare($query); |
|
289 | + $sth->execute(); |
|
290 | + } catch(PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | - } |
|
293 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | - if ($row['engine'] == 'ARCHIVE') { |
|
292 | + } |
|
293 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | + if ($row['engine'] == 'ARCHIVE') { |
|
295 | 295 | $query = "CREATE TABLE copy LIKE spotter_archive; |
296 | 296 | ALTER TABLE copy ENGINE=ARCHIVE; |
297 | 297 | ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
298 | 298 | INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`; |
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | - } else { |
|
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | - } |
|
304 | - } else { |
|
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | - } |
|
307 | - try { |
|
308 | - $sth = $Connection->db->prepare($query); |
|
309 | - $sth->execute(); |
|
310 | - } catch(PDOException $e) { |
|
311 | - return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | - } |
|
301 | + } else { |
|
302 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | + } |
|
304 | + } else { |
|
305 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | + } |
|
307 | + try { |
|
308 | + $sth = $Connection->db->prepare($query); |
|
309 | + $sth->execute(); |
|
310 | + } catch(PDOException $e) { |
|
311 | + return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | + } |
|
313 | 313 | |
314 | - $error = ''; |
|
315 | - // Update table aircraft |
|
314 | + $error = ''; |
|
315 | + // Update table aircraft |
|
316 | 316 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | 317 | if ($error != '') return $error; |
318 | 318 | // Update schema_version to 6 |
319 | 319 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | - try { |
|
321 | - $sth = $Connection->db->prepare($query); |
|
322 | - $sth->execute(); |
|
323 | - } catch(PDOException $e) { |
|
324 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | - } |
|
320 | + try { |
|
321 | + $sth = $Connection->db->prepare($query); |
|
322 | + $sth->execute(); |
|
323 | + } catch(PDOException $e) { |
|
324 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | + } |
|
326 | 326 | return $error; |
327 | 327 | } |
328 | 328 | |
329 | 329 | private static function update_from_8() { |
330 | - $Connection = new Connection(); |
|
331 | - $error = ''; |
|
332 | - // Update table aircraft |
|
330 | + $Connection = new Connection(); |
|
331 | + $error = ''; |
|
332 | + // Update table aircraft |
|
333 | 333 | $error .= create_db::import_file('../db/notam.sql'); |
334 | 334 | if ($error != '') return $error; |
335 | 335 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 336 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 337 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
338 | 338 | INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());"; |
339 | - try { |
|
340 | - $sth = $Connection->db->prepare($query); |
|
341 | - $sth->execute(); |
|
342 | - } catch(PDOException $e) { |
|
343 | - return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | - } |
|
339 | + try { |
|
340 | + $sth = $Connection->db->prepare($query); |
|
341 | + $sth->execute(); |
|
342 | + } catch(PDOException $e) { |
|
343 | + return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | + } |
|
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | - try { |
|
347 | - $sth = $Connection->db->prepare($query); |
|
348 | - $sth->execute(); |
|
349 | - } catch(PDOException $e) { |
|
350 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | - } |
|
346 | + try { |
|
347 | + $sth = $Connection->db->prepare($query); |
|
348 | + $sth->execute(); |
|
349 | + } catch(PDOException $e) { |
|
350 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | + } |
|
352 | 352 | return $error; |
353 | 353 | } |
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | - $Connection = new Connection(); |
|
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
356 | + $Connection = new Connection(); |
|
357 | + $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | - try { |
|
360 | - $sth = $Connection->db->prepare($query); |
|
361 | - $sth->execute(); |
|
362 | - } catch(PDOException $e) { |
|
363 | - return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | - } |
|
359 | + try { |
|
360 | + $sth = $Connection->db->prepare($query); |
|
361 | + $sth->execute(); |
|
362 | + } catch(PDOException $e) { |
|
363 | + return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | + } |
|
365 | 365 | $error = ''; |
366 | - // Update table atc |
|
366 | + // Update table atc |
|
367 | 367 | $error .= create_db::import_file('../db/atc.sql'); |
368 | 368 | if ($error != '') return $error; |
369 | 369 | |
370 | 370 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | - try { |
|
372 | - $sth = $Connection->db->prepare($query); |
|
373 | - $sth->execute(); |
|
374 | - } catch(PDOException $e) { |
|
375 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | - } |
|
371 | + try { |
|
372 | + $sth = $Connection->db->prepare($query); |
|
373 | + $sth->execute(); |
|
374 | + } catch(PDOException $e) { |
|
375 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | + } |
|
377 | 377 | return $error; |
378 | 378 | } |
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | - $Connection = new Connection(); |
|
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | - try { |
|
384 | - $sth = $Connection->db->prepare($query); |
|
385 | - $sth->execute(); |
|
386 | - } catch(PDOException $e) { |
|
387 | - return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | - } |
|
381 | + $Connection = new Connection(); |
|
382 | + $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | + try { |
|
384 | + $sth = $Connection->db->prepare($query); |
|
385 | + $sth->execute(); |
|
386 | + } catch(PDOException $e) { |
|
387 | + return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | + } |
|
389 | 389 | $error = ''; |
390 | - // Add tables |
|
390 | + // Add tables |
|
391 | 391 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | 392 | if ($error != '') return $error; |
393 | 393 | $error .= create_db::import_file('../db/metar.sql'); |
@@ -398,76 +398,76 @@ discard block |
||
398 | 398 | if ($error != '') return $error; |
399 | 399 | |
400 | 400 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | - try { |
|
402 | - $sth = $Connection->db->prepare($query); |
|
403 | - $sth->execute(); |
|
404 | - } catch(PDOException $e) { |
|
405 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | - } |
|
401 | + try { |
|
402 | + $sth = $Connection->db->prepare($query); |
|
403 | + $sth->execute(); |
|
404 | + } catch(PDOException $e) { |
|
405 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | + } |
|
407 | 407 | return $error; |
408 | 408 | } |
409 | 409 | |
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | - $Connection = new Connection(); |
|
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | - try { |
|
415 | - $sth = $Connection->db->prepare($query); |
|
416 | - $sth->execute(); |
|
417 | - } catch(PDOException $e) { |
|
418 | - return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | - } |
|
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | - try { |
|
422 | - $sth = $Connection->db->prepare($query); |
|
423 | - $sth->execute(); |
|
424 | - } catch(PDOException $e) { |
|
425 | - return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | - } |
|
427 | - if ($globalDBdriver == 'mysql') { |
|
428 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | - try { |
|
430 | - $sth = $Connection->db->prepare($query); |
|
431 | - $sth->execute(); |
|
432 | - } catch(PDOException $e) { |
|
412 | + $Connection = new Connection(); |
|
413 | + $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | + try { |
|
415 | + $sth = $Connection->db->prepare($query); |
|
416 | + $sth->execute(); |
|
417 | + } catch(PDOException $e) { |
|
418 | + return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | + } |
|
420 | + $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | + try { |
|
422 | + $sth = $Connection->db->prepare($query); |
|
423 | + $sth->execute(); |
|
424 | + } catch(PDOException $e) { |
|
425 | + return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | + } |
|
427 | + if ($globalDBdriver == 'mysql') { |
|
428 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | + try { |
|
430 | + $sth = $Connection->db->prepare($query); |
|
431 | + $sth->execute(); |
|
432 | + } catch(PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | - } |
|
435 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | - if ($row['engine'] == 'ARCHIVE') { |
|
434 | + } |
|
435 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | + if ($row['engine'] == 'ARCHIVE') { |
|
437 | 437 | $query = "CREATE TABLE copy LIKE spotter_archive; |
438 | 438 | ALTER TABLE copy ENGINE=ARCHIVE; |
439 | 439 | ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE; |
440 | 440 | INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`; |
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | - } else { |
|
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | - } |
|
446 | - } else { |
|
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | - } |
|
449 | - try { |
|
450 | - $sth = $Connection->db->prepare($query); |
|
451 | - $sth->execute(); |
|
452 | - } catch(PDOException $e) { |
|
453 | - return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | - } |
|
443 | + } else { |
|
444 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | + } |
|
446 | + } else { |
|
447 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | + } |
|
449 | + try { |
|
450 | + $sth = $Connection->db->prepare($query); |
|
451 | + $sth->execute(); |
|
452 | + } catch(PDOException $e) { |
|
453 | + return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | + } |
|
455 | 455 | |
456 | 456 | $error = ''; |
457 | 457 | |
458 | 458 | $query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'"; |
459 | - try { |
|
460 | - $sth = $Connection->db->prepare($query); |
|
461 | - $sth->execute(); |
|
462 | - } catch(PDOException $e) { |
|
463 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | - } |
|
459 | + try { |
|
460 | + $sth = $Connection->db->prepare($query); |
|
461 | + $sth->execute(); |
|
462 | + } catch(PDOException $e) { |
|
463 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | + } |
|
465 | 465 | return $error; |
466 | 466 | } |
467 | 467 | private static function update_from_12() { |
468 | - $Connection = new Connection(); |
|
468 | + $Connection = new Connection(); |
|
469 | 469 | $error = ''; |
470 | - // Add tables |
|
470 | + // Add tables |
|
471 | 471 | $error .= create_db::import_file('../db/stats.sql'); |
472 | 472 | if ($error != '') return $error; |
473 | 473 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
@@ -484,166 +484,166 @@ discard block |
||
484 | 484 | if ($error != '') return $error; |
485 | 485 | |
486 | 486 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | - try { |
|
488 | - $sth = $Connection->db->prepare($query); |
|
489 | - $sth->execute(); |
|
490 | - } catch(PDOException $e) { |
|
491 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | - } |
|
487 | + try { |
|
488 | + $sth = $Connection->db->prepare($query); |
|
489 | + $sth->execute(); |
|
490 | + } catch(PDOException $e) { |
|
491 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | + } |
|
493 | 493 | return $error; |
494 | 494 | } |
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | - $Connection = new Connection(); |
|
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
497 | + $Connection = new Connection(); |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | + $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch(PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | - } |
|
505 | + } |
|
506 | 506 | } |
507 | - $error = ''; |
|
507 | + $error = ''; |
|
508 | 508 | $query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'"; |
509 | - try { |
|
510 | - $sth = $Connection->db->prepare($query); |
|
511 | - $sth->execute(); |
|
512 | - } catch(PDOException $e) { |
|
513 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | - } |
|
509 | + try { |
|
510 | + $sth = $Connection->db->prepare($query); |
|
511 | + $sth->execute(); |
|
512 | + } catch(PDOException $e) { |
|
513 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | + } |
|
515 | 515 | return $error; |
516 | 516 | } |
517 | 517 | |
518 | 518 | private static function update_from_14() { |
519 | - $Connection = new Connection(); |
|
519 | + $Connection = new Connection(); |
|
520 | 520 | $error = ''; |
521 | - // Add tables |
|
522 | - if (!$Connection->tableExists('stats_flight')) { |
|
521 | + // Add tables |
|
522 | + if (!$Connection->tableExists('stats_flight')) { |
|
523 | 523 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | 524 | if ($error != '') return $error; |
525 | 525 | } |
526 | 526 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | - try { |
|
528 | - $sth = $Connection->db->prepare($query); |
|
529 | - $sth->execute(); |
|
530 | - } catch(PDOException $e) { |
|
531 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | - } |
|
527 | + try { |
|
528 | + $sth = $Connection->db->prepare($query); |
|
529 | + $sth->execute(); |
|
530 | + } catch(PDOException $e) { |
|
531 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | + } |
|
533 | 533 | return $error; |
534 | 534 | } |
535 | 535 | |
536 | 536 | |
537 | 537 | private static function update_from_15() { |
538 | - $Connection = new Connection(); |
|
538 | + $Connection = new Connection(); |
|
539 | 539 | $error = ''; |
540 | - // Add tables |
|
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | - try { |
|
543 | - $sth = $Connection->db->prepare($query); |
|
544 | - $sth->execute(); |
|
545 | - } catch(PDOException $e) { |
|
546 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | - } |
|
540 | + // Add tables |
|
541 | + $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | + try { |
|
543 | + $sth = $Connection->db->prepare($query); |
|
544 | + $sth->execute(); |
|
545 | + } catch(PDOException $e) { |
|
546 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | + } |
|
548 | 548 | if ($error != '') return $error; |
549 | 549 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | - try { |
|
551 | - $sth = $Connection->db->prepare($query); |
|
552 | - $sth->execute(); |
|
553 | - } catch(PDOException $e) { |
|
554 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | - } |
|
550 | + try { |
|
551 | + $sth = $Connection->db->prepare($query); |
|
552 | + $sth->execute(); |
|
553 | + } catch(PDOException $e) { |
|
554 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | + } |
|
556 | 556 | return $error; |
557 | 557 | } |
558 | 558 | |
559 | 559 | private static function update_from_16() { |
560 | - $Connection = new Connection(); |
|
560 | + $Connection = new Connection(); |
|
561 | 561 | $error = ''; |
562 | - // Add tables |
|
563 | - if (!$Connection->tableExists('stats_registration')) { |
|
562 | + // Add tables |
|
563 | + if (!$Connection->tableExists('stats_registration')) { |
|
564 | 564 | $error .= create_db::import_file('../db/stats_registration.sql'); |
565 | 565 | } |
566 | - if (!$Connection->tableExists('stats_callsign')) { |
|
566 | + if (!$Connection->tableExists('stats_callsign')) { |
|
567 | 567 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 568 | } |
569 | 569 | if ($error != '') return $error; |
570 | 570 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | - try { |
|
572 | - $sth = $Connection->db->prepare($query); |
|
573 | - $sth->execute(); |
|
574 | - } catch(PDOException $e) { |
|
575 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | - } |
|
571 | + try { |
|
572 | + $sth = $Connection->db->prepare($query); |
|
573 | + $sth->execute(); |
|
574 | + } catch(PDOException $e) { |
|
575 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | + } |
|
577 | 577 | return $error; |
578 | 578 | } |
579 | 579 | |
580 | 580 | private static function update_from_17() { |
581 | - $Connection = new Connection(); |
|
581 | + $Connection = new Connection(); |
|
582 | 582 | $error = ''; |
583 | - // Add tables |
|
584 | - if (!$Connection->tableExists('stats_country')) { |
|
583 | + // Add tables |
|
584 | + if (!$Connection->tableExists('stats_country')) { |
|
585 | 585 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 586 | } |
587 | 587 | if ($error != '') return $error; |
588 | 588 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | - try { |
|
590 | - $sth = $Connection->db->prepare($query); |
|
591 | - $sth->execute(); |
|
592 | - } catch(PDOException $e) { |
|
593 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | - } |
|
589 | + try { |
|
590 | + $sth = $Connection->db->prepare($query); |
|
591 | + $sth->execute(); |
|
592 | + } catch(PDOException $e) { |
|
593 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | + } |
|
595 | 595 | return $error; |
596 | 596 | } |
597 | 597 | private static function update_from_18() { |
598 | - $Connection = new Connection(); |
|
598 | + $Connection = new Connection(); |
|
599 | 599 | $error = ''; |
600 | - // Modify stats_airport table |
|
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | - $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | - try { |
|
604 | - $sth = $Connection->db->prepare($query); |
|
605 | - $sth->execute(); |
|
606 | - } catch(PDOException $e) { |
|
607 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | - } |
|
609 | - } |
|
600 | + // Modify stats_airport table |
|
601 | + if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | + $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | + try { |
|
604 | + $sth = $Connection->db->prepare($query); |
|
605 | + $sth->execute(); |
|
606 | + } catch(PDOException $e) { |
|
607 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | + } |
|
609 | + } |
|
610 | 610 | if ($error != '') return $error; |
611 | 611 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | - try { |
|
613 | - $sth = $Connection->db->prepare($query); |
|
614 | - $sth->execute(); |
|
615 | - } catch(PDOException $e) { |
|
616 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | - } |
|
612 | + try { |
|
613 | + $sth = $Connection->db->prepare($query); |
|
614 | + $sth->execute(); |
|
615 | + } catch(PDOException $e) { |
|
616 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | + } |
|
618 | 618 | return $error; |
619 | 619 | } |
620 | 620 | |
621 | 621 | private static function update_from_19() { |
622 | - $Connection = new Connection(); |
|
622 | + $Connection = new Connection(); |
|
623 | 623 | $error = ''; |
624 | - // Update airport table |
|
624 | + // Update airport table |
|
625 | 625 | $error .= create_db::import_file('../db/airport.sql'); |
626 | 626 | if ($error != '') return 'Import airport.sql : '.$error; |
627 | 627 | // Remove primary key on Spotter_Archive |
628 | 628 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | - try { |
|
630 | - $sth = $Connection->db->prepare($query); |
|
631 | - $sth->execute(); |
|
632 | - } catch(PDOException $e) { |
|
633 | - return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | - } |
|
629 | + try { |
|
630 | + $sth = $Connection->db->prepare($query); |
|
631 | + $sth->execute(); |
|
632 | + } catch(PDOException $e) { |
|
633 | + return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | + } |
|
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | - try { |
|
637 | - $sth = $Connection->db->prepare($query); |
|
638 | - $sth->execute(); |
|
639 | - } catch(PDOException $e) { |
|
640 | - return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | - } |
|
636 | + try { |
|
637 | + $sth = $Connection->db->prepare($query); |
|
638 | + $sth->execute(); |
|
639 | + } catch(PDOException $e) { |
|
640 | + return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | + } |
|
642 | 642 | if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
643 | 643 | // Add column over_country |
644 | - $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
644 | + $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
645 | 645 | try { |
646 | - $sth = $Connection->db->prepare($query); |
|
646 | + $sth = $Connection->db->prepare($query); |
|
647 | 647 | $sth->execute(); |
648 | 648 | } catch(PDOException $e) { |
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | } |
652 | 652 | if (!$Connection->checkColumnName('spotter_live','over_country')) { |
653 | 653 | // Add column over_country |
654 | - $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
654 | + $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
655 | 655 | try { |
656 | - $sth = $Connection->db->prepare($query); |
|
656 | + $sth = $Connection->db->prepare($query); |
|
657 | 657 | $sth->execute(); |
658 | 658 | } catch(PDOException $e) { |
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -661,74 +661,74 @@ discard block |
||
661 | 661 | } |
662 | 662 | if (!$Connection->checkColumnName('spotter_output','source_name')) { |
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | - $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
664 | + $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | 668 | } catch(PDOException $e) { |
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | - } |
|
671 | - } |
|
670 | + } |
|
671 | + } |
|
672 | 672 | if (!$Connection->checkColumnName('spotter_live','source_name')) { |
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | - $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
674 | + $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | 678 | } catch(PDOException $e) { |
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | - } |
|
681 | - } |
|
680 | + } |
|
681 | + } |
|
682 | 682 | if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | - $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
684 | + $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | 688 | } catch(PDOException $e) { |
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | - } |
|
691 | - } |
|
690 | + } |
|
691 | + } |
|
692 | 692 | if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | - $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
694 | + $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | 698 | } catch(PDOException $e) { |
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | - } |
|
701 | - } |
|
700 | + } |
|
701 | + } |
|
702 | 702 | if ($error != '') return $error; |
703 | 703 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | - try { |
|
705 | - $sth = $Connection->db->prepare($query); |
|
706 | - $sth->execute(); |
|
707 | - } catch(PDOException $e) { |
|
708 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | - } |
|
704 | + try { |
|
705 | + $sth = $Connection->db->prepare($query); |
|
706 | + $sth->execute(); |
|
707 | + } catch(PDOException $e) { |
|
708 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | + } |
|
710 | 710 | return $error; |
711 | 711 | } |
712 | 712 | |
713 | 713 | private static function update_from_20() { |
714 | 714 | global $globalIVAO, $globalVATSIM, $globalphpVMS; |
715 | - $Connection = new Connection(); |
|
715 | + $Connection = new Connection(); |
|
716 | 716 | $error = ''; |
717 | - // Update airline table |
|
718 | - if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
717 | + // Update airline table |
|
718 | + if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | 722 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 723 | // Add column over_country |
724 | - $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | - try { |
|
724 | + $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | + try { |
|
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | 728 | } catch(PDOException $e) { |
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | - } |
|
731 | - } |
|
730 | + } |
|
731 | + } |
|
732 | 732 | if ($error != '') return $error; |
733 | 733 | /* |
734 | 734 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
@@ -738,12 +738,12 @@ discard block |
||
738 | 738 | } |
739 | 739 | */ |
740 | 740 | $query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'"; |
741 | - try { |
|
742 | - $sth = $Connection->db->prepare($query); |
|
743 | - $sth->execute(); |
|
744 | - } catch(PDOException $e) { |
|
745 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | - } |
|
741 | + try { |
|
742 | + $sth = $Connection->db->prepare($query); |
|
743 | + $sth->execute(); |
|
744 | + } catch(PDOException $e) { |
|
745 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | + } |
|
747 | 747 | return $error; |
748 | 748 | } |
749 | 749 | |
@@ -762,35 +762,35 @@ discard block |
||
762 | 762 | if ($error != '') return $error; |
763 | 763 | } |
764 | 764 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | - try { |
|
766 | - $sth = $Connection->db->prepare($query); |
|
767 | - $sth->execute(); |
|
768 | - } catch(PDOException $e) { |
|
769 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | - } |
|
765 | + try { |
|
766 | + $sth = $Connection->db->prepare($query); |
|
767 | + $sth->execute(); |
|
768 | + } catch(PDOException $e) { |
|
769 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | + } |
|
771 | 771 | return $error; |
772 | 772 | } |
773 | 773 | |
774 | 774 | private static function update_from_22() { |
775 | 775 | global $globalDBdriver; |
776 | - $Connection = new Connection(); |
|
776 | + $Connection = new Connection(); |
|
777 | 777 | $error = ''; |
778 | 778 | // Add table stats polar |
779 | - if (!$Connection->tableExists('stats_source')) { |
|
779 | + if (!$Connection->tableExists('stats_source')) { |
|
780 | 780 | if ($globalDBdriver == 'mysql') { |
781 | - $error .= create_db::import_file('../db/stats_source.sql'); |
|
781 | + $error .= create_db::import_file('../db/stats_source.sql'); |
|
782 | 782 | } else { |
783 | 783 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 784 | } |
785 | 785 | if ($error != '') return $error; |
786 | 786 | } |
787 | 787 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | - try { |
|
789 | - $sth = $Connection->db->prepare($query); |
|
790 | - $sth->execute(); |
|
791 | - } catch(PDOException $e) { |
|
792 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | - } |
|
788 | + try { |
|
789 | + $sth = $Connection->db->prepare($query); |
|
790 | + $sth->execute(); |
|
791 | + } catch(PDOException $e) { |
|
792 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | + } |
|
794 | 794 | return $error; |
795 | 795 | } |
796 | 796 | |
@@ -821,14 +821,14 @@ discard block |
||
821 | 821 | } |
822 | 822 | if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | - $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
824 | + $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | 828 | } catch(PDOException $e) { |
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | - } |
|
831 | - } |
|
830 | + } |
|
831 | + } |
|
832 | 832 | |
833 | 833 | $query = "UPDATE config SET value = '24' WHERE name = 'schema_version'"; |
834 | 834 | try { |
@@ -1176,7 +1176,7 @@ discard block |
||
1176 | 1176 | } catch(PDOException $e) { |
1177 | 1177 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
1178 | 1178 | } |
1179 | - } |
|
1179 | + } |
|
1180 | 1180 | if (!$Connection->checkColumnName('aircraft','mfr')) { |
1181 | 1181 | // Add mfr to aircraft |
1182 | 1182 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | } catch(PDOException $e) { |
1251 | 1251 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
1252 | 1252 | } |
1253 | - } |
|
1253 | + } |
|
1254 | 1254 | if (!$Connection->indexExists('accidents','registration_idx')) { |
1255 | 1255 | // Add index key |
1256 | 1256 | $query = "create index registration_idx on accidents (registration)"; |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | } catch(PDOException $e) { |
1261 | 1261 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
1262 | 1262 | } |
1263 | - } |
|
1263 | + } |
|
1264 | 1264 | if (!$Connection->indexExists('accidents','rdts')) { |
1265 | 1265 | // Add index key |
1266 | 1266 | $query = "create index rdts on accidents (registration,date,type,source)"; |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | } catch(PDOException $e) { |
1271 | 1271 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
1272 | 1272 | } |
1273 | - } |
|
1273 | + } |
|
1274 | 1274 | |
1275 | 1275 | $query = "UPDATE config SET value = '31' WHERE name = 'schema_version'"; |
1276 | 1276 | try { |
@@ -1562,7 +1562,7 @@ discard block |
||
1562 | 1562 | } catch(PDOException $e) { |
1563 | 1563 | return "error (add index type on accidents) : ".$e->getMessage()."\n"; |
1564 | 1564 | } |
1565 | - } |
|
1565 | + } |
|
1566 | 1566 | $query = "UPDATE config SET value = '36' WHERE name = 'schema_version'"; |
1567 | 1567 | try { |
1568 | 1568 | $sth = $Connection->db->prepare($query); |
@@ -1723,7 +1723,7 @@ discard block |
||
1723 | 1723 | } catch(PDOException $e) { |
1724 | 1724 | return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n"; |
1725 | 1725 | } |
1726 | - } |
|
1726 | + } |
|
1727 | 1727 | $query = "UPDATE config SET value = '38' WHERE name = 'schema_version'"; |
1728 | 1728 | try { |
1729 | 1729 | $sth = $Connection->db->prepare($query); |
@@ -2129,205 +2129,205 @@ discard block |
||
2129 | 2129 | |
2130 | 2130 | |
2131 | 2131 | |
2132 | - public static function check_version($update = false) { |
|
2133 | - global $globalDBname; |
|
2134 | - $version = 0; |
|
2135 | - $Connection = new Connection(); |
|
2136 | - if ($Connection->tableExists('aircraft')) { |
|
2137 | - if (!$Connection->tableExists('config')) { |
|
2138 | - $version = '1'; |
|
2139 | - if ($update) return self::update_from_1(); |
|
2140 | - else return $version; |
|
2132 | + public static function check_version($update = false) { |
|
2133 | + global $globalDBname; |
|
2134 | + $version = 0; |
|
2135 | + $Connection = new Connection(); |
|
2136 | + if ($Connection->tableExists('aircraft')) { |
|
2137 | + if (!$Connection->tableExists('config')) { |
|
2138 | + $version = '1'; |
|
2139 | + if ($update) return self::update_from_1(); |
|
2140 | + else return $version; |
|
2141 | 2141 | } else { |
2142 | - $Connection = new Connection(); |
|
2143 | - $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
2144 | - try { |
|
2145 | - $sth = $Connection->db->prepare($query); |
|
2146 | - $sth->execute(); |
|
2147 | - } catch(PDOException $e) { |
|
2142 | + $Connection = new Connection(); |
|
2143 | + $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
2144 | + try { |
|
2145 | + $sth = $Connection->db->prepare($query); |
|
2146 | + $sth->execute(); |
|
2147 | + } catch(PDOException $e) { |
|
2148 | 2148 | return "error : ".$e->getMessage()."\n"; |
2149 | - } |
|
2150 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
2151 | - if ($update) { |
|
2152 | - if ($result['value'] == '2') { |
|
2153 | - $error = self::update_from_2(); |
|
2154 | - if ($error != '') return $error; |
|
2155 | - else return self::check_version(true); |
|
2156 | - } elseif ($result['value'] == '3') { |
|
2157 | - $error = self::update_from_3(); |
|
2158 | - if ($error != '') return $error; |
|
2159 | - else return self::check_version(true); |
|
2160 | - } elseif ($result['value'] == '4') { |
|
2161 | - $error = self::update_from_4(); |
|
2162 | - if ($error != '') return $error; |
|
2163 | - else return self::check_version(true); |
|
2164 | - } elseif ($result['value'] == '5') { |
|
2165 | - $error = self::update_from_5(); |
|
2166 | - if ($error != '') return $error; |
|
2167 | - else return self::check_version(true); |
|
2168 | - } elseif ($result['value'] == '6') { |
|
2169 | - $error = self::update_from_6(); |
|
2170 | - if ($error != '') return $error; |
|
2171 | - else return self::check_version(true); |
|
2172 | - } elseif ($result['value'] == '7') { |
|
2173 | - $error = self::update_from_7(); |
|
2174 | - if ($error != '') return $error; |
|
2175 | - else return self::check_version(true); |
|
2176 | - } elseif ($result['value'] == '8') { |
|
2177 | - $error = self::update_from_8(); |
|
2178 | - if ($error != '') return $error; |
|
2179 | - else return self::check_version(true); |
|
2180 | - } elseif ($result['value'] == '9') { |
|
2181 | - $error = self::update_from_9(); |
|
2182 | - if ($error != '') return $error; |
|
2183 | - else return self::check_version(true); |
|
2184 | - } elseif ($result['value'] == '10') { |
|
2185 | - $error = self::update_from_10(); |
|
2186 | - if ($error != '') return $error; |
|
2187 | - else return self::check_version(true); |
|
2188 | - } elseif ($result['value'] == '11') { |
|
2189 | - $error = self::update_from_11(); |
|
2190 | - if ($error != '') return $error; |
|
2191 | - else return self::check_version(true); |
|
2192 | - } elseif ($result['value'] == '12') { |
|
2193 | - $error = self::update_from_12(); |
|
2194 | - if ($error != '') return $error; |
|
2195 | - else return self::check_version(true); |
|
2196 | - } elseif ($result['value'] == '13') { |
|
2197 | - $error = self::update_from_13(); |
|
2198 | - if ($error != '') return $error; |
|
2199 | - else return self::check_version(true); |
|
2200 | - } elseif ($result['value'] == '14') { |
|
2201 | - $error = self::update_from_14(); |
|
2202 | - if ($error != '') return $error; |
|
2203 | - else return self::check_version(true); |
|
2204 | - } elseif ($result['value'] == '15') { |
|
2205 | - $error = self::update_from_15(); |
|
2206 | - if ($error != '') return $error; |
|
2207 | - else return self::check_version(true); |
|
2208 | - } elseif ($result['value'] == '16') { |
|
2209 | - $error = self::update_from_16(); |
|
2210 | - if ($error != '') return $error; |
|
2211 | - else return self::check_version(true); |
|
2212 | - } elseif ($result['value'] == '17') { |
|
2213 | - $error = self::update_from_17(); |
|
2214 | - if ($error != '') return $error; |
|
2215 | - else return self::check_version(true); |
|
2216 | - } elseif ($result['value'] == '18') { |
|
2217 | - $error = self::update_from_18(); |
|
2218 | - if ($error != '') return $error; |
|
2219 | - else return self::check_version(true); |
|
2220 | - } elseif ($result['value'] == '19') { |
|
2221 | - $error = self::update_from_19(); |
|
2222 | - if ($error != '') return $error; |
|
2223 | - else return self::check_version(true); |
|
2224 | - } elseif ($result['value'] == '20') { |
|
2225 | - $error = self::update_from_20(); |
|
2226 | - if ($error != '') return $error; |
|
2227 | - else return self::check_version(true); |
|
2228 | - } elseif ($result['value'] == '21') { |
|
2229 | - $error = self::update_from_21(); |
|
2230 | - if ($error != '') return $error; |
|
2231 | - else return self::check_version(true); |
|
2232 | - } elseif ($result['value'] == '22') { |
|
2233 | - $error = self::update_from_22(); |
|
2234 | - if ($error != '') return $error; |
|
2235 | - else return self::check_version(true); |
|
2236 | - } elseif ($result['value'] == '23') { |
|
2237 | - $error = self::update_from_23(); |
|
2238 | - if ($error != '') return $error; |
|
2239 | - else return self::check_version(true); |
|
2240 | - } elseif ($result['value'] == '24') { |
|
2241 | - $error = self::update_from_24(); |
|
2242 | - if ($error != '') return $error; |
|
2243 | - else return self::check_version(true); |
|
2244 | - } elseif ($result['value'] == '25') { |
|
2245 | - $error = self::update_from_25(); |
|
2246 | - if ($error != '') return $error; |
|
2247 | - else return self::check_version(true); |
|
2248 | - } elseif ($result['value'] == '26') { |
|
2249 | - $error = self::update_from_26(); |
|
2250 | - if ($error != '') return $error; |
|
2251 | - else return self::check_version(true); |
|
2252 | - } elseif ($result['value'] == '27') { |
|
2253 | - $error = self::update_from_27(); |
|
2254 | - if ($error != '') return $error; |
|
2255 | - else return self::check_version(true); |
|
2256 | - } elseif ($result['value'] == '28') { |
|
2257 | - $error = self::update_from_28(); |
|
2258 | - if ($error != '') return $error; |
|
2259 | - else return self::check_version(true); |
|
2260 | - } elseif ($result['value'] == '29') { |
|
2261 | - $error = self::update_from_29(); |
|
2262 | - if ($error != '') return $error; |
|
2263 | - else return self::check_version(true); |
|
2264 | - } elseif ($result['value'] == '30') { |
|
2265 | - $error = self::update_from_30(); |
|
2266 | - if ($error != '') return $error; |
|
2267 | - else return self::check_version(true); |
|
2268 | - } elseif ($result['value'] == '31') { |
|
2269 | - $error = self::update_from_31(); |
|
2270 | - if ($error != '') return $error; |
|
2271 | - else return self::check_version(true); |
|
2272 | - } elseif ($result['value'] == '32') { |
|
2273 | - $error = self::update_from_32(); |
|
2274 | - if ($error != '') return $error; |
|
2275 | - else return self::check_version(true); |
|
2276 | - } elseif ($result['value'] == '33') { |
|
2277 | - $error = self::update_from_33(); |
|
2278 | - if ($error != '') return $error; |
|
2279 | - else return self::check_version(true); |
|
2280 | - } elseif ($result['value'] == '34') { |
|
2281 | - $error = self::update_from_34(); |
|
2282 | - if ($error != '') return $error; |
|
2283 | - else return self::check_version(true); |
|
2284 | - } elseif ($result['value'] == '35') { |
|
2285 | - $error = self::update_from_35(); |
|
2286 | - if ($error != '') return $error; |
|
2287 | - else return self::check_version(true); |
|
2288 | - } elseif ($result['value'] == '36') { |
|
2289 | - $error = self::update_from_36(); |
|
2290 | - if ($error != '') return $error; |
|
2291 | - else return self::check_version(true); |
|
2292 | - } elseif ($result['value'] == '37') { |
|
2293 | - $error = self::update_from_37(); |
|
2294 | - if ($error != '') return $error; |
|
2295 | - else return self::check_version(true); |
|
2296 | - } elseif ($result['value'] == '38') { |
|
2297 | - $error = self::update_from_38(); |
|
2298 | - if ($error != '') return $error; |
|
2299 | - else return self::check_version(true); |
|
2300 | - } elseif ($result['value'] == '39') { |
|
2301 | - $error = self::update_from_39(); |
|
2302 | - if ($error != '') return $error; |
|
2303 | - else return self::check_version(true); |
|
2304 | - } elseif ($result['value'] == '40') { |
|
2305 | - $error = self::update_from_40(); |
|
2306 | - if ($error != '') return $error; |
|
2307 | - else return self::check_version(true); |
|
2308 | - } elseif ($result['value'] == '41') { |
|
2309 | - $error = self::update_from_41(); |
|
2310 | - if ($error != '') return $error; |
|
2311 | - else return self::check_version(true); |
|
2312 | - } elseif ($result['value'] == '42') { |
|
2313 | - $error = self::update_from_42(); |
|
2314 | - if ($error != '') return $error; |
|
2315 | - else return self::check_version(true); |
|
2316 | - } elseif ($result['value'] == '43') { |
|
2317 | - $error = self::update_from_43(); |
|
2318 | - if ($error != '') return $error; |
|
2319 | - else return self::check_version(true); |
|
2320 | - } elseif ($result['value'] == '44') { |
|
2321 | - $error = self::update_from_44(); |
|
2322 | - if ($error != '') return $error; |
|
2323 | - else return self::check_version(true); |
|
2324 | - } else return ''; |
|
2325 | - } |
|
2326 | - else return $result['value']; |
|
2149 | + } |
|
2150 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
2151 | + if ($update) { |
|
2152 | + if ($result['value'] == '2') { |
|
2153 | + $error = self::update_from_2(); |
|
2154 | + if ($error != '') return $error; |
|
2155 | + else return self::check_version(true); |
|
2156 | + } elseif ($result['value'] == '3') { |
|
2157 | + $error = self::update_from_3(); |
|
2158 | + if ($error != '') return $error; |
|
2159 | + else return self::check_version(true); |
|
2160 | + } elseif ($result['value'] == '4') { |
|
2161 | + $error = self::update_from_4(); |
|
2162 | + if ($error != '') return $error; |
|
2163 | + else return self::check_version(true); |
|
2164 | + } elseif ($result['value'] == '5') { |
|
2165 | + $error = self::update_from_5(); |
|
2166 | + if ($error != '') return $error; |
|
2167 | + else return self::check_version(true); |
|
2168 | + } elseif ($result['value'] == '6') { |
|
2169 | + $error = self::update_from_6(); |
|
2170 | + if ($error != '') return $error; |
|
2171 | + else return self::check_version(true); |
|
2172 | + } elseif ($result['value'] == '7') { |
|
2173 | + $error = self::update_from_7(); |
|
2174 | + if ($error != '') return $error; |
|
2175 | + else return self::check_version(true); |
|
2176 | + } elseif ($result['value'] == '8') { |
|
2177 | + $error = self::update_from_8(); |
|
2178 | + if ($error != '') return $error; |
|
2179 | + else return self::check_version(true); |
|
2180 | + } elseif ($result['value'] == '9') { |
|
2181 | + $error = self::update_from_9(); |
|
2182 | + if ($error != '') return $error; |
|
2183 | + else return self::check_version(true); |
|
2184 | + } elseif ($result['value'] == '10') { |
|
2185 | + $error = self::update_from_10(); |
|
2186 | + if ($error != '') return $error; |
|
2187 | + else return self::check_version(true); |
|
2188 | + } elseif ($result['value'] == '11') { |
|
2189 | + $error = self::update_from_11(); |
|
2190 | + if ($error != '') return $error; |
|
2191 | + else return self::check_version(true); |
|
2192 | + } elseif ($result['value'] == '12') { |
|
2193 | + $error = self::update_from_12(); |
|
2194 | + if ($error != '') return $error; |
|
2195 | + else return self::check_version(true); |
|
2196 | + } elseif ($result['value'] == '13') { |
|
2197 | + $error = self::update_from_13(); |
|
2198 | + if ($error != '') return $error; |
|
2199 | + else return self::check_version(true); |
|
2200 | + } elseif ($result['value'] == '14') { |
|
2201 | + $error = self::update_from_14(); |
|
2202 | + if ($error != '') return $error; |
|
2203 | + else return self::check_version(true); |
|
2204 | + } elseif ($result['value'] == '15') { |
|
2205 | + $error = self::update_from_15(); |
|
2206 | + if ($error != '') return $error; |
|
2207 | + else return self::check_version(true); |
|
2208 | + } elseif ($result['value'] == '16') { |
|
2209 | + $error = self::update_from_16(); |
|
2210 | + if ($error != '') return $error; |
|
2211 | + else return self::check_version(true); |
|
2212 | + } elseif ($result['value'] == '17') { |
|
2213 | + $error = self::update_from_17(); |
|
2214 | + if ($error != '') return $error; |
|
2215 | + else return self::check_version(true); |
|
2216 | + } elseif ($result['value'] == '18') { |
|
2217 | + $error = self::update_from_18(); |
|
2218 | + if ($error != '') return $error; |
|
2219 | + else return self::check_version(true); |
|
2220 | + } elseif ($result['value'] == '19') { |
|
2221 | + $error = self::update_from_19(); |
|
2222 | + if ($error != '') return $error; |
|
2223 | + else return self::check_version(true); |
|
2224 | + } elseif ($result['value'] == '20') { |
|
2225 | + $error = self::update_from_20(); |
|
2226 | + if ($error != '') return $error; |
|
2227 | + else return self::check_version(true); |
|
2228 | + } elseif ($result['value'] == '21') { |
|
2229 | + $error = self::update_from_21(); |
|
2230 | + if ($error != '') return $error; |
|
2231 | + else return self::check_version(true); |
|
2232 | + } elseif ($result['value'] == '22') { |
|
2233 | + $error = self::update_from_22(); |
|
2234 | + if ($error != '') return $error; |
|
2235 | + else return self::check_version(true); |
|
2236 | + } elseif ($result['value'] == '23') { |
|
2237 | + $error = self::update_from_23(); |
|
2238 | + if ($error != '') return $error; |
|
2239 | + else return self::check_version(true); |
|
2240 | + } elseif ($result['value'] == '24') { |
|
2241 | + $error = self::update_from_24(); |
|
2242 | + if ($error != '') return $error; |
|
2243 | + else return self::check_version(true); |
|
2244 | + } elseif ($result['value'] == '25') { |
|
2245 | + $error = self::update_from_25(); |
|
2246 | + if ($error != '') return $error; |
|
2247 | + else return self::check_version(true); |
|
2248 | + } elseif ($result['value'] == '26') { |
|
2249 | + $error = self::update_from_26(); |
|
2250 | + if ($error != '') return $error; |
|
2251 | + else return self::check_version(true); |
|
2252 | + } elseif ($result['value'] == '27') { |
|
2253 | + $error = self::update_from_27(); |
|
2254 | + if ($error != '') return $error; |
|
2255 | + else return self::check_version(true); |
|
2256 | + } elseif ($result['value'] == '28') { |
|
2257 | + $error = self::update_from_28(); |
|
2258 | + if ($error != '') return $error; |
|
2259 | + else return self::check_version(true); |
|
2260 | + } elseif ($result['value'] == '29') { |
|
2261 | + $error = self::update_from_29(); |
|
2262 | + if ($error != '') return $error; |
|
2263 | + else return self::check_version(true); |
|
2264 | + } elseif ($result['value'] == '30') { |
|
2265 | + $error = self::update_from_30(); |
|
2266 | + if ($error != '') return $error; |
|
2267 | + else return self::check_version(true); |
|
2268 | + } elseif ($result['value'] == '31') { |
|
2269 | + $error = self::update_from_31(); |
|
2270 | + if ($error != '') return $error; |
|
2271 | + else return self::check_version(true); |
|
2272 | + } elseif ($result['value'] == '32') { |
|
2273 | + $error = self::update_from_32(); |
|
2274 | + if ($error != '') return $error; |
|
2275 | + else return self::check_version(true); |
|
2276 | + } elseif ($result['value'] == '33') { |
|
2277 | + $error = self::update_from_33(); |
|
2278 | + if ($error != '') return $error; |
|
2279 | + else return self::check_version(true); |
|
2280 | + } elseif ($result['value'] == '34') { |
|
2281 | + $error = self::update_from_34(); |
|
2282 | + if ($error != '') return $error; |
|
2283 | + else return self::check_version(true); |
|
2284 | + } elseif ($result['value'] == '35') { |
|
2285 | + $error = self::update_from_35(); |
|
2286 | + if ($error != '') return $error; |
|
2287 | + else return self::check_version(true); |
|
2288 | + } elseif ($result['value'] == '36') { |
|
2289 | + $error = self::update_from_36(); |
|
2290 | + if ($error != '') return $error; |
|
2291 | + else return self::check_version(true); |
|
2292 | + } elseif ($result['value'] == '37') { |
|
2293 | + $error = self::update_from_37(); |
|
2294 | + if ($error != '') return $error; |
|
2295 | + else return self::check_version(true); |
|
2296 | + } elseif ($result['value'] == '38') { |
|
2297 | + $error = self::update_from_38(); |
|
2298 | + if ($error != '') return $error; |
|
2299 | + else return self::check_version(true); |
|
2300 | + } elseif ($result['value'] == '39') { |
|
2301 | + $error = self::update_from_39(); |
|
2302 | + if ($error != '') return $error; |
|
2303 | + else return self::check_version(true); |
|
2304 | + } elseif ($result['value'] == '40') { |
|
2305 | + $error = self::update_from_40(); |
|
2306 | + if ($error != '') return $error; |
|
2307 | + else return self::check_version(true); |
|
2308 | + } elseif ($result['value'] == '41') { |
|
2309 | + $error = self::update_from_41(); |
|
2310 | + if ($error != '') return $error; |
|
2311 | + else return self::check_version(true); |
|
2312 | + } elseif ($result['value'] == '42') { |
|
2313 | + $error = self::update_from_42(); |
|
2314 | + if ($error != '') return $error; |
|
2315 | + else return self::check_version(true); |
|
2316 | + } elseif ($result['value'] == '43') { |
|
2317 | + $error = self::update_from_43(); |
|
2318 | + if ($error != '') return $error; |
|
2319 | + else return self::check_version(true); |
|
2320 | + } elseif ($result['value'] == '44') { |
|
2321 | + $error = self::update_from_44(); |
|
2322 | + if ($error != '') return $error; |
|
2323 | + else return self::check_version(true); |
|
2324 | + } else return ''; |
|
2325 | + } |
|
2326 | + else return $result['value']; |
|
2327 | 2327 | } |
2328 | 2328 | |
2329 | - } else return $version; |
|
2330 | - } |
|
2329 | + } else return $version; |
|
2330 | + } |
|
2331 | 2331 | |
2332 | 2332 | } |
2333 | 2333 | //echo update_schema::check_version(); |
@@ -7,35 +7,35 @@ discard block |
||
7 | 7 | public $latest_schema = 45; |
8 | 8 | |
9 | 9 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
10 | - global $globalDBdriver, $globalNoDB; |
|
11 | - if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
10 | + global $globalDBdriver, $globalNoDB; |
|
11 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
12 | 12 | $this->db = null; |
13 | - } else { |
|
13 | + } else { |
|
14 | 14 | if ($dbc === null) { |
15 | - if ($this->db === null && $dbname === null) { |
|
15 | + if ($this->db === null && $dbname === null) { |
|
16 | 16 | if ($user === null && $pass === null) { |
17 | - $this->createDBConnection(); |
|
17 | + $this->createDBConnection(); |
|
18 | 18 | } else { |
19 | - $this->createDBConnection(null,$user,$pass); |
|
19 | + $this->createDBConnection(null,$user,$pass); |
|
20 | 20 | } |
21 | - } else { |
|
21 | + } else { |
|
22 | 22 | $this->createDBConnection($dbname); |
23 | - } |
|
23 | + } |
|
24 | 24 | } elseif ($dbname === null || $dbname === 'default') { |
25 | - $this->db = $dbc; |
|
26 | - if ($this->connectionExists() === false) { |
|
25 | + $this->db = $dbc; |
|
26 | + if ($this->connectionExists() === false) { |
|
27 | 27 | /* |
28 | 28 | echo 'Restart Connection !!!'."\n"; |
29 | 29 | $e = new \Exception; |
30 | 30 | var_dump($e->getTraceAsString()); |
31 | 31 | */ |
32 | 32 | $this->createDBConnection(); |
33 | - } |
|
33 | + } |
|
34 | 34 | } else { |
35 | - //$this->connectionExists(); |
|
36 | - $this->dbs[$dbname] = $dbc; |
|
35 | + //$this->connectionExists(); |
|
36 | + $this->dbs[$dbname] = $dbc; |
|
37 | + } |
|
37 | 38 | } |
38 | - } |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function db() { |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | - * Creates the database connection |
|
60 | - * |
|
61 | - * @return Boolean of the database connection |
|
62 | - * |
|
63 | - */ |
|
59 | + * Creates the database connection |
|
60 | + * |
|
61 | + * @return Boolean of the database connection |
|
62 | + * |
|
63 | + */ |
|
64 | 64 | |
65 | 65 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
66 | 66 | { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | if($results->rowCount()>0) { |
160 | - return true; |
|
160 | + return true; |
|
161 | 161 | } |
162 | 162 | else return false; |
163 | 163 | } |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | $sum = $sum->fetchColumn(0); |
175 | 175 | } else $sum = 0; |
176 | 176 | if (intval($sum) !== 2) { |
177 | - return false; |
|
177 | + return false; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | } catch(PDOException $e) { |
181 | 181 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
182 | - throw $e; |
|
183 | - } |
|
184 | - //echo 'error ! '.$e->getMessage(); |
|
182 | + throw $e; |
|
183 | + } |
|
184 | + //echo 'error ! '.$e->getMessage(); |
|
185 | 185 | return false; |
186 | 186 | } |
187 | 187 | return true; |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | $version = 0; |
286 | 286 | if ($this->tableExists('aircraft')) { |
287 | 287 | if (!$this->tableExists('config')) { |
288 | - $version = '1'; |
|
289 | - return $version; |
|
288 | + $version = '1'; |
|
289 | + return $version; |
|
290 | 290 | } else { |
291 | 291 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
292 | 292 | try { |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | * @return Boolean if latest version or not |
308 | 308 | */ |
309 | 309 | public function latest() { |
310 | - global $globalNoDB; |
|
311 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
312 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
313 | - else return false; |
|
310 | + global $globalNoDB; |
|
311 | + if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
312 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
313 | + else return false; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | } |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
17 | 17 | $Connection = new Connection($dbc); |
18 | 18 | $this->db = $Connection->db(); |
19 | - } |
|
19 | + } |
|
20 | 20 | |
21 | 21 | public function addLastStatsUpdate($type,$stats_date) { |
22 | - $query = "DELETE FROM config WHERE name = :type; |
|
22 | + $query = "DELETE FROM config WHERE name = :type; |
|
23 | 23 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
24 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
25 | - try { |
|
26 | - $sth = $this->db->prepare($query); |
|
27 | - $sth->execute($query_values); |
|
28 | - } catch(PDOException $e) { |
|
29 | - return "error : ".$e->getMessage(); |
|
30 | - } |
|
31 | - } |
|
24 | + $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
25 | + try { |
|
26 | + $sth = $this->db->prepare($query); |
|
27 | + $sth->execute($query_values); |
|
28 | + } catch(PDOException $e) { |
|
29 | + return "error : ".$e->getMessage(); |
|
30 | + } |
|
31 | + } |
|
32 | 32 | |
33 | 33 | public function getLastStatsUpdate($type = 'last_update_stats') { |
34 | - $query = "SELECT value FROM config WHERE name = :type"; |
|
35 | - try { |
|
36 | - $sth = $this->db->prepare($query); |
|
37 | - $sth->execute(array(':type' => $type)); |
|
38 | - } catch(PDOException $e) { |
|
39 | - echo "error : ".$e->getMessage(); |
|
40 | - } |
|
41 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
42 | - return $all; |
|
43 | - } |
|
44 | - public function deleteStats($filter_name = '') { |
|
45 | - /* |
|
34 | + $query = "SELECT value FROM config WHERE name = :type"; |
|
35 | + try { |
|
36 | + $sth = $this->db->prepare($query); |
|
37 | + $sth->execute(array(':type' => $type)); |
|
38 | + } catch(PDOException $e) { |
|
39 | + echo "error : ".$e->getMessage(); |
|
40 | + } |
|
41 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
42 | + return $all; |
|
43 | + } |
|
44 | + public function deleteStats($filter_name = '') { |
|
45 | + /* |
|
46 | 46 | $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
47 | 47 | try { |
48 | 48 | $sth = $this->db->prepare($query); |
@@ -51,109 +51,109 @@ discard block |
||
51 | 51 | return "error : ".$e->getMessage(); |
52 | 52 | } |
53 | 53 | */ |
54 | - $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
55 | - try { |
|
56 | - $sth = $this->db->prepare($query); |
|
57 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
58 | - } catch(PDOException $e) { |
|
59 | - return "error : ".$e->getMessage(); |
|
60 | - } |
|
61 | - } |
|
62 | - public function deleteOldStats($filter_name = '') { |
|
63 | - if ($filter_name == '') { |
|
64 | - $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
65 | - } else { |
|
66 | - $query = "DELETE FROM config WHERE name = 'last_update_stats_".$filter_name."'"; |
|
67 | - } |
|
68 | - try { |
|
69 | - $sth = $this->db->prepare($query); |
|
70 | - $sth->execute(); |
|
71 | - } catch(PDOException $e) { |
|
72 | - return "error : ".$e->getMessage(); |
|
73 | - } |
|
54 | + $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
55 | + try { |
|
56 | + $sth = $this->db->prepare($query); |
|
57 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
58 | + } catch(PDOException $e) { |
|
59 | + return "error : ".$e->getMessage(); |
|
60 | + } |
|
61 | + } |
|
62 | + public function deleteOldStats($filter_name = '') { |
|
63 | + if ($filter_name == '') { |
|
64 | + $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
65 | + } else { |
|
66 | + $query = "DELETE FROM config WHERE name = 'last_update_stats_".$filter_name."'"; |
|
67 | + } |
|
68 | + try { |
|
69 | + $sth = $this->db->prepare($query); |
|
70 | + $sth->execute(); |
|
71 | + } catch(PDOException $e) { |
|
72 | + return "error : ".$e->getMessage(); |
|
73 | + } |
|
74 | 74 | |
75 | - $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
76 | - try { |
|
77 | - $sth = $this->db->prepare($query); |
|
78 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error : ".$e->getMessage(); |
|
81 | - } |
|
82 | - } |
|
75 | + $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
76 | + try { |
|
77 | + $sth = $this->db->prepare($query); |
|
78 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error : ".$e->getMessage(); |
|
81 | + } |
|
82 | + } |
|
83 | 83 | public function getAllAirlineNames($filter_name = '') { |
84 | 84 | if ($filter_name == '') $filter_name = $this->filter_name; |
85 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
86 | - try { |
|
87 | - $sth = $this->db->prepare($query); |
|
88 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
89 | - } catch(PDOException $e) { |
|
90 | - echo "error : ".$e->getMessage(); |
|
91 | - } |
|
92 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
93 | - return $all; |
|
94 | - } |
|
85 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
86 | + try { |
|
87 | + $sth = $this->db->prepare($query); |
|
88 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
89 | + } catch(PDOException $e) { |
|
90 | + echo "error : ".$e->getMessage(); |
|
91 | + } |
|
92 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
93 | + return $all; |
|
94 | + } |
|
95 | 95 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
96 | 96 | if ($filter_name == '') $filter_name = $this->filter_name; |
97 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
98 | - try { |
|
99 | - $sth = $this->db->prepare($query); |
|
100 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
101 | - } catch(PDOException $e) { |
|
102 | - echo "error : ".$e->getMessage(); |
|
103 | - } |
|
104 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
105 | - return $all; |
|
106 | - } |
|
97 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
98 | + try { |
|
99 | + $sth = $this->db->prepare($query); |
|
100 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
101 | + } catch(PDOException $e) { |
|
102 | + echo "error : ".$e->getMessage(); |
|
103 | + } |
|
104 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
105 | + return $all; |
|
106 | + } |
|
107 | 107 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
108 | 108 | if ($filter_name == '') $filter_name = $this->filter_name; |
109 | - $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
|
110 | - try { |
|
111 | - $sth = $this->db->prepare($query); |
|
112 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
113 | - } catch(PDOException $e) { |
|
114 | - echo "error : ".$e->getMessage(); |
|
115 | - } |
|
116 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
117 | - return $all; |
|
118 | - } |
|
109 | + $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
|
110 | + try { |
|
111 | + $sth = $this->db->prepare($query); |
|
112 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
113 | + } catch(PDOException $e) { |
|
114 | + echo "error : ".$e->getMessage(); |
|
115 | + } |
|
116 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
117 | + return $all; |
|
118 | + } |
|
119 | 119 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
120 | 120 | if ($filter_name == '') $filter_name = $this->filter_name; |
121 | - $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
122 | - try { |
|
123 | - $sth = $this->db->prepare($query); |
|
124 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
125 | - } catch(PDOException $e) { |
|
126 | - echo "error : ".$e->getMessage(); |
|
127 | - } |
|
128 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
129 | - return $all; |
|
130 | - } |
|
121 | + $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
122 | + try { |
|
123 | + $sth = $this->db->prepare($query); |
|
124 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
125 | + } catch(PDOException $e) { |
|
126 | + echo "error : ".$e->getMessage(); |
|
127 | + } |
|
128 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
129 | + return $all; |
|
130 | + } |
|
131 | 131 | |
132 | 132 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
133 | 133 | if ($filter_name == '') $filter_name = $this->filter_name; |
134 | - $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
|
135 | - try { |
|
136 | - $sth = $this->db->prepare($query); |
|
137 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
138 | - } catch(PDOException $e) { |
|
139 | - echo "error : ".$e->getMessage(); |
|
140 | - } |
|
141 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
142 | - return $all; |
|
143 | - } |
|
134 | + $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
|
135 | + try { |
|
136 | + $sth = $this->db->prepare($query); |
|
137 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
138 | + } catch(PDOException $e) { |
|
139 | + echo "error : ".$e->getMessage(); |
|
140 | + } |
|
141 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
142 | + return $all; |
|
143 | + } |
|
144 | 144 | |
145 | 145 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
146 | 146 | if ($filter_name == '') $filter_name = $this->filter_name; |
147 | - $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
|
148 | - try { |
|
149 | - $sth = $this->db->prepare($query); |
|
150 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
151 | - } catch(PDOException $e) { |
|
152 | - echo "error : ".$e->getMessage(); |
|
153 | - } |
|
154 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
155 | - return $all; |
|
156 | - } |
|
147 | + $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
|
148 | + try { |
|
149 | + $sth = $this->db->prepare($query); |
|
150 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
151 | + } catch(PDOException $e) { |
|
152 | + echo "error : ".$e->getMessage(); |
|
153 | + } |
|
154 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
155 | + return $all; |
|
156 | + } |
|
157 | 157 | |
158 | 158 | |
159 | 159 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
@@ -170,16 +170,16 @@ discard block |
||
170 | 170 | } |
171 | 171 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
172 | 172 | } else $all = array(); |
173 | - if (empty($all)) { |
|
174 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
175 | - if ($filter_name != '') { |
|
176 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
177 | - } |
|
178 | - $Spotter = new Spotter($this->db); |
|
179 | - //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
|
180 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
181 | - } |
|
182 | - return $all; |
|
173 | + if (empty($all)) { |
|
174 | + $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
175 | + if ($filter_name != '') { |
|
176 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
177 | + } |
|
178 | + $Spotter = new Spotter($this->db); |
|
179 | + //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
|
180 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
181 | + } |
|
182 | + return $all; |
|
183 | 183 | } |
184 | 184 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
185 | 185 | global $globalStatsFilters; |
@@ -195,17 +195,17 @@ discard block |
||
195 | 195 | } |
196 | 196 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
197 | 197 | } else $all = array(); |
198 | - if (empty($all)) { |
|
199 | - $Spotter = new Spotter($this->db); |
|
200 | - $filters = array(); |
|
201 | - $filters = array('year' => $year,'month' => $month); |
|
202 | - if ($filter_name != '') { |
|
203 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
204 | - } |
|
205 | - //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
|
206 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
207 | - } |
|
208 | - return $all; |
|
198 | + if (empty($all)) { |
|
199 | + $Spotter = new Spotter($this->db); |
|
200 | + $filters = array(); |
|
201 | + $filters = array('year' => $year,'month' => $month); |
|
202 | + if ($filter_name != '') { |
|
203 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
204 | + } |
|
205 | + //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
|
206 | + $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
207 | + } |
|
208 | + return $all; |
|
209 | 209 | } |
210 | 210 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
211 | 211 | global $globalStatsFilters; |
@@ -247,39 +247,39 @@ discard block |
||
247 | 247 | } |
248 | 248 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
249 | 249 | } else $all = array(); |
250 | - if (empty($all)) { |
|
250 | + if (empty($all)) { |
|
251 | 251 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
252 | 252 | if ($filter_name != '') { |
253 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
253 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
254 | 254 | } |
255 | 255 | $Spotter = new Spotter($this->db); |
256 | 256 | //$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
257 | 257 | $all = $Spotter->countAllArrivalCountries($limit,$filters); |
258 | - } |
|
259 | - return $all; |
|
258 | + } |
|
259 | + return $all; |
|
260 | 260 | } |
261 | 261 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
262 | 262 | global $globalStatsFilters; |
263 | 263 | if ($filter_name == '') $filter_name = $this->filter_name; |
264 | 264 | if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
265 | 265 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
266 | - try { |
|
267 | - $sth = $this->db->prepare($query); |
|
268 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
269 | - } catch(PDOException $e) { |
|
270 | - echo "error : ".$e->getMessage(); |
|
271 | - } |
|
272 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
273 | - if (empty($all)) { |
|
266 | + try { |
|
267 | + $sth = $this->db->prepare($query); |
|
268 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
269 | + } catch(PDOException $e) { |
|
270 | + echo "error : ".$e->getMessage(); |
|
271 | + } |
|
272 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
273 | + if (empty($all)) { |
|
274 | 274 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
275 | 275 | if ($filter_name != '') { |
276 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
276 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
277 | 277 | } |
278 | 278 | $Spotter = new Spotter($this->db); |
279 | 279 | //$all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
280 | 280 | $all = $Spotter->countAllDepartureCountries($filters); |
281 | - } |
|
282 | - return $all; |
|
281 | + } |
|
282 | + return $all; |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
@@ -305,17 +305,17 @@ discard block |
||
305 | 305 | } |
306 | 306 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
307 | 307 | } else $all = array(); |
308 | - if (empty($all)) { |
|
309 | - $Spotter = new Spotter($this->db); |
|
310 | - $filters = array(); |
|
308 | + if (empty($all)) { |
|
309 | + $Spotter = new Spotter($this->db); |
|
310 | + $filters = array(); |
|
311 | 311 | $filters = array('year' => $year,'month' => $month); |
312 | - if ($filter_name != '') { |
|
313 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
312 | + if ($filter_name != '') { |
|
313 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
314 | 314 | } |
315 | 315 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
316 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
317 | - } |
|
318 | - return $all; |
|
316 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
317 | + } |
|
318 | + return $all; |
|
319 | 319 | } |
320 | 320 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
321 | 321 | global $globalStatsFilters; |
@@ -331,16 +331,16 @@ discard block |
||
331 | 331 | } |
332 | 332 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
333 | 333 | } else $all = array(); |
334 | - if (empty($all)) { |
|
334 | + if (empty($all)) { |
|
335 | 335 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
336 | 336 | if ($filter_name != '') { |
337 | 337 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
338 | 338 | } |
339 | - $Spotter = new Spotter($this->db); |
|
340 | - //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
|
341 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
342 | - } |
|
343 | - return $all; |
|
339 | + $Spotter = new Spotter($this->db); |
|
340 | + //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
|
341 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
342 | + } |
|
343 | + return $all; |
|
344 | 344 | } |
345 | 345 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
346 | 346 | global $globalStatsFilters; |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | echo "error : ".$e->getMessage(); |
382 | 382 | } |
383 | 383 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
384 | - /* |
|
384 | + /* |
|
385 | 385 | if (empty($all)) { |
386 | 386 | $Spotter = new Spotter($this->db); |
387 | 387 | $all = $Spotter->countAllFlightOverCountries($limit); |
@@ -433,16 +433,16 @@ discard block |
||
433 | 433 | } |
434 | 434 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
435 | 435 | } else $all = array(); |
436 | - if (empty($all)) { |
|
436 | + if (empty($all)) { |
|
437 | 437 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
438 | 438 | if ($filter_name != '') { |
439 | 439 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
440 | 440 | } |
441 | - $Spotter = new Spotter($this->db); |
|
442 | - //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
|
443 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
444 | - } |
|
445 | - return $all; |
|
441 | + $Spotter = new Spotter($this->db); |
|
442 | + //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
|
443 | + $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
444 | + } |
|
445 | + return $all; |
|
446 | 446 | } |
447 | 447 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
448 | 448 | global $globalStatsFilters; |
@@ -458,35 +458,35 @@ discard block |
||
458 | 458 | } |
459 | 459 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
460 | 460 | } else $all = array(); |
461 | - if (empty($all)) { |
|
461 | + if (empty($all)) { |
|
462 | 462 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
463 | - if ($filter_name != '') { |
|
464 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
463 | + if ($filter_name != '') { |
|
464 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
465 | 465 | } |
466 | - $Spotter = new Spotter($this->db); |
|
466 | + $Spotter = new Spotter($this->db); |
|
467 | 467 | // $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
468 | 468 | // $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
469 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
470 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
471 | - $all = array(); |
|
472 | - foreach ($pall as $value) { |
|
473 | - $icao = $value['airport_departure_icao']; |
|
474 | - $all[$icao] = $value; |
|
475 | - } |
|
469 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
470 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
471 | + $all = array(); |
|
472 | + foreach ($pall as $value) { |
|
473 | + $icao = $value['airport_departure_icao']; |
|
474 | + $all[$icao] = $value; |
|
475 | + } |
|
476 | 476 | |
477 | - foreach ($dall as $value) { |
|
478 | - $icao = $value['airport_departure_icao']; |
|
479 | - if (isset($all[$icao])) { |
|
480 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
481 | - } else $all[$icao] = $value; |
|
482 | - } |
|
483 | - $count = array(); |
|
484 | - foreach ($all as $key => $row) { |
|
485 | - $count[$key] = $row['airport_departure_icao_count']; |
|
486 | - } |
|
487 | - array_multisort($count,SORT_DESC,$all); |
|
488 | - } |
|
489 | - return $all; |
|
477 | + foreach ($dall as $value) { |
|
478 | + $icao = $value['airport_departure_icao']; |
|
479 | + if (isset($all[$icao])) { |
|
480 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
481 | + } else $all[$icao] = $value; |
|
482 | + } |
|
483 | + $count = array(); |
|
484 | + foreach ($all as $key => $row) { |
|
485 | + $count[$key] = $row['airport_departure_icao_count']; |
|
486 | + } |
|
487 | + array_multisort($count,SORT_DESC,$all); |
|
488 | + } |
|
489 | + return $all; |
|
490 | 490 | } |
491 | 491 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
492 | 492 | global $globalStatsFilters; |
@@ -512,26 +512,26 @@ discard block |
||
512 | 512 | // $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
513 | 513 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
514 | 514 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
515 | - $all = array(); |
|
516 | - foreach ($pall as $value) { |
|
517 | - $icao = $value['airport_arrival_icao']; |
|
518 | - $all[$icao] = $value; |
|
519 | - } |
|
515 | + $all = array(); |
|
516 | + foreach ($pall as $value) { |
|
517 | + $icao = $value['airport_arrival_icao']; |
|
518 | + $all[$icao] = $value; |
|
519 | + } |
|
520 | 520 | |
521 | - foreach ($dall as $value) { |
|
522 | - $icao = $value['airport_arrival_icao']; |
|
523 | - if (isset($all[$icao])) { |
|
524 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
525 | - } else $all[$icao] = $value; |
|
526 | - } |
|
527 | - $count = array(); |
|
528 | - foreach ($all as $key => $row) { |
|
529 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
530 | - } |
|
531 | - array_multisort($count,SORT_DESC,$all); |
|
532 | - } |
|
521 | + foreach ($dall as $value) { |
|
522 | + $icao = $value['airport_arrival_icao']; |
|
523 | + if (isset($all[$icao])) { |
|
524 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
525 | + } else $all[$icao] = $value; |
|
526 | + } |
|
527 | + $count = array(); |
|
528 | + foreach ($all as $key => $row) { |
|
529 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
530 | + } |
|
531 | + array_multisort($count,SORT_DESC,$all); |
|
532 | + } |
|
533 | 533 | |
534 | - return $all; |
|
534 | + return $all; |
|
535 | 535 | } |
536 | 536 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
537 | 537 | global $globalDBdriver, $globalStatsFilters; |
@@ -544,23 +544,23 @@ discard block |
||
544 | 544 | else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
545 | 545 | } |
546 | 546 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
547 | - try { |
|
548 | - $sth = $this->db->prepare($query); |
|
549 | - $sth->execute($query_data); |
|
550 | - } catch(PDOException $e) { |
|
551 | - echo "error : ".$e->getMessage(); |
|
552 | - } |
|
553 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
554 | - if (empty($all)) { |
|
547 | + try { |
|
548 | + $sth = $this->db->prepare($query); |
|
549 | + $sth->execute($query_data); |
|
550 | + } catch(PDOException $e) { |
|
551 | + echo "error : ".$e->getMessage(); |
|
552 | + } |
|
553 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
554 | + if (empty($all)) { |
|
555 | 555 | $filters = array('airlines' => array($stats_airline)); |
556 | 556 | if ($filter_name != '') { |
557 | 557 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
558 | 558 | } |
559 | - $Spotter = new Spotter($this->db); |
|
560 | - $all = $Spotter->countAllMonthsLastYear($filters); |
|
561 | - } |
|
559 | + $Spotter = new Spotter($this->db); |
|
560 | + $all = $Spotter->countAllMonthsLastYear($filters); |
|
561 | + } |
|
562 | 562 | |
563 | - return $all; |
|
563 | + return $all; |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
@@ -568,22 +568,22 @@ discard block |
||
568 | 568 | if ($filter_name == '') $filter_name = $this->filter_name; |
569 | 569 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
570 | 570 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
571 | - try { |
|
572 | - $sth = $this->db->prepare($query); |
|
573 | - $sth->execute($query_data); |
|
574 | - } catch(PDOException $e) { |
|
575 | - echo "error : ".$e->getMessage(); |
|
576 | - } |
|
577 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
578 | - if (empty($all)) { |
|
571 | + try { |
|
572 | + $sth = $this->db->prepare($query); |
|
573 | + $sth->execute($query_data); |
|
574 | + } catch(PDOException $e) { |
|
575 | + echo "error : ".$e->getMessage(); |
|
576 | + } |
|
577 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
578 | + if (empty($all)) { |
|
579 | 579 | $filters = array('airlines' => array($stats_airline)); |
580 | 580 | if ($filter_name != '') { |
581 | 581 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
582 | 582 | } |
583 | - $Spotter = new Spotter($this->db); |
|
584 | - $all = $Spotter->countAllDatesLastMonth($filters); |
|
585 | - } |
|
586 | - return $all; |
|
583 | + $Spotter = new Spotter($this->db); |
|
584 | + $all = $Spotter->countAllDatesLastMonth($filters); |
|
585 | + } |
|
586 | + return $all; |
|
587 | 587 | } |
588 | 588 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
589 | 589 | global $globalDBdriver, $globalStatsFilters; |
@@ -594,66 +594,66 @@ discard block |
||
594 | 594 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
595 | 595 | } |
596 | 596 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
597 | - try { |
|
598 | - $sth = $this->db->prepare($query); |
|
599 | - $sth->execute($query_data); |
|
600 | - } catch(PDOException $e) { |
|
601 | - echo "error : ".$e->getMessage(); |
|
602 | - } |
|
603 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
604 | - if (empty($all)) { |
|
597 | + try { |
|
598 | + $sth = $this->db->prepare($query); |
|
599 | + $sth->execute($query_data); |
|
600 | + } catch(PDOException $e) { |
|
601 | + echo "error : ".$e->getMessage(); |
|
602 | + } |
|
603 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
604 | + if (empty($all)) { |
|
605 | 605 | $filters = array('airlines' => array($stats_airline)); |
606 | 606 | if ($filter_name != '') { |
607 | 607 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
608 | 608 | } |
609 | - $Spotter = new Spotter($this->db); |
|
610 | - $all = $Spotter->countAllDatesLast7Days($filters); |
|
611 | - } |
|
612 | - return $all; |
|
609 | + $Spotter = new Spotter($this->db); |
|
610 | + $all = $Spotter->countAllDatesLast7Days($filters); |
|
611 | + } |
|
612 | + return $all; |
|
613 | 613 | } |
614 | 614 | public function countAllDates($stats_airline = '',$filter_name = '') { |
615 | 615 | global $globalStatsFilters; |
616 | 616 | if ($filter_name == '') $filter_name = $this->filter_name; |
617 | 617 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC"; |
618 | 618 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
619 | - try { |
|
620 | - $sth = $this->db->prepare($query); |
|
621 | - $sth->execute($query_data); |
|
622 | - } catch(PDOException $e) { |
|
623 | - echo "error : ".$e->getMessage(); |
|
624 | - } |
|
625 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
626 | - if (empty($all)) { |
|
619 | + try { |
|
620 | + $sth = $this->db->prepare($query); |
|
621 | + $sth->execute($query_data); |
|
622 | + } catch(PDOException $e) { |
|
623 | + echo "error : ".$e->getMessage(); |
|
624 | + } |
|
625 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
626 | + if (empty($all)) { |
|
627 | 627 | $filters = array('airlines' => array($stats_airline)); |
628 | 628 | if ($filter_name != '') { |
629 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
629 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
630 | 630 | } |
631 | - $Spotter = new Spotter($this->db); |
|
632 | - $all = $Spotter->countAllDates($filters); |
|
633 | - } |
|
634 | - return $all; |
|
631 | + $Spotter = new Spotter($this->db); |
|
632 | + $all = $Spotter->countAllDates($filters); |
|
633 | + } |
|
634 | + return $all; |
|
635 | 635 | } |
636 | 636 | public function countAllDatesByAirlines($filter_name = '') { |
637 | 637 | global $globalStatsFilters; |
638 | 638 | if ($filter_name == '') $filter_name = $this->filter_name; |
639 | 639 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
640 | 640 | $query_data = array('filter_name' => $filter_name); |
641 | - try { |
|
642 | - $sth = $this->db->prepare($query); |
|
643 | - $sth->execute($query_data); |
|
644 | - } catch(PDOException $e) { |
|
645 | - echo "error : ".$e->getMessage(); |
|
646 | - } |
|
647 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
648 | - if (empty($all)) { |
|
649 | - $filters = array(); |
|
650 | - if ($filter_name != '') { |
|
651 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
641 | + try { |
|
642 | + $sth = $this->db->prepare($query); |
|
643 | + $sth->execute($query_data); |
|
644 | + } catch(PDOException $e) { |
|
645 | + echo "error : ".$e->getMessage(); |
|
646 | + } |
|
647 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
648 | + if (empty($all)) { |
|
649 | + $filters = array(); |
|
650 | + if ($filter_name != '') { |
|
651 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
652 | 652 | } |
653 | - $Spotter = new Spotter($this->db); |
|
654 | - $all = $Spotter->countAllDatesByAirlines($filters); |
|
655 | - } |
|
656 | - return $all; |
|
653 | + $Spotter = new Spotter($this->db); |
|
654 | + $all = $Spotter->countAllDatesByAirlines($filters); |
|
655 | + } |
|
656 | + return $all; |
|
657 | 657 | } |
658 | 658 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
659 | 659 | global $globalStatsFilters, $globalDBdriver; |
@@ -663,24 +663,24 @@ discard block |
||
663 | 663 | } else { |
664 | 664 | $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC"; |
665 | 665 | } |
666 | - try { |
|
667 | - $sth = $this->db->prepare($query); |
|
668 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
669 | - } catch(PDOException $e) { |
|
670 | - echo "error : ".$e->getMessage(); |
|
671 | - } |
|
672 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
666 | + try { |
|
667 | + $sth = $this->db->prepare($query); |
|
668 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
669 | + } catch(PDOException $e) { |
|
670 | + echo "error : ".$e->getMessage(); |
|
671 | + } |
|
672 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
673 | 673 | |
674 | - if (empty($all)) { |
|
674 | + if (empty($all)) { |
|
675 | 675 | $filters = array('airlines' => array($stats_airline)); |
676 | 676 | if ($filter_name != '') { |
677 | 677 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
678 | 678 | } |
679 | - $Spotter = new Spotter($this->db); |
|
680 | - $all = $Spotter->countAllMonths($filters); |
|
681 | - } |
|
679 | + $Spotter = new Spotter($this->db); |
|
680 | + $all = $Spotter->countAllMonths($filters); |
|
681 | + } |
|
682 | 682 | |
683 | - return $all; |
|
683 | + return $all; |
|
684 | 684 | } |
685 | 685 | public function countFatalitiesLast12Months() { |
686 | 686 | global $globalStatsFilters, $globalDBdriver; |
@@ -689,19 +689,19 @@ discard block |
||
689 | 689 | } else { |
690 | 690 | $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year, EXTRACT(MONTH FROM stats_date) as month,cnt as count FROM stats WHERE stats_type = 'fatalities_bymonth' ORDER BY stats_date"; |
691 | 691 | } |
692 | - try { |
|
693 | - $sth = $this->db->prepare($query); |
|
694 | - $sth->execute(); |
|
695 | - } catch(PDOException $e) { |
|
696 | - echo "error : ".$e->getMessage(); |
|
697 | - } |
|
698 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
692 | + try { |
|
693 | + $sth = $this->db->prepare($query); |
|
694 | + $sth->execute(); |
|
695 | + } catch(PDOException $e) { |
|
696 | + echo "error : ".$e->getMessage(); |
|
697 | + } |
|
698 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
699 | 699 | |
700 | - if (empty($all)) { |
|
701 | - $Accident = new Accident($this->db); |
|
702 | - $all = $Accident->countFatalitiesLast12Months(); |
|
703 | - } |
|
704 | - return $all; |
|
700 | + if (empty($all)) { |
|
701 | + $Accident = new Accident($this->db); |
|
702 | + $all = $Accident->countFatalitiesLast12Months(); |
|
703 | + } |
|
704 | + return $all; |
|
705 | 705 | } |
706 | 706 | public function countFatalitiesByYear() { |
707 | 707 | global $globalStatsFilters, $globalDBdriver; |
@@ -710,40 +710,40 @@ discard block |
||
710 | 710 | } else { |
711 | 711 | $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year, cnt as count FROM stats WHERE stats_type = 'fatalities_byyear' ORDER BY stats_date"; |
712 | 712 | } |
713 | - try { |
|
714 | - $sth = $this->db->prepare($query); |
|
715 | - $sth->execute(); |
|
716 | - } catch(PDOException $e) { |
|
717 | - echo "error : ".$e->getMessage(); |
|
718 | - } |
|
719 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
713 | + try { |
|
714 | + $sth = $this->db->prepare($query); |
|
715 | + $sth->execute(); |
|
716 | + } catch(PDOException $e) { |
|
717 | + echo "error : ".$e->getMessage(); |
|
718 | + } |
|
719 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
720 | 720 | |
721 | - if (empty($all)) { |
|
722 | - $Accident = new Accident($this->db); |
|
723 | - $all = $Accident->countFatalitiesByYear(); |
|
724 | - } |
|
725 | - return $all; |
|
721 | + if (empty($all)) { |
|
722 | + $Accident = new Accident($this->db); |
|
723 | + $all = $Accident->countFatalitiesByYear(); |
|
724 | + } |
|
725 | + return $all; |
|
726 | 726 | } |
727 | 727 | public function countAllMilitaryMonths($filter_name = '') { |
728 | 728 | global $globalStatsFilters; |
729 | 729 | if ($filter_name == '') $filter_name = $this->filter_name; |
730 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
|
731 | - try { |
|
732 | - $sth = $this->db->prepare($query); |
|
733 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
734 | - } catch(PDOException $e) { |
|
735 | - echo "error : ".$e->getMessage(); |
|
736 | - } |
|
737 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
738 | - if (empty($all)) { |
|
739 | - $filters = array(); |
|
740 | - if ($filter_name != '') { |
|
741 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
730 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
|
731 | + try { |
|
732 | + $sth = $this->db->prepare($query); |
|
733 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
734 | + } catch(PDOException $e) { |
|
735 | + echo "error : ".$e->getMessage(); |
|
736 | + } |
|
737 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
738 | + if (empty($all)) { |
|
739 | + $filters = array(); |
|
740 | + if ($filter_name != '') { |
|
741 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
742 | 742 | } |
743 | - $Spotter = new Spotter($this->db); |
|
744 | - $all = $Spotter->countAllMilitaryMonths($filters); |
|
745 | - } |
|
746 | - return $all; |
|
743 | + $Spotter = new Spotter($this->db); |
|
744 | + $all = $Spotter->countAllMilitaryMonths($filters); |
|
745 | + } |
|
746 | + return $all; |
|
747 | 747 | } |
748 | 748 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
749 | 749 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
@@ -759,22 +759,22 @@ discard block |
||
759 | 759 | } |
760 | 760 | } |
761 | 761 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
762 | - try { |
|
763 | - $sth = $this->db->prepare($query); |
|
764 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
765 | - } catch(PDOException $e) { |
|
766 | - echo "error : ".$e->getMessage(); |
|
767 | - } |
|
768 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
769 | - if (empty($all)) { |
|
762 | + try { |
|
763 | + $sth = $this->db->prepare($query); |
|
764 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
765 | + } catch(PDOException $e) { |
|
766 | + echo "error : ".$e->getMessage(); |
|
767 | + } |
|
768 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
769 | + if (empty($all)) { |
|
770 | 770 | $filters = array('airlines' => array($stats_airline)); |
771 | 771 | if ($filter_name != '') { |
772 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
772 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
773 | 773 | } |
774 | - $Spotter = new Spotter($this->db); |
|
775 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
776 | - } |
|
777 | - return $all; |
|
774 | + $Spotter = new Spotter($this->db); |
|
775 | + $all = $Spotter->countAllHours($orderby,$filters); |
|
776 | + } |
|
777 | + return $all; |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
@@ -799,10 +799,10 @@ discard block |
||
799 | 799 | if ($year == '') $year = date('Y'); |
800 | 800 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
801 | 801 | if (empty($all)) { |
802 | - $filters = array(); |
|
802 | + $filters = array(); |
|
803 | 803 | $filters = array('year' => $year,'month' => $month); |
804 | - if ($filter_name != '') { |
|
805 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
804 | + if ($filter_name != '') { |
|
805 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
806 | 806 | } |
807 | 807 | $Spotter = new Spotter($this->db); |
808 | 808 | //$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
@@ -866,10 +866,10 @@ discard block |
||
866 | 866 | $all = $result[0]['nb_airline']; |
867 | 867 | } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
868 | 868 | if (empty($all)) { |
869 | - $filters = array(); |
|
869 | + $filters = array(); |
|
870 | 870 | $filters = array('year' => $year,'month' => $month); |
871 | - if ($filter_name != '') { |
|
872 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
871 | + if ($filter_name != '') { |
|
872 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
873 | 873 | } |
874 | 874 | $Spotter = new Spotter($this->db); |
875 | 875 | //$all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -939,44 +939,44 @@ discard block |
||
939 | 939 | if ($filter_name == '') $filter_name = $this->filter_name; |
940 | 940 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
941 | 941 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
942 | - try { |
|
943 | - $sth = $this->db->prepare($query); |
|
944 | - $sth->execute($query_values); |
|
945 | - } catch(PDOException $e) { |
|
946 | - echo "error : ".$e->getMessage(); |
|
947 | - } |
|
948 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
949 | - return $all; |
|
942 | + try { |
|
943 | + $sth = $this->db->prepare($query); |
|
944 | + $sth->execute($query_values); |
|
945 | + } catch(PDOException $e) { |
|
946 | + echo "error : ".$e->getMessage(); |
|
947 | + } |
|
948 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
949 | + return $all; |
|
950 | 950 | } |
951 | 951 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
952 | 952 | if ($filter_name == '') $filter_name = $this->filter_name; |
953 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
954 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
955 | - try { |
|
956 | - $sth = $this->db->prepare($query); |
|
957 | - $sth->execute($query_values); |
|
958 | - } catch(PDOException $e) { |
|
959 | - echo "error : ".$e->getMessage(); |
|
960 | - } |
|
961 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
962 | - return $all; |
|
963 | - } |
|
953 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
954 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
955 | + try { |
|
956 | + $sth = $this->db->prepare($query); |
|
957 | + $sth->execute($query_values); |
|
958 | + } catch(PDOException $e) { |
|
959 | + echo "error : ".$e->getMessage(); |
|
960 | + } |
|
961 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
962 | + return $all; |
|
963 | + } |
|
964 | 964 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
965 | 965 | if ($filter_name == '') $filter_name = $this->filter_name; |
966 | - $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
967 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
968 | - try { |
|
969 | - $sth = $this->db->prepare($query); |
|
970 | - $sth->execute($query_values); |
|
971 | - } catch(PDOException $e) { |
|
972 | - echo "error : ".$e->getMessage(); |
|
973 | - } |
|
974 | - } |
|
966 | + $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
967 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
968 | + try { |
|
969 | + $sth = $this->db->prepare($query); |
|
970 | + $sth->execute($query_values); |
|
971 | + } catch(PDOException $e) { |
|
972 | + echo "error : ".$e->getMessage(); |
|
973 | + } |
|
974 | + } |
|
975 | 975 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
976 | 976 | if ($filter_name == '') $filter_name = $this->filter_name; |
977 | - global $globalArchiveMonths, $globalDBdriver; |
|
978 | - if ($globalDBdriver == 'mysql') { |
|
979 | - if ($month == '') { |
|
977 | + global $globalArchiveMonths, $globalDBdriver; |
|
978 | + if ($globalDBdriver == 'mysql') { |
|
979 | + if ($month == '') { |
|
980 | 980 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
981 | 981 | $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
982 | 982 | } else { |
@@ -991,165 +991,165 @@ discard block |
||
991 | 991 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
992 | 992 | $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
993 | 993 | } |
994 | - } |
|
995 | - try { |
|
996 | - $sth = $this->db->prepare($query); |
|
997 | - $sth->execute($query_values); |
|
998 | - } catch(PDOException $e) { |
|
999 | - echo "error : ".$e->getMessage(); |
|
1000 | - } |
|
1001 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1002 | - return $all[0]['total']; |
|
1003 | - } |
|
994 | + } |
|
995 | + try { |
|
996 | + $sth = $this->db->prepare($query); |
|
997 | + $sth->execute($query_values); |
|
998 | + } catch(PDOException $e) { |
|
999 | + echo "error : ".$e->getMessage(); |
|
1000 | + } |
|
1001 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1002 | + return $all[0]['total']; |
|
1003 | + } |
|
1004 | 1004 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
1005 | - global $globalArchiveMonths, $globalDBdriver; |
|
1005 | + global $globalArchiveMonths, $globalDBdriver; |
|
1006 | 1006 | if ($filter_name == '') $filter_name = $this->filter_name; |
1007 | - if ($globalDBdriver == 'mysql') { |
|
1007 | + if ($globalDBdriver == 'mysql') { |
|
1008 | 1008 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1009 | 1009 | } else { |
1010 | 1010 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1011 | - } |
|
1012 | - $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1013 | - try { |
|
1014 | - $sth = $this->db->prepare($query); |
|
1015 | - $sth->execute($query_values); |
|
1016 | - } catch(PDOException $e) { |
|
1017 | - echo "error : ".$e->getMessage(); |
|
1018 | - } |
|
1019 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1020 | - return $all[0]['total']; |
|
1021 | - } |
|
1011 | + } |
|
1012 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1013 | + try { |
|
1014 | + $sth = $this->db->prepare($query); |
|
1015 | + $sth->execute($query_values); |
|
1016 | + } catch(PDOException $e) { |
|
1017 | + echo "error : ".$e->getMessage(); |
|
1018 | + } |
|
1019 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1020 | + return $all[0]['total']; |
|
1021 | + } |
|
1022 | 1022 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
1023 | - global $globalArchiveMonths, $globalDBdriver; |
|
1023 | + global $globalArchiveMonths, $globalDBdriver; |
|
1024 | 1024 | if ($filter_name == '') $filter_name = $this->filter_name; |
1025 | - if ($globalDBdriver == 'mysql') { |
|
1025 | + if ($globalDBdriver == 'mysql') { |
|
1026 | 1026 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
1027 | - } else { |
|
1027 | + } else { |
|
1028 | 1028 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
1029 | - } |
|
1030 | - try { |
|
1031 | - $sth = $this->db->prepare($query); |
|
1032 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
1033 | - } catch(PDOException $e) { |
|
1034 | - echo "error : ".$e->getMessage(); |
|
1035 | - } |
|
1036 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1037 | - return $all[0]['total']; |
|
1038 | - } |
|
1029 | + } |
|
1030 | + try { |
|
1031 | + $sth = $this->db->prepare($query); |
|
1032 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
1033 | + } catch(PDOException $e) { |
|
1034 | + echo "error : ".$e->getMessage(); |
|
1035 | + } |
|
1036 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1037 | + return $all[0]['total']; |
|
1038 | + } |
|
1039 | 1039 | public function getStatsAirlineTotal($filter_name = '') { |
1040 | - global $globalArchiveMonths, $globalDBdriver; |
|
1040 | + global $globalArchiveMonths, $globalDBdriver; |
|
1041 | 1041 | if ($filter_name == '') $filter_name = $this->filter_name; |
1042 | - if ($globalDBdriver == 'mysql') { |
|
1042 | + if ($globalDBdriver == 'mysql') { |
|
1043 | 1043 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
1044 | - } else { |
|
1044 | + } else { |
|
1045 | 1045 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
1046 | - } |
|
1047 | - try { |
|
1048 | - $sth = $this->db->prepare($query); |
|
1049 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
1050 | - } catch(PDOException $e) { |
|
1051 | - echo "error : ".$e->getMessage(); |
|
1052 | - } |
|
1053 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1054 | - return $all[0]['total']; |
|
1055 | - } |
|
1046 | + } |
|
1047 | + try { |
|
1048 | + $sth = $this->db->prepare($query); |
|
1049 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
1050 | + } catch(PDOException $e) { |
|
1051 | + echo "error : ".$e->getMessage(); |
|
1052 | + } |
|
1053 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1054 | + return $all[0]['total']; |
|
1055 | + } |
|
1056 | 1056 | public function getStatsOwnerTotal($filter_name = '') { |
1057 | - global $globalArchiveMonths, $globalDBdriver; |
|
1057 | + global $globalArchiveMonths, $globalDBdriver; |
|
1058 | 1058 | if ($filter_name == '') $filter_name = $this->filter_name; |
1059 | - if ($globalDBdriver == 'mysql') { |
|
1059 | + if ($globalDBdriver == 'mysql') { |
|
1060 | 1060 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
1061 | 1061 | } else { |
1062 | 1062 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
1063 | - } |
|
1064 | - try { |
|
1065 | - $sth = $this->db->prepare($query); |
|
1066 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
1067 | - } catch(PDOException $e) { |
|
1068 | - echo "error : ".$e->getMessage(); |
|
1069 | - } |
|
1070 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1071 | - return $all[0]['total']; |
|
1072 | - } |
|
1063 | + } |
|
1064 | + try { |
|
1065 | + $sth = $this->db->prepare($query); |
|
1066 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
1067 | + } catch(PDOException $e) { |
|
1068 | + echo "error : ".$e->getMessage(); |
|
1069 | + } |
|
1070 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1071 | + return $all[0]['total']; |
|
1072 | + } |
|
1073 | 1073 | public function getStatsOwner($owner_name,$filter_name = '') { |
1074 | - global $globalArchiveMonths, $globalDBdriver; |
|
1074 | + global $globalArchiveMonths, $globalDBdriver; |
|
1075 | 1075 | if ($filter_name == '') $filter_name = $this->filter_name; |
1076 | 1076 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1077 | - try { |
|
1078 | - $sth = $this->db->prepare($query); |
|
1079 | - $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
1080 | - } catch(PDOException $e) { |
|
1081 | - echo "error : ".$e->getMessage(); |
|
1082 | - } |
|
1083 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1084 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1085 | - else return 0; |
|
1086 | - } |
|
1077 | + try { |
|
1078 | + $sth = $this->db->prepare($query); |
|
1079 | + $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
1080 | + } catch(PDOException $e) { |
|
1081 | + echo "error : ".$e->getMessage(); |
|
1082 | + } |
|
1083 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1084 | + if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1085 | + else return 0; |
|
1086 | + } |
|
1087 | 1087 | public function getStatsPilotTotal($filter_name = '') { |
1088 | - global $globalArchiveMonths, $globalDBdriver; |
|
1088 | + global $globalArchiveMonths, $globalDBdriver; |
|
1089 | 1089 | if ($filter_name == '') $filter_name = $this->filter_name; |
1090 | - if ($globalDBdriver == 'mysql') { |
|
1091 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
1092 | - } else { |
|
1093 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
1094 | - } |
|
1095 | - try { |
|
1096 | - $sth = $this->db->prepare($query); |
|
1097 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
1098 | - } catch(PDOException $e) { |
|
1099 | - echo "error : ".$e->getMessage(); |
|
1100 | - } |
|
1101 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1102 | - return $all[0]['total']; |
|
1103 | - } |
|
1090 | + if ($globalDBdriver == 'mysql') { |
|
1091 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
1092 | + } else { |
|
1093 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
1094 | + } |
|
1095 | + try { |
|
1096 | + $sth = $this->db->prepare($query); |
|
1097 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
1098 | + } catch(PDOException $e) { |
|
1099 | + echo "error : ".$e->getMessage(); |
|
1100 | + } |
|
1101 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1102 | + return $all[0]['total']; |
|
1103 | + } |
|
1104 | 1104 | public function getStatsPilot($pilot,$filter_name = '') { |
1105 | - global $globalArchiveMonths, $globalDBdriver; |
|
1105 | + global $globalArchiveMonths, $globalDBdriver; |
|
1106 | 1106 | if ($filter_name == '') $filter_name = $this->filter_name; |
1107 | 1107 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1108 | - try { |
|
1109 | - $sth = $this->db->prepare($query); |
|
1110 | - $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
1111 | - } catch(PDOException $e) { |
|
1112 | - echo "error : ".$e->getMessage(); |
|
1113 | - } |
|
1114 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1115 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1116 | - else return 0; |
|
1117 | - } |
|
1108 | + try { |
|
1109 | + $sth = $this->db->prepare($query); |
|
1110 | + $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
1111 | + } catch(PDOException $e) { |
|
1112 | + echo "error : ".$e->getMessage(); |
|
1113 | + } |
|
1114 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1115 | + if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1116 | + else return 0; |
|
1117 | + } |
|
1118 | 1118 | |
1119 | 1119 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1120 | 1120 | global $globalDBdriver; |
1121 | 1121 | if ($filter_name == '') $filter_name = $this->filter_name; |
1122 | 1122 | if ($globalDBdriver == 'mysql') { |
1123 | 1123 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
1124 | - } else { |
|
1124 | + } else { |
|
1125 | 1125 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1126 | 1126 | } |
1127 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1128 | - try { |
|
1129 | - $sth = $this->db->prepare($query); |
|
1130 | - $sth->execute($query_values); |
|
1131 | - } catch(PDOException $e) { |
|
1132 | - return "error : ".$e->getMessage(); |
|
1133 | - } |
|
1134 | - } |
|
1127 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1128 | + try { |
|
1129 | + $sth = $this->db->prepare($query); |
|
1130 | + $sth->execute($query_values); |
|
1131 | + } catch(PDOException $e) { |
|
1132 | + return "error : ".$e->getMessage(); |
|
1133 | + } |
|
1134 | + } |
|
1135 | 1135 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1136 | 1136 | global $globalDBdriver; |
1137 | 1137 | if ($filter_name == '') $filter_name = $this->filter_name; |
1138 | 1138 | if ($globalDBdriver == 'mysql') { |
1139 | 1139 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
1140 | 1140 | } else { |
1141 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
1141 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
1142 | 1142 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1143 | - } |
|
1144 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1145 | - try { |
|
1146 | - $sth = $this->db->prepare($query); |
|
1147 | - $sth->execute($query_values); |
|
1148 | - } catch(PDOException $e) { |
|
1149 | - return "error : ".$e->getMessage(); |
|
1150 | - } |
|
1151 | - } |
|
1152 | - /* |
|
1143 | + } |
|
1144 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1145 | + try { |
|
1146 | + $sth = $this->db->prepare($query); |
|
1147 | + $sth->execute($query_values); |
|
1148 | + } catch(PDOException $e) { |
|
1149 | + return "error : ".$e->getMessage(); |
|
1150 | + } |
|
1151 | + } |
|
1152 | + /* |
|
1153 | 1153 | public function getStatsSource($date,$stats_type = '') { |
1154 | 1154 | if ($stats_type == '') { |
1155 | 1155 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -1218,25 +1218,25 @@ discard block |
||
1218 | 1218 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
1219 | 1219 | } else { |
1220 | 1220 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
1221 | - } |
|
1222 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
1223 | - try { |
|
1224 | - $sth = $this->db->prepare($query); |
|
1225 | - $sth->execute($query_values); |
|
1226 | - } catch(PDOException $e) { |
|
1227 | - return "error : ".$e->getMessage(); |
|
1228 | - } |
|
1229 | - } |
|
1230 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
1231 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
1232 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1233 | - try { |
|
1234 | - $sth = $this->db->prepare($query); |
|
1235 | - $sth->execute($query_values); |
|
1236 | - } catch(PDOException $e) { |
|
1237 | - return "error : ".$e->getMessage(); |
|
1238 | - } |
|
1239 | - } |
|
1221 | + } |
|
1222 | + $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
1223 | + try { |
|
1224 | + $sth = $this->db->prepare($query); |
|
1225 | + $sth->execute($query_values); |
|
1226 | + } catch(PDOException $e) { |
|
1227 | + return "error : ".$e->getMessage(); |
|
1228 | + } |
|
1229 | + } |
|
1230 | + public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
1231 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
1232 | + $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1233 | + try { |
|
1234 | + $sth = $this->db->prepare($query); |
|
1235 | + $sth->execute($query_values); |
|
1236 | + } catch(PDOException $e) { |
|
1237 | + return "error : ".$e->getMessage(); |
|
1238 | + } |
|
1239 | + } |
|
1240 | 1240 | public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
1241 | 1241 | global $globalDBdriver; |
1242 | 1242 | if ($globalDBdriver == 'mysql') { |
@@ -1252,14 +1252,14 @@ discard block |
||
1252 | 1252 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1253 | 1253 | } |
1254 | 1254 | } |
1255 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1256 | - try { |
|
1257 | - $sth = $this->db->prepare($query); |
|
1258 | - $sth->execute($query_values); |
|
1259 | - } catch(PDOException $e) { |
|
1260 | - return "error : ".$e->getMessage(); |
|
1261 | - } |
|
1262 | - } |
|
1255 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1256 | + try { |
|
1257 | + $sth = $this->db->prepare($query); |
|
1258 | + $sth->execute($query_values); |
|
1259 | + } catch(PDOException $e) { |
|
1260 | + return "error : ".$e->getMessage(); |
|
1261 | + } |
|
1262 | + } |
|
1263 | 1263 | public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
1264 | 1264 | global $globalDBdriver; |
1265 | 1265 | if ($globalDBdriver == 'mysql') { |
@@ -1275,14 +1275,14 @@ discard block |
||
1275 | 1275 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
1276 | 1276 | } |
1277 | 1277 | } |
1278 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1279 | - try { |
|
1280 | - $sth = $this->db->prepare($query); |
|
1281 | - $sth->execute($query_values); |
|
1282 | - } catch(PDOException $e) { |
|
1283 | - return "error : ".$e->getMessage(); |
|
1284 | - } |
|
1285 | - } |
|
1278 | + $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1279 | + try { |
|
1280 | + $sth = $this->db->prepare($query); |
|
1281 | + $sth->execute($query_values); |
|
1282 | + } catch(PDOException $e) { |
|
1283 | + return "error : ".$e->getMessage(); |
|
1284 | + } |
|
1285 | + } |
|
1286 | 1286 | public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
1287 | 1287 | global $globalDBdriver; |
1288 | 1288 | if ($globalDBdriver == 'mysql') { |
@@ -1298,14 +1298,14 @@ discard block |
||
1298 | 1298 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; |
1299 | 1299 | } |
1300 | 1300 | } |
1301 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
1302 | - try { |
|
1303 | - $sth = $this->db->prepare($query); |
|
1304 | - $sth->execute($query_values); |
|
1305 | - } catch(PDOException $e) { |
|
1306 | - return "error : ".$e->getMessage(); |
|
1307 | - } |
|
1308 | - } |
|
1301 | + $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
1302 | + try { |
|
1303 | + $sth = $this->db->prepare($query); |
|
1304 | + $sth->execute($query_values); |
|
1305 | + } catch(PDOException $e) { |
|
1306 | + return "error : ".$e->getMessage(); |
|
1307 | + } |
|
1308 | + } |
|
1309 | 1309 | public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
1310 | 1310 | global $globalDBdriver; |
1311 | 1311 | if ($globalDBdriver == 'mysql') { |
@@ -1321,14 +1321,14 @@ discard block |
||
1321 | 1321 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1322 | 1322 | } |
1323 | 1323 | } |
1324 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1325 | - try { |
|
1326 | - $sth = $this->db->prepare($query); |
|
1327 | - $sth->execute($query_values); |
|
1328 | - } catch(PDOException $e) { |
|
1329 | - return "error : ".$e->getMessage(); |
|
1330 | - } |
|
1331 | - } |
|
1324 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1325 | + try { |
|
1326 | + $sth = $this->db->prepare($query); |
|
1327 | + $sth->execute($query_values); |
|
1328 | + } catch(PDOException $e) { |
|
1329 | + return "error : ".$e->getMessage(); |
|
1330 | + } |
|
1331 | + } |
|
1332 | 1332 | public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
1333 | 1333 | global $globalDBdriver; |
1334 | 1334 | if ($globalDBdriver == 'mysql') { |
@@ -1344,14 +1344,14 @@ discard block |
||
1344 | 1344 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
1345 | 1345 | } |
1346 | 1346 | } |
1347 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1348 | - try { |
|
1349 | - $sth = $this->db->prepare($query); |
|
1350 | - $sth->execute($query_values); |
|
1351 | - } catch(PDOException $e) { |
|
1352 | - return "error : ".$e->getMessage(); |
|
1353 | - } |
|
1354 | - } |
|
1347 | + $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1348 | + try { |
|
1349 | + $sth = $this->db->prepare($query); |
|
1350 | + $sth->execute($query_values); |
|
1351 | + } catch(PDOException $e) { |
|
1352 | + return "error : ".$e->getMessage(); |
|
1353 | + } |
|
1354 | + } |
|
1355 | 1355 | public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
1356 | 1356 | global $globalDBdriver; |
1357 | 1357 | if ($globalDBdriver == 'mysql') { |
@@ -1367,14 +1367,14 @@ discard block |
||
1367 | 1367 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1368 | 1368 | } |
1369 | 1369 | } |
1370 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1371 | - try { |
|
1372 | - $sth = $this->db->prepare($query); |
|
1373 | - $sth->execute($query_values); |
|
1374 | - } catch(PDOException $e) { |
|
1375 | - return "error : ".$e->getMessage(); |
|
1376 | - } |
|
1377 | - } |
|
1370 | + $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1371 | + try { |
|
1372 | + $sth = $this->db->prepare($query); |
|
1373 | + $sth->execute($query_values); |
|
1374 | + } catch(PDOException $e) { |
|
1375 | + return "error : ".$e->getMessage(); |
|
1376 | + } |
|
1377 | + } |
|
1378 | 1378 | public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
1379 | 1379 | global $globalDBdriver; |
1380 | 1380 | if ($globalDBdriver == 'mysql') { |
@@ -1390,14 +1390,14 @@ discard block |
||
1390 | 1390 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1391 | 1391 | } |
1392 | 1392 | } |
1393 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1394 | - try { |
|
1395 | - $sth = $this->db->prepare($query); |
|
1396 | - $sth->execute($query_values); |
|
1397 | - } catch(PDOException $e) { |
|
1398 | - return "error : ".$e->getMessage(); |
|
1399 | - } |
|
1400 | - } |
|
1393 | + $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1394 | + try { |
|
1395 | + $sth = $this->db->prepare($query); |
|
1396 | + $sth->execute($query_values); |
|
1397 | + } catch(PDOException $e) { |
|
1398 | + return "error : ".$e->getMessage(); |
|
1399 | + } |
|
1400 | + } |
|
1401 | 1401 | public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
1402 | 1402 | global $globalDBdriver; |
1403 | 1403 | if ($airport_icao != '') { |
@@ -1421,8 +1421,8 @@ discard block |
||
1421 | 1421 | } catch(PDOException $e) { |
1422 | 1422 | return "error : ".$e->getMessage(); |
1423 | 1423 | } |
1424 | - } |
|
1425 | - } |
|
1424 | + } |
|
1425 | + } |
|
1426 | 1426 | public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1427 | 1427 | global $globalDBdriver; |
1428 | 1428 | if ($airport_icao != '') { |
@@ -1438,8 +1438,8 @@ discard block |
||
1438 | 1438 | } catch(PDOException $e) { |
1439 | 1439 | return "error : ".$e->getMessage(); |
1440 | 1440 | } |
1441 | - } |
|
1442 | - } |
|
1441 | + } |
|
1442 | + } |
|
1443 | 1443 | public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
1444 | 1444 | global $globalDBdriver; |
1445 | 1445 | if ($airport_icao != '') { |
@@ -1456,15 +1456,15 @@ discard block |
||
1456 | 1456 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1457 | 1457 | } |
1458 | 1458 | } |
1459 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1459 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1460 | 1460 | try { |
1461 | - $sth = $this->db->prepare($query); |
|
1462 | - $sth->execute($query_values); |
|
1463 | - } catch(PDOException $e) { |
|
1464 | - return "error : ".$e->getMessage(); |
|
1465 | - } |
|
1466 | - } |
|
1467 | - } |
|
1461 | + $sth = $this->db->prepare($query); |
|
1462 | + $sth->execute($query_values); |
|
1463 | + } catch(PDOException $e) { |
|
1464 | + return "error : ".$e->getMessage(); |
|
1465 | + } |
|
1466 | + } |
|
1467 | + } |
|
1468 | 1468 | public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1469 | 1469 | global $globalDBdriver; |
1470 | 1470 | if ($airport_icao != '') { |
@@ -1480,46 +1480,46 @@ discard block |
||
1480 | 1480 | } catch(PDOException $e) { |
1481 | 1481 | return "error : ".$e->getMessage(); |
1482 | 1482 | } |
1483 | - } |
|
1484 | - } |
|
1483 | + } |
|
1484 | + } |
|
1485 | 1485 | |
1486 | 1486 | public function deleteStat($id) { |
1487 | - $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1488 | - $query_values = array(':id' => $id); |
|
1489 | - try { |
|
1490 | - $sth = $this->db->prepare($query); |
|
1491 | - $sth->execute($query_values); |
|
1492 | - } catch(PDOException $e) { |
|
1493 | - return "error : ".$e->getMessage(); |
|
1494 | - } |
|
1495 | - } |
|
1487 | + $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1488 | + $query_values = array(':id' => $id); |
|
1489 | + try { |
|
1490 | + $sth = $this->db->prepare($query); |
|
1491 | + $sth->execute($query_values); |
|
1492 | + } catch(PDOException $e) { |
|
1493 | + return "error : ".$e->getMessage(); |
|
1494 | + } |
|
1495 | + } |
|
1496 | 1496 | public function deleteStatFlight($type) { |
1497 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1498 | - $query_values = array(':type' => $type); |
|
1499 | - try { |
|
1500 | - $sth = $this->db->prepare($query); |
|
1501 | - $sth->execute($query_values); |
|
1502 | - } catch(PDOException $e) { |
|
1503 | - return "error : ".$e->getMessage(); |
|
1504 | - } |
|
1505 | - } |
|
1497 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1498 | + $query_values = array(':type' => $type); |
|
1499 | + try { |
|
1500 | + $sth = $this->db->prepare($query); |
|
1501 | + $sth->execute($query_values); |
|
1502 | + } catch(PDOException $e) { |
|
1503 | + return "error : ".$e->getMessage(); |
|
1504 | + } |
|
1505 | + } |
|
1506 | 1506 | public function deleteStatAirport($type) { |
1507 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1508 | - $query_values = array(':type' => $type); |
|
1509 | - try { |
|
1510 | - $sth = $this->db->prepare($query); |
|
1511 | - $sth->execute($query_values); |
|
1512 | - } catch(PDOException $e) { |
|
1513 | - return "error : ".$e->getMessage(); |
|
1514 | - } |
|
1515 | - } |
|
1507 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1508 | + $query_values = array(':type' => $type); |
|
1509 | + try { |
|
1510 | + $sth = $this->db->prepare($query); |
|
1511 | + $sth->execute($query_values); |
|
1512 | + } catch(PDOException $e) { |
|
1513 | + return "error : ".$e->getMessage(); |
|
1514 | + } |
|
1515 | + } |
|
1516 | 1516 | |
1517 | - public function addOldStats() { |
|
1518 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents; |
|
1519 | - $Common = new Common(); |
|
1520 | - $Connection = new Connection(); |
|
1521 | - date_default_timezone_set('UTC'); |
|
1522 | - $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1517 | + public function addOldStats() { |
|
1518 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents; |
|
1519 | + $Common = new Common(); |
|
1520 | + $Connection = new Connection(); |
|
1521 | + date_default_timezone_set('UTC'); |
|
1522 | + $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1523 | 1523 | if ($globalDebug) echo 'Update stats !'."\n"; |
1524 | 1524 | if (isset($last_update[0]['value'])) { |
1525 | 1525 | $last_update_day = $last_update[0]['value']; |
@@ -1567,24 +1567,24 @@ discard block |
||
1567 | 1567 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1568 | 1568 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1569 | 1569 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1570 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1570 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1571 | 1571 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1572 | - $alldata = array(); |
|
1572 | + $alldata = array(); |
|
1573 | 1573 | |
1574 | - foreach ($pall as $value) { |
|
1575 | - $icao = $value['airport_departure_icao']; |
|
1576 | - $alldata[$icao] = $value; |
|
1577 | - } |
|
1578 | - foreach ($dall as $value) { |
|
1579 | - $icao = $value['airport_departure_icao']; |
|
1580 | - if (isset($alldata[$icao])) { |
|
1581 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1582 | - } else $alldata[$icao] = $value; |
|
1583 | - } |
|
1584 | - $count = array(); |
|
1585 | - foreach ($alldata as $key => $row) { |
|
1586 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1587 | - } |
|
1574 | + foreach ($pall as $value) { |
|
1575 | + $icao = $value['airport_departure_icao']; |
|
1576 | + $alldata[$icao] = $value; |
|
1577 | + } |
|
1578 | + foreach ($dall as $value) { |
|
1579 | + $icao = $value['airport_departure_icao']; |
|
1580 | + if (isset($alldata[$icao])) { |
|
1581 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1582 | + } else $alldata[$icao] = $value; |
|
1583 | + } |
|
1584 | + $count = array(); |
|
1585 | + foreach ($alldata as $key => $row) { |
|
1586 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1587 | + } |
|
1588 | 1588 | array_multisort($count,SORT_DESC,$alldata); |
1589 | 1589 | foreach ($alldata as $number) { |
1590 | 1590 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
@@ -1592,25 +1592,25 @@ discard block |
||
1592 | 1592 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1593 | 1593 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1594 | 1594 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1595 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1595 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1596 | 1596 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1597 | - $alldata = array(); |
|
1598 | - foreach ($pall as $value) { |
|
1599 | - $icao = $value['airport_arrival_icao']; |
|
1600 | - $alldata[$icao] = $value; |
|
1601 | - } |
|
1602 | - foreach ($dall as $value) { |
|
1603 | - $icao = $value['airport_arrival_icao']; |
|
1604 | - if (isset($alldata[$icao])) { |
|
1605 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1606 | - } else $alldata[$icao] = $value; |
|
1607 | - } |
|
1608 | - $count = array(); |
|
1609 | - foreach ($alldata as $key => $row) { |
|
1610 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1611 | - } |
|
1612 | - array_multisort($count,SORT_DESC,$alldata); |
|
1613 | - foreach ($alldata as $number) { |
|
1597 | + $alldata = array(); |
|
1598 | + foreach ($pall as $value) { |
|
1599 | + $icao = $value['airport_arrival_icao']; |
|
1600 | + $alldata[$icao] = $value; |
|
1601 | + } |
|
1602 | + foreach ($dall as $value) { |
|
1603 | + $icao = $value['airport_arrival_icao']; |
|
1604 | + if (isset($alldata[$icao])) { |
|
1605 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1606 | + } else $alldata[$icao] = $value; |
|
1607 | + } |
|
1608 | + $count = array(); |
|
1609 | + foreach ($alldata as $key => $row) { |
|
1610 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1611 | + } |
|
1612 | + array_multisort($count,SORT_DESC,$alldata); |
|
1613 | + foreach ($alldata as $number) { |
|
1614 | 1614 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
1615 | 1615 | } |
1616 | 1616 | if ($Connection->tableExists('countries')) { |
@@ -1687,8 +1687,8 @@ discard block |
||
1687 | 1687 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1688 | 1688 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
1689 | 1689 | $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1690 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1691 | - /* |
|
1690 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1691 | + /* |
|
1692 | 1692 | $alldata = array(); |
1693 | 1693 | foreach ($pall as $value) { |
1694 | 1694 | $icao = $value['departure_airport_icao']; |
@@ -1707,29 +1707,29 @@ discard block |
||
1707 | 1707 | } |
1708 | 1708 | array_multisort($count,SORT_DESC,$alldata); |
1709 | 1709 | */ |
1710 | - foreach ($dall as $value) { |
|
1711 | - $icao = $value['departure_airport_icao']; |
|
1712 | - $ddate = $value['date']; |
|
1713 | - $find = false; |
|
1714 | - foreach ($pall as $pvalue) { |
|
1715 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1716 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1717 | - $find = true; |
|
1718 | - break; |
|
1719 | - } |
|
1720 | - } |
|
1721 | - if ($find === false) { |
|
1722 | - $pall[] = $value; |
|
1723 | - } |
|
1724 | - } |
|
1725 | - $alldata = $pall; |
|
1710 | + foreach ($dall as $value) { |
|
1711 | + $icao = $value['departure_airport_icao']; |
|
1712 | + $ddate = $value['date']; |
|
1713 | + $find = false; |
|
1714 | + foreach ($pall as $pvalue) { |
|
1715 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1716 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1717 | + $find = true; |
|
1718 | + break; |
|
1719 | + } |
|
1720 | + } |
|
1721 | + if ($find === false) { |
|
1722 | + $pall[] = $value; |
|
1723 | + } |
|
1724 | + } |
|
1725 | + $alldata = $pall; |
|
1726 | 1726 | foreach ($alldata as $number) { |
1727 | 1727 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
1728 | 1728 | } |
1729 | 1729 | echo '...Arrival'."\n"; |
1730 | 1730 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
1731 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1732 | - /* |
|
1731 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1732 | + /* |
|
1733 | 1733 | $alldata = array(); |
1734 | 1734 | foreach ($pall as $value) { |
1735 | 1735 | $icao = $value['arrival_airport_icao']; |
@@ -1749,22 +1749,22 @@ discard block |
||
1749 | 1749 | */ |
1750 | 1750 | |
1751 | 1751 | |
1752 | - foreach ($dall as $value) { |
|
1753 | - $icao = $value['arrival_airport_icao']; |
|
1754 | - $ddate = $value['date']; |
|
1755 | - $find = false; |
|
1756 | - foreach ($pall as $pvalue) { |
|
1757 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1758 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1759 | - $find = true; |
|
1760 | - break; |
|
1761 | - } |
|
1762 | - } |
|
1763 | - if ($find === false) { |
|
1764 | - $pall[] = $value; |
|
1765 | - } |
|
1766 | - } |
|
1767 | - $alldata = $pall; |
|
1752 | + foreach ($dall as $value) { |
|
1753 | + $icao = $value['arrival_airport_icao']; |
|
1754 | + $ddate = $value['date']; |
|
1755 | + $find = false; |
|
1756 | + foreach ($pall as $pvalue) { |
|
1757 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1758 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1759 | + $find = true; |
|
1760 | + break; |
|
1761 | + } |
|
1762 | + } |
|
1763 | + if ($find === false) { |
|
1764 | + $pall[] = $value; |
|
1765 | + } |
|
1766 | + } |
|
1767 | + $alldata = $pall; |
|
1768 | 1768 | foreach ($alldata as $number) { |
1769 | 1769 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
1770 | 1770 | } |
@@ -1841,51 +1841,51 @@ discard block |
||
1841 | 1841 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1842 | 1842 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1843 | 1843 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1844 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1844 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1845 | 1845 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1846 | - //$alldata = array(); |
|
1847 | - foreach ($dall as $value) { |
|
1848 | - $icao = $value['airport_departure_icao']; |
|
1849 | - $dicao = $value['airline_icao']; |
|
1850 | - $find = false; |
|
1851 | - foreach ($pall as $pvalue) { |
|
1852 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1853 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1854 | - $find = true; |
|
1855 | - break; |
|
1856 | - } |
|
1857 | - } |
|
1858 | - if ($find === false) { |
|
1859 | - $pall[] = $value; |
|
1860 | - } |
|
1861 | - } |
|
1862 | - $alldata = $pall; |
|
1846 | + //$alldata = array(); |
|
1847 | + foreach ($dall as $value) { |
|
1848 | + $icao = $value['airport_departure_icao']; |
|
1849 | + $dicao = $value['airline_icao']; |
|
1850 | + $find = false; |
|
1851 | + foreach ($pall as $pvalue) { |
|
1852 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1853 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1854 | + $find = true; |
|
1855 | + break; |
|
1856 | + } |
|
1857 | + } |
|
1858 | + if ($find === false) { |
|
1859 | + $pall[] = $value; |
|
1860 | + } |
|
1861 | + } |
|
1862 | + $alldata = $pall; |
|
1863 | 1863 | foreach ($alldata as $number) { |
1864 | 1864 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
1865 | 1865 | } |
1866 | 1866 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1867 | 1867 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1868 | 1868 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1869 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1869 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1870 | 1870 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1871 | - //$alldata = array(); |
|
1872 | - foreach ($dall as $value) { |
|
1873 | - $icao = $value['airport_arrival_icao']; |
|
1874 | - $dicao = $value['airline_icao']; |
|
1875 | - $find = false; |
|
1876 | - foreach ($pall as $pvalue) { |
|
1877 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1878 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1879 | - $find = true; |
|
1880 | - break; |
|
1881 | - } |
|
1882 | - } |
|
1883 | - if ($find === false) { |
|
1884 | - $pall[] = $value; |
|
1885 | - } |
|
1886 | - } |
|
1887 | - $alldata = $pall; |
|
1888 | - foreach ($alldata as $number) { |
|
1871 | + //$alldata = array(); |
|
1872 | + foreach ($dall as $value) { |
|
1873 | + $icao = $value['airport_arrival_icao']; |
|
1874 | + $dicao = $value['airline_icao']; |
|
1875 | + $find = false; |
|
1876 | + foreach ($pall as $pvalue) { |
|
1877 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1878 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1879 | + $find = true; |
|
1880 | + break; |
|
1881 | + } |
|
1882 | + } |
|
1883 | + if ($find === false) { |
|
1884 | + $pall[] = $value; |
|
1885 | + } |
|
1886 | + } |
|
1887 | + $alldata = $pall; |
|
1888 | + foreach ($alldata as $number) { |
|
1889 | 1889 | if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
1890 | 1890 | } |
1891 | 1891 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
@@ -1918,47 +1918,47 @@ discard block |
||
1918 | 1918 | } |
1919 | 1919 | if ($globalDebug) echo '...Departure'."\n"; |
1920 | 1920 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1921 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1922 | - foreach ($dall as $value) { |
|
1923 | - $icao = $value['departure_airport_icao']; |
|
1924 | - $airline = $value['airline_icao']; |
|
1925 | - $ddate = $value['date']; |
|
1926 | - $find = false; |
|
1927 | - foreach ($pall as $pvalue) { |
|
1928 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1929 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1930 | - $find = true; |
|
1931 | - break; |
|
1932 | - } |
|
1933 | - } |
|
1934 | - if ($find === false) { |
|
1935 | - $pall[] = $value; |
|
1936 | - } |
|
1937 | - } |
|
1938 | - $alldata = $pall; |
|
1921 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1922 | + foreach ($dall as $value) { |
|
1923 | + $icao = $value['departure_airport_icao']; |
|
1924 | + $airline = $value['airline_icao']; |
|
1925 | + $ddate = $value['date']; |
|
1926 | + $find = false; |
|
1927 | + foreach ($pall as $pvalue) { |
|
1928 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1929 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1930 | + $find = true; |
|
1931 | + break; |
|
1932 | + } |
|
1933 | + } |
|
1934 | + if ($find === false) { |
|
1935 | + $pall[] = $value; |
|
1936 | + } |
|
1937 | + } |
|
1938 | + $alldata = $pall; |
|
1939 | 1939 | foreach ($alldata as $number) { |
1940 | 1940 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
1941 | 1941 | } |
1942 | 1942 | if ($globalDebug) echo '...Arrival'."\n"; |
1943 | 1943 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1944 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1945 | - foreach ($dall as $value) { |
|
1946 | - $icao = $value['arrival_airport_icao']; |
|
1947 | - $airline = $value['airline_icao']; |
|
1948 | - $ddate = $value['date']; |
|
1949 | - $find = false; |
|
1950 | - foreach ($pall as $pvalue) { |
|
1951 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1952 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1953 | - $find = true; |
|
1954 | - break; |
|
1955 | - } |
|
1956 | - } |
|
1957 | - if ($find === false) { |
|
1958 | - $pall[] = $value; |
|
1959 | - } |
|
1960 | - } |
|
1961 | - $alldata = $pall; |
|
1944 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1945 | + foreach ($dall as $value) { |
|
1946 | + $icao = $value['arrival_airport_icao']; |
|
1947 | + $airline = $value['airline_icao']; |
|
1948 | + $ddate = $value['date']; |
|
1949 | + $find = false; |
|
1950 | + foreach ($pall as $pvalue) { |
|
1951 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1952 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1953 | + $find = true; |
|
1954 | + break; |
|
1955 | + } |
|
1956 | + } |
|
1957 | + if ($find === false) { |
|
1958 | + $pall[] = $value; |
|
1959 | + } |
|
1960 | + } |
|
1961 | + $alldata = $pall; |
|
1962 | 1962 | foreach ($alldata as $number) { |
1963 | 1963 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
1964 | 1964 | } |
@@ -2043,44 +2043,44 @@ discard block |
||
2043 | 2043 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
2044 | 2044 | } |
2045 | 2045 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
2046 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
2047 | - $alldata = array(); |
|
2048 | - foreach ($pall as $value) { |
|
2049 | - $icao = $value['airport_departure_icao']; |
|
2050 | - $alldata[$icao] = $value; |
|
2051 | - } |
|
2052 | - foreach ($dall as $value) { |
|
2053 | - $icao = $value['airport_departure_icao']; |
|
2054 | - if (isset($alldata[$icao])) { |
|
2055 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
2056 | - } else $alldata[$icao] = $value; |
|
2057 | - } |
|
2058 | - $count = array(); |
|
2059 | - foreach ($alldata as $key => $row) { |
|
2060 | - $count[$key] = $row['airport_departure_icao_count']; |
|
2061 | - } |
|
2046 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
2047 | + $alldata = array(); |
|
2048 | + foreach ($pall as $value) { |
|
2049 | + $icao = $value['airport_departure_icao']; |
|
2050 | + $alldata[$icao] = $value; |
|
2051 | + } |
|
2052 | + foreach ($dall as $value) { |
|
2053 | + $icao = $value['airport_departure_icao']; |
|
2054 | + if (isset($alldata[$icao])) { |
|
2055 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
2056 | + } else $alldata[$icao] = $value; |
|
2057 | + } |
|
2058 | + $count = array(); |
|
2059 | + foreach ($alldata as $key => $row) { |
|
2060 | + $count[$key] = $row['airport_departure_icao_count']; |
|
2061 | + } |
|
2062 | 2062 | array_multisort($count,SORT_DESC,$alldata); |
2063 | 2063 | foreach ($alldata as $number) { |
2064 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
|
2064 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
|
2065 | 2065 | } |
2066 | 2066 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
2067 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
2067 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
2068 | 2068 | $alldata = array(); |
2069 | - foreach ($pall as $value) { |
|
2070 | - $icao = $value['airport_arrival_icao']; |
|
2071 | - $alldata[$icao] = $value; |
|
2072 | - } |
|
2073 | - foreach ($dall as $value) { |
|
2074 | - $icao = $value['airport_arrival_icao']; |
|
2075 | - if (isset($alldata[$icao])) { |
|
2076 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
2077 | - } else $alldata[$icao] = $value; |
|
2078 | - } |
|
2079 | - $count = array(); |
|
2080 | - foreach ($alldata as $key => $row) { |
|
2081 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
2082 | - } |
|
2083 | - array_multisort($count,SORT_DESC,$alldata); |
|
2069 | + foreach ($pall as $value) { |
|
2070 | + $icao = $value['airport_arrival_icao']; |
|
2071 | + $alldata[$icao] = $value; |
|
2072 | + } |
|
2073 | + foreach ($dall as $value) { |
|
2074 | + $icao = $value['airport_arrival_icao']; |
|
2075 | + if (isset($alldata[$icao])) { |
|
2076 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
2077 | + } else $alldata[$icao] = $value; |
|
2078 | + } |
|
2079 | + $count = array(); |
|
2080 | + foreach ($alldata as $key => $row) { |
|
2081 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
2082 | + } |
|
2083 | + array_multisort($count,SORT_DESC,$alldata); |
|
2084 | 2084 | foreach ($alldata as $number) { |
2085 | 2085 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
2086 | 2086 | } |
@@ -2113,45 +2113,45 @@ discard block |
||
2113 | 2113 | } |
2114 | 2114 | echo '...Departure'."\n"; |
2115 | 2115 | $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
2116 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
2116 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
2117 | 2117 | foreach ($dall as $value) { |
2118 | - $icao = $value['departure_airport_icao']; |
|
2119 | - $ddate = $value['date']; |
|
2120 | - $find = false; |
|
2121 | - foreach ($pall as $pvalue) { |
|
2122 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
2123 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
2124 | - $find = true; |
|
2125 | - break; |
|
2126 | - } |
|
2127 | - } |
|
2128 | - if ($find === false) { |
|
2129 | - $pall[] = $value; |
|
2130 | - } |
|
2131 | - } |
|
2132 | - $alldata = $pall; |
|
2118 | + $icao = $value['departure_airport_icao']; |
|
2119 | + $ddate = $value['date']; |
|
2120 | + $find = false; |
|
2121 | + foreach ($pall as $pvalue) { |
|
2122 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
2123 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
2124 | + $find = true; |
|
2125 | + break; |
|
2126 | + } |
|
2127 | + } |
|
2128 | + if ($find === false) { |
|
2129 | + $pall[] = $value; |
|
2130 | + } |
|
2131 | + } |
|
2132 | + $alldata = $pall; |
|
2133 | 2133 | foreach ($alldata as $number) { |
2134 | 2134 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
2135 | 2135 | } |
2136 | 2136 | echo '...Arrival'."\n"; |
2137 | 2137 | $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
2138 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
2138 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
2139 | 2139 | foreach ($dall as $value) { |
2140 | 2140 | $icao = $value['arrival_airport_icao']; |
2141 | 2141 | $ddate = $value['date']; |
2142 | - $find = false; |
|
2142 | + $find = false; |
|
2143 | 2143 | foreach ($pall as $pvalue) { |
2144 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
2145 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
2146 | - $find = true; |
|
2147 | - break; |
|
2148 | - } |
|
2149 | - } |
|
2150 | - if ($find === false) { |
|
2151 | - $pall[] = $value; |
|
2152 | - } |
|
2153 | - } |
|
2154 | - $alldata = $pall; |
|
2144 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
2145 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
2146 | + $find = true; |
|
2147 | + break; |
|
2148 | + } |
|
2149 | + } |
|
2150 | + if ($find === false) { |
|
2151 | + $pall[] = $value; |
|
2152 | + } |
|
2153 | + } |
|
2154 | + $alldata = $pall; |
|
2155 | 2155 | foreach ($alldata as $number) { |
2156 | 2156 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
2157 | 2157 | } |