@@ -8,29 +8,29 @@ discard block |
||
8 | 8 | |
9 | 9 | class Schedule { |
10 | 10 | protected $cookies = array(); |
11 | - public $db; |
|
11 | + public $db; |
|
12 | 12 | public function __construct($dbc = null) { |
13 | 13 | $Connection = new Connection($dbc); |
14 | 14 | $this->db = $Connection->db(); |
15 | - } |
|
15 | + } |
|
16 | 16 | |
17 | 17 | /** |
18 | - * Add schedule data to database |
|
19 | - * @param String $ident aircraft ident |
|
20 | - * @param String $departure_airport_icao departure airport icao |
|
21 | - * @param String $departure_airport_time departure airport time |
|
22 | - * @param String $arrival_airport_icao arrival airport icao |
|
23 | - * @param String $arrival_airport_time arrival airport time |
|
18 | + * Add schedule data to database |
|
19 | + * @param String $ident aircraft ident |
|
20 | + * @param String $departure_airport_icao departure airport icao |
|
21 | + * @param String $departure_airport_time departure airport time |
|
22 | + * @param String $arrival_airport_icao arrival airport icao |
|
23 | + * @param String $arrival_airport_time arrival airport time |
|
24 | 24 | / @param String $source source of data |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
28 | 28 | date_default_timezone_set('UTC'); |
29 | 29 | $date = date("Y-m-d H:i:s",time()); |
30 | - //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
|
31 | - //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
|
32 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
|
33 | - $query_values = array(':ident' => $ident); |
|
30 | + //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
|
31 | + //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
|
32 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
|
33 | + $query_values = array(':ident' => $ident); |
|
34 | 34 | try { |
35 | 35 | $sth = $this->db->prepare($query); |
36 | 36 | $sth->execute($query_values); |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | } |
40 | 40 | if ($sth->fetchColumn() > 0) { |
41 | 41 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
42 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
43 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
42 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
43 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
44 | 44 | } elseif ($arrival_airport_time == '') { |
45 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
|
46 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
45 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
|
46 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
47 | 47 | } elseif ($departure_airport_time == '') { |
48 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
49 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
48 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
49 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
50 | 50 | } else { |
51 | - //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
|
52 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
53 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
51 | + //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
|
52 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
53 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
54 | 54 | } |
55 | 55 | try { |
56 | 56 | $sth = $this->db->prepare($query); |
@@ -61,17 +61,17 @@ discard block |
||
61 | 61 | if ($sth->fetchColumn() == 0) { |
62 | 62 | //$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident'; |
63 | 63 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
64 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
65 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
64 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
65 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
66 | 66 | } elseif ($arrival_airport_time == '') { |
67 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
68 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
67 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
68 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
69 | 69 | } elseif ($departure_airport_time == '') { |
70 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
71 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
70 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
71 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
72 | 72 | } else { |
73 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
74 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
73 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
74 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
75 | 75 | } |
76 | 76 | try { |
77 | 77 | $sth = $this->db->prepare($query); |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | public function getSchedule($ident) { |
107 | - $Translation = new Translation($this->db); |
|
108 | - $operator = $Translation->checkTranslation($ident,false); |
|
109 | - if ($ident != $operator) { |
|
110 | - $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1"; |
|
111 | - $query_values = array(':ident' => $ident,'operator' => $operator); |
|
112 | - } else { |
|
113 | - $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1"; |
|
114 | - $query_values = array(':ident' => $ident); |
|
115 | - } |
|
107 | + $Translation = new Translation($this->db); |
|
108 | + $operator = $Translation->checkTranslation($ident,false); |
|
109 | + if ($ident != $operator) { |
|
110 | + $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1"; |
|
111 | + $query_values = array(':ident' => $ident,'operator' => $operator); |
|
112 | + } else { |
|
113 | + $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1"; |
|
114 | + $query_values = array(':ident' => $ident); |
|
115 | + } |
|
116 | 116 | try { |
117 | 117 | $sth = $this->db->prepare($query); |
118 | 118 | $sth->execute($query_values); |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | |
129 | 129 | public function checkSchedule($ident) { |
130 | 130 | global $globalDBdriver; |
131 | - //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
132 | - if ($globalDBdriver == 'mysql') { |
|
131 | + //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
132 | + if ($globalDBdriver == 'mysql') { |
|
133 | 133 | $query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1"; |
134 | 134 | } else { |
135 | 135 | $query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident |
136 | 136 | AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL) |
137 | 137 | OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1"; |
138 | 138 | } |
139 | - $query_values = array(':ident' => $ident); |
|
139 | + $query_values = array(':ident' => $ident); |
|
140 | 140 | try { |
141 | 141 | $sth = $this->db->prepare($query); |
142 | 142 | $sth->execute($query_values); |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
152 | - * Get flight info from Air France |
|
153 | - * @param String $callsign The callsign |
|
154 | - * @param String $date date we want flight number info |
|
155 | - * @param String $carrier IATA code |
|
156 | - * @return Flight departure and arrival airports and time |
|
157 | - */ |
|
152 | + * Get flight info from Air France |
|
153 | + * @param String $callsign The callsign |
|
154 | + * @param String $date date we want flight number info |
|
155 | + * @param String $carrier IATA code |
|
156 | + * @return Flight departure and arrival airports and time |
|
157 | + */ |
|
158 | 158 | private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
159 | 159 | $Common = new Common(); |
160 | 160 | $check_date = new Datetime($date); |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
193 | - * Get flight info from EasyJet |
|
194 | - * @param String $callsign The callsign |
|
195 | - * @param String $date date we want flight number info |
|
196 | - * @return Flight departure and arrival airports and time |
|
197 | - */ |
|
193 | + * Get flight info from EasyJet |
|
194 | + * @param String $callsign The callsign |
|
195 | + * @param String $date date we want flight number info |
|
196 | + * @return Flight departure and arrival airports and time |
|
197 | + */ |
|
198 | 198 | private function getEasyJet($callsign, $date = 'NOW') { |
199 | 199 | global $globalTimezone; |
200 | 200 | $Common = new Common(); |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
221 | - * Get flight info from Ryanair |
|
222 | - * @param String $callsign The callsign |
|
223 | - * @return Flight departure and arrival airports and time |
|
224 | - */ |
|
221 | + * Get flight info from Ryanair |
|
222 | + * @param String $callsign The callsign |
|
223 | + * @return Flight departure and arrival airports and time |
|
224 | + */ |
|
225 | 225 | private function getRyanair($callsign) { |
226 | 226 | $Common = new Common(); |
227 | 227 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
247 | - * Get flight info from Swiss |
|
248 | - * @param String $callsign The callsign |
|
249 | - * @return Flight departure and arrival airports and time |
|
250 | - */ |
|
247 | + * Get flight info from Swiss |
|
248 | + * @param String $callsign The callsign |
|
249 | + * @return Flight departure and arrival airports and time |
|
250 | + */ |
|
251 | 251 | private function getSwiss($callsign) { |
252 | 252 | $Common = new Common(); |
253 | 253 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
279 | - * Get flight info from British Airways API |
|
280 | - * @param String $callsign The callsign |
|
281 | - * @param String $date date we want flight number info |
|
282 | - * @return Flight departure and arrival airports and time |
|
283 | - */ |
|
279 | + * Get flight info from British Airways API |
|
280 | + * @param String $callsign The callsign |
|
281 | + * @param String $date date we want flight number info |
|
282 | + * @return Flight departure and arrival airports and time |
|
283 | + */ |
|
284 | 284 | public function getBritishAirways($callsign, $date = 'NOW') { |
285 | 285 | global $globalBritishAirwaysKey; |
286 | 286 | $Common = new Common(); |
@@ -304,11 +304,11 @@ discard block |
||
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
307 | - * Get flight info from Lutfhansa API |
|
308 | - * @param String $callsign The callsign |
|
309 | - * @param String $date date we want flight number info |
|
310 | - * @return Flight departure and arrival airports and time |
|
311 | - */ |
|
307 | + * Get flight info from Lutfhansa API |
|
308 | + * @param String $callsign The callsign |
|
309 | + * @param String $date date we want flight number info |
|
310 | + * @return Flight departure and arrival airports and time |
|
311 | + */ |
|
312 | 312 | public function getLufthansa($callsign, $date = 'NOW') { |
313 | 313 | global $globalLufthansaKey; |
314 | 314 | $Common = new Common(); |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
341 | - * Get flight info from Transavia API |
|
342 | - * @param String $callsign The callsign |
|
343 | - * @param String $date date we want flight number info |
|
344 | - * @return Flight departure and arrival airports and time |
|
345 | - */ |
|
341 | + * Get flight info from Transavia API |
|
342 | + * @param String $callsign The callsign |
|
343 | + * @param String $date date we want flight number info |
|
344 | + * @return Flight departure and arrival airports and time |
|
345 | + */ |
|
346 | 346 | public function getTransavia($callsign, $date = 'NOW') { |
347 | 347 | global $globalTransaviaKey; |
348 | 348 | $Common = new Common(); |
@@ -368,10 +368,10 @@ discard block |
||
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
371 | - * Get flight info from Tunisair |
|
372 | - * @param String $callsign The callsign |
|
373 | - * @return Flight departure and arrival airports and time |
|
374 | - */ |
|
371 | + * Get flight info from Tunisair |
|
372 | + * @param String $callsign The callsign |
|
373 | + * @return Flight departure and arrival airports and time |
|
374 | + */ |
|
375 | 375 | public function getTunisair($callsign) { |
376 | 376 | $Common = new Common(); |
377 | 377 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -388,10 +388,10 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
391 | - * Get flight info from Vueling |
|
392 | - * @param String $callsign The callsign |
|
393 | - * @return Flight departure and arrival airports and time |
|
394 | - */ |
|
391 | + * Get flight info from Vueling |
|
392 | + * @param String $callsign The callsign |
|
393 | + * @return Flight departure and arrival airports and time |
|
394 | + */ |
|
395 | 395 | public function getVueling($callsign,$date = 'NOW') { |
396 | 396 | $Common = new Common(); |
397 | 397 | $check_date = new Datetime($date); |
@@ -413,11 +413,11 @@ discard block |
||
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
416 | - * Get flight info from Iberia |
|
417 | - * @param String $callsign The callsign |
|
418 | - * @param String $date date we want flight number info |
|
419 | - * @return Flight departure and arrival airports and time |
|
420 | - */ |
|
416 | + * Get flight info from Iberia |
|
417 | + * @param String $callsign The callsign |
|
418 | + * @param String $date date we want flight number info |
|
419 | + * @return Flight departure and arrival airports and time |
|
420 | + */ |
|
421 | 421 | public function getIberia($callsign, $date = 'NOW') { |
422 | 422 | $Common = new Common(); |
423 | 423 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -447,11 +447,11 @@ discard block |
||
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
450 | - * Get flight info from Star Alliance |
|
451 | - * @param String $callsign The callsign |
|
452 | - * @param String $date date we want flight number info |
|
453 | - * @return Flight departure and arrival airports and time |
|
454 | - */ |
|
450 | + * Get flight info from Star Alliance |
|
451 | + * @param String $callsign The callsign |
|
452 | + * @param String $date date we want flight number info |
|
453 | + * @return Flight departure and arrival airports and time |
|
454 | + */ |
|
455 | 455 | |
456 | 456 | private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
457 | 457 | $Common = new Common(); |
@@ -483,11 +483,11 @@ discard block |
||
483 | 483 | |
484 | 484 | |
485 | 485 | /** |
486 | - * Get flight info from Alitalia |
|
487 | - * @param String $callsign The callsign |
|
488 | - * @param String $date date we want flight number info |
|
489 | - * @return Flight departure and arrival airports and time |
|
490 | - */ |
|
486 | + * Get flight info from Alitalia |
|
487 | + * @param String $callsign The callsign |
|
488 | + * @param String $date date we want flight number info |
|
489 | + * @return Flight departure and arrival airports and time |
|
490 | + */ |
|
491 | 491 | private function getAlitalia($callsign, $date = 'NOW') { |
492 | 492 | $Common = new Common(); |
493 | 493 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -506,11 +506,11 @@ discard block |
||
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
509 | - * Get flight info from Brussels airlines |
|
510 | - * @param String $callsign The callsign |
|
511 | - * @param String $date date we want flight number info |
|
512 | - * @return Flight departure and arrival airports and time |
|
513 | - */ |
|
509 | + * Get flight info from Brussels airlines |
|
510 | + * @param String $callsign The callsign |
|
511 | + * @param String $date date we want flight number info |
|
512 | + * @return Flight departure and arrival airports and time |
|
513 | + */ |
|
514 | 514 | private function getBrussels($callsign, $date = 'NOW') { |
515 | 515 | $Common = new Common(); |
516 | 516 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -520,24 +520,24 @@ discard block |
||
520 | 520 | if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
521 | 521 | $data = $Common->getData($url); |
522 | 522 | if ($data != '') { |
523 | - //echo $data; |
|
524 | - $parsed_json = json_decode($data,true); |
|
525 | - if (isset($parsed_json[0]['FromAirportCode'])) { |
|
523 | + //echo $data; |
|
524 | + $parsed_json = json_decode($data,true); |
|
525 | + if (isset($parsed_json[0]['FromAirportCode'])) { |
|
526 | 526 | $DepartureAirportIata = $parsed_json[0]['FromAirportCode']; |
527 | 527 | $ArrivalAirportIata = $parsed_json[0]['ToAirportCode']; |
528 | 528 | $departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
529 | 529 | $arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
530 | 530 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
531 | - } |
|
531 | + } |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
536 | - * Get flight info from FlightRadar24 |
|
537 | - * @param String $callsign The callsign |
|
538 | - * @param String $date date we want flight number info |
|
539 | - * @return Flight departure and arrival airports and time |
|
540 | - */ |
|
536 | + * Get flight info from FlightRadar24 |
|
537 | + * @param String $callsign The callsign |
|
538 | + * @param String $date date we want flight number info |
|
539 | + * @return Flight departure and arrival airports and time |
|
540 | + */ |
|
541 | 541 | /* |
542 | 542 | public function getFlightRadar24($callsign, $date = 'NOW') { |
543 | 543 | $Common = new Common(); |
@@ -566,11 +566,11 @@ discard block |
||
566 | 566 | } |
567 | 567 | */ |
568 | 568 | /** |
569 | - * Get flight info from Lufthansa |
|
570 | - * @param String $callsign The callsign |
|
571 | - * @param String $date date we want flight number info |
|
572 | - * @return Flight departure and arrival airports and time |
|
573 | - */ |
|
569 | + * Get flight info from Lufthansa |
|
570 | + * @param String $callsign The callsign |
|
571 | + * @param String $date date we want flight number info |
|
572 | + * @return Flight departure and arrival airports and time |
|
573 | + */ |
|
574 | 574 | |
575 | 575 | /* private function getLufthansa($callsign, $date = 'NOW') { |
576 | 576 | $Common = new Common(); |
@@ -598,10 +598,10 @@ discard block |
||
598 | 598 | } |
599 | 599 | */ |
600 | 600 | /** |
601 | - * Get flight info from flytap |
|
602 | - * @param String $callsign The callsign |
|
603 | - * @return Flight departure and arrival airports and time |
|
604 | - */ |
|
601 | + * Get flight info from flytap |
|
602 | + * @param String $callsign The callsign |
|
603 | + * @return Flight departure and arrival airports and time |
|
604 | + */ |
|
605 | 605 | private function getFlyTap($callsign) { |
606 | 606 | $Common = new Common(); |
607 | 607 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -624,10 +624,10 @@ discard block |
||
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
627 | - * Get flight info from flightmapper |
|
628 | - * @param String $callsign The callsign |
|
629 | - * @return Flight departure and arrival airports and time |
|
630 | - */ |
|
627 | + * Get flight info from flightmapper |
|
628 | + * @param String $callsign The callsign |
|
629 | + * @return Flight departure and arrival airports and time |
|
630 | + */ |
|
631 | 631 | public function getFlightMapper($callsign) { |
632 | 632 | $Common = new Common(); |
633 | 633 | $airline_icao = ''; |
@@ -655,11 +655,11 @@ discard block |
||
655 | 655 | $aarr = ''; |
656 | 656 | $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
657 | 657 | if ($n == 7) { |
658 | - $departureTime = $dhour; |
|
659 | - $arrivalTime = $ahour; |
|
660 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
661 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
662 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
658 | + $departureTime = $dhour; |
|
659 | + $arrivalTime = $ahour; |
|
660 | + $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
661 | + $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
662 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
663 | 663 | } |
664 | 664 | } |
665 | 665 | } |
@@ -667,10 +667,10 @@ discard block |
||
667 | 667 | } |
668 | 668 | |
669 | 669 | /** |
670 | - * Get flight info from flightaware |
|
671 | - * @param String $callsign The callsign |
|
672 | - * @return Flight departure and arrival airports and time |
|
673 | - */ |
|
670 | + * Get flight info from flightaware |
|
671 | + * @param String $callsign The callsign |
|
672 | + * @return Flight departure and arrival airports and time |
|
673 | + */ |
|
674 | 674 | public function getFlightAware($callsign) { |
675 | 675 | $Common = new Common(); |
676 | 676 | /* |
@@ -703,10 +703,10 @@ discard block |
||
703 | 703 | } |
704 | 704 | |
705 | 705 | /** |
706 | - * Get flight info from CostToTravel |
|
707 | - * @param String $callsign The callsign |
|
708 | - * @return Flight departure and arrival airports and time |
|
709 | - */ |
|
706 | + * Get flight info from CostToTravel |
|
707 | + * @param String $callsign The callsign |
|
708 | + * @return Flight departure and arrival airports and time |
|
709 | + */ |
|
710 | 710 | public function getCostToTravel($callsign) { |
711 | 711 | $Common = new Common(); |
712 | 712 | $url= "http://www.costtotravel.com/flight-number/".$callsign; |
@@ -728,11 +728,11 @@ discard block |
||
728 | 728 | } |
729 | 729 | |
730 | 730 | /** |
731 | - * Get flight info from Air Canada |
|
732 | - * @param String $callsign The callsign |
|
733 | - * @param String $date date we want flight number info |
|
734 | - * @return Flight departure and arrival airports and time |
|
735 | - */ |
|
731 | + * Get flight info from Air Canada |
|
732 | + * @param String $callsign The callsign |
|
733 | + * @param String $date date we want flight number info |
|
734 | + * @return Flight departure and arrival airports and time |
|
735 | + */ |
|
736 | 736 | private function getAirCanada($callsign,$date = 'NOW') { |
737 | 737 | $Common = new Common(); |
738 | 738 | date_default_timezone_set('UTC'); |
@@ -756,11 +756,11 @@ discard block |
||
756 | 756 | } |
757 | 757 | |
758 | 758 | /** |
759 | - * Get flight info from Vietnam Airlines |
|
760 | - * @param String $callsign The callsign |
|
761 | - * @param String $date date we want flight number info |
|
762 | - * @return Flight departure and arrival airports and time |
|
763 | - */ |
|
759 | + * Get flight info from Vietnam Airlines |
|
760 | + * @param String $callsign The callsign |
|
761 | + * @param String $date date we want flight number info |
|
762 | + * @return Flight departure and arrival airports and time |
|
763 | + */ |
|
764 | 764 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
765 | 765 | $Common = new Common(); |
766 | 766 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -782,12 +782,12 @@ discard block |
||
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
785 | - * Get flight info from Air Berlin |
|
786 | - * @param String $callsign The callsign |
|
787 | - * @param String $date date we want flight number info |
|
788 | - * @param String $carrier airline code |
|
789 | - * @return Flight departure and arrival airports and time |
|
790 | - */ |
|
785 | + * Get flight info from Air Berlin |
|
786 | + * @param String $callsign The callsign |
|
787 | + * @param String $date date we want flight number info |
|
788 | + * @param String $carrier airline code |
|
789 | + * @return Flight departure and arrival airports and time |
|
790 | + */ |
|
791 | 791 | private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
792 | 792 | $Common = new Common(); |
793 | 793 | date_default_timezone_set('UTC'); |
@@ -816,11 +816,11 @@ discard block |
||
816 | 816 | $table = $Common->table2array($data); |
817 | 817 | $flight = $table; |
818 | 818 | if (isset($flight[5][4])) { |
819 | - $arrivalTime = $flight[5][4]; |
|
820 | - $arrivalAirport = $flight[5][3]; |
|
819 | + $arrivalTime = $flight[5][4]; |
|
820 | + $arrivalAirport = $flight[5][3]; |
|
821 | 821 | } else { |
822 | - $arrivalTime = ''; |
|
823 | - $arrivalAirport = ''; |
|
822 | + $arrivalTime = ''; |
|
823 | + $arrivalAirport = ''; |
|
824 | 824 | } |
825 | 825 | } else return array(); |
826 | 826 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | } |
1089 | 1089 | } |
1090 | 1090 | } |
1091 | - return array(); |
|
1091 | + return array(); |
|
1092 | 1092 | } |
1093 | 1093 | } |
1094 | 1094 |
@@ -9,16 +9,16 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | |
11 | 11 | class SpotterImport { |
12 | - private $all_flights = array(); |
|
13 | - private $last_delete_hourly = 0; |
|
14 | - private $last_delete = 0; |
|
15 | - private $stats = array(); |
|
16 | - private $tmd = 0; |
|
17 | - private $source_location = array(); |
|
18 | - public $db = null; |
|
19 | - public $nb = 0; |
|
20 | - |
|
21 | - public function __construct($dbc = null) { |
|
12 | + private $all_flights = array(); |
|
13 | + private $last_delete_hourly = 0; |
|
14 | + private $last_delete = 0; |
|
15 | + private $stats = array(); |
|
16 | + private $tmd = 0; |
|
17 | + private $source_location = array(); |
|
18 | + public $db = null; |
|
19 | + public $nb = 0; |
|
20 | + |
|
21 | + public function __construct($dbc = null) { |
|
22 | 22 | global $globalBeta; |
23 | 23 | $Connection = new Connection($dbc); |
24 | 24 | $this->db = $Connection->db(); |
@@ -29,18 +29,18 @@ discard block |
||
29 | 29 | $currentdate = date('Y-m-d'); |
30 | 30 | $sourcestat = $Stats->getStatsSource($currentdate); |
31 | 31 | if (!empty($sourcestat)) { |
32 | - foreach($sourcestat as $srcst) { |
|
33 | - $type = $srcst['stats_type']; |
|
32 | + foreach($sourcestat as $srcst) { |
|
33 | + $type = $srcst['stats_type']; |
|
34 | 34 | if ($type == 'polar' || $type == 'hist') { |
35 | - $source = $srcst['source_name']; |
|
36 | - $data = $srcst['source_data']; |
|
37 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
38 | - } |
|
39 | - } |
|
35 | + $source = $srcst['source_name']; |
|
36 | + $data = $srcst['source_data']; |
|
37 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
38 | + } |
|
39 | + } |
|
40 | + } |
|
40 | 41 | } |
41 | - } |
|
42 | 42 | |
43 | - public function get_Schedule($id,$ident) { |
|
43 | + public function get_Schedule($id,$ident) { |
|
44 | 44 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
45 | 45 | // Get schedule here, so it's done only one time |
46 | 46 | |
@@ -60,42 +60,42 @@ discard block |
||
60 | 60 | $operator = $Spotter->getOperator($ident); |
61 | 61 | $scheduleexist = false; |
62 | 62 | if ($Schedule->checkSchedule($operator) == 0) { |
63 | - $operator = $Translation->checkTranslation($ident); |
|
64 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
63 | + $operator = $Translation->checkTranslation($ident); |
|
64 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
65 | 65 | $schedule = $Schedule->fetchSchedule($operator); |
66 | 66 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
67 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
68 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
69 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
70 | - // Should also check if route schedule = route from DB |
|
71 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
67 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
68 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
69 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
70 | + // Should also check if route schedule = route from DB |
|
71 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
72 | 72 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
73 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
74 | - if (trim($airport_icao) != '') { |
|
73 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
74 | + if (trim($airport_icao) != '') { |
|
75 | 75 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
76 | 76 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
77 | - } |
|
77 | + } |
|
78 | + } |
|
78 | 79 | } |
79 | - } |
|
80 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
80 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
81 | 81 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
82 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
83 | - if (trim($airport_icao) != '') { |
|
82 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
83 | + if (trim($airport_icao) != '') { |
|
84 | 84 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
85 | 85 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
86 | - } |
|
86 | + } |
|
87 | + } |
|
87 | 88 | } |
88 | - } |
|
89 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
89 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
90 | 90 | } |
91 | - } else $scheduleexist = true; |
|
91 | + } else $scheduleexist = true; |
|
92 | 92 | } else $scheduleexist = true; |
93 | 93 | // close connection, at least one way will work ? |
94 | - if ($scheduleexist) { |
|
94 | + if ($scheduleexist) { |
|
95 | 95 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
96 | - $sch = $Schedule->getSchedule($operator); |
|
96 | + $sch = $Schedule->getSchedule($operator); |
|
97 | 97 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
98 | - } |
|
98 | + } |
|
99 | 99 | $Spotter->db = null; |
100 | 100 | $Schedule->db = null; |
101 | 101 | $Translation->db = null; |
@@ -110,92 +110,92 @@ discard block |
||
110 | 110 | } |
111 | 111 | */ |
112 | 112 | } |
113 | - } |
|
113 | + } |
|
114 | 114 | |
115 | - public function checkAll() { |
|
115 | + public function checkAll() { |
|
116 | 116 | global $globalDebug; |
117 | 117 | if ($globalDebug) echo "Update last seen flights data...\n"; |
118 | 118 | foreach ($this->all_flights as $key => $flight) { |
119 | - if (isset($this->all_flights[$key]['id'])) { |
|
119 | + if (isset($this->all_flights[$key]['id'])) { |
|
120 | 120 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
121 | - $Spotter = new Spotter($this->db); |
|
122 | - $real_arrival = $this->arrival($key); |
|
123 | - $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
124 | - } |
|
121 | + $Spotter = new Spotter($this->db); |
|
122 | + $real_arrival = $this->arrival($key); |
|
123 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
124 | + } |
|
125 | + } |
|
125 | 126 | } |
126 | - } |
|
127 | 127 | |
128 | - public function arrival($key) { |
|
128 | + public function arrival($key) { |
|
129 | 129 | global $globalClosestMinDist, $globalDebug; |
130 | 130 | if ($globalDebug) echo 'Update arrival...'."\n"; |
131 | 131 | $Spotter = new Spotter($this->db); |
132 | - $airport_icao = ''; |
|
133 | - $airport_time = ''; |
|
134 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
132 | + $airport_icao = ''; |
|
133 | + $airport_time = ''; |
|
134 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
135 | 135 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
136 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
137 | - if (isset($closestAirports[0])) { |
|
138 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
139 | - $airport_icao = $closestAirports[0]['icao']; |
|
140 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
141 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
142 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
143 | - foreach ($closestAirports as $airport) { |
|
144 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
145 | - $airport_icao = $airport['icao']; |
|
146 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
147 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
148 | - break; |
|
149 | - } |
|
150 | - } |
|
151 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
152 | - $airport_icao = $closestAirports[0]['icao']; |
|
153 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
154 | - } else { |
|
155 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
156 | - } |
|
157 | - } else { |
|
158 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
159 | - } |
|
160 | - |
|
161 | - } else { |
|
162 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
163 | - } |
|
164 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - |
|
169 | - public function del() { |
|
136 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
137 | + if (isset($closestAirports[0])) { |
|
138 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
139 | + $airport_icao = $closestAirports[0]['icao']; |
|
140 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
141 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
142 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
143 | + foreach ($closestAirports as $airport) { |
|
144 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
145 | + $airport_icao = $airport['icao']; |
|
146 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
147 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
148 | + break; |
|
149 | + } |
|
150 | + } |
|
151 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
152 | + $airport_icao = $closestAirports[0]['icao']; |
|
153 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
154 | + } else { |
|
155 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
156 | + } |
|
157 | + } else { |
|
158 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
159 | + } |
|
160 | + |
|
161 | + } else { |
|
162 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
163 | + } |
|
164 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + |
|
169 | + public function del() { |
|
170 | 170 | global $globalDebug; |
171 | 171 | // Delete old infos |
172 | 172 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
173 | 173 | foreach ($this->all_flights as $key => $flight) { |
174 | - if (isset($flight['lastupdate'])) { |
|
175 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
176 | - if (isset($this->all_flights[$key]['id'])) { |
|
177 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
174 | + if (isset($flight['lastupdate'])) { |
|
175 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
176 | + if (isset($this->all_flights[$key]['id'])) { |
|
177 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
178 | 178 | /* |
179 | 179 | $SpotterLive = new SpotterLive(); |
180 | 180 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
181 | 181 | $SpotterLive->db = null; |
182 | 182 | */ |
183 | - $real_arrival = $this->arrival($key); |
|
184 | - $Spotter = new Spotter($this->db); |
|
185 | - if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
183 | + $real_arrival = $this->arrival($key); |
|
184 | + $Spotter = new Spotter($this->db); |
|
185 | + if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
186 | 186 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
187 | 187 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
188 | 188 | } |
189 | 189 | // Put in archive |
190 | 190 | // $Spotter->db = null; |
191 | - } |
|
192 | - unset($this->all_flights[$key]); |
|
193 | - } |
|
194 | - } |
|
195 | - } |
|
196 | - } |
|
197 | - |
|
198 | - public function add($line) { |
|
191 | + } |
|
192 | + unset($this->all_flights[$key]); |
|
193 | + } |
|
194 | + } |
|
195 | + } |
|
196 | + } |
|
197 | + |
|
198 | + public function add($line) { |
|
199 | 199 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights; |
200 | 200 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
201 | 201 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
@@ -220,18 +220,18 @@ discard block |
||
220 | 220 | |
221 | 221 | // SBS format is CSV format |
222 | 222 | if(is_array($line) && isset($line['hex'])) { |
223 | - //print_r($line); |
|
224 | - if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) { |
|
223 | + //print_r($line); |
|
224 | + if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) { |
|
225 | 225 | |
226 | 226 | // Increment message number |
227 | 227 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
228 | - $current_date = date('Y-m-d'); |
|
229 | - $source = $line['source_name']; |
|
230 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
231 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
232 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
233 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
234 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
228 | + $current_date = date('Y-m-d'); |
|
229 | + $source = $line['source_name']; |
|
230 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
231 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
232 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
233 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
234 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /* |
@@ -247,17 +247,17 @@ discard block |
||
247 | 247 | //$this->db = $dbc; |
248 | 248 | |
249 | 249 | $hex = trim($line['hex']); |
250 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
251 | - else $id = trim($line['id']); |
|
250 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
251 | + else $id = trim($line['id']); |
|
252 | 252 | |
253 | 253 | //print_r($this->all_flights); |
254 | 254 | if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) { |
255 | - $this->all_flights[$id] = array('hex' => $hex); |
|
256 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
257 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
255 | + $this->all_flights[$id] = array('hex' => $hex); |
|
256 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
257 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
258 | 258 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
259 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
260 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) { |
|
259 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
260 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) { |
|
261 | 261 | |
262 | 262 | $timeelapsed = microtime(true); |
263 | 263 | $Spotter = new Spotter($this->db); |
@@ -266,38 +266,38 @@ discard block |
||
266 | 266 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
267 | 267 | |
268 | 268 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
269 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
270 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
271 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
272 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
269 | + if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
270 | + elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
271 | + elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
272 | + elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
273 | 273 | } |
274 | 274 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
275 | - } else if (isset($line['aircraft_name'])) { |
|
275 | + } else if (isset($line['aircraft_name'])) { |
|
276 | 276 | // Get aircraft ICAO from aircraft name |
277 | 277 | $Spotter = new Spotter($this->db); |
278 | 278 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
279 | 279 | $Spotter->db = null; |
280 | 280 | if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
281 | 281 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
282 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
283 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
|
284 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
285 | - if (!isset($line['id'])) { |
|
282 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
283 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
|
284 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
285 | + if (!isset($line['id'])) { |
|
286 | 286 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
287 | 287 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
288 | 288 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
289 | 289 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
290 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
291 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
291 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
292 | 292 | |
293 | - if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
294 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
293 | + if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
294 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
298 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
298 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
299 | 299 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
300 | - } else { |
|
300 | + } else { |
|
301 | 301 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
302 | 302 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
303 | 303 | /* |
@@ -306,38 +306,38 @@ discard block |
||
306 | 306 | print_r($line); |
307 | 307 | */ |
308 | 308 | return ''; |
309 | - } |
|
309 | + } |
|
310 | 310 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
311 | 311 | |
312 | 312 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
313 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
313 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
314 | 314 | } |
315 | 315 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
316 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
316 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
317 | 317 | } |
318 | 318 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
319 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
319 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
320 | 320 | } |
321 | 321 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
322 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
322 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
326 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
327 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
326 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
327 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
328 | 328 | $timeelapsed = microtime(true); |
329 | - $Spotter = new Spotter($this->db); |
|
330 | - $fromsource = NULL; |
|
331 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
332 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
329 | + $Spotter = new Spotter($this->db); |
|
330 | + $fromsource = NULL; |
|
331 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
332 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
333 | 333 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
334 | 334 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
335 | 335 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
336 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
336 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
337 | 337 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
338 | 338 | $Spotter->db = null; |
339 | 339 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
340 | - } |
|
340 | + } |
|
341 | 341 | |
342 | 342 | /* |
343 | 343 | if (!isset($line['id'])) { |
@@ -347,26 +347,26 @@ discard block |
||
347 | 347 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
348 | 348 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
349 | 349 | */ |
350 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
350 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
351 | 351 | |
352 | - //$putinarchive = true; |
|
353 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
352 | + //$putinarchive = true; |
|
353 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
354 | 354 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
355 | - } |
|
356 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
355 | + } |
|
356 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
357 | 357 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
358 | - } |
|
359 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
360 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
361 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
358 | + } |
|
359 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
360 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
361 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
362 | 362 | $timeelapsed = microtime(true); |
363 | 363 | $Spotter = new Spotter($this->db); |
364 | 364 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
365 | 365 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
366 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
366 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
367 | 367 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
368 | 368 | |
369 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
369 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
370 | 370 | $timeelapsed = microtime(true); |
371 | 371 | $Spotter = new Spotter($this->db); |
372 | 372 | $route = $Spotter->getRouteInfo(trim($line['ident'])); |
@@ -380,43 +380,43 @@ discard block |
||
380 | 380 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
381 | 381 | |
382 | 382 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
383 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
384 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
383 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
384 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
385 | 385 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
386 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
387 | - } |
|
386 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
387 | + } |
|
388 | 388 | } |
389 | 389 | if (!isset($globalFork)) $globalFork = TRUE; |
390 | 390 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
391 | 391 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
392 | 392 | } |
393 | - } |
|
393 | + } |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | if (isset($line['speed']) && $line['speed'] != '') { |
397 | 397 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
398 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
399 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
400 | - //$dataFound = true; |
|
398 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
399 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
400 | + //$dataFound = true; |
|
401 | 401 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
402 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
403 | - if ($distance > 1000 && $distance < 10000) { |
|
404 | - // use datetime |
|
402 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
403 | + if ($distance > 1000 && $distance < 10000) { |
|
404 | + // use datetime |
|
405 | 405 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
406 | 406 | $speed = $speed*3.6; |
407 | 407 | if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
408 | 408 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
409 | - } |
|
409 | + } |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | |
413 | 413 | |
414 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
415 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
416 | - else unset($timediff); |
|
417 | - if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
414 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
415 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
416 | + else unset($timediff); |
|
417 | + if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
418 | 418 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
419 | - if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
419 | + if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
420 | 420 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
421 | 421 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
422 | 422 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -430,16 +430,16 @@ discard block |
||
430 | 430 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
431 | 431 | $this->tmd = 0; |
432 | 432 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
433 | - } |
|
433 | + } |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
437 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
437 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
438 | 438 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
439 | 439 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
440 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
441 | - $dataFound = true; |
|
442 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
440 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
441 | + $dataFound = true; |
|
442 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
443 | 443 | } |
444 | 444 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
445 | 445 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -450,20 +450,20 @@ discard block |
||
450 | 450 | //$putinarchive = true; |
451 | 451 | } |
452 | 452 | */ |
453 | - /* |
|
453 | + /* |
|
454 | 454 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
455 | 455 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
456 | 456 | } |
457 | 457 | */ |
458 | 458 | } |
459 | 459 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
460 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
461 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
460 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
461 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
462 | 462 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
463 | 463 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
464 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
465 | - $dataFound = true; |
|
466 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
464 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
465 | + $dataFound = true; |
|
466 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
467 | 467 | } |
468 | 468 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
469 | 469 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -481,53 +481,53 @@ discard block |
||
481 | 481 | */ |
482 | 482 | } |
483 | 483 | |
484 | - } else if ($globalDebug && $timediff > 20) { |
|
484 | + } else if ($globalDebug && $timediff > 20) { |
|
485 | 485 | $this->tmd = $this->tmd + 1; |
486 | 486 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
487 | 487 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
488 | 488 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
489 | 489 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
490 | - } |
|
490 | + } |
|
491 | 491 | } |
492 | 492 | if (isset($line['last_update']) && $line['last_update'] != '') { |
493 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
493 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
495 | 495 | } |
496 | 496 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
497 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
498 | - //$dataFound = true; |
|
497 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
498 | + //$dataFound = true; |
|
499 | 499 | } |
500 | 500 | if (isset($line['format_source']) && $line['format_source'] != '') { |
501 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
501 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
502 | 502 | } |
503 | 503 | if (isset($line['source_name']) && $line['source_name'] != '') { |
504 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
504 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
505 | 505 | } |
506 | 506 | if (isset($line['emergency']) && $line['emergency'] != '') { |
507 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
508 | - //$dataFound = true; |
|
507 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
508 | + //$dataFound = true; |
|
509 | 509 | } |
510 | 510 | if (isset($line['ground']) && $line['ground'] != '') { |
511 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
511 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
512 | 512 | // Here we force archive of flight because after ground it's a new one (or should be) |
513 | 513 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
514 | 514 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
515 | 515 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
516 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
516 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
517 | 517 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
518 | - } |
|
519 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
520 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
521 | - //$dataFound = true; |
|
518 | + } |
|
519 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
520 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
521 | + //$dataFound = true; |
|
522 | 522 | } |
523 | 523 | if (isset($line['squawk']) && $line['squawk'] != '') { |
524 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
525 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
526 | - $highlight = ''; |
|
527 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
528 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
529 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
530 | - if ($highlight != '') { |
|
524 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
525 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
526 | + $highlight = ''; |
|
527 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
528 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
529 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
530 | + if ($highlight != '') { |
|
531 | 531 | $timeelapsed = microtime(true); |
532 | 532 | $Spotter = new Spotter($this->db); |
533 | 533 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
@@ -537,38 +537,38 @@ discard block |
||
537 | 537 | $this->all_flights[$id]['putinarchive'] = true; |
538 | 538 | //$putinarchive = true; |
539 | 539 | //$highlight = ''; |
540 | - } |
|
540 | + } |
|
541 | 541 | |
542 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
543 | - //$dataFound = true; |
|
542 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
543 | + //$dataFound = true; |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | if (isset($line['altitude']) && $line['altitude'] != '') { |
547 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
547 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
548 | 548 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true; |
549 | 549 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
550 | 550 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
551 | 551 | //$dataFound = true; |
552 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
552 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
556 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
556 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | if (isset($line['heading']) && $line['heading'] != '') { |
560 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
561 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
562 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
563 | - //$dataFound = true; |
|
560 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
561 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
562 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
563 | + //$dataFound = true; |
|
564 | 564 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
565 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
566 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
567 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
568 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
565 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
566 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
567 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
568 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
569 | 569 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
570 | - // If not enough messages and ACARS set heading to 0 |
|
571 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
570 | + // If not enough messages and ACARS set heading to 0 |
|
571 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
572 | 572 | } |
573 | 573 | if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
574 | 574 | elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -579,119 +579,119 @@ discard block |
||
579 | 579 | //if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
580 | 580 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
581 | 581 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
582 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
583 | - if ($this->all_flights[$id]['addedSpotter'] == 0) { |
|
584 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
585 | - //print_r($this->all_flights); |
|
586 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
587 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
588 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
582 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
583 | + if ($this->all_flights[$id]['addedSpotter'] == 0) { |
|
584 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
585 | + //print_r($this->all_flights); |
|
586 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
587 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
588 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
589 | 589 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
590 | 590 | $timeelapsed = microtime(true); |
591 | 591 | $SpotterLive = new SpotterLive($this->db); |
592 | 592 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
593 | - $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
|
594 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
593 | + $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
|
594 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
595 | 595 | } elseif (isset($line['id'])) { |
596 | - $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
|
597 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
596 | + $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
|
597 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
598 | 598 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
599 | - $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
|
600 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
599 | + $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
|
600 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
601 | 601 | } else $recent_ident = ''; |
602 | 602 | $SpotterLive->db=null; |
603 | 603 | |
604 | 604 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
605 | 605 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
606 | - } else { |
|
606 | + } else { |
|
607 | 607 | $recent_ident = ''; |
608 | 608 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
609 | - } |
|
610 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
611 | - if($recent_ident == "") |
|
612 | - { |
|
609 | + } |
|
610 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
611 | + if($recent_ident == "") |
|
612 | + { |
|
613 | 613 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
614 | 614 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
615 | 615 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
616 | 616 | //adds the spotter data for the archive |
617 | 617 | $ignoreImport = false; |
618 | 618 | foreach($globalAirportIgnore as $airportIgnore) { |
619 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
619 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
620 | 620 | $ignoreImport = true; |
621 | - } |
|
621 | + } |
|
622 | 622 | } |
623 | 623 | if (count($globalAirportAccept) > 0) { |
624 | - $ignoreImport = true; |
|
625 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
624 | + $ignoreImport = true; |
|
625 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
626 | 626 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
627 | - $ignoreImport = false; |
|
627 | + $ignoreImport = false; |
|
628 | + } |
|
628 | 629 | } |
629 | - } |
|
630 | 630 | } |
631 | 631 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
632 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
632 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
633 | 633 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
634 | - $ignoreImport = true; |
|
634 | + $ignoreImport = true; |
|
635 | + } |
|
635 | 636 | } |
636 | - } |
|
637 | 637 | } |
638 | 638 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
639 | - $ignoreImport = true; |
|
640 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
639 | + $ignoreImport = true; |
|
640 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
641 | 641 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
642 | - $ignoreImport = false; |
|
642 | + $ignoreImport = false; |
|
643 | + } |
|
643 | 644 | } |
644 | - } |
|
645 | 645 | } |
646 | 646 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
647 | - $ignoreImport = true; |
|
648 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
647 | + $ignoreImport = true; |
|
648 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
649 | 649 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
650 | - $ignoreImport = false; |
|
650 | + $ignoreImport = false; |
|
651 | + } |
|
651 | 652 | } |
652 | - } |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | if (!$ignoreImport) { |
656 | - $highlight = ''; |
|
657 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
658 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
659 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
660 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
661 | - $timeelapsed = microtime(true); |
|
662 | - $Spotter = new Spotter($this->db); |
|
663 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
|
664 | - $Spotter->db = null; |
|
665 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
666 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
656 | + $highlight = ''; |
|
657 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
658 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
659 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
660 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
661 | + $timeelapsed = microtime(true); |
|
662 | + $Spotter = new Spotter($this->db); |
|
663 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
|
664 | + $Spotter->db = null; |
|
665 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
666 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
667 | 667 | |
668 | - // Add source stat in DB |
|
669 | - $Stats = new Stats($this->db); |
|
670 | - if (!empty($this->stats)) { |
|
668 | + // Add source stat in DB |
|
669 | + $Stats = new Stats($this->db); |
|
670 | + if (!empty($this->stats)) { |
|
671 | 671 | if ($globalDebug) echo 'Add source stats : '; |
672 | - foreach($this->stats as $date => $data) { |
|
673 | - foreach($data as $source => $sourced) { |
|
674 | - //print_r($sourced); |
|
675 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
676 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
677 | - if (isset($sourced['msg'])) { |
|
678 | - if (time() - $sourced['msg']['date'] > 10) { |
|
679 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
680 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
681 | - unset($this->stats[$date][$source]['msg']); |
|
682 | - } |
|
683 | - } |
|
684 | - } |
|
685 | - if ($date != date('Y-m-d')) { |
|
686 | - unset($this->stats[$date]); |
|
687 | - } |
|
688 | - } |
|
689 | - if ($globalDebug) echo 'Done'."\n"; |
|
690 | - |
|
691 | - } |
|
692 | - $Stats->db = null; |
|
672 | + foreach($this->stats as $date => $data) { |
|
673 | + foreach($data as $source => $sourced) { |
|
674 | + //print_r($sourced); |
|
675 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
676 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
677 | + if (isset($sourced['msg'])) { |
|
678 | + if (time() - $sourced['msg']['date'] > 10) { |
|
679 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
680 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
681 | + unset($this->stats[$date][$source]['msg']); |
|
682 | + } |
|
683 | + } |
|
684 | + } |
|
685 | + if ($date != date('Y-m-d')) { |
|
686 | + unset($this->stats[$date]); |
|
687 | + } |
|
688 | + } |
|
689 | + if ($globalDebug) echo 'Done'."\n"; |
|
690 | + |
|
691 | + } |
|
692 | + $Stats->db = null; |
|
693 | 693 | |
694 | - $this->del(); |
|
694 | + $this->del(); |
|
695 | 695 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
696 | 696 | //$ignoreImport = false; |
697 | 697 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -709,18 +709,18 @@ discard block |
||
709 | 709 | */ |
710 | 710 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
711 | 711 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
712 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
713 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
714 | - $SpotterLive = new SpotterLive($this->db); |
|
715 | - $SpotterLive->deleteLiveSpotterData(); |
|
716 | - $SpotterLive->db=null; |
|
717 | - if ($globalDebug) echo " Done\n"; |
|
718 | - $this->last_delete = time(); |
|
712 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
713 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
714 | + $SpotterLive = new SpotterLive($this->db); |
|
715 | + $SpotterLive->deleteLiveSpotterData(); |
|
716 | + $SpotterLive->db=null; |
|
717 | + if ($globalDebug) echo " Done\n"; |
|
718 | + $this->last_delete = time(); |
|
719 | 719 | } |
720 | - } else { |
|
720 | + } else { |
|
721 | 721 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
722 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
723 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
722 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
723 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
724 | 724 | } |
725 | 725 | if (isset($globalDaemon) && !$globalDaemon) { |
726 | 726 | $Spotter = new Spotter($this->db); |
@@ -728,14 +728,14 @@ discard block |
||
728 | 728 | $Spotter->db = null; |
729 | 729 | } |
730 | 730 | |
731 | - } |
|
731 | + } |
|
732 | + } |
|
732 | 733 | } |
733 | - } |
|
734 | - //adds the spotter LIVE data |
|
735 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
736 | - //echo "\nAdd in Live !! \n"; |
|
737 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
738 | - if ($globalDebug) { |
|
734 | + //adds the spotter LIVE data |
|
735 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
736 | + //echo "\nAdd in Live !! \n"; |
|
737 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
738 | + if ($globalDebug) { |
|
739 | 739 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
740 | 740 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
741 | 741 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -743,49 +743,49 @@ discard block |
||
743 | 743 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
744 | 744 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
745 | 745 | } |
746 | - } |
|
747 | - $ignoreImport = false; |
|
748 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
749 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
746 | + } |
|
747 | + $ignoreImport = false; |
|
748 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
749 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
750 | 750 | |
751 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
752 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
753 | - $ignoreImport = true; |
|
751 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
752 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
753 | + $ignoreImport = true; |
|
754 | + } |
|
754 | 755 | } |
755 | - } |
|
756 | - if (count($globalAirportAccept) > 0) { |
|
757 | - $ignoreImport = true; |
|
758 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
759 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
756 | + if (count($globalAirportAccept) > 0) { |
|
757 | + $ignoreImport = true; |
|
758 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
759 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
760 | 760 | $ignoreImport = false; |
761 | - } |
|
761 | + } |
|
762 | 762 | } |
763 | - } |
|
764 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
763 | + } |
|
764 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
765 | 765 | foreach($globalAirlineIgnore as $airlineIgnore) { |
766 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
766 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
767 | 767 | $ignoreImport = true; |
768 | - } |
|
768 | + } |
|
769 | 769 | } |
770 | - } |
|
771 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
770 | + } |
|
771 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
772 | 772 | $ignoreImport = true; |
773 | 773 | foreach($globalAirlineAccept as $airlineAccept) { |
774 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
774 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
775 | 775 | $ignoreImport = false; |
776 | - } |
|
776 | + } |
|
777 | 777 | } |
778 | - } |
|
779 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
778 | + } |
|
779 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
780 | 780 | $ignoreImport = true; |
781 | 781 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
782 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
783 | - $ignoreImport = false; |
|
784 | - } |
|
782 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
783 | + $ignoreImport = false; |
|
784 | + } |
|
785 | + } |
|
785 | 786 | } |
786 | - } |
|
787 | 787 | |
788 | - if (!$ignoreImport) { |
|
788 | + if (!$ignoreImport) { |
|
789 | 789 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
790 | 790 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
791 | 791 | $timeelapsed = microtime(true); |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | if ($stats_heading == 16) $stats_heading = 0; |
824 | 824 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
825 | 825 | for ($i=0;$i<=15;$i++) { |
826 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
826 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
827 | 827 | } |
828 | 828 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
829 | 829 | } else { |
@@ -836,11 +836,11 @@ discard block |
||
836 | 836 | //var_dump($this->stats); |
837 | 837 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
838 | 838 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
839 | - end($this->stats[$current_date][$source]['hist']); |
|
840 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
839 | + end($this->stats[$current_date][$source]['hist']); |
|
840 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
841 | 841 | } else $mini = 0; |
842 | 842 | for ($i=$mini;$i<=$distance;$i+=10) { |
843 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
843 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
844 | 844 | } |
845 | 845 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
846 | 846 | } else { |
@@ -857,22 +857,22 @@ discard block |
||
857 | 857 | |
858 | 858 | |
859 | 859 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
860 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
861 | - $SpotterLive = new SpotterLive($this->db); |
|
862 | - $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
863 | - $SpotterLive->db = null; |
|
864 | - //SpotterLive->deleteLiveSpotterData(); |
|
865 | - if ($globalDebug) echo " Done\n"; |
|
866 | - $this->last_delete_hourly = time(); |
|
860 | + if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
861 | + $SpotterLive = new SpotterLive($this->db); |
|
862 | + $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
863 | + $SpotterLive->db = null; |
|
864 | + //SpotterLive->deleteLiveSpotterData(); |
|
865 | + if ($globalDebug) echo " Done\n"; |
|
866 | + $this->last_delete_hourly = time(); |
|
867 | 867 | } |
868 | 868 | |
869 | - } |
|
870 | - //$ignoreImport = false; |
|
869 | + } |
|
870 | + //$ignoreImport = false; |
|
871 | 871 | } |
872 | 872 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
873 | 873 | if ($send) return $this->all_flights[$id]; |
874 | - } |
|
874 | + } |
|
875 | + } |
|
875 | 876 | } |
876 | - } |
|
877 | 877 | } |
878 | 878 | ?> |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | <div id="showdetails" class="showdetails"></div> |
37 | 37 | <div id="infobox" class="infobox"><h4><?php echo _("Aircrafts detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div> |
38 | 38 | <?php |
39 | - if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
39 | + if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
40 | 40 | |
41 | 41 | ?> |
42 | 42 | <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script> |
43 | 43 | <?php |
44 | - } |
|
44 | + } |
|
45 | 45 | ?> |
46 | 46 | <div id="dialog" title="<?php echo _("Session has timed-out"); ?>"> |
47 | 47 | <p><?php echo _("In order to save data consumption web page times out after 30 minutes. Close this dialog to continue."); ?></p> |
@@ -55,34 +55,34 @@ discard block |
||
55 | 55 | <li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li> |
56 | 56 | <li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li> |
57 | 57 | <?php |
58 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
58 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
59 | 59 | if (isset($globalArchive) && $globalArchive == TRUE) { |
60 | 60 | ?> |
61 | 61 | <li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li> |
62 | 62 | <?php |
63 | 63 | } |
64 | - } |
|
64 | + } |
|
65 | 65 | ?> |
66 | 66 | <li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li> |
67 | 67 | <li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li> |
68 | 68 | <li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li> |
69 | 69 | <?php |
70 | - if (isset($globalMap3D) && $globalMap3D) { |
|
70 | + if (isset($globalMap3D) && $globalMap3D) { |
|
71 | 71 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
72 | 72 | ?> |
73 | 73 | <li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li> |
74 | 74 | <?php |
75 | - } else { |
|
76 | - if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
75 | + } else { |
|
76 | + if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
77 | 77 | ?> |
78 | 78 | <li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li> |
79 | 79 | <?php |
80 | - } |
|
80 | + } |
|
81 | 81 | ?> |
82 | 82 | <li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li> |
83 | 83 | <?php |
84 | 84 | } |
85 | - } |
|
85 | + } |
|
86 | 86 | ?> |
87 | 87 | </ul> |
88 | 88 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | ?> |
157 | 157 | </div> |
158 | 158 | <?php |
159 | - if (isset($globalArchive) && $globalArchive == TRUE) { |
|
159 | + if (isset($globalArchive) && $globalArchive == TRUE) { |
|
160 | 160 | ?> |
161 | 161 | <div class="sidebar-pane" id="archive"> |
162 | 162 | <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | </form> |
217 | 217 | </div> |
218 | 218 | <?php |
219 | - } |
|
219 | + } |
|
220 | 220 | ?> |
221 | 221 | <div class="sidebar-pane" id="settings"> |
222 | 222 | <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -227,56 +227,56 @@ discard block |
||
227 | 227 | <?php |
228 | 228 | if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
229 | 229 | else $MapType = $_COOKIE['MapType']; |
230 | - ?> |
|
230 | + ?> |
|
231 | 231 | <?php |
232 | 232 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
233 | - ?> |
|
233 | + ?> |
|
234 | 234 | <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
235 | 235 | <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
236 | 236 | <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
237 | 237 | <?php |
238 | 238 | } |
239 | - ?> |
|
239 | + ?> |
|
240 | 240 | <?php |
241 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
242 | - ?> |
|
241 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
242 | + ?> |
|
243 | 243 | <?php |
244 | - if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
245 | - ?> |
|
244 | + if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
245 | + ?> |
|
246 | 246 | <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
247 | 247 | <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
248 | 248 | <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
249 | 249 | <?php |
250 | - } |
|
251 | - ?> |
|
250 | + } |
|
251 | + ?> |
|
252 | 252 | <?php |
253 | - if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
254 | - ?> |
|
253 | + if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
254 | + ?> |
|
255 | 255 | <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
256 | 256 | <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
257 | 257 | <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
258 | 258 | <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
259 | 259 | <?php |
260 | - } |
|
261 | - ?> |
|
260 | + } |
|
261 | + ?> |
|
262 | 262 | <?php |
263 | - if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
264 | - ?> |
|
263 | + if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
264 | + ?> |
|
265 | 265 | <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
266 | 266 | <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
267 | 267 | <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
268 | 268 | <?php |
269 | - } |
|
270 | - ?> |
|
269 | + } |
|
270 | + ?> |
|
271 | 271 | <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
272 | 272 | <?php |
273 | 273 | } |
274 | - ?> |
|
274 | + ?> |
|
275 | 275 | <?php |
276 | - if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
276 | + if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
277 | 277 | if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
278 | 278 | else $MapBoxId = $_COOKIE['MapTypeId']; |
279 | - ?> |
|
279 | + ?> |
|
280 | 280 | <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
281 | 281 | <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
282 | 282 | <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
@@ -290,13 +290,13 @@ discard block |
||
290 | 290 | <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
291 | 291 | <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
292 | 292 | <?php |
293 | - } |
|
294 | - ?> |
|
293 | + } |
|
294 | + ?> |
|
295 | 295 | <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
296 | 296 | </select> |
297 | 297 | </li> |
298 | 298 | <?php |
299 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
299 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
300 | 300 | ?> |
301 | 301 | <li><?php echo _("Type of Terrain:"); ?> |
302 | 302 | <select class="selectpicker" onchange="terrainType(this);"> |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | </select> |
307 | 307 | </li> |
308 | 308 | <?php |
309 | - } |
|
309 | + } |
|
310 | 310 | ?> |
311 | 311 | <?php |
312 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
312 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
313 | 313 | ?> |
314 | 314 | |
315 | 315 | <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> |
@@ -317,59 +317,59 @@ discard block |
||
317 | 317 | <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
318 | 318 | <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> |
319 | 319 | <?php |
320 | - } |
|
320 | + } |
|
321 | 321 | ?> |
322 | 322 | <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> |
323 | 323 | <?php |
324 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
324 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
325 | 325 | ?> |
326 | 326 | <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> |
327 | 327 | <?php |
328 | - } |
|
329 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
328 | + } |
|
329 | + if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
330 | 330 | ?> |
331 | 331 | <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> |
332 | 332 | <?php |
333 | - } |
|
333 | + } |
|
334 | 334 | ?> |
335 | 335 | |
336 | 336 | <?php |
337 | 337 | if (function_exists('array_column')) { |
338 | - if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
339 | - ?> |
|
338 | + if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
339 | + ?> |
|
340 | 340 | <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> |
341 | 341 | <?php |
342 | - } |
|
342 | + } |
|
343 | 343 | } elseif (isset($globalSources)) { |
344 | - $dispolar = false; |
|
345 | - foreach ($globalSources as $testsource) { |
|
346 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
347 | - } |
|
348 | - if ($dispolar) { |
|
349 | - ?> |
|
344 | + $dispolar = false; |
|
345 | + foreach ($globalSources as $testsource) { |
|
346 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
347 | + } |
|
348 | + if ($dispolar) { |
|
349 | + ?> |
|
350 | 350 | <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> |
351 | 351 | <?php |
352 | - } |
|
353 | - } |
|
354 | - ?> |
|
352 | + } |
|
353 | + } |
|
354 | + ?> |
|
355 | 355 | <?php |
356 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
356 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
357 | 357 | ?> |
358 | 358 | |
359 | 359 | <?php |
360 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
361 | - ?> |
|
360 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
361 | + ?> |
|
362 | 362 | <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> |
363 | 363 | <?php |
364 | 364 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
365 | - ?> |
|
365 | + ?> |
|
366 | 366 | <li><?php echo _("Aircraft icon color:"); ?> |
367 | 367 | <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'; ?>"> |
368 | 368 | </li> |
369 | 369 | <?php |
370 | - } |
|
371 | - } |
|
372 | - ?> |
|
370 | + } |
|
371 | + } |
|
372 | + ?> |
|
373 | 373 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
374 | 374 | <div class="range"> |
375 | 375 | <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'; ?>"> |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | </div> |
378 | 378 | </li> |
379 | 379 | <?php |
380 | - } |
|
380 | + } |
|
381 | 381 | ?> |
382 | 382 | <li><?php echo _("Distance unit:"); ?> |
383 | 383 | <select class="selectpicker" onchange="unitdistance(this);"> |
@@ -410,16 +410,16 @@ discard block |
||
410 | 410 | <ul> |
411 | 411 | <?php |
412 | 412 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
413 | - ?> |
|
413 | + ?> |
|
414 | 414 | <?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 } ?> |
415 | 415 | <?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 } ?> |
416 | 416 | <?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 } ?> |
417 | 417 | <?php |
418 | 418 | } |
419 | - ?> |
|
419 | + ?> |
|
420 | 420 | <?php |
421 | 421 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
422 | - ?> |
|
422 | + ?> |
|
423 | 423 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
424 | 424 | <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> |
425 | 425 | <?php } ?> |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | <?php } ?> |
429 | 429 | <?php |
430 | 430 | } |
431 | - ?> |
|
431 | + ?> |
|
432 | 432 | <li><?php echo _("Display airlines:"); ?> |
433 | 433 | <br/> |
434 | 434 | <select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines"> |
@@ -448,14 +448,14 @@ discard block |
||
448 | 448 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
449 | 449 | } |
450 | 450 | } |
451 | - ?> |
|
451 | + ?> |
|
452 | 452 | </select> |
453 | 453 | </li> |
454 | 454 | <?php |
455 | 455 | $Spotter = new Spotter(); |
456 | 456 | $allalliancenames = $Spotter->getAllAllianceNames(); |
457 | 457 | if (!empty($allalliancenames)) { |
458 | - ?> |
|
458 | + ?> |
|
459 | 459 | <li><?php echo _("Display alliance:"); ?> |
460 | 460 | <br/> |
461 | 461 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
@@ -469,15 +469,15 @@ discard block |
||
469 | 469 | echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>'; |
470 | 470 | } |
471 | 471 | } |
472 | - ?> |
|
472 | + ?> |
|
473 | 473 | </select> |
474 | 474 | </li> |
475 | 475 | <?php |
476 | 476 | } |
477 | - ?> |
|
477 | + ?> |
|
478 | 478 | <?php |
479 | 479 | if (isset($globalAPRS) && $globalAPRS) { |
480 | - ?> |
|
480 | + ?> |
|
481 | 481 | <li><?php echo _("Display APRS sources name:"); ?> |
482 | 482 | <select class="selectpicker" multiple onchange="sources(this);"> |
483 | 483 | <?php |
@@ -489,15 +489,15 @@ discard block |
||
489 | 489 | echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>'; |
490 | 490 | } |
491 | 491 | } |
492 | - ?> |
|
492 | + ?> |
|
493 | 493 | </select> |
494 | 494 | </li> |
495 | 495 | <?php |
496 | 496 | } |
497 | - ?> |
|
497 | + ?> |
|
498 | 498 | <?php |
499 | 499 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
500 | - ?> |
|
500 | + ?> |
|
501 | 501 | <li><?php echo _("Display airlines of type:"); ?><br/> |
502 | 502 | <select class="selectpicker" onchange="airlinestype(this);"> |
503 | 503 | <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | </li> |
509 | 509 | <?php |
510 | 510 | } |
511 | - ?> |
|
511 | + ?> |
|
512 | 512 | <li> |
513 | 513 | <?php echo _("Display flight with ident:"); ?> |
514 | 514 | <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | </form> |
522 | 522 | </div> |
523 | 523 | <?php |
524 | - if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
524 | + if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
525 | 525 | ?> |
526 | 526 | <div class="sidebar-pane" id="satellites"> |
527 | 527 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -561,14 +561,14 @@ discard block |
||
561 | 561 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
562 | 562 | } |
563 | 563 | } |
564 | - ?> |
|
564 | + ?> |
|
565 | 565 | </select> |
566 | 566 | </li> |
567 | 567 | </ul> |
568 | 568 | </form> |
569 | 569 | </div> |
570 | 570 | <?php |
571 | - } |
|
571 | + } |
|
572 | 572 | ?> |
573 | 573 | </div> |
574 | 574 | </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); |
|
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 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
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); |
|
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); |
|
431 | 416 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
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 { |
@@ -1384,161 +1384,161 @@ discard block |
||
1384 | 1384 | } |
1385 | 1385 | |
1386 | 1386 | |
1387 | - public static function check_version($update = false) { |
|
1388 | - global $globalDBname; |
|
1389 | - $version = 0; |
|
1390 | - $Connection = new Connection(); |
|
1391 | - if ($Connection->tableExists('aircraft')) { |
|
1392 | - if (!$Connection->tableExists('config')) { |
|
1393 | - $version = '1'; |
|
1394 | - if ($update) return self::update_from_1(); |
|
1395 | - else return $version; |
|
1387 | + public static function check_version($update = false) { |
|
1388 | + global $globalDBname; |
|
1389 | + $version = 0; |
|
1390 | + $Connection = new Connection(); |
|
1391 | + if ($Connection->tableExists('aircraft')) { |
|
1392 | + if (!$Connection->tableExists('config')) { |
|
1393 | + $version = '1'; |
|
1394 | + if ($update) return self::update_from_1(); |
|
1395 | + else return $version; |
|
1396 | 1396 | } else { |
1397 | - $Connection = new Connection(); |
|
1398 | - $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1399 | - try { |
|
1400 | - $sth = $Connection->db->prepare($query); |
|
1401 | - $sth->execute(); |
|
1402 | - } catch(PDOException $e) { |
|
1397 | + $Connection = new Connection(); |
|
1398 | + $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1399 | + try { |
|
1400 | + $sth = $Connection->db->prepare($query); |
|
1401 | + $sth->execute(); |
|
1402 | + } catch(PDOException $e) { |
|
1403 | 1403 | return "error : ".$e->getMessage()."\n"; |
1404 | - } |
|
1405 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1406 | - if ($update) { |
|
1407 | - if ($result['value'] == '2') { |
|
1408 | - $error = self::update_from_2(); |
|
1409 | - if ($error != '') return $error; |
|
1410 | - else return self::check_version(true); |
|
1411 | - } elseif ($result['value'] == '3') { |
|
1412 | - $error = self::update_from_3(); |
|
1413 | - if ($error != '') return $error; |
|
1414 | - else return self::check_version(true); |
|
1415 | - } elseif ($result['value'] == '4') { |
|
1416 | - $error = self::update_from_4(); |
|
1417 | - if ($error != '') return $error; |
|
1418 | - else return self::check_version(true); |
|
1419 | - } elseif ($result['value'] == '5') { |
|
1420 | - $error = self::update_from_5(); |
|
1421 | - if ($error != '') return $error; |
|
1422 | - else return self::check_version(true); |
|
1423 | - } elseif ($result['value'] == '6') { |
|
1424 | - $error = self::update_from_6(); |
|
1425 | - if ($error != '') return $error; |
|
1426 | - else return self::check_version(true); |
|
1427 | - } elseif ($result['value'] == '7') { |
|
1428 | - $error = self::update_from_7(); |
|
1429 | - if ($error != '') return $error; |
|
1430 | - else return self::check_version(true); |
|
1431 | - } elseif ($result['value'] == '8') { |
|
1432 | - $error = self::update_from_8(); |
|
1433 | - if ($error != '') return $error; |
|
1434 | - else return self::check_version(true); |
|
1435 | - } elseif ($result['value'] == '9') { |
|
1436 | - $error = self::update_from_9(); |
|
1437 | - if ($error != '') return $error; |
|
1438 | - else return self::check_version(true); |
|
1439 | - } elseif ($result['value'] == '10') { |
|
1440 | - $error = self::update_from_10(); |
|
1441 | - if ($error != '') return $error; |
|
1442 | - else return self::check_version(true); |
|
1443 | - } elseif ($result['value'] == '11') { |
|
1444 | - $error = self::update_from_11(); |
|
1445 | - if ($error != '') return $error; |
|
1446 | - else return self::check_version(true); |
|
1447 | - } elseif ($result['value'] == '12') { |
|
1448 | - $error = self::update_from_12(); |
|
1449 | - if ($error != '') return $error; |
|
1450 | - else return self::check_version(true); |
|
1451 | - } elseif ($result['value'] == '13') { |
|
1452 | - $error = self::update_from_13(); |
|
1453 | - if ($error != '') return $error; |
|
1454 | - else return self::check_version(true); |
|
1455 | - } elseif ($result['value'] == '14') { |
|
1456 | - $error = self::update_from_14(); |
|
1457 | - if ($error != '') return $error; |
|
1458 | - else return self::check_version(true); |
|
1459 | - } elseif ($result['value'] == '15') { |
|
1460 | - $error = self::update_from_15(); |
|
1461 | - if ($error != '') return $error; |
|
1462 | - else return self::check_version(true); |
|
1463 | - } elseif ($result['value'] == '16') { |
|
1464 | - $error = self::update_from_16(); |
|
1465 | - if ($error != '') return $error; |
|
1466 | - else return self::check_version(true); |
|
1467 | - } elseif ($result['value'] == '17') { |
|
1468 | - $error = self::update_from_17(); |
|
1469 | - if ($error != '') return $error; |
|
1470 | - else return self::check_version(true); |
|
1471 | - } elseif ($result['value'] == '18') { |
|
1472 | - $error = self::update_from_18(); |
|
1473 | - if ($error != '') return $error; |
|
1474 | - else return self::check_version(true); |
|
1475 | - } elseif ($result['value'] == '19') { |
|
1476 | - $error = self::update_from_19(); |
|
1477 | - if ($error != '') return $error; |
|
1478 | - else return self::check_version(true); |
|
1479 | - } elseif ($result['value'] == '20') { |
|
1480 | - $error = self::update_from_20(); |
|
1481 | - if ($error != '') return $error; |
|
1482 | - else return self::check_version(true); |
|
1483 | - } elseif ($result['value'] == '21') { |
|
1484 | - $error = self::update_from_21(); |
|
1485 | - if ($error != '') return $error; |
|
1486 | - else return self::check_version(true); |
|
1487 | - } elseif ($result['value'] == '22') { |
|
1488 | - $error = self::update_from_22(); |
|
1489 | - if ($error != '') return $error; |
|
1490 | - else return self::check_version(true); |
|
1491 | - } elseif ($result['value'] == '23') { |
|
1492 | - $error = self::update_from_23(); |
|
1493 | - if ($error != '') return $error; |
|
1494 | - else return self::check_version(true); |
|
1495 | - } elseif ($result['value'] == '24') { |
|
1496 | - $error = self::update_from_24(); |
|
1497 | - if ($error != '') return $error; |
|
1498 | - else return self::check_version(true); |
|
1499 | - } elseif ($result['value'] == '25') { |
|
1500 | - $error = self::update_from_25(); |
|
1501 | - if ($error != '') return $error; |
|
1502 | - else return self::check_version(true); |
|
1503 | - } elseif ($result['value'] == '26') { |
|
1504 | - $error = self::update_from_26(); |
|
1505 | - if ($error != '') return $error; |
|
1506 | - else return self::check_version(true); |
|
1507 | - } elseif ($result['value'] == '27') { |
|
1508 | - $error = self::update_from_27(); |
|
1509 | - if ($error != '') return $error; |
|
1510 | - else return self::check_version(true); |
|
1511 | - } elseif ($result['value'] == '28') { |
|
1512 | - $error = self::update_from_28(); |
|
1513 | - if ($error != '') return $error; |
|
1514 | - else return self::check_version(true); |
|
1515 | - } elseif ($result['value'] == '29') { |
|
1516 | - $error = self::update_from_29(); |
|
1517 | - if ($error != '') return $error; |
|
1518 | - else return self::check_version(true); |
|
1519 | - } elseif ($result['value'] == '30') { |
|
1520 | - $error = self::update_from_30(); |
|
1521 | - if ($error != '') return $error; |
|
1522 | - else return self::check_version(true); |
|
1523 | - } elseif ($result['value'] == '31') { |
|
1524 | - $error = self::update_from_31(); |
|
1525 | - if ($error != '') return $error; |
|
1526 | - else return self::check_version(true); |
|
1527 | - } elseif ($result['value'] == '32') { |
|
1528 | - $error = self::update_from_32(); |
|
1529 | - if ($error != '') return $error; |
|
1530 | - else return self::check_version(true); |
|
1531 | - } elseif ($result['value'] == '33') { |
|
1532 | - $error = self::update_from_33(); |
|
1533 | - if ($error != '') return $error; |
|
1534 | - else return self::check_version(true); |
|
1535 | - } else return ''; |
|
1536 | - } |
|
1537 | - else return $result['value']; |
|
1404 | + } |
|
1405 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1406 | + if ($update) { |
|
1407 | + if ($result['value'] == '2') { |
|
1408 | + $error = self::update_from_2(); |
|
1409 | + if ($error != '') return $error; |
|
1410 | + else return self::check_version(true); |
|
1411 | + } elseif ($result['value'] == '3') { |
|
1412 | + $error = self::update_from_3(); |
|
1413 | + if ($error != '') return $error; |
|
1414 | + else return self::check_version(true); |
|
1415 | + } elseif ($result['value'] == '4') { |
|
1416 | + $error = self::update_from_4(); |
|
1417 | + if ($error != '') return $error; |
|
1418 | + else return self::check_version(true); |
|
1419 | + } elseif ($result['value'] == '5') { |
|
1420 | + $error = self::update_from_5(); |
|
1421 | + if ($error != '') return $error; |
|
1422 | + else return self::check_version(true); |
|
1423 | + } elseif ($result['value'] == '6') { |
|
1424 | + $error = self::update_from_6(); |
|
1425 | + if ($error != '') return $error; |
|
1426 | + else return self::check_version(true); |
|
1427 | + } elseif ($result['value'] == '7') { |
|
1428 | + $error = self::update_from_7(); |
|
1429 | + if ($error != '') return $error; |
|
1430 | + else return self::check_version(true); |
|
1431 | + } elseif ($result['value'] == '8') { |
|
1432 | + $error = self::update_from_8(); |
|
1433 | + if ($error != '') return $error; |
|
1434 | + else return self::check_version(true); |
|
1435 | + } elseif ($result['value'] == '9') { |
|
1436 | + $error = self::update_from_9(); |
|
1437 | + if ($error != '') return $error; |
|
1438 | + else return self::check_version(true); |
|
1439 | + } elseif ($result['value'] == '10') { |
|
1440 | + $error = self::update_from_10(); |
|
1441 | + if ($error != '') return $error; |
|
1442 | + else return self::check_version(true); |
|
1443 | + } elseif ($result['value'] == '11') { |
|
1444 | + $error = self::update_from_11(); |
|
1445 | + if ($error != '') return $error; |
|
1446 | + else return self::check_version(true); |
|
1447 | + } elseif ($result['value'] == '12') { |
|
1448 | + $error = self::update_from_12(); |
|
1449 | + if ($error != '') return $error; |
|
1450 | + else return self::check_version(true); |
|
1451 | + } elseif ($result['value'] == '13') { |
|
1452 | + $error = self::update_from_13(); |
|
1453 | + if ($error != '') return $error; |
|
1454 | + else return self::check_version(true); |
|
1455 | + } elseif ($result['value'] == '14') { |
|
1456 | + $error = self::update_from_14(); |
|
1457 | + if ($error != '') return $error; |
|
1458 | + else return self::check_version(true); |
|
1459 | + } elseif ($result['value'] == '15') { |
|
1460 | + $error = self::update_from_15(); |
|
1461 | + if ($error != '') return $error; |
|
1462 | + else return self::check_version(true); |
|
1463 | + } elseif ($result['value'] == '16') { |
|
1464 | + $error = self::update_from_16(); |
|
1465 | + if ($error != '') return $error; |
|
1466 | + else return self::check_version(true); |
|
1467 | + } elseif ($result['value'] == '17') { |
|
1468 | + $error = self::update_from_17(); |
|
1469 | + if ($error != '') return $error; |
|
1470 | + else return self::check_version(true); |
|
1471 | + } elseif ($result['value'] == '18') { |
|
1472 | + $error = self::update_from_18(); |
|
1473 | + if ($error != '') return $error; |
|
1474 | + else return self::check_version(true); |
|
1475 | + } elseif ($result['value'] == '19') { |
|
1476 | + $error = self::update_from_19(); |
|
1477 | + if ($error != '') return $error; |
|
1478 | + else return self::check_version(true); |
|
1479 | + } elseif ($result['value'] == '20') { |
|
1480 | + $error = self::update_from_20(); |
|
1481 | + if ($error != '') return $error; |
|
1482 | + else return self::check_version(true); |
|
1483 | + } elseif ($result['value'] == '21') { |
|
1484 | + $error = self::update_from_21(); |
|
1485 | + if ($error != '') return $error; |
|
1486 | + else return self::check_version(true); |
|
1487 | + } elseif ($result['value'] == '22') { |
|
1488 | + $error = self::update_from_22(); |
|
1489 | + if ($error != '') return $error; |
|
1490 | + else return self::check_version(true); |
|
1491 | + } elseif ($result['value'] == '23') { |
|
1492 | + $error = self::update_from_23(); |
|
1493 | + if ($error != '') return $error; |
|
1494 | + else return self::check_version(true); |
|
1495 | + } elseif ($result['value'] == '24') { |
|
1496 | + $error = self::update_from_24(); |
|
1497 | + if ($error != '') return $error; |
|
1498 | + else return self::check_version(true); |
|
1499 | + } elseif ($result['value'] == '25') { |
|
1500 | + $error = self::update_from_25(); |
|
1501 | + if ($error != '') return $error; |
|
1502 | + else return self::check_version(true); |
|
1503 | + } elseif ($result['value'] == '26') { |
|
1504 | + $error = self::update_from_26(); |
|
1505 | + if ($error != '') return $error; |
|
1506 | + else return self::check_version(true); |
|
1507 | + } elseif ($result['value'] == '27') { |
|
1508 | + $error = self::update_from_27(); |
|
1509 | + if ($error != '') return $error; |
|
1510 | + else return self::check_version(true); |
|
1511 | + } elseif ($result['value'] == '28') { |
|
1512 | + $error = self::update_from_28(); |
|
1513 | + if ($error != '') return $error; |
|
1514 | + else return self::check_version(true); |
|
1515 | + } elseif ($result['value'] == '29') { |
|
1516 | + $error = self::update_from_29(); |
|
1517 | + if ($error != '') return $error; |
|
1518 | + else return self::check_version(true); |
|
1519 | + } elseif ($result['value'] == '30') { |
|
1520 | + $error = self::update_from_30(); |
|
1521 | + if ($error != '') return $error; |
|
1522 | + else return self::check_version(true); |
|
1523 | + } elseif ($result['value'] == '31') { |
|
1524 | + $error = self::update_from_31(); |
|
1525 | + if ($error != '') return $error; |
|
1526 | + else return self::check_version(true); |
|
1527 | + } elseif ($result['value'] == '32') { |
|
1528 | + $error = self::update_from_32(); |
|
1529 | + if ($error != '') return $error; |
|
1530 | + else return self::check_version(true); |
|
1531 | + } elseif ($result['value'] == '33') { |
|
1532 | + $error = self::update_from_33(); |
|
1533 | + if ($error != '') return $error; |
|
1534 | + else return self::check_version(true); |
|
1535 | + } else return ''; |
|
1536 | + } |
|
1537 | + else return $result['value']; |
|
1538 | 1538 | } |
1539 | 1539 | |
1540 | - } else return $version; |
|
1541 | - } |
|
1540 | + } else return $version; |
|
1541 | + } |
|
1542 | 1542 | |
1543 | 1543 | } |
1544 | 1544 | //echo update_schema::check_version(); |
@@ -4,8 +4,8 @@ |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['airline'])) { |
7 | - header('Location: '.$globalURL.'/airline'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/airline'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
11 | 11 | $Spotter = new Spotter(); |
@@ -4,8 +4,8 @@ |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['aircraft_manufacturer'])) { |
7 | - header('Location: '.$globalURL.'/manufacturer'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/manufacturer'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $Spotter = new Spotter(); |
11 | 11 | $manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING))); |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['airline'])) { |
7 | - header('Location: '.$globalURL.'/airline'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/airline'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
11 | 11 | $Spotter = new Spotter(); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | function drawChart() { |
73 | 73 | var data = google.visualization.arrayToDataTable([ |
74 | 74 | ["'._("Country").'", "'._("# of times").'"], '; |
75 | - $country_data = ''; |
|
75 | + $country_data = ''; |
|
76 | 76 | foreach($airport_country_array as $airport_item) |
77 | 77 | { |
78 | 78 | $country_data .= '[ "'.$airport_item['arrival_airport_country'].'",'.$airport_item['airport_arrival_country_count'].'],'; |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['airline'])) { |
7 | - header('Location: '.$globalURL.'/airline'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/airline'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
11 | 11 | $Spotter = new Spotter(); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | var data = google.visualization.arrayToDataTable([ |
77 | 77 | ["'._("Airport").'", "'._("# of times").'"],'; |
78 | - $airport_data = ''; |
|
78 | + $airport_data = ''; |
|
79 | 79 | foreach($airport_airport_array as $airport_item) |
80 | 80 | { |
81 | 81 | $name = $airport_item['airport_arrival_city'].', '.$airport_item['airport_arrival_country'].' ('.$airport_item['airport_arrival_icao'].')'; |
@@ -4,55 +4,55 @@ |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | 6 | if (isset($_GET['start_date'])) { |
7 | - //for the date manipulation into the query |
|
8 | - if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
9 | - $start_date = $_GET['start_date'].":00"; |
|
10 | - $end_date = $_GET['end_date'].":00"; |
|
11 | - $sql_date = $start_date.",".$end_date; |
|
12 | - } else if($_GET['start_date'] != ""){ |
|
13 | - $start_date = $_GET['start_date'].":00"; |
|
14 | - $sql_date = $start_date; |
|
15 | - } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
16 | - $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
|
17 | - $sql_date = $end_date; |
|
18 | - } else $sql_date = ''; |
|
7 | + //for the date manipulation into the query |
|
8 | + if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
9 | + $start_date = $_GET['start_date'].":00"; |
|
10 | + $end_date = $_GET['end_date'].":00"; |
|
11 | + $sql_date = $start_date.",".$end_date; |
|
12 | + } else if($_GET['start_date'] != ""){ |
|
13 | + $start_date = $_GET['start_date'].":00"; |
|
14 | + $sql_date = $start_date; |
|
15 | + } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
16 | + $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
|
17 | + $sql_date = $end_date; |
|
18 | + } else $sql_date = ''; |
|
19 | 19 | } else $sql_date = ''; |
20 | 20 | |
21 | 21 | if (isset($_GET['highest_altitude'])) { |
22 | - //for altitude manipulation |
|
23 | - if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
24 | - $end_altitude = $_GET['highest_altitude']; |
|
25 | - $start_altitude = $_GET['lowest_altitude']; |
|
26 | - $sql_altitude = $start_altitude.",".$end_altitude; |
|
27 | - } else if($_GET['highest_altitude'] != ""){ |
|
28 | - $end_altitude = $_GET['highest_altitude']; |
|
29 | - $sql_altitude = $end_altitude; |
|
30 | - } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
31 | - $start_altitude = $_GET['lowest_altitude'].",60000"; |
|
32 | - $sql_altitude = $start_altitude; |
|
33 | - } else $sql_altitude = ''; |
|
22 | + //for altitude manipulation |
|
23 | + if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
24 | + $end_altitude = $_GET['highest_altitude']; |
|
25 | + $start_altitude = $_GET['lowest_altitude']; |
|
26 | + $sql_altitude = $start_altitude.",".$end_altitude; |
|
27 | + } else if($_GET['highest_altitude'] != ""){ |
|
28 | + $end_altitude = $_GET['highest_altitude']; |
|
29 | + $sql_altitude = $end_altitude; |
|
30 | + } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
31 | + $start_altitude = $_GET['lowest_altitude'].",60000"; |
|
32 | + $sql_altitude = $start_altitude; |
|
33 | + } else $sql_altitude = ''; |
|
34 | 34 | } else $sql_altitude = ''; |
35 | 35 | |
36 | 36 | //calculuation for the pagination |
37 | 37 | if(!isset($_GET['limit'])) |
38 | 38 | { |
39 | - if (!isset($_GET['number_results'])) |
|
40 | - { |
|
41 | - $limit_start = 0; |
|
42 | - $limit_end = 25; |
|
43 | - $absolute_difference = 25; |
|
44 | - } else { |
|
45 | - if ($_GET['number_results'] > 1000){ |
|
46 | - $_GET['number_results'] = 1000; |
|
47 | - } |
|
48 | - $limit_start = 0; |
|
49 | - $limit_end = $_GET['number_results']; |
|
50 | - $absolute_difference = $_GET['number_results']; |
|
51 | - } |
|
39 | + if (!isset($_GET['number_results'])) |
|
40 | + { |
|
41 | + $limit_start = 0; |
|
42 | + $limit_end = 25; |
|
43 | + $absolute_difference = 25; |
|
44 | + } else { |
|
45 | + if ($_GET['number_results'] > 1000){ |
|
46 | + $_GET['number_results'] = 1000; |
|
47 | + } |
|
48 | + $limit_start = 0; |
|
49 | + $limit_end = $_GET['number_results']; |
|
50 | + $absolute_difference = $_GET['number_results']; |
|
51 | + } |
|
52 | 52 | } else { |
53 | - $limit_explode = explode(",", $_GET['limit']); |
|
54 | - $limit_start = $limit_explode[0]; |
|
55 | - $limit_end = $limit_explode[1]; |
|
53 | + $limit_explode = explode(",", $_GET['limit']); |
|
54 | + $limit_start = $limit_explode[0]; |
|
55 | + $limit_end = $limit_explode[1]; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | $absolute_difference = abs($limit_start - $limit_end); |