@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | $currentdate = date('Y-m-d'); |
35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
36 | 36 | if (!empty($sourcestat)) { |
37 | - foreach($sourcestat as $srcst) { |
|
37 | + foreach ($sourcestat as $srcst) { |
|
38 | 38 | $type = $srcst['stats_type']; |
39 | 39 | if ($type == 'polar' || $type == 'hist') { |
40 | 40 | $source = $srcst['source_name']; |
41 | 41 | $data = $srcst['source_data']; |
42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
42 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | if (isset($globalGeoid) && $globalGeoid) { |
52 | 52 | try { |
53 | 53 | $GeoidClass = new GeoidHeight(); |
54 | - } catch(Exception $e) { |
|
54 | + } catch (Exception $e) { |
|
55 | 55 | if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php \n"; |
56 | 56 | $GeoidClass = FALSE; |
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - public function get_Schedule($id,$ident) { |
|
61 | + public function get_Schedule($id, $ident) { |
|
62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
63 | 63 | // Get schedule here, so it's done only one time |
64 | 64 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | 85 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | 88 | // Should also check if route schedule = route from DB |
89 | 89 | if ($schedule['DepartureAirportIATA'] != '') { |
90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
107 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
108 | 108 | } |
109 | 109 | } else $scheduleexist = true; |
110 | 110 | } else $scheduleexist = true; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if ($scheduleexist) { |
113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
114 | 114 | $sch = $Schedule->getSchedule($operator); |
115 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
115 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
116 | 116 | } |
117 | 117 | $Spotter->db = null; |
118 | 118 | $Schedule->db = null; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
140 | 140 | $Spotter = new Spotter($this->db); |
141 | 141 | $real_arrival = $this->arrival($key); |
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
142 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $airport_time = ''; |
154 | 154 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
155 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
156 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
157 | 157 | if (isset($closestAirports[0])) { |
158 | 158 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
159 | 159 | $airport_icao = $closestAirports[0]['icao']; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | break; |
169 | 169 | } |
170 | 170 | } |
171 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
171 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
172 | 172 | $airport_icao = $closestAirports[0]['icao']; |
173 | 173 | $airport_time = $this->all_flights[$key]['datetime']; |
174 | 174 | } else { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } else { |
182 | 182 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
183 | 183 | } |
184 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
184 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
193 | 193 | foreach ($this->all_flights as $key => $flight) { |
194 | 194 | if (isset($flight['lastupdate'])) { |
195 | - if ($flight['lastupdate'] < (time()-5900)) { |
|
195 | + if ($flight['lastupdate'] < (time() - 5900)) { |
|
196 | 196 | $this->delKey($key); |
197 | 197 | } |
198 | 198 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $real_arrival = $this->arrival($key); |
209 | 209 | $Spotter = new Spotter($this->db); |
210 | 210 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
211 | - $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']); |
|
211 | + $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']); |
|
212 | 212 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
213 | 213 | } |
214 | 214 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $send = false; |
242 | 242 | |
243 | 243 | // SBS format is CSV format |
244 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
244 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
245 | 245 | //print_r($line); |
246 | 246 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
247 | 247 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
@@ -277,25 +277,25 @@ discard block |
||
277 | 277 | if (!isset($this->all_flights[$id])) { |
278 | 278 | if ($globalDebug) echo 'New flight...'."\n"; |
279 | 279 | $this->all_flights[$id] = array(); |
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
282 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
283 | 283 | if (!isset($line['id'])) { |
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
286 | 286 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
287 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
288 | 288 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
289 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
290 | 290 | if ($globalAllFlights !== FALSE) $dataFound = true; |
291 | 291 | } |
292 | 292 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | //print_r($this->all_flights); |
297 | 297 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
298 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
298 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
299 | 299 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
300 | 300 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
301 | 301 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -304,27 +304,27 @@ discard block |
||
304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
305 | 305 | $Spotter = new Spotter($this->db); |
306 | 306 | if (isset($this->all_flights[$id]['source_type'])) { |
307 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
307 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
308 | 308 | } else { |
309 | 309 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | 310 | } |
311 | 311 | $Spotter->db = null; |
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
312 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
313 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | if ($globalAllFlights !== FALSE) $dataFound = true; |
317 | 317 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
318 | 318 | } |
319 | 319 | if (isset($line['id']) && !isset($line['hex'])) { |
320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
321 | 321 | } |
322 | 322 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
323 | 323 | $icao = $line['aircraft_icao']; |
324 | 324 | $Spotter = new Spotter($this->db); |
325 | 325 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
326 | 326 | $Spotter->db = null; |
327 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
327 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
328 | 328 | } |
329 | 329 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
330 | 330 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $Spotter = new Spotter($this->db); |
333 | 333 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
334 | 334 | $Spotter->db = null; |
335 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
335 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
341 | 341 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
342 | 342 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
343 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
343 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
344 | 344 | } |
345 | 345 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
346 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
346 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
347 | 347 | } |
348 | 348 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
349 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
349 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
350 | 350 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
351 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
351 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
352 | 352 | } else { |
353 | 353 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
354 | 354 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -359,31 +359,31 @@ discard block |
||
359 | 359 | */ |
360 | 360 | return ''; |
361 | 361 | } |
362 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
362 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
363 | 363 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
364 | 364 | return ''; |
365 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
365 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
366 | 366 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
367 | 367 | return ''; |
368 | 368 | } elseif (!isset($line['datetime'])) { |
369 | 369 | date_default_timezone_set('UTC'); |
370 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
370 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
371 | 371 | } else { |
372 | 372 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
373 | 373 | return ''; |
374 | 374 | } |
375 | 375 | |
376 | 376 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
377 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
377 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
378 | 378 | } |
379 | 379 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
380 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
380 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
381 | 381 | } |
382 | 382 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
383 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
383 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
384 | 384 | } |
385 | 385 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
386 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
386 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
392 | 392 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
393 | 393 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
395 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
396 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
397 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
398 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
395 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
396 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
397 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
398 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
399 | 399 | } else { |
400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
401 | 401 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
402 | 402 | $timeelapsed = microtime(true); |
403 | 403 | $Spotter = new Spotter($this->db); |
@@ -407,13 +407,13 @@ discard block |
||
407 | 407 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
408 | 408 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
409 | 409 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
410 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
410 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
411 | 411 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
412 | 412 | $Spotter->db = null; |
413 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
413 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
414 | 414 | } |
415 | 415 | } |
416 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
416 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
417 | 417 | |
418 | 418 | /* |
419 | 419 | if (!isset($line['id'])) { |
@@ -423,25 +423,25 @@ discard block |
||
423 | 423 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
424 | 424 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
425 | 425 | */ |
426 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
426 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
427 | 427 | |
428 | 428 | //$putinarchive = true; |
429 | 429 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
430 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
430 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
431 | 431 | } |
432 | 432 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
433 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
433 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
434 | 434 | } |
435 | 435 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
436 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
436 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
437 | 437 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
438 | 438 | $timeelapsed = microtime(true); |
439 | 439 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
440 | 440 | $Spotter = new Spotter($this->db); |
441 | 441 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
442 | 442 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
443 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
443 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
444 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
445 | 445 | } |
446 | 446 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
447 | 447 | $timeelapsed = microtime(true); |
@@ -455,35 +455,35 @@ discard block |
||
455 | 455 | $Translation->db = null; |
456 | 456 | } |
457 | 457 | $Spotter->db = null; |
458 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
458 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
459 | 459 | } |
460 | 460 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
461 | 461 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
462 | 462 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
463 | 463 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
464 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
464 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | if (!isset($globalFork)) $globalFork = TRUE; |
468 | 468 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
469 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
469 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | } |
473 | 473 | |
474 | 474 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
475 | 475 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
476 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
477 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
476 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
477 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
478 | 478 | //$dataFound = true; |
479 | 479 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
480 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
480 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
481 | 481 | if ($distance > 1000 && $distance < 10000) { |
482 | 482 | // use datetime |
483 | 483 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
484 | 484 | $speed = $speed*3.6; |
485 | 485 | if ($speed < 1000) { |
486 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
486 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
487 | 487 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
488 | 488 | } else { |
489 | 489 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
499 | 499 | return false; |
500 | 500 | } |
501 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
501 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
502 | 502 | else unset($timediff); |
503 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
503 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
504 | 504 | else unset($timediff_archive); |
505 | 505 | if ($this->tmd > 5 |
506 | 506 | || (isset($line['format_source']) |
@@ -524,14 +524,14 @@ discard block |
||
524 | 524 | || ($timediff > 30 |
525 | 525 | && isset($this->all_flights[$id]['latitude']) |
526 | 526 | && isset($this->all_flights[$id]['longitude']) |
527 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
527 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
528 | 528 | ) |
529 | 529 | ) { |
530 | 530 | |
531 | 531 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
532 | 532 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
533 | 533 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
534 | - || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
534 | + || !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
535 | 535 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
536 | 536 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
537 | 537 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -541,11 +541,11 @@ discard block |
||
541 | 541 | $timeelapsed = microtime(true); |
542 | 542 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
543 | 543 | $Spotter = new Spotter($this->db); |
544 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
544 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
545 | 545 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
546 | 546 | else $this->all_flights[$id]['over_country'] = ''; |
547 | 547 | $Spotter->db = null; |
548 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
548 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
549 | 549 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
550 | 550 | } |
551 | 551 | } |
@@ -571,13 +571,13 @@ discard block |
||
571 | 571 | $this->all_flights[$id]['time_last_coord'] = time(); |
572 | 572 | } |
573 | 573 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
574 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
574 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
575 | 575 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
576 | 576 | $dataFound = true; |
577 | 577 | $this->all_flights[$id]['time_last_coord'] = time(); |
578 | 578 | } |
579 | 579 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
580 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
580 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
581 | 581 | /* |
582 | 582 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
583 | 583 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -599,13 +599,13 @@ discard block |
||
599 | 599 | $this->all_flights[$id]['time_last_coord'] = time(); |
600 | 600 | } |
601 | 601 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
602 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
602 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
603 | 603 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
604 | 604 | $dataFound = true; |
605 | 605 | $this->all_flights[$id]['time_last_coord'] = time(); |
606 | 606 | } |
607 | 607 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
608 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
608 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
609 | 609 | /* |
610 | 610 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
611 | 611 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -623,46 +623,46 @@ discard block |
||
623 | 623 | } else if ($globalDebug && $timediff > 30) { |
624 | 624 | $this->tmd = $this->tmd + 1; |
625 | 625 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
626 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
627 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
626 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
627 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
628 | 628 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
629 | 629 | } |
630 | 630 | } |
631 | 631 | if (isset($line['last_update']) && $line['last_update'] != '') { |
632 | 632 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
633 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
633 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
634 | 634 | } |
635 | 635 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
636 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
636 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
637 | 637 | //$dataFound = true; |
638 | 638 | } |
639 | 639 | if (isset($line['format_source']) && $line['format_source'] != '') { |
640 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
640 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
641 | 641 | } |
642 | 642 | if (isset($line['source_name']) && $line['source_name'] != '') { |
643 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
643 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
644 | 644 | } |
645 | 645 | if (isset($line['emergency']) && $line['emergency'] != '') { |
646 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
646 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
647 | 647 | //$dataFound = true; |
648 | 648 | } |
649 | 649 | if (isset($line['ground']) && $line['ground'] != '') { |
650 | 650 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
651 | 651 | // Here we force archive of flight because after ground it's a new one (or should be) |
652 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
653 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
654 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
655 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
656 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
652 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
653 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
654 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
655 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
656 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
657 | 657 | } |
658 | 658 | if ($line['ground'] != 1) $line['ground'] = 0; |
659 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
659 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
660 | 660 | //$dataFound = true; |
661 | 661 | } |
662 | 662 | if (isset($line['squawk']) && $line['squawk'] != '') { |
663 | 663 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
664 | 664 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
665 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
665 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
666 | 666 | $highlight = ''; |
667 | 667 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
668 | 668 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -671,66 +671,66 @@ discard block |
||
671 | 671 | $timeelapsed = microtime(true); |
672 | 672 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
673 | 673 | $Spotter = new Spotter($this->db); |
674 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
674 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
675 | 675 | $Spotter->db = null; |
676 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
676 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
677 | 677 | } |
678 | 678 | //$putinarchive = true; |
679 | 679 | //$highlight = ''; |
680 | 680 | } |
681 | 681 | |
682 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
682 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
683 | 683 | //$dataFound = true; |
684 | 684 | } |
685 | 685 | |
686 | 686 | if (isset($line['altitude']) && $line['altitude'] != '') { |
687 | 687 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
688 | 688 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
689 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
689 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
690 | 690 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
691 | 691 | $line['altitude'] = $line['altitude'] + $geoid; |
692 | 692 | } |
693 | 693 | } |
694 | 694 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
695 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
696 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
697 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
695 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
696 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
697 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
698 | 698 | //$dataFound = true; |
699 | 699 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
700 | 700 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
701 | 701 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
702 | 702 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
703 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
704 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
705 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
706 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
707 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
703 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
704 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
705 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
706 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
707 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
708 | 708 | } |
709 | 709 | } |
710 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
710 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
714 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
714 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | if (isset($line['heading']) && $line['heading'] != '') { |
718 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
719 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
720 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
718 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
719 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
720 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
721 | 721 | //$dataFound = true; |
722 | 722 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
723 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
724 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
725 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
723 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
724 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
725 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
726 | 726 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
727 | 727 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
728 | 728 | // If not enough messages and ACARS set heading to 0 |
729 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
729 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
730 | 730 | } |
731 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
732 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
733 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
731 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
732 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
733 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
734 | 734 | |
735 | 735 | // print_r($this->all_flights[$id]); |
736 | 736 | //gets the callsign from the last hour |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
742 | 742 | $this->all_flights[$id]['lastupdate'] = time(); |
743 | 743 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
744 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
744 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
745 | 745 | //print_r($this->all_flights); |
746 | 746 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
747 | 747 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -752,61 +752,61 @@ discard block |
||
752 | 752 | $SpotterLive = new SpotterLive($this->db); |
753 | 753 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
754 | 754 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
755 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
755 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
756 | 756 | } elseif (isset($line['id'])) { |
757 | 757 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
758 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
758 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
759 | 759 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
760 | 760 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
761 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
761 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
762 | 762 | } else $recent_ident = ''; |
763 | - $SpotterLive->db=null; |
|
763 | + $SpotterLive->db = null; |
|
764 | 764 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
765 | 765 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
766 | 766 | } else $recent_ident = ''; |
767 | 767 | } else { |
768 | 768 | $recent_ident = ''; |
769 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
769 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
770 | 770 | } |
771 | 771 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
772 | - if($recent_ident == "") |
|
772 | + if ($recent_ident == "") |
|
773 | 773 | { |
774 | 774 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
775 | 775 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
776 | 776 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
777 | 777 | //adds the spotter data for the archive |
778 | 778 | $ignoreImport = false; |
779 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
779 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
780 | 780 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
781 | 781 | $ignoreImport = true; |
782 | 782 | } |
783 | 783 | } |
784 | 784 | if (count($globalAirportAccept) > 0) { |
785 | 785 | $ignoreImport = true; |
786 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
786 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
787 | 787 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
788 | 788 | $ignoreImport = false; |
789 | 789 | } |
790 | 790 | } |
791 | 791 | } |
792 | 792 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
793 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
794 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
793 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
794 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
795 | 795 | $ignoreImport = true; |
796 | 796 | } |
797 | 797 | } |
798 | 798 | } |
799 | 799 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
800 | 800 | $ignoreImport = true; |
801 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
802 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
801 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
802 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
803 | 803 | $ignoreImport = false; |
804 | 804 | } |
805 | 805 | } |
806 | 806 | } |
807 | 807 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
808 | 808 | $ignoreImport = true; |
809 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
809 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
810 | 810 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
811 | 811 | $ignoreImport = false; |
812 | 812 | } |
@@ -818,32 +818,32 @@ discard block |
||
818 | 818 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
819 | 819 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
820 | 820 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
821 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
821 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
822 | 822 | $timeelapsed = microtime(true); |
823 | 823 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
824 | 824 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
825 | 825 | $Spotter = new Spotter($this->db); |
826 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
826 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
827 | 827 | $Spotter->db = null; |
828 | 828 | if ($globalDebug && isset($result)) echo $result."\n"; |
829 | 829 | } |
830 | 830 | } |
831 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
831 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
832 | 832 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
833 | 833 | |
834 | 834 | // Add source stat in DB |
835 | 835 | $Stats = new Stats($this->db); |
836 | 836 | if (!empty($this->stats)) { |
837 | 837 | if ($globalDebug) echo 'Add source stats : '; |
838 | - foreach($this->stats as $date => $data) { |
|
839 | - foreach($data as $source => $sourced) { |
|
838 | + foreach ($this->stats as $date => $data) { |
|
839 | + foreach ($data as $source => $sourced) { |
|
840 | 840 | //print_r($sourced); |
841 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
842 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
841 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
842 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
843 | 843 | if (isset($sourced['msg'])) { |
844 | 844 | if (time() - $sourced['msg']['date'] > 10) { |
845 | 845 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
846 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
846 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
847 | 847 | unset($this->stats[$date][$source]['msg']); |
848 | 848 | } |
849 | 849 | } |
@@ -881,14 +881,14 @@ discard block |
||
881 | 881 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
882 | 882 | $SpotterLive = new SpotterLive($this->db); |
883 | 883 | $SpotterLive->deleteLiveSpotterData(); |
884 | - $SpotterLive->db=null; |
|
884 | + $SpotterLive->db = null; |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 | if ($globalDebug) echo " Done\n"; |
888 | 888 | $this->last_delete = time(); |
889 | 889 | } |
890 | 890 | } else { |
891 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
891 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
892 | 892 | $this->all_flights[$id]['id'] = $recent_ident; |
893 | 893 | $this->all_flights[$id]['addedSpotter'] = 1; |
894 | 894 | } |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
897 | 897 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
898 | 898 | $Spotter = new Spotter($this->db); |
899 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
899 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
900 | 900 | $Spotter->db = null; |
901 | 901 | } |
902 | 902 | } |
@@ -922,37 +922,37 @@ discard block |
||
922 | 922 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
923 | 923 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
924 | 924 | |
925 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
925 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
926 | 926 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
927 | 927 | $ignoreImport = true; |
928 | 928 | } |
929 | 929 | } |
930 | 930 | if (count($globalAirportAccept) > 0) { |
931 | 931 | $ignoreImport = true; |
932 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
932 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
933 | 933 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
934 | 934 | $ignoreImport = false; |
935 | 935 | } |
936 | 936 | } |
937 | 937 | } |
938 | 938 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
939 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
940 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
939 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
940 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
941 | 941 | $ignoreImport = true; |
942 | 942 | } |
943 | 943 | } |
944 | 944 | } |
945 | 945 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
946 | 946 | $ignoreImport = true; |
947 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
948 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
947 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
948 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
949 | 949 | $ignoreImport = false; |
950 | 950 | } |
951 | 951 | } |
952 | 952 | } |
953 | 953 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
954 | 954 | $ignoreImport = true; |
955 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
955 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
956 | 956 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
957 | 957 | $ignoreImport = false; |
958 | 958 | } |
@@ -960,23 +960,23 @@ discard block |
||
960 | 960 | } |
961 | 961 | |
962 | 962 | if (!$ignoreImport) { |
963 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
964 | - 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'))); |
|
963 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
964 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
965 | 965 | $timeelapsed = microtime(true); |
966 | 966 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
967 | 967 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
968 | 968 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
969 | 969 | $SpotterLive = new SpotterLive($this->db); |
970 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
970 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
971 | 971 | $SpotterLive->db = null; |
972 | 972 | if ($globalDebug) echo $result."\n"; |
973 | 973 | } |
974 | 974 | } |
975 | 975 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
976 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
976 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
977 | 977 | } |
978 | 978 | $this->all_flights[$id]['putinarchive'] = false; |
979 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
979 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
980 | 980 | |
981 | 981 | // Put statistics in $this->stats variable |
982 | 982 | //if ($line['format_source'] != 'aprs') { |
@@ -995,19 +995,19 @@ discard block |
||
995 | 995 | $latitude = $globalCenterLatitude; |
996 | 996 | $longitude = $globalCenterLongitude; |
997 | 997 | } |
998 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
998 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
999 | 999 | } else { |
1000 | 1000 | $latitude = $this->source_location[$source]['latitude']; |
1001 | 1001 | $longitude = $this->source_location[$source]['longitude']; |
1002 | 1002 | } |
1003 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1003 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1004 | 1004 | //$stats_heading = $stats_heading%22.5; |
1005 | 1005 | $stats_heading = round($stats_heading/22.5); |
1006 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1006 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1007 | 1007 | $current_date = date('Y-m-d'); |
1008 | 1008 | if ($stats_heading == 16) $stats_heading = 0; |
1009 | 1009 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1010 | - for ($i=0;$i<=15;$i++) { |
|
1010 | + for ($i = 0; $i <= 15; $i++) { |
|
1011 | 1011 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
1012 | 1012 | } |
1013 | 1013 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1022,9 +1022,9 @@ discard block |
||
1022 | 1022 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1023 | 1023 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1024 | 1024 | end($this->stats[$current_date][$source]['hist']); |
1025 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1025 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
1026 | 1026 | } else $mini = 0; |
1027 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
1027 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
1028 | 1028 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1029 | 1029 | } |
1030 | 1030 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | $this->all_flights[$id]['lastupdate'] = time(); |
1038 | 1038 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
1039 | 1039 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1040 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1040 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
1041 | 1041 | //$this->del(); |
1042 | 1042 | |
1043 | 1043 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | try { |
53 | 53 | $GeoidClass = new GeoidHeight(); |
54 | 54 | } catch(Exception $e) { |
55 | - if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php \n"; |
|
55 | + if ($globalDebug) { |
|
56 | + echo "Can't calculate geoid, check that you downloaded it via update_db.php \n"; |
|
57 | + } |
|
56 | 58 | $GeoidClass = FALSE; |
57 | 59 | } |
58 | 60 | } |
@@ -71,7 +73,9 @@ discard block |
||
71 | 73 | $dbc = $this->db; |
72 | 74 | $this->all_flights[$id]['schedule_check'] = true; |
73 | 75 | if ($globalSchedulesFetch) { |
74 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
76 | + if ($globalDebug) { |
|
77 | + echo 'Getting schedule info...'."\n"; |
|
78 | + } |
|
75 | 79 | $Spotter = new Spotter($dbc); |
76 | 80 | $Schedule = new Schedule($dbc); |
77 | 81 | $Translation = new Translation($dbc); |
@@ -82,7 +86,9 @@ discard block |
||
82 | 86 | if ($Schedule->checkSchedule($operator) == 0) { |
83 | 87 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 88 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
89 | + if ($globalDebug) { |
|
90 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
91 | + } |
|
86 | 92 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
87 | 93 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
88 | 94 | // Should also check if route schedule = route from DB |
@@ -91,7 +97,9 @@ discard block |
||
91 | 97 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
92 | 98 | if (trim($airport_icao) != '') { |
93 | 99 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
94 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
100 | + if ($globalDebug) { |
|
101 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
102 | + } |
|
95 | 103 | } |
96 | 104 | } |
97 | 105 | } |
@@ -100,17 +108,25 @@ discard block |
||
100 | 108 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
101 | 109 | if (trim($airport_icao) != '') { |
102 | 110 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
103 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
111 | + if ($globalDebug) { |
|
112 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
113 | + } |
|
104 | 114 | } |
105 | 115 | } |
106 | 116 | } |
107 | 117 | $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
108 | 118 | } |
109 | - } else $scheduleexist = true; |
|
110 | - } else $scheduleexist = true; |
|
119 | + } else { |
|
120 | + $scheduleexist = true; |
|
121 | + } |
|
122 | + } else { |
|
123 | + $scheduleexist = true; |
|
124 | + } |
|
111 | 125 | // close connection, at least one way will work ? |
112 | 126 | if ($scheduleexist) { |
113 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
127 | + if ($globalDebug) { |
|
128 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
129 | + } |
|
114 | 130 | $sch = $Schedule->getSchedule($operator); |
115 | 131 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
116 | 132 | } |
@@ -132,14 +148,18 @@ discard block |
||
132 | 148 | |
133 | 149 | public function checkAll() { |
134 | 150 | global $globalDebug, $globalNoImport; |
135 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
151 | + if ($globalDebug) { |
|
152 | + echo "Update last seen flights data...\n"; |
|
153 | + } |
|
136 | 154 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
137 | 155 | foreach ($this->all_flights as $key => $flight) { |
138 | 156 | if (isset($this->all_flights[$key]['id'])) { |
139 | 157 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
140 | 158 | $Spotter = new Spotter($this->db); |
141 | 159 | $real_arrival = $this->arrival($key); |
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
160 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) { |
|
161 | + $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']); |
|
162 | + } |
|
143 | 163 | } |
144 | 164 | } |
145 | 165 | } |
@@ -147,24 +167,32 @@ discard block |
||
147 | 167 | |
148 | 168 | public function arrival($key) { |
149 | 169 | global $globalClosestMinDist, $globalDebug; |
150 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
170 | + if ($globalDebug) { |
|
171 | + echo 'Update arrival...'."\n"; |
|
172 | + } |
|
151 | 173 | $Spotter = new Spotter($this->db); |
152 | 174 | $airport_icao = ''; |
153 | 175 | $airport_time = ''; |
154 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
176 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
177 | + $globalClosestMinDist = 50; |
|
178 | + } |
|
155 | 179 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | 180 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
157 | 181 | if (isset($closestAirports[0])) { |
158 | 182 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
159 | 183 | $airport_icao = $closestAirports[0]['icao']; |
160 | 184 | $airport_time = $this->all_flights[$key]['datetime']; |
161 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
185 | + if ($globalDebug) { |
|
186 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
187 | + } |
|
162 | 188 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
163 | 189 | foreach ($closestAirports as $airport) { |
164 | 190 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
165 | 191 | $airport_icao = $airport['icao']; |
166 | 192 | $airport_time = $this->all_flights[$key]['datetime']; |
167 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
193 | + if ($globalDebug) { |
|
194 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
195 | + } |
|
168 | 196 | break; |
169 | 197 | } |
170 | 198 | } |
@@ -172,14 +200,20 @@ discard block |
||
172 | 200 | $airport_icao = $closestAirports[0]['icao']; |
173 | 201 | $airport_time = $this->all_flights[$key]['datetime']; |
174 | 202 | } else { |
175 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
203 | + if ($globalDebug) { |
|
204 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
205 | + } |
|
176 | 206 | } |
177 | 207 | } else { |
178 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
208 | + if ($globalDebug) { |
|
209 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
210 | + } |
|
179 | 211 | } |
180 | 212 | |
181 | 213 | } else { |
182 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
216 | + } |
|
183 | 217 | } |
184 | 218 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
185 | 219 | } |
@@ -189,7 +223,9 @@ discard block |
||
189 | 223 | public function del() { |
190 | 224 | global $globalDebug, $globalNoImport, $globalNoDB; |
191 | 225 | // Delete old infos |
192 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
226 | + if ($globalDebug) { |
|
227 | + echo 'Delete old values and update latest data...'."\n"; |
|
228 | + } |
|
193 | 229 | foreach ($this->all_flights as $key => $flight) { |
194 | 230 | if (isset($flight['lastupdate'])) { |
195 | 231 | if ($flight['lastupdate'] < (time()-5900)) { |
@@ -203,13 +239,17 @@ discard block |
||
203 | 239 | global $globalDebug, $globalNoImport, $globalNoDB; |
204 | 240 | // Delete old infos |
205 | 241 | if (isset($this->all_flights[$key]['id'])) { |
206 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
244 | + } |
|
207 | 245 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
208 | 246 | $real_arrival = $this->arrival($key); |
209 | 247 | $Spotter = new Spotter($this->db); |
210 | 248 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
211 | 249 | $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']); |
212 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
250 | + if ($globalDebug && $result != 'success') { |
|
251 | + echo '!!! ERROR : '.$result."\n"; |
|
252 | + } |
|
213 | 253 | } |
214 | 254 | } |
215 | 255 | } |
@@ -219,9 +259,13 @@ discard block |
||
219 | 259 | public function add($line) { |
220 | 260 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass; |
221 | 261 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
222 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
223 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
224 | -/* |
|
262 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
263 | + $globalCoordMinChange = '0.02'; |
|
264 | + } |
|
265 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
266 | + $globalAircraftMaxUpdate = 3000; |
|
267 | + } |
|
268 | + /* |
|
225 | 269 | $Spotter = new Spotter(); |
226 | 270 | $dbc = $Spotter->db; |
227 | 271 | $SpotterLive = new SpotterLive($dbc); |
@@ -243,19 +287,28 @@ discard block |
||
243 | 287 | // SBS format is CSV format |
244 | 288 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
245 | 289 | //print_r($line); |
246 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
290 | + if (isset($line['hex'])) { |
|
291 | + $line['hex'] = strtoupper($line['hex']); |
|
292 | + } |
|
247 | 293 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
248 | 294 | |
249 | 295 | // Increment message number |
250 | 296 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
251 | 297 | $current_date = date('Y-m-d'); |
252 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
253 | - else $source = ''; |
|
254 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
298 | + if (isset($line['source_name'])) { |
|
299 | + $source = $line['source_name']; |
|
300 | + } else { |
|
301 | + $source = ''; |
|
302 | + } |
|
303 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
304 | + $source = $line['format_source']; |
|
305 | + } |
|
255 | 306 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
256 | 307 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
257 | 308 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
258 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
309 | + } else { |
|
310 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
311 | + } |
|
259 | 312 | } |
260 | 313 | |
261 | 314 | /* |
@@ -271,23 +324,38 @@ discard block |
||
271 | 324 | //$this->db = $dbc; |
272 | 325 | |
273 | 326 | //$hex = trim($line['hex']); |
274 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | - else $id = trim($line['id']); |
|
327 | + if (!isset($line['id'])) { |
|
328 | + $id = trim($line['hex']); |
|
329 | + } else { |
|
330 | + $id = trim($line['id']); |
|
331 | + } |
|
276 | 332 | |
277 | 333 | if (!isset($this->all_flights[$id])) { |
278 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
334 | + if ($globalDebug) { |
|
335 | + echo 'New flight...'."\n"; |
|
336 | + } |
|
279 | 337 | $this->all_flights[$id] = array(); |
280 | 338 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
281 | 339 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
340 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
341 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
342 | + } |
|
283 | 343 | if (!isset($line['id'])) { |
284 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
285 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
344 | + if (!isset($globalDaemon)) { |
|
345 | + $globalDaemon = TRUE; |
|
346 | + } |
|
347 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
286 | 348 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
349 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
350 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
351 | + } |
|
288 | 352 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
353 | + } else { |
|
354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
355 | + } |
|
356 | + if ($globalAllFlights !== FALSE) { |
|
357 | + $dataFound = true; |
|
358 | + } |
|
291 | 359 | } |
292 | 360 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | 361 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -309,12 +377,20 @@ discard block |
||
309 | 377 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | 378 | } |
311 | 379 | $Spotter->db = null; |
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
380 | + if ($globalDebugTimeElapsed) { |
|
381 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
382 | + } |
|
383 | + if ($aircraft_icao != '') { |
|
384 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
385 | + } |
|
314 | 386 | } |
315 | 387 | } |
316 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
388 | + if ($globalAllFlights !== FALSE) { |
|
389 | + $dataFound = true; |
|
390 | + } |
|
391 | + if ($globalDebug) { |
|
392 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
393 | + } |
|
318 | 394 | } |
319 | 395 | if (isset($line['id']) && !isset($line['hex'])) { |
320 | 396 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
@@ -322,7 +398,9 @@ discard block |
||
322 | 398 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
323 | 399 | $icao = $line['aircraft_icao']; |
324 | 400 | $Spotter = new Spotter($this->db); |
325 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
401 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
402 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
403 | + } |
|
326 | 404 | $Spotter->db = null; |
327 | 405 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
328 | 406 | } |
@@ -332,15 +410,24 @@ discard block |
||
332 | 410 | $Spotter = new Spotter($this->db); |
333 | 411 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
334 | 412 | $Spotter->db = null; |
335 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
413 | + if ($aircraft_icao != '') { |
|
414 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
415 | + } |
|
336 | 416 | } |
337 | 417 | } |
338 | 418 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
339 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
340 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
341 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
342 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
343 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
419 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
420 | + $aircraft_icao = 'GLID'; |
|
421 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
422 | + $aircraft_icao = 'UHEL'; |
|
423 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
424 | + $aircraft_icao = 'TOWPLANE'; |
|
425 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
426 | + $aircraft_icao = 'POWAIRC'; |
|
427 | + } |
|
428 | + if (isset($aircraft_icao)) { |
|
429 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
430 | + } |
|
344 | 431 | } |
345 | 432 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
346 | 433 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -350,8 +437,11 @@ discard block |
||
350 | 437 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
351 | 438 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
352 | 439 | } else { |
353 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
354 | - 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"; |
|
440 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
441 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
442 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
443 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
444 | + } |
|
355 | 445 | /* |
356 | 446 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
357 | 447 | print_r($this->all_flights[$id]); |
@@ -360,16 +450,22 @@ discard block |
||
360 | 450 | return ''; |
361 | 451 | } |
362 | 452 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
363 | - if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
453 | + if ($globalDebug) { |
|
454 | + echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
455 | + } |
|
364 | 456 | return ''; |
365 | 457 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
366 | - if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
458 | + if ($globalDebug) { |
|
459 | + echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
460 | + } |
|
367 | 461 | return ''; |
368 | 462 | } elseif (!isset($line['datetime'])) { |
369 | 463 | date_default_timezone_set('UTC'); |
370 | 464 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
371 | 465 | } else { |
372 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
466 | + if ($globalDebug) { |
|
467 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
468 | + } |
|
373 | 469 | return ''; |
374 | 470 | } |
375 | 471 | |
@@ -390,30 +486,48 @@ discard block |
||
390 | 486 | |
391 | 487 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
392 | 488 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
393 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
489 | + if ($globalDebug) { |
|
490 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
491 | + } |
|
394 | 492 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
395 | 493 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
396 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
397 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
398 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
494 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
495 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
496 | + } elseif (isset($line['id'])) { |
|
497 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
498 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
499 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
500 | + } |
|
399 | 501 | } else { |
400 | 502 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
401 | 503 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
402 | 504 | $timeelapsed = microtime(true); |
403 | 505 | $Spotter = new Spotter($this->db); |
404 | 506 | $fromsource = NULL; |
405 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
406 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
407 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
408 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
409 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
507 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
508 | + $fromsource = $globalAirlinesSource; |
|
509 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
510 | + $fromsource = 'vatsim'; |
|
511 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
512 | + $fromsource = 'ivao'; |
|
513 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
514 | + $fromsource = 'vatsim'; |
|
515 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
516 | + $fromsource = 'ivao'; |
|
517 | + } |
|
410 | 518 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
411 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
519 | + if ($globalDebug && $result != 'success') { |
|
520 | + echo '!!! ERROR : '.$result."\n"; |
|
521 | + } |
|
412 | 522 | $Spotter->db = null; |
413 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
523 | + if ($globalDebugTimeElapsed) { |
|
524 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
525 | + } |
|
414 | 526 | } |
415 | 527 | } |
416 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
528 | + } else { |
|
529 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
530 | + } |
|
417 | 531 | |
418 | 532 | /* |
419 | 533 | if (!isset($line['id'])) { |
@@ -423,7 +537,9 @@ discard block |
||
423 | 537 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
424 | 538 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
425 | 539 | */ |
426 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
540 | + if (!isset($this->all_flights[$id]['id'])) { |
|
541 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
542 | + } |
|
427 | 543 | |
428 | 544 | //$putinarchive = true; |
429 | 545 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -441,7 +557,9 @@ discard block |
||
441 | 557 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
442 | 558 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
443 | 559 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
560 | + if ($globalDebugTimeElapsed) { |
|
561 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
562 | + } |
|
445 | 563 | } |
446 | 564 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
447 | 565 | $timeelapsed = microtime(true); |
@@ -455,7 +573,9 @@ discard block |
||
455 | 573 | $Translation->db = null; |
456 | 574 | } |
457 | 575 | $Spotter->db = null; |
458 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
576 | + if ($globalDebugTimeElapsed) { |
|
577 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
578 | + } |
|
459 | 579 | } |
460 | 580 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
461 | 581 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -464,9 +584,13 @@ discard block |
||
464 | 584 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
465 | 585 | } |
466 | 586 | } |
467 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
587 | + if (!isset($globalFork)) { |
|
588 | + $globalFork = TRUE; |
|
589 | + } |
|
468 | 590 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
469 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
591 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
592 | + $this->get_Schedule($id,trim($line['ident'])); |
|
593 | + } |
|
470 | 594 | } |
471 | 595 | } |
472 | 596 | } |
@@ -484,9 +608,13 @@ discard block |
||
484 | 608 | $speed = $speed*3.6; |
485 | 609 | if ($speed < 1000) { |
486 | 610 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
487 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
611 | + if ($globalDebug) { |
|
612 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
613 | + } |
|
488 | 614 | } else { |
489 | - if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
615 | + if ($globalDebug) { |
|
616 | + echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
617 | + } |
|
490 | 618 | } |
491 | 619 | } |
492 | 620 | } |
@@ -495,13 +623,21 @@ discard block |
||
495 | 623 | |
496 | 624 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
497 | 625 | if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
498 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
626 | + if ($globalDebug) { |
|
627 | + echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
628 | + } |
|
499 | 629 | return false; |
500 | 630 | } |
501 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
502 | - else unset($timediff); |
|
503 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
504 | - else unset($timediff_archive); |
|
631 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
632 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
633 | + } else { |
|
634 | + unset($timediff); |
|
635 | + } |
|
636 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
637 | + $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
638 | + } else { |
|
639 | + unset($timediff_archive); |
|
640 | + } |
|
505 | 641 | if ($this->tmd > 5 |
506 | 642 | || (isset($line['format_source']) |
507 | 643 | && $line['format_source'] == 'airwhere' |
@@ -537,16 +673,25 @@ discard block |
||
537 | 673 | $this->all_flights[$id]['putinarchive'] = true; |
538 | 674 | $this->tmd = 0; |
539 | 675 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
540 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
676 | + if ($globalDebug) { |
|
677 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
678 | + } |
|
541 | 679 | $timeelapsed = microtime(true); |
542 | 680 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
543 | 681 | $Spotter = new Spotter($this->db); |
544 | 682 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
545 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
546 | - else $this->all_flights[$id]['over_country'] = ''; |
|
683 | + if (!empty($all_country)) { |
|
684 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
685 | + } else { |
|
686 | + $this->all_flights[$id]['over_country'] = ''; |
|
687 | + } |
|
547 | 688 | $Spotter->db = null; |
548 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
549 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
689 | + if ($globalDebugTimeElapsed) { |
|
690 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
691 | + } |
|
692 | + if ($globalDebug) { |
|
693 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
694 | + } |
|
550 | 695 | } |
551 | 696 | } |
552 | 697 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
@@ -592,7 +737,9 @@ discard block |
||
592 | 737 | */ |
593 | 738 | } |
594 | 739 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
595 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
740 | + if ($line['longitude'] > 180) { |
|
741 | + $line['longitude'] = $line['longitude'] - 360; |
|
742 | + } |
|
596 | 743 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
597 | 744 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
598 | 745 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -629,7 +776,9 @@ discard block |
||
629 | 776 | } |
630 | 777 | } |
631 | 778 | if (isset($line['last_update']) && $line['last_update'] != '') { |
632 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
779 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
780 | + $dataFound = true; |
|
781 | + } |
|
633 | 782 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
634 | 783 | } |
635 | 784 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -651,35 +800,53 @@ discard block |
||
651 | 800 | // Here we force archive of flight because after ground it's a new one (or should be) |
652 | 801 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
653 | 802 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
654 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
655 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
656 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
803 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
804 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
805 | + } elseif (isset($line['id'])) { |
|
806 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
807 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
808 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
809 | + } |
|
810 | + } |
|
811 | + if ($line['ground'] != 1) { |
|
812 | + $line['ground'] = 0; |
|
657 | 813 | } |
658 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
659 | 814 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
660 | 815 | //$dataFound = true; |
661 | 816 | } |
662 | 817 | if (isset($line['squawk']) && $line['squawk'] != '') { |
663 | 818 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
664 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
819 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
820 | + $this->all_flights[$id]['putinarchive'] = true; |
|
821 | + } |
|
665 | 822 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
666 | 823 | $highlight = ''; |
667 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
668 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
669 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
824 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
825 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
826 | + } |
|
827 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
828 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
829 | + } |
|
830 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
831 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
832 | + } |
|
670 | 833 | if ($highlight != '') { |
671 | 834 | $timeelapsed = microtime(true); |
672 | 835 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
673 | 836 | $Spotter = new Spotter($this->db); |
674 | 837 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
675 | 838 | $Spotter->db = null; |
676 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
839 | + if ($globalDebugTimeElapsed) { |
|
840 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
841 | + } |
|
677 | 842 | } |
678 | 843 | //$putinarchive = true; |
679 | 844 | //$highlight = ''; |
680 | 845 | } |
681 | 846 | |
682 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
847 | + } else { |
|
848 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
849 | + } |
|
683 | 850 | //$dataFound = true; |
684 | 851 | } |
685 | 852 | |
@@ -692,19 +859,27 @@ discard block |
||
692 | 859 | } |
693 | 860 | } |
694 | 861 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
695 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
862 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
863 | + $this->all_flights[$id]['putinarchive'] = true; |
|
864 | + } |
|
696 | 865 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
697 | 866 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
698 | 867 | //$dataFound = true; |
699 | 868 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
700 | 869 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
701 | 870 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
702 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
871 | + if ($globalDebug) { |
|
872 | + echo '--- Reset because of altitude'."\n"; |
|
873 | + } |
|
703 | 874 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
704 | 875 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
705 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
706 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
707 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
876 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
877 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
878 | + } elseif (isset($line['id'])) { |
|
879 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
880 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
881 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
882 | + } |
|
708 | 883 | } |
709 | 884 | } |
710 | 885 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -715,22 +890,32 @@ discard block |
||
715 | 890 | } |
716 | 891 | |
717 | 892 | if (isset($line['heading']) && $line['heading'] != '') { |
718 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
893 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
894 | + $this->all_flights[$id]['putinarchive'] = true; |
|
895 | + } |
|
719 | 896 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
720 | 897 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
721 | 898 | //$dataFound = true; |
722 | 899 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
723 | 900 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
724 | 901 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
725 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
726 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
902 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
903 | + $this->all_flights[$id]['putinarchive'] = true; |
|
904 | + } |
|
905 | + if ($globalDebug) { |
|
906 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
907 | + } |
|
727 | 908 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
728 | 909 | // If not enough messages and ACARS set heading to 0 |
729 | 910 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
730 | 911 | } |
731 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
732 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
733 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
912 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
913 | + $dataFound = false; |
|
914 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
915 | + $dataFound = false; |
|
916 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) { |
|
917 | + $dataFound = false; |
|
918 | + } |
|
734 | 919 | |
735 | 920 | // print_r($this->all_flights[$id]); |
736 | 921 | //gets the callsign from the last hour |
@@ -747,23 +932,38 @@ discard block |
||
747 | 932 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
748 | 933 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
749 | 934 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
750 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
935 | + if ($globalDebug) { |
|
936 | + echo "Check if aircraft is already in DB..."; |
|
937 | + } |
|
751 | 938 | $timeelapsed = microtime(true); |
752 | 939 | $SpotterLive = new SpotterLive($this->db); |
753 | 940 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
754 | 941 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
755 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
942 | + if ($globalDebugTimeElapsed) { |
|
943 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
944 | + } |
|
756 | 945 | } elseif (isset($line['id'])) { |
757 | 946 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
758 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
947 | + if ($globalDebugTimeElapsed) { |
|
948 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
949 | + } |
|
759 | 950 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
760 | 951 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
761 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
762 | - } else $recent_ident = ''; |
|
952 | + if ($globalDebugTimeElapsed) { |
|
953 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
954 | + } |
|
955 | + } else { |
|
956 | + $recent_ident = ''; |
|
957 | + } |
|
763 | 958 | $SpotterLive->db=null; |
764 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
765 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
766 | - } else $recent_ident = ''; |
|
959 | + if ($globalDebug && $recent_ident == '') { |
|
960 | + echo " Not in DB.\n"; |
|
961 | + } elseif ($globalDebug && $recent_ident != '') { |
|
962 | + echo " Already in DB.\n"; |
|
963 | + } |
|
964 | + } else { |
|
965 | + $recent_ident = ''; |
|
966 | + } |
|
767 | 967 | } else { |
768 | 968 | $recent_ident = ''; |
769 | 969 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -771,7 +971,9 @@ discard block |
||
771 | 971 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
772 | 972 | if($recent_ident == "") |
773 | 973 | { |
774 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
974 | + if ($globalDebug) { |
|
975 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
976 | + } |
|
775 | 977 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
776 | 978 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
777 | 979 | //adds the spotter data for the archive |
@@ -815,31 +1017,49 @@ discard block |
||
815 | 1017 | |
816 | 1018 | if (!$ignoreImport) { |
817 | 1019 | $highlight = ''; |
818 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
819 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
820 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
821 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1020 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
1021 | + $highlight = 'Squawk 7500 : Hijack'; |
|
1022 | + } |
|
1023 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
1024 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
1025 | + } |
|
1026 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
1027 | + $highlight = 'Squawk 7700 : Emergency'; |
|
1028 | + } |
|
1029 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1030 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1031 | + } |
|
822 | 1032 | $timeelapsed = microtime(true); |
823 | 1033 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
824 | 1034 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
825 | 1035 | $Spotter = new Spotter($this->db); |
826 | 1036 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
827 | 1037 | $Spotter->db = null; |
828 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
1038 | + if ($globalDebug && isset($result)) { |
|
1039 | + echo $result."\n"; |
|
1040 | + } |
|
829 | 1041 | } |
830 | 1042 | } |
831 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1043 | + if ($globalDebugTimeElapsed) { |
|
1044 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1045 | + } |
|
832 | 1046 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
833 | 1047 | |
834 | 1048 | // Add source stat in DB |
835 | 1049 | $Stats = new Stats($this->db); |
836 | 1050 | if (!empty($this->stats)) { |
837 | - if ($globalDebug) echo 'Add source stats : '; |
|
1051 | + if ($globalDebug) { |
|
1052 | + echo 'Add source stats : '; |
|
1053 | + } |
|
838 | 1054 | foreach($this->stats as $date => $data) { |
839 | 1055 | foreach($data as $source => $sourced) { |
840 | 1056 | //print_r($sourced); |
841 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
842 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1057 | + if (isset($sourced['polar'])) { |
|
1058 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
1059 | + } |
|
1060 | + if (isset($sourced['hist'])) { |
|
1061 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1062 | + } |
|
843 | 1063 | if (isset($sourced['msg'])) { |
844 | 1064 | if (time() - $sourced['msg']['date'] > 10) { |
845 | 1065 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -852,13 +1072,17 @@ discard block |
||
852 | 1072 | unset($this->stats[$date]); |
853 | 1073 | } |
854 | 1074 | } |
855 | - if ($globalDebug) echo 'Done'."\n"; |
|
1075 | + if ($globalDebug) { |
|
1076 | + echo 'Done'."\n"; |
|
1077 | + } |
|
856 | 1078 | |
857 | 1079 | } |
858 | 1080 | $Stats->db = null; |
859 | 1081 | } |
860 | 1082 | $this->del(); |
861 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
1083 | + } elseif ($globalDebug) { |
|
1084 | + echo 'Ignore data'."\n"; |
|
1085 | + } |
|
862 | 1086 | //$ignoreImport = false; |
863 | 1087 | $this->all_flights[$id]['addedSpotter'] = 1; |
864 | 1088 | //print_r($this->all_flights[$id]); |
@@ -875,7 +1099,9 @@ discard block |
||
875 | 1099 | */ |
876 | 1100 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
877 | 1101 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
878 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1102 | + if ($globalDebug) { |
|
1103 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1104 | + } |
|
879 | 1105 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
880 | 1106 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
881 | 1107 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -884,7 +1110,9 @@ discard block |
||
884 | 1110 | $SpotterLive->db=null; |
885 | 1111 | } |
886 | 1112 | } |
887 | - if ($globalDebug) echo " Done\n"; |
|
1113 | + if ($globalDebug) { |
|
1114 | + echo " Done\n"; |
|
1115 | + } |
|
888 | 1116 | $this->last_delete = time(); |
889 | 1117 | } |
890 | 1118 | } else { |
@@ -911,11 +1139,17 @@ discard block |
||
911 | 1139 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
912 | 1140 | if ($globalDebug) { |
913 | 1141 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
914 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
915 | - 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"; |
|
1142 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1143 | + 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"; |
|
1144 | + } else { |
|
1145 | + 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"; |
|
1146 | + } |
|
916 | 1147 | } else { |
917 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
918 | - 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"; |
|
1148 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1149 | + 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"; |
|
1150 | + } else { |
|
1151 | + 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"; |
|
1152 | + } |
|
919 | 1153 | } |
920 | 1154 | } |
921 | 1155 | $ignoreImport = false; |
@@ -961,22 +1195,30 @@ discard block |
||
961 | 1195 | |
962 | 1196 | if (!$ignoreImport) { |
963 | 1197 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
964 | - 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'))); |
|
1198 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1199 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1200 | + } |
|
965 | 1201 | $timeelapsed = microtime(true); |
966 | 1202 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
967 | 1203 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
968 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1204 | + if ($globalDebug) { |
|
1205 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1206 | + } |
|
969 | 1207 | $SpotterLive = new SpotterLive($this->db); |
970 | 1208 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
971 | 1209 | $SpotterLive->db = null; |
972 | - if ($globalDebug) echo $result."\n"; |
|
1210 | + if ($globalDebug) { |
|
1211 | + echo $result."\n"; |
|
1212 | + } |
|
973 | 1213 | } |
974 | 1214 | } |
975 | 1215 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
976 | 1216 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
977 | 1217 | } |
978 | 1218 | $this->all_flights[$id]['putinarchive'] = false; |
979 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1219 | + if ($globalDebugTimeElapsed) { |
|
1220 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1221 | + } |
|
980 | 1222 | |
981 | 1223 | // Put statistics in $this->stats variable |
982 | 1224 | //if ($line['format_source'] != 'aprs') { |
@@ -984,7 +1226,9 @@ discard block |
||
984 | 1226 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
985 | 1227 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
986 | 1228 | $source = $this->all_flights[$id]['source_name']; |
987 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
1229 | + if ($source == '') { |
|
1230 | + $source = $this->all_flights[$id]['format_source']; |
|
1231 | + } |
|
988 | 1232 | if (!isset($this->source_location[$source])) { |
989 | 1233 | $Location = new Source(); |
990 | 1234 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -1005,7 +1249,9 @@ discard block |
||
1005 | 1249 | $stats_heading = round($stats_heading/22.5); |
1006 | 1250 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
1007 | 1251 | $current_date = date('Y-m-d'); |
1008 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1252 | + if ($stats_heading == 16) { |
|
1253 | + $stats_heading = 0; |
|
1254 | + } |
|
1009 | 1255 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1010 | 1256 | for ($i=0;$i<=15;$i++) { |
1011 | 1257 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -1023,7 +1269,9 @@ discard block |
||
1023 | 1269 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1024 | 1270 | end($this->stats[$current_date][$source]['hist']); |
1025 | 1271 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
1026 | - } else $mini = 0; |
|
1272 | + } else { |
|
1273 | + $mini = 0; |
|
1274 | + } |
|
1027 | 1275 | for ($i=$mini;$i<=$distance;$i+=10) { |
1028 | 1276 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1029 | 1277 | } |
@@ -1035,19 +1283,27 @@ discard block |
||
1035 | 1283 | } |
1036 | 1284 | |
1037 | 1285 | $this->all_flights[$id]['lastupdate'] = time(); |
1038 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1286 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1287 | + $send = true; |
|
1288 | + } |
|
1039 | 1289 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1040 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1290 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1291 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1292 | + } |
|
1041 | 1293 | //$this->del(); |
1042 | 1294 | |
1043 | 1295 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1044 | 1296 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
1045 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1297 | + if ($globalDebug) { |
|
1298 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1299 | + } |
|
1046 | 1300 | $SpotterLive = new SpotterLive($this->db); |
1047 | 1301 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
1048 | 1302 | $SpotterLive->db = null; |
1049 | 1303 | //SpotterLive->deleteLiveSpotterData(); |
1050 | - if ($globalDebug) echo " Done\n"; |
|
1304 | + if ($globalDebug) { |
|
1305 | + echo " Done\n"; |
|
1306 | + } |
|
1051 | 1307 | $this->last_delete_hourly = time(); |
1052 | 1308 | } else { |
1053 | 1309 | $this->del(); |
@@ -1059,7 +1315,9 @@ discard block |
||
1059 | 1315 | //$ignoreImport = false; |
1060 | 1316 | } |
1061 | 1317 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1062 | - if ($send) return $this->all_flights[$id]; |
|
1318 | + if ($send) { |
|
1319 | + return $this->all_flights[$id]; |
|
1320 | + } |
|
1063 | 1321 | } |
1064 | 1322 | } |
1065 | 1323 | } |
@@ -76,38 +76,38 @@ discard block |
||
76 | 76 | try { |
77 | 77 | //$Connection = new Connection(); |
78 | 78 | $sth = $Connection->db->prepare($query); |
79 | - $sth->execute(array(':source' => $database_file)); |
|
80 | - } catch(PDOException $e) { |
|
81 | - return "error : ".$e->getMessage(); |
|
82 | - } |
|
79 | + $sth->execute(array(':source' => $database_file)); |
|
80 | + } catch(PDOException $e) { |
|
81 | + return "error : ".$e->getMessage(); |
|
82 | + } |
|
83 | 83 | |
84 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
85 | - update_db::connect_sqlite($database_file); |
|
84 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
85 | + update_db::connect_sqlite($database_file); |
|
86 | 86 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
87 | 87 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
88 | 88 | try { |
89 | - $sth = update_db::$db_sqlite->prepare($query); |
|
90 | - $sth->execute(); |
|
91 | - } catch(PDOException $e) { |
|
92 | - return "error : ".$e->getMessage(); |
|
93 | - } |
|
89 | + $sth = update_db::$db_sqlite->prepare($query); |
|
90 | + $sth->execute(); |
|
91 | + } catch(PDOException $e) { |
|
92 | + return "error : ".$e->getMessage(); |
|
93 | + } |
|
94 | 94 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
95 | 95 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
96 | 96 | $Connection = new Connection(); |
97 | 97 | $sth_dest = $Connection->db->prepare($query_dest); |
98 | 98 | try { |
99 | 99 | if ($globalTransaction) $Connection->db->beginTransaction(); |
100 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
100 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
101 | 101 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
102 | 102 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
103 | 103 | $sth_dest->execute($query_dest_values); |
104 | - } |
|
104 | + } |
|
105 | 105 | if ($globalTransaction) $Connection->db->commit(); |
106 | 106 | } catch(PDOException $e) { |
107 | 107 | if ($globalTransaction) $Connection->db->rollBack(); |
108 | 108 | return "error : ".$e->getMessage(); |
109 | 109 | } |
110 | - return ''; |
|
110 | + return ''; |
|
111 | 111 | } |
112 | 112 | public static function retrieve_route_oneworld($database_file) { |
113 | 113 | global $globalDebug, $globalTransaction; |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | try { |
119 | 119 | //$Connection = new Connection(); |
120 | 120 | $sth = $Connection->db->prepare($query); |
121 | - $sth->execute(array(':source' => 'oneworld')); |
|
122 | - } catch(PDOException $e) { |
|
123 | - return "error : ".$e->getMessage(); |
|
124 | - } |
|
121 | + $sth->execute(array(':source' => 'oneworld')); |
|
122 | + } catch(PDOException $e) { |
|
123 | + return "error : ".$e->getMessage(); |
|
124 | + } |
|
125 | 125 | |
126 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
126 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
127 | 127 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
128 | 128 | $Spotter = new Spotter(); |
129 | 129 | if ($fh = fopen($database_file,"r")) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | if ($globalTransaction) $Connection->db->commit(); |
149 | 149 | } |
150 | - return ''; |
|
150 | + return ''; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | public static function retrieve_route_skyteam($database_file) { |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | try { |
160 | 160 | //$Connection = new Connection(); |
161 | 161 | $sth = $Connection->db->prepare($query); |
162 | - $sth->execute(array(':source' => 'skyteam')); |
|
163 | - } catch(PDOException $e) { |
|
164 | - return "error : ".$e->getMessage(); |
|
165 | - } |
|
162 | + $sth->execute(array(':source' => 'skyteam')); |
|
163 | + } catch(PDOException $e) { |
|
164 | + return "error : ".$e->getMessage(); |
|
165 | + } |
|
166 | 166 | |
167 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
167 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
168 | 168 | |
169 | 169 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
170 | 170 | $Spotter = new Spotter(); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | return "error : ".$e->getMessage(); |
191 | 191 | } |
192 | 192 | } |
193 | - return ''; |
|
193 | + return ''; |
|
194 | 194 | } |
195 | 195 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
196 | 196 | global $globalTransaction; |
@@ -199,27 +199,27 @@ discard block |
||
199 | 199 | try { |
200 | 200 | $Connection = new Connection(); |
201 | 201 | $sth = $Connection->db->prepare($query); |
202 | - $sth->execute(array(':source' => $database_file)); |
|
203 | - } catch(PDOException $e) { |
|
204 | - return "error : ".$e->getMessage(); |
|
205 | - } |
|
202 | + $sth->execute(array(':source' => $database_file)); |
|
203 | + } catch(PDOException $e) { |
|
204 | + return "error : ".$e->getMessage(); |
|
205 | + } |
|
206 | 206 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
207 | 207 | try { |
208 | 208 | $Connection = new Connection(); |
209 | 209 | $sth = $Connection->db->prepare($query); |
210 | - $sth->execute(array(':source' => $database_file)); |
|
211 | - } catch(PDOException $e) { |
|
212 | - return "error : ".$e->getMessage(); |
|
213 | - } |
|
210 | + $sth->execute(array(':source' => $database_file)); |
|
211 | + } catch(PDOException $e) { |
|
212 | + return "error : ".$e->getMessage(); |
|
213 | + } |
|
214 | 214 | |
215 | - update_db::connect_sqlite($database_file); |
|
215 | + update_db::connect_sqlite($database_file); |
|
216 | 216 | $query = 'select * from Aircraft'; |
217 | 217 | try { |
218 | - $sth = update_db::$db_sqlite->prepare($query); |
|
219 | - $sth->execute(); |
|
220 | - } catch(PDOException $e) { |
|
221 | - return "error : ".$e->getMessage(); |
|
222 | - } |
|
218 | + $sth = update_db::$db_sqlite->prepare($query); |
|
219 | + $sth->execute(); |
|
220 | + } catch(PDOException $e) { |
|
221 | + return "error : ".$e->getMessage(); |
|
222 | + } |
|
223 | 223 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
224 | 224 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
225 | 225 | |
@@ -230,17 +230,17 @@ discard block |
||
230 | 230 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
231 | 231 | try { |
232 | 232 | if ($globalTransaction) $Connection->db->beginTransaction(); |
233 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
233 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
234 | 234 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
235 | 235 | if ($values['UserString4'] == 'M') $type = 'military'; |
236 | 236 | else $type = null; |
237 | 237 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
238 | 238 | $sth_dest->execute($query_dest_values); |
239 | 239 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
240 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
241 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
240 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
241 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
242 | 242 | } |
243 | - } |
|
243 | + } |
|
244 | 244 | if ($globalTransaction) $Connection->db->commit(); |
245 | 245 | } catch(PDOException $e) { |
246 | 246 | return "error : ".$e->getMessage(); |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | try { |
252 | 252 | $Connection = new Connection(); |
253 | 253 | $sth = $Connection->db->prepare($query); |
254 | - $sth->execute(array(':source' => $database_file)); |
|
255 | - } catch(PDOException $e) { |
|
256 | - return "error : ".$e->getMessage(); |
|
257 | - } |
|
254 | + $sth->execute(array(':source' => $database_file)); |
|
255 | + } catch(PDOException $e) { |
|
256 | + return "error : ".$e->getMessage(); |
|
257 | + } |
|
258 | 258 | return ''; |
259 | 259 | } |
260 | 260 | |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | try { |
267 | 267 | $Connection = new Connection(); |
268 | 268 | $sth = $Connection->db->prepare($query); |
269 | - $sth->execute(array(':source' => $database_file)); |
|
270 | - } catch(PDOException $e) { |
|
271 | - return "error : ".$e->getMessage(); |
|
272 | - } |
|
269 | + $sth->execute(array(':source' => $database_file)); |
|
270 | + } catch(PDOException $e) { |
|
271 | + return "error : ".$e->getMessage(); |
|
272 | + } |
|
273 | 273 | |
274 | 274 | if ($fh = fopen($database_file,"r")) { |
275 | 275 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -279,26 +279,26 @@ discard block |
||
279 | 279 | $sth_dest = $Connection->db->prepare($query_dest); |
280 | 280 | try { |
281 | 281 | if ($globalTransaction) $Connection->db->beginTransaction(); |
282 | - while (!feof($fh)) { |
|
283 | - $values = array(); |
|
284 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
282 | + while (!feof($fh)) { |
|
283 | + $values = array(); |
|
284 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
285 | 285 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
286 | - $values['ModeS'] = substr($line,0,6); |
|
287 | - $values['Registration'] = trim(substr($line,69,6)); |
|
288 | - $aircraft_name = trim(substr($line,48,6)); |
|
289 | - // Check if we can find ICAO, else set it to GLID |
|
290 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
291 | - $search_more = ''; |
|
292 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
293 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
294 | - $sth_search = $Connection->db->prepare($query_search); |
|
286 | + $values['ModeS'] = substr($line,0,6); |
|
287 | + $values['Registration'] = trim(substr($line,69,6)); |
|
288 | + $aircraft_name = trim(substr($line,48,6)); |
|
289 | + // Check if we can find ICAO, else set it to GLID |
|
290 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
291 | + $search_more = ''; |
|
292 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
293 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
294 | + $sth_search = $Connection->db->prepare($query_search); |
|
295 | 295 | try { |
296 | - $sth_search->execute(); |
|
297 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
298 | - //if (count($result) > 0) { |
|
299 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
300 | - $values['ICAOTypeCode'] = $result['icao']; |
|
301 | - } |
|
296 | + $sth_search->execute(); |
|
297 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
298 | + //if (count($result) > 0) { |
|
299 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
300 | + $values['ICAOTypeCode'] = $result['icao']; |
|
301 | + } |
|
302 | 302 | } catch(PDOException $e) { |
303 | 303 | return "error : ".$e->getMessage(); |
304 | 304 | } |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | try { |
322 | 322 | $Connection = new Connection(); |
323 | 323 | $sth = $Connection->db->prepare($query); |
324 | - $sth->execute(array(':source' => $database_file)); |
|
325 | - } catch(PDOException $e) { |
|
326 | - return "error : ".$e->getMessage(); |
|
327 | - } |
|
324 | + $sth->execute(array(':source' => $database_file)); |
|
325 | + } catch(PDOException $e) { |
|
326 | + return "error : ".$e->getMessage(); |
|
327 | + } |
|
328 | 328 | return ''; |
329 | 329 | } |
330 | 330 | |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | try { |
336 | 336 | $Connection = new Connection(); |
337 | 337 | $sth = $Connection->db->prepare($query); |
338 | - $sth->execute(array(':source' => $database_file)); |
|
339 | - } catch(PDOException $e) { |
|
340 | - return "error : ".$e->getMessage(); |
|
341 | - } |
|
338 | + $sth->execute(array(':source' => $database_file)); |
|
339 | + } catch(PDOException $e) { |
|
340 | + return "error : ".$e->getMessage(); |
|
341 | + } |
|
342 | 342 | |
343 | 343 | if ($fh = fopen($database_file,"r")) { |
344 | 344 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -349,25 +349,25 @@ discard block |
||
349 | 349 | try { |
350 | 350 | if ($globalTransaction) $Connection->db->beginTransaction(); |
351 | 351 | $tmp = fgetcsv($fh,9999,',',"'"); |
352 | - while (!feof($fh)) { |
|
353 | - $line = fgetcsv($fh,9999,',',"'"); |
|
352 | + while (!feof($fh)) { |
|
353 | + $line = fgetcsv($fh,9999,',',"'"); |
|
354 | 354 | |
355 | 355 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
356 | 356 | //print_r($line); |
357 | - $values['ModeS'] = $line[1]; |
|
358 | - $values['Registration'] = $line[3]; |
|
359 | - $values['ICAOTypeCode'] = ''; |
|
360 | - $aircraft_name = $line[2]; |
|
361 | - // Check if we can find ICAO, else set it to GLID |
|
362 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
363 | - $search_more = ''; |
|
364 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
365 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
366 | - $sth_search = $Connection->db->prepare($query_search); |
|
357 | + $values['ModeS'] = $line[1]; |
|
358 | + $values['Registration'] = $line[3]; |
|
359 | + $values['ICAOTypeCode'] = ''; |
|
360 | + $aircraft_name = $line[2]; |
|
361 | + // Check if we can find ICAO, else set it to GLID |
|
362 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
363 | + $search_more = ''; |
|
364 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
365 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
366 | + $sth_search = $Connection->db->prepare($query_search); |
|
367 | 367 | try { |
368 | - $sth_search->execute(); |
|
369 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
370 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
368 | + $sth_search->execute(); |
|
369 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
370 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
371 | 371 | } catch(PDOException $e) { |
372 | 372 | return "error : ".$e->getMessage(); |
373 | 373 | } |
@@ -390,10 +390,10 @@ discard block |
||
390 | 390 | try { |
391 | 391 | $Connection = new Connection(); |
392 | 392 | $sth = $Connection->db->prepare($query); |
393 | - $sth->execute(array(':source' => $database_file)); |
|
394 | - } catch(PDOException $e) { |
|
395 | - return "error : ".$e->getMessage(); |
|
396 | - } |
|
393 | + $sth->execute(array(':source' => $database_file)); |
|
394 | + } catch(PDOException $e) { |
|
395 | + return "error : ".$e->getMessage(); |
|
396 | + } |
|
397 | 397 | return ''; |
398 | 398 | } |
399 | 399 | |
@@ -404,16 +404,16 @@ discard block |
||
404 | 404 | try { |
405 | 405 | $Connection = new Connection(); |
406 | 406 | $sth = $Connection->db->prepare($query); |
407 | - $sth->execute(array(':source' => $database_file)); |
|
408 | - } catch(PDOException $e) { |
|
409 | - return "error : ".$e->getMessage(); |
|
410 | - } |
|
407 | + $sth->execute(array(':source' => $database_file)); |
|
408 | + } catch(PDOException $e) { |
|
409 | + return "error : ".$e->getMessage(); |
|
410 | + } |
|
411 | 411 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
412 | 412 | $Spotter = new Spotter(); |
413 | 413 | if ($fh = fopen($database_file,"r")) { |
414 | 414 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
415 | 415 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
416 | - $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
416 | + $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
417 | 417 | |
418 | 418 | $Connection = new Connection(); |
419 | 419 | $sth_dest = $Connection->db->prepare($query_dest); |
@@ -421,126 +421,126 @@ discard block |
||
421 | 421 | try { |
422 | 422 | if ($globalTransaction) $Connection->db->beginTransaction(); |
423 | 423 | $tmp = fgetcsv($fh,9999,',','"'); |
424 | - while (!feof($fh)) { |
|
425 | - $line = fgetcsv($fh,9999,',','"'); |
|
426 | - $values = array(); |
|
427 | - //print_r($line); |
|
428 | - if ($country == 'F') { |
|
429 | - $values['registration'] = $line[0]; |
|
430 | - $values['base'] = $line[4]; |
|
431 | - $values['owner'] = $line[5]; |
|
432 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
434 | - $values['cancel'] = $line[7]; |
|
424 | + while (!feof($fh)) { |
|
425 | + $line = fgetcsv($fh,9999,',','"'); |
|
426 | + $values = array(); |
|
427 | + //print_r($line); |
|
428 | + if ($country == 'F') { |
|
429 | + $values['registration'] = $line[0]; |
|
430 | + $values['base'] = $line[4]; |
|
431 | + $values['owner'] = $line[5]; |
|
432 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
433 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
434 | + $values['cancel'] = $line[7]; |
|
435 | 435 | } elseif ($country == 'EI') { |
436 | - // TODO : add modeS & reg to aircraft_modes |
|
437 | - $values['registration'] = $line[0]; |
|
438 | - $values['base'] = $line[3]; |
|
439 | - $values['owner'] = $line[2]; |
|
440 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
442 | - $values['cancel'] = ''; |
|
443 | - $values['modes'] = $line[7]; |
|
444 | - $values['icao'] = $line[8]; |
|
436 | + // TODO : add modeS & reg to aircraft_modes |
|
437 | + $values['registration'] = $line[0]; |
|
438 | + $values['base'] = $line[3]; |
|
439 | + $values['owner'] = $line[2]; |
|
440 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
441 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
442 | + $values['cancel'] = ''; |
|
443 | + $values['modes'] = $line[7]; |
|
444 | + $values['icao'] = $line[8]; |
|
445 | 445 | |
446 | 446 | } elseif ($country == 'HB') { |
447 | - // TODO : add modeS & reg to aircraft_modes |
|
448 | - $values['registration'] = $line[0]; |
|
449 | - $values['base'] = null; |
|
450 | - $values['owner'] = $line[5]; |
|
451 | - $values['date_first_reg'] = null; |
|
452 | - $values['cancel'] = ''; |
|
453 | - $values['modes'] = $line[4]; |
|
454 | - $values['icao'] = $line[7]; |
|
447 | + // TODO : add modeS & reg to aircraft_modes |
|
448 | + $values['registration'] = $line[0]; |
|
449 | + $values['base'] = null; |
|
450 | + $values['owner'] = $line[5]; |
|
451 | + $values['date_first_reg'] = null; |
|
452 | + $values['cancel'] = ''; |
|
453 | + $values['modes'] = $line[4]; |
|
454 | + $values['icao'] = $line[7]; |
|
455 | 455 | } elseif ($country == 'OK') { |
456 | - // TODO : add modeS & reg to aircraft_modes |
|
457 | - $values['registration'] = $line[3]; |
|
458 | - $values['base'] = null; |
|
459 | - $values['owner'] = $line[5]; |
|
460 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
462 | - $values['cancel'] = ''; |
|
456 | + // TODO : add modeS & reg to aircraft_modes |
|
457 | + $values['registration'] = $line[3]; |
|
458 | + $values['base'] = null; |
|
459 | + $values['owner'] = $line[5]; |
|
460 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
461 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
462 | + $values['cancel'] = ''; |
|
463 | 463 | } elseif ($country == 'VH') { |
464 | - // TODO : add modeS & reg to aircraft_modes |
|
465 | - $values['registration'] = $line[0]; |
|
466 | - $values['base'] = null; |
|
467 | - $values['owner'] = $line[12]; |
|
468 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
470 | - |
|
471 | - $values['cancel'] = $line[39]; |
|
464 | + // TODO : add modeS & reg to aircraft_modes |
|
465 | + $values['registration'] = $line[0]; |
|
466 | + $values['base'] = null; |
|
467 | + $values['owner'] = $line[12]; |
|
468 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
469 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
470 | + |
|
471 | + $values['cancel'] = $line[39]; |
|
472 | 472 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
473 | - $values['registration'] = $line[0]; |
|
474 | - $values['base'] = null; |
|
475 | - $values['owner'] = $line[4]; |
|
476 | - $values['date_first_reg'] = null; |
|
477 | - $values['cancel'] = ''; |
|
473 | + $values['registration'] = $line[0]; |
|
474 | + $values['base'] = null; |
|
475 | + $values['owner'] = $line[4]; |
|
476 | + $values['date_first_reg'] = null; |
|
477 | + $values['cancel'] = ''; |
|
478 | 478 | } elseif ($country == 'CC') { |
479 | - $values['registration'] = $line[0]; |
|
480 | - $values['base'] = null; |
|
481 | - $values['owner'] = $line[6]; |
|
482 | - $values['date_first_reg'] = null; |
|
483 | - $values['cancel'] = ''; |
|
479 | + $values['registration'] = $line[0]; |
|
480 | + $values['base'] = null; |
|
481 | + $values['owner'] = $line[6]; |
|
482 | + $values['date_first_reg'] = null; |
|
483 | + $values['cancel'] = ''; |
|
484 | 484 | } elseif ($country == 'HJ') { |
485 | - $values['registration'] = $line[0]; |
|
486 | - $values['base'] = null; |
|
487 | - $values['owner'] = $line[8]; |
|
488 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
490 | - $values['cancel'] = ''; |
|
485 | + $values['registration'] = $line[0]; |
|
486 | + $values['base'] = null; |
|
487 | + $values['owner'] = $line[8]; |
|
488 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
489 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
490 | + $values['cancel'] = ''; |
|
491 | 491 | } elseif ($country == 'PP') { |
492 | - $values['registration'] = $line[0]; |
|
493 | - $values['base'] = null; |
|
494 | - $values['owner'] = $line[4]; |
|
495 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
497 | - $values['cancel'] = $line[7]; |
|
492 | + $values['registration'] = $line[0]; |
|
493 | + $values['base'] = null; |
|
494 | + $values['owner'] = $line[4]; |
|
495 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
496 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
497 | + $values['cancel'] = $line[7]; |
|
498 | 498 | } elseif ($country == 'E7') { |
499 | - $values['registration'] = $line[0]; |
|
500 | - $values['base'] = null; |
|
501 | - $values['owner'] = $line[4]; |
|
502 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
504 | - $values['cancel'] = ''; |
|
499 | + $values['registration'] = $line[0]; |
|
500 | + $values['base'] = null; |
|
501 | + $values['owner'] = $line[4]; |
|
502 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
503 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
504 | + $values['cancel'] = ''; |
|
505 | 505 | } elseif ($country == '8Q') { |
506 | - $values['registration'] = $line[0]; |
|
507 | - $values['base'] = null; |
|
508 | - $values['owner'] = $line[3]; |
|
509 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
511 | - $values['cancel'] = ''; |
|
506 | + $values['registration'] = $line[0]; |
|
507 | + $values['base'] = null; |
|
508 | + $values['owner'] = $line[3]; |
|
509 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
510 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
511 | + $values['cancel'] = ''; |
|
512 | 512 | } elseif ($country == 'ZK') { |
513 | - $values['registration'] = $line[0]; |
|
514 | - $values['base'] = null; |
|
515 | - $values['owner'] = $line[3]; |
|
516 | - $values['date_first_reg'] = null; |
|
517 | - $values['cancel'] = ''; |
|
518 | - $values['modes'] = $line[5]; |
|
519 | - $values['icao'] = $line[9]; |
|
513 | + $values['registration'] = $line[0]; |
|
514 | + $values['base'] = null; |
|
515 | + $values['owner'] = $line[3]; |
|
516 | + $values['date_first_reg'] = null; |
|
517 | + $values['cancel'] = ''; |
|
518 | + $values['modes'] = $line[5]; |
|
519 | + $values['icao'] = $line[9]; |
|
520 | 520 | } elseif ($country == 'M') { |
521 | - $values['registration'] = $line[0]; |
|
522 | - $values['base'] = null; |
|
523 | - $values['owner'] = $line[6]; |
|
524 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
525 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
526 | - $values['modes'] = $line[4]; |
|
527 | - $values['icao'] = $line[10]; |
|
521 | + $values['registration'] = $line[0]; |
|
522 | + $values['base'] = null; |
|
523 | + $values['owner'] = $line[6]; |
|
524 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
525 | + $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
526 | + $values['modes'] = $line[4]; |
|
527 | + $values['icao'] = $line[10]; |
|
528 | 528 | } elseif ($country == 'OY') { |
529 | - $values['registration'] = $line[0]; |
|
530 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
531 | - $values['modes'] = $line[5]; |
|
532 | - $values['icao'] = $line[6]; |
|
529 | + $values['registration'] = $line[0]; |
|
530 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
531 | + $values['modes'] = $line[5]; |
|
532 | + $values['icao'] = $line[6]; |
|
533 | 533 | } elseif ($country == 'PH') { |
534 | - $values['registration'] = $line[0]; |
|
535 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
536 | - $values['modes'] = $line[4]; |
|
537 | - $values['icao'] = $line[5]; |
|
534 | + $values['registration'] = $line[0]; |
|
535 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
536 | + $values['modes'] = $line[4]; |
|
537 | + $values['icao'] = $line[5]; |
|
538 | 538 | } elseif ($country == 'OM' || $country == 'TF') { |
539 | - $values['registration'] = $line[0]; |
|
540 | - $values['base'] = null; |
|
541 | - $values['owner'] = $line[3]; |
|
542 | - $values['date_first_reg'] = null; |
|
543 | - $values['cancel'] = ''; |
|
539 | + $values['registration'] = $line[0]; |
|
540 | + $values['base'] = null; |
|
541 | + $values['owner'] = $line[3]; |
|
542 | + $values['date_first_reg'] = null; |
|
543 | + $values['cancel'] = ''; |
|
544 | 544 | } |
545 | 545 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
546 | 546 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | return "error : ".$e->getMessage(); |
674 | 674 | } |
675 | 675 | */ |
676 | - /* |
|
676 | + /* |
|
677 | 677 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
678 | 678 | try { |
679 | 679 | $Connection = new Connection(); |
@@ -918,10 +918,10 @@ discard block |
||
918 | 918 | try { |
919 | 919 | $Connection = new Connection(); |
920 | 920 | $sth = $Connection->db->prepare($query); |
921 | - $sth->execute(array(':source' => 'translation.csv')); |
|
922 | - } catch(PDOException $e) { |
|
923 | - return "error : ".$e->getMessage(); |
|
924 | - } |
|
921 | + $sth->execute(array(':source' => 'translation.csv')); |
|
922 | + } catch(PDOException $e) { |
|
923 | + return "error : ".$e->getMessage(); |
|
924 | + } |
|
925 | 925 | |
926 | 926 | |
927 | 927 | //update_db::unzip($out_file); |
@@ -940,21 +940,21 @@ discard block |
||
940 | 940 | $data = $row; |
941 | 941 | $operator = $data[2]; |
942 | 942 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
943 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
944 | - //echo substr($operator, 0, 2)."\n";; |
|
945 | - if (count($airline_array) > 0) { |
|
943 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
944 | + //echo substr($operator, 0, 2)."\n";; |
|
945 | + if (count($airline_array) > 0) { |
|
946 | 946 | //print_r($airline_array); |
947 | 947 | $operator = $airline_array[0]['icao'].substr($operator,2); |
948 | - } |
|
949 | - } |
|
948 | + } |
|
949 | + } |
|
950 | 950 | |
951 | 951 | $operator_correct = $data[3]; |
952 | 952 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
953 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
954 | - if (count($airline_array) > 0) { |
|
955 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
956 | - } |
|
957 | - } |
|
953 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
954 | + if (count($airline_array) > 0) { |
|
955 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
956 | + } |
|
957 | + } |
|
958 | 958 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
959 | 959 | try { |
960 | 960 | $sth = $Connection->db->prepare($query); |
@@ -968,7 +968,7 @@ discard block |
||
968 | 968 | //$Connection->db->commit(); |
969 | 969 | } |
970 | 970 | return ''; |
971 | - } |
|
971 | + } |
|
972 | 972 | |
973 | 973 | public static function translation_fam() { |
974 | 974 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -978,10 +978,10 @@ discard block |
||
978 | 978 | try { |
979 | 979 | $Connection = new Connection(); |
980 | 980 | $sth = $Connection->db->prepare($query); |
981 | - $sth->execute(array(':source' => 'website_fam')); |
|
982 | - } catch(PDOException $e) { |
|
983 | - return "error : ".$e->getMessage(); |
|
984 | - } |
|
981 | + $sth->execute(array(':source' => 'website_fam')); |
|
982 | + } catch(PDOException $e) { |
|
983 | + return "error : ".$e->getMessage(); |
|
984 | + } |
|
985 | 985 | |
986 | 986 | |
987 | 987 | //update_db::unzip($out_file); |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | //$Connection->db->commit(); |
1011 | 1011 | } |
1012 | 1012 | return ''; |
1013 | - } |
|
1013 | + } |
|
1014 | 1014 | |
1015 | 1015 | /* |
1016 | 1016 | * This function use FAA public data. |
@@ -1022,19 +1022,19 @@ discard block |
||
1022 | 1022 | try { |
1023 | 1023 | $Connection = new Connection(); |
1024 | 1024 | $sth = $Connection->db->prepare($query); |
1025 | - $sth->execute(array(':source' => 'website_faa')); |
|
1026 | - } catch(PDOException $e) { |
|
1027 | - return "error : ".$e->getMessage(); |
|
1028 | - } |
|
1025 | + $sth->execute(array(':source' => 'website_faa')); |
|
1026 | + } catch(PDOException $e) { |
|
1027 | + return "error : ".$e->getMessage(); |
|
1028 | + } |
|
1029 | 1029 | |
1030 | 1030 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
1031 | 1031 | try { |
1032 | 1032 | $Connection = new Connection(); |
1033 | 1033 | $sth = $Connection->db->prepare($query); |
1034 | - $sth->execute(array(':source' => 'website_faa')); |
|
1035 | - } catch(PDOException $e) { |
|
1036 | - return "error : ".$e->getMessage(); |
|
1037 | - } |
|
1034 | + $sth->execute(array(':source' => 'website_faa')); |
|
1035 | + } catch(PDOException $e) { |
|
1036 | + return "error : ".$e->getMessage(); |
|
1037 | + } |
|
1038 | 1038 | |
1039 | 1039 | $delimiter = ","; |
1040 | 1040 | $mfr = array(); |
@@ -1110,17 +1110,17 @@ discard block |
||
1110 | 1110 | } |
1111 | 1111 | print_r($mfr); |
1112 | 1112 | return ''; |
1113 | - } |
|
1113 | + } |
|
1114 | 1114 | public static function modes_fam() { |
1115 | 1115 | global $tmp_dir, $globalTransaction; |
1116 | 1116 | $query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source"; |
1117 | 1117 | try { |
1118 | 1118 | $Connection = new Connection(); |
1119 | 1119 | $sth = $Connection->db->prepare($query); |
1120 | - $sth->execute(array(':source' => 'website_fam')); |
|
1121 | - } catch(PDOException $e) { |
|
1122 | - return "error : ".$e->getMessage(); |
|
1123 | - } |
|
1120 | + $sth->execute(array(':source' => 'website_fam')); |
|
1121 | + } catch(PDOException $e) { |
|
1122 | + return "error : ".$e->getMessage(); |
|
1123 | + } |
|
1124 | 1124 | |
1125 | 1125 | |
1126 | 1126 | //update_db::unzip($out_file); |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | if ($globalTransaction) $Connection->db->commit(); |
1151 | 1151 | } |
1152 | 1152 | return ''; |
1153 | - } |
|
1153 | + } |
|
1154 | 1154 | |
1155 | 1155 | public static function owner_fam() { |
1156 | 1156 | global $tmp_dir, $globalTransaction; |
@@ -1158,10 +1158,10 @@ discard block |
||
1158 | 1158 | try { |
1159 | 1159 | $Connection = new Connection(); |
1160 | 1160 | $sth = $Connection->db->prepare($query); |
1161 | - $sth->execute(array(':source' => 'website_fam')); |
|
1162 | - } catch(PDOException $e) { |
|
1163 | - return "error : ".$e->getMessage(); |
|
1164 | - } |
|
1161 | + $sth->execute(array(':source' => 'website_fam')); |
|
1162 | + } catch(PDOException $e) { |
|
1163 | + return "error : ".$e->getMessage(); |
|
1164 | + } |
|
1165 | 1165 | |
1166 | 1166 | $delimiter = "\t"; |
1167 | 1167 | $Connection = new Connection(); |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | if ($globalTransaction) $Connection->db->commit(); |
1188 | 1188 | } |
1189 | 1189 | return ''; |
1190 | - } |
|
1190 | + } |
|
1191 | 1191 | |
1192 | 1192 | public static function routes_fam() { |
1193 | 1193 | global $tmp_dir, $globalTransaction; |
@@ -1195,10 +1195,10 @@ discard block |
||
1195 | 1195 | try { |
1196 | 1196 | $Connection = new Connection(); |
1197 | 1197 | $sth = $Connection->db->prepare($query); |
1198 | - $sth->execute(array(':source' => 'website_fam')); |
|
1199 | - } catch(PDOException $e) { |
|
1200 | - return "error : ".$e->getMessage(); |
|
1201 | - } |
|
1198 | + $sth->execute(array(':source' => 'website_fam')); |
|
1199 | + } catch(PDOException $e) { |
|
1200 | + return "error : ".$e->getMessage(); |
|
1201 | + } |
|
1202 | 1202 | |
1203 | 1203 | |
1204 | 1204 | //update_db::unzip($out_file); |
@@ -1227,7 +1227,7 @@ discard block |
||
1227 | 1227 | if ($globalTransaction) $Connection->db->commit(); |
1228 | 1228 | } |
1229 | 1229 | return ''; |
1230 | - } |
|
1230 | + } |
|
1231 | 1231 | |
1232 | 1232 | public static function marine_identity_fam() { |
1233 | 1233 | global $tmp_dir, $globalTransaction; |
@@ -1235,10 +1235,10 @@ discard block |
||
1235 | 1235 | try { |
1236 | 1236 | $Connection = new Connection(); |
1237 | 1237 | $sth = $Connection->db->prepare($query); |
1238 | - $sth->execute(); |
|
1239 | - } catch(PDOException $e) { |
|
1240 | - return "error : ".$e->getMessage(); |
|
1241 | - } |
|
1238 | + $sth->execute(); |
|
1239 | + } catch(PDOException $e) { |
|
1240 | + return "error : ".$e->getMessage(); |
|
1241 | + } |
|
1242 | 1242 | |
1243 | 1243 | |
1244 | 1244 | //update_db::unzip($out_file); |
@@ -1268,7 +1268,7 @@ discard block |
||
1268 | 1268 | if ($globalTransaction) $Connection->db->commit(); |
1269 | 1269 | } |
1270 | 1270 | return ''; |
1271 | - } |
|
1271 | + } |
|
1272 | 1272 | |
1273 | 1273 | public static function banned_fam() { |
1274 | 1274 | global $tmp_dir, $globalTransaction; |
@@ -1302,7 +1302,7 @@ discard block |
||
1302 | 1302 | if ($globalTransaction) $Connection->db->commit(); |
1303 | 1303 | } |
1304 | 1304 | return ''; |
1305 | - } |
|
1305 | + } |
|
1306 | 1306 | |
1307 | 1307 | public static function tle($filename,$tletype) { |
1308 | 1308 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1313,10 +1313,10 @@ discard block |
||
1313 | 1313 | try { |
1314 | 1314 | $Connection = new Connection(); |
1315 | 1315 | $sth = $Connection->db->prepare($query); |
1316 | - $sth->execute(array(':source' => $filename)); |
|
1317 | - } catch(PDOException $e) { |
|
1318 | - return "error : ".$e->getMessage(); |
|
1319 | - } |
|
1316 | + $sth->execute(array(':source' => $filename)); |
|
1317 | + } catch(PDOException $e) { |
|
1318 | + return "error : ".$e->getMessage(); |
|
1319 | + } |
|
1320 | 1320 | |
1321 | 1321 | $Connection = new Connection(); |
1322 | 1322 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1351,54 +1351,54 @@ discard block |
||
1351 | 1351 | //$Connection->db->commit(); |
1352 | 1352 | } |
1353 | 1353 | return ''; |
1354 | - } |
|
1354 | + } |
|
1355 | 1355 | |
1356 | 1356 | /** |
1357 | - * Convert a HTML table to an array |
|
1358 | - * @param String $data HTML page |
|
1359 | - * @return Array array of the tables in HTML page |
|
1360 | - */ |
|
1361 | - private static function table2array($data) { |
|
1362 | - $html = str_get_html($data); |
|
1363 | - $tabledata=array(); |
|
1364 | - foreach($html->find('tr') as $element) |
|
1365 | - { |
|
1366 | - $td = array(); |
|
1367 | - foreach( $element->find('th') as $row) |
|
1368 | - { |
|
1369 | - $td [] = trim($row->plaintext); |
|
1370 | - } |
|
1371 | - $td=array_filter($td); |
|
1372 | - $tabledata[] = $td; |
|
1373 | - |
|
1374 | - $td = array(); |
|
1375 | - $tdi = array(); |
|
1376 | - foreach( $element->find('td') as $row) |
|
1377 | - { |
|
1378 | - $td [] = trim($row->plaintext); |
|
1379 | - $tdi [] = trim($row->innertext); |
|
1380 | - } |
|
1381 | - $td=array_filter($td); |
|
1382 | - $tdi=array_filter($tdi); |
|
1383 | - // $tabledata[]=array_merge($td,$tdi); |
|
1384 | - $tabledata[]=$td; |
|
1385 | - } |
|
1386 | - return(array_filter($tabledata)); |
|
1387 | - } |
|
1388 | - |
|
1389 | - /** |
|
1390 | - * Get data from form result |
|
1391 | - * @param String $url form URL |
|
1392 | - * @return String the result |
|
1393 | - */ |
|
1394 | - private static function getData($url) { |
|
1395 | - $ch = curl_init(); |
|
1396 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
1397 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1398 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1399 | - curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
|
1400 | - return curl_exec($ch); |
|
1401 | - } |
|
1357 | + * Convert a HTML table to an array |
|
1358 | + * @param String $data HTML page |
|
1359 | + * @return Array array of the tables in HTML page |
|
1360 | + */ |
|
1361 | + private static function table2array($data) { |
|
1362 | + $html = str_get_html($data); |
|
1363 | + $tabledata=array(); |
|
1364 | + foreach($html->find('tr') as $element) |
|
1365 | + { |
|
1366 | + $td = array(); |
|
1367 | + foreach( $element->find('th') as $row) |
|
1368 | + { |
|
1369 | + $td [] = trim($row->plaintext); |
|
1370 | + } |
|
1371 | + $td=array_filter($td); |
|
1372 | + $tabledata[] = $td; |
|
1373 | + |
|
1374 | + $td = array(); |
|
1375 | + $tdi = array(); |
|
1376 | + foreach( $element->find('td') as $row) |
|
1377 | + { |
|
1378 | + $td [] = trim($row->plaintext); |
|
1379 | + $tdi [] = trim($row->innertext); |
|
1380 | + } |
|
1381 | + $td=array_filter($td); |
|
1382 | + $tdi=array_filter($tdi); |
|
1383 | + // $tabledata[]=array_merge($td,$tdi); |
|
1384 | + $tabledata[]=$td; |
|
1385 | + } |
|
1386 | + return(array_filter($tabledata)); |
|
1387 | + } |
|
1388 | + |
|
1389 | + /** |
|
1390 | + * Get data from form result |
|
1391 | + * @param String $url form URL |
|
1392 | + * @return String the result |
|
1393 | + */ |
|
1394 | + private static function getData($url) { |
|
1395 | + $ch = curl_init(); |
|
1396 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
1397 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1398 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1399 | + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
|
1400 | + return curl_exec($ch); |
|
1401 | + } |
|
1402 | 1402 | /* |
1403 | 1403 | public static function waypoints() { |
1404 | 1404 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -1481,7 +1481,7 @@ discard block |
||
1481 | 1481 | if ($globalTransaction) $Connection->db->commit(); |
1482 | 1482 | } |
1483 | 1483 | return ''; |
1484 | - } |
|
1484 | + } |
|
1485 | 1485 | |
1486 | 1486 | public static function ivao_airlines($filename) { |
1487 | 1487 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1491,10 +1491,10 @@ discard block |
||
1491 | 1491 | try { |
1492 | 1492 | $Connection = new Connection(); |
1493 | 1493 | $sth = $Connection->db->prepare($query); |
1494 | - $sth->execute(); |
|
1495 | - } catch(PDOException $e) { |
|
1496 | - return "error : ".$e->getMessage(); |
|
1497 | - } |
|
1494 | + $sth->execute(); |
|
1495 | + } catch(PDOException $e) { |
|
1496 | + return "error : ".$e->getMessage(); |
|
1497 | + } |
|
1498 | 1498 | |
1499 | 1499 | $header = NULL; |
1500 | 1500 | $delimiter = ':'; |
@@ -1518,7 +1518,7 @@ discard block |
||
1518 | 1518 | if ($globalTransaction) $Connection->db->commit(); |
1519 | 1519 | } |
1520 | 1520 | return ''; |
1521 | - } |
|
1521 | + } |
|
1522 | 1522 | |
1523 | 1523 | public static function update_airspace() { |
1524 | 1524 | global $tmp_dir, $globalDBdriver; |
@@ -1528,11 +1528,11 @@ discard block |
||
1528 | 1528 | $query = 'DROP TABLE airspace'; |
1529 | 1529 | try { |
1530 | 1530 | $sth = $Connection->db->prepare($query); |
1531 | - $sth->execute(); |
|
1532 | - } catch(PDOException $e) { |
|
1531 | + $sth->execute(); |
|
1532 | + } catch(PDOException $e) { |
|
1533 | 1533 | return "error : ".$e->getMessage(); |
1534 | - } |
|
1535 | - } |
|
1534 | + } |
|
1535 | + } |
|
1536 | 1536 | |
1537 | 1537 | |
1538 | 1538 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1587,10 +1587,10 @@ discard block |
||
1587 | 1587 | $query = 'DROP TABLE countries'; |
1588 | 1588 | try { |
1589 | 1589 | $sth = $Connection->db->prepare($query); |
1590 | - $sth->execute(); |
|
1591 | - } catch(PDOException $e) { |
|
1592 | - echo "error : ".$e->getMessage(); |
|
1593 | - } |
|
1590 | + $sth->execute(); |
|
1591 | + } catch(PDOException $e) { |
|
1592 | + echo "error : ".$e->getMessage(); |
|
1593 | + } |
|
1594 | 1594 | } |
1595 | 1595 | if ($globalDBdriver == 'mysql') { |
1596 | 1596 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -2119,11 +2119,11 @@ discard block |
||
2119 | 2119 | $query = 'DROP TABLE airspace'; |
2120 | 2120 | try { |
2121 | 2121 | $sth = $Connection->db->prepare($query); |
2122 | - $sth->execute(); |
|
2123 | - } catch(PDOException $e) { |
|
2122 | + $sth->execute(); |
|
2123 | + } catch(PDOException $e) { |
|
2124 | 2124 | return "error : ".$e->getMessage(); |
2125 | - } |
|
2126 | - } |
|
2125 | + } |
|
2126 | + } |
|
2127 | 2127 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2128 | 2128 | update_db::insert_airspace_version($airspace_md5); |
2129 | 2129 | } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
@@ -2303,12 +2303,12 @@ discard block |
||
2303 | 2303 | echo $data; |
2304 | 2304 | */ |
2305 | 2305 | if (file_exists($tmp_dir.'aircrafts.html')) { |
2306 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2307 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2308 | - $result = fread($fh,100000000); |
|
2309 | - //echo $result; |
|
2310 | - //var_dump(str_get_html($result)); |
|
2311 | - //print_r(self::table2array($result)); |
|
2306 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2307 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2308 | + $result = fread($fh,100000000); |
|
2309 | + //echo $result; |
|
2310 | + //var_dump(str_get_html($result)); |
|
2311 | + //print_r(self::table2array($result)); |
|
2312 | 2312 | } |
2313 | 2313 | |
2314 | 2314 | } |
@@ -2322,10 +2322,10 @@ discard block |
||
2322 | 2322 | try { |
2323 | 2323 | $Connection = new Connection(); |
2324 | 2324 | $sth = $Connection->db->prepare($query); |
2325 | - $sth->execute(); |
|
2326 | - } catch(PDOException $e) { |
|
2327 | - return "error : ".$e->getMessage(); |
|
2328 | - } |
|
2325 | + $sth->execute(); |
|
2326 | + } catch(PDOException $e) { |
|
2327 | + return "error : ".$e->getMessage(); |
|
2328 | + } |
|
2329 | 2329 | |
2330 | 2330 | $error = ''; |
2331 | 2331 | if ($globalDebug) echo "Notam : Download..."; |
@@ -2381,8 +2381,8 @@ discard block |
||
2381 | 2381 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
2382 | 2382 | $data['permanent'] = 0; |
2383 | 2383 | } else { |
2384 | - $data['date_end'] = NULL; |
|
2385 | - $data['permanent'] = 1; |
|
2384 | + $data['date_end'] = NULL; |
|
2385 | + $data['permanent'] = 1; |
|
2386 | 2386 | } |
2387 | 2387 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
2388 | 2388 | $NOTAM = new NOTAM(); |
@@ -2456,13 +2456,13 @@ discard block |
||
2456 | 2456 | try { |
2457 | 2457 | $Connection = new Connection(); |
2458 | 2458 | $sth = $Connection->db->prepare($query); |
2459 | - $sth->execute(); |
|
2460 | - } catch(PDOException $e) { |
|
2461 | - return "error : ".$e->getMessage(); |
|
2462 | - } |
|
2463 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2464 | - if ($row['nb'] > 0) return false; |
|
2465 | - else return true; |
|
2459 | + $sth->execute(); |
|
2460 | + } catch(PDOException $e) { |
|
2461 | + return "error : ".$e->getMessage(); |
|
2462 | + } |
|
2463 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2464 | + if ($row['nb'] > 0) return false; |
|
2465 | + else return true; |
|
2466 | 2466 | } |
2467 | 2467 | |
2468 | 2468 | public static function insert_last_update() { |
@@ -2471,10 +2471,10 @@ discard block |
||
2471 | 2471 | try { |
2472 | 2472 | $Connection = new Connection(); |
2473 | 2473 | $sth = $Connection->db->prepare($query); |
2474 | - $sth->execute(); |
|
2475 | - } catch(PDOException $e) { |
|
2476 | - return "error : ".$e->getMessage(); |
|
2477 | - } |
|
2474 | + $sth->execute(); |
|
2475 | + } catch(PDOException $e) { |
|
2476 | + return "error : ".$e->getMessage(); |
|
2477 | + } |
|
2478 | 2478 | } |
2479 | 2479 | |
2480 | 2480 | public static function check_airspace_version($version) { |
@@ -2482,13 +2482,13 @@ discard block |
||
2482 | 2482 | try { |
2483 | 2483 | $Connection = new Connection(); |
2484 | 2484 | $sth = $Connection->db->prepare($query); |
2485 | - $sth->execute(array(':version' => $version)); |
|
2486 | - } catch(PDOException $e) { |
|
2487 | - return "error : ".$e->getMessage(); |
|
2488 | - } |
|
2489 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2490 | - if ($row['nb'] > 0) return true; |
|
2491 | - else return false; |
|
2485 | + $sth->execute(array(':version' => $version)); |
|
2486 | + } catch(PDOException $e) { |
|
2487 | + return "error : ".$e->getMessage(); |
|
2488 | + } |
|
2489 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2490 | + if ($row['nb'] > 0) return true; |
|
2491 | + else return false; |
|
2492 | 2492 | } |
2493 | 2493 | |
2494 | 2494 | public static function check_geoid_version($version) { |
@@ -2496,13 +2496,13 @@ discard block |
||
2496 | 2496 | try { |
2497 | 2497 | $Connection = new Connection(); |
2498 | 2498 | $sth = $Connection->db->prepare($query); |
2499 | - $sth->execute(array(':version' => $version)); |
|
2500 | - } catch(PDOException $e) { |
|
2501 | - return "error : ".$e->getMessage(); |
|
2502 | - } |
|
2503 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2504 | - if ($row['nb'] > 0) return true; |
|
2505 | - else return false; |
|
2499 | + $sth->execute(array(':version' => $version)); |
|
2500 | + } catch(PDOException $e) { |
|
2501 | + return "error : ".$e->getMessage(); |
|
2502 | + } |
|
2503 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2504 | + if ($row['nb'] > 0) return true; |
|
2505 | + else return false; |
|
2506 | 2506 | } |
2507 | 2507 | |
2508 | 2508 | public static function check_marine_identity_version($version) { |
@@ -2510,13 +2510,13 @@ discard block |
||
2510 | 2510 | try { |
2511 | 2511 | $Connection = new Connection(); |
2512 | 2512 | $sth = $Connection->db->prepare($query); |
2513 | - $sth->execute(array(':version' => $version)); |
|
2514 | - } catch(PDOException $e) { |
|
2515 | - return "error : ".$e->getMessage(); |
|
2516 | - } |
|
2517 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2518 | - if ($row['nb'] > 0) return true; |
|
2519 | - else return false; |
|
2513 | + $sth->execute(array(':version' => $version)); |
|
2514 | + } catch(PDOException $e) { |
|
2515 | + return "error : ".$e->getMessage(); |
|
2516 | + } |
|
2517 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2518 | + if ($row['nb'] > 0) return true; |
|
2519 | + else return false; |
|
2520 | 2520 | } |
2521 | 2521 | |
2522 | 2522 | |
@@ -2538,10 +2538,10 @@ discard block |
||
2538 | 2538 | try { |
2539 | 2539 | $Connection = new Connection(); |
2540 | 2540 | $sth = $Connection->db->prepare($query); |
2541 | - $sth->execute(array(':version' => $version)); |
|
2542 | - } catch(PDOException $e) { |
|
2543 | - return "error : ".$e->getMessage(); |
|
2544 | - } |
|
2541 | + $sth->execute(array(':version' => $version)); |
|
2542 | + } catch(PDOException $e) { |
|
2543 | + return "error : ".$e->getMessage(); |
|
2544 | + } |
|
2545 | 2545 | } |
2546 | 2546 | |
2547 | 2547 | public static function insert_marine_identity_version($version) { |
@@ -2550,10 +2550,10 @@ discard block |
||
2550 | 2550 | try { |
2551 | 2551 | $Connection = new Connection(); |
2552 | 2552 | $sth = $Connection->db->prepare($query); |
2553 | - $sth->execute(array(':version' => $version)); |
|
2554 | - } catch(PDOException $e) { |
|
2555 | - return "error : ".$e->getMessage(); |
|
2556 | - } |
|
2553 | + $sth->execute(array(':version' => $version)); |
|
2554 | + } catch(PDOException $e) { |
|
2555 | + return "error : ".$e->getMessage(); |
|
2556 | + } |
|
2557 | 2557 | } |
2558 | 2558 | |
2559 | 2559 | public static function check_last_notam_update() { |
@@ -2566,13 +2566,13 @@ discard block |
||
2566 | 2566 | try { |
2567 | 2567 | $Connection = new Connection(); |
2568 | 2568 | $sth = $Connection->db->prepare($query); |
2569 | - $sth->execute(); |
|
2570 | - } catch(PDOException $e) { |
|
2571 | - return "error : ".$e->getMessage(); |
|
2572 | - } |
|
2573 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2574 | - if ($row['nb'] > 0) return false; |
|
2575 | - else return true; |
|
2569 | + $sth->execute(); |
|
2570 | + } catch(PDOException $e) { |
|
2571 | + return "error : ".$e->getMessage(); |
|
2572 | + } |
|
2573 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2574 | + if ($row['nb'] > 0) return false; |
|
2575 | + else return true; |
|
2576 | 2576 | } |
2577 | 2577 | |
2578 | 2578 | public static function insert_last_notam_update() { |
@@ -2581,10 +2581,10 @@ discard block |
||
2581 | 2581 | try { |
2582 | 2582 | $Connection = new Connection(); |
2583 | 2583 | $sth = $Connection->db->prepare($query); |
2584 | - $sth->execute(); |
|
2585 | - } catch(PDOException $e) { |
|
2586 | - return "error : ".$e->getMessage(); |
|
2587 | - } |
|
2584 | + $sth->execute(); |
|
2585 | + } catch(PDOException $e) { |
|
2586 | + return "error : ".$e->getMessage(); |
|
2587 | + } |
|
2588 | 2588 | } |
2589 | 2589 | |
2590 | 2590 | public static function check_last_airspace_update() { |
@@ -2597,13 +2597,13 @@ discard block |
||
2597 | 2597 | try { |
2598 | 2598 | $Connection = new Connection(); |
2599 | 2599 | $sth = $Connection->db->prepare($query); |
2600 | - $sth->execute(); |
|
2601 | - } catch(PDOException $e) { |
|
2602 | - return "error : ".$e->getMessage(); |
|
2603 | - } |
|
2604 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2605 | - if ($row['nb'] > 0) return false; |
|
2606 | - else return true; |
|
2600 | + $sth->execute(); |
|
2601 | + } catch(PDOException $e) { |
|
2602 | + return "error : ".$e->getMessage(); |
|
2603 | + } |
|
2604 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2605 | + if ($row['nb'] > 0) return false; |
|
2606 | + else return true; |
|
2607 | 2607 | } |
2608 | 2608 | |
2609 | 2609 | public static function insert_last_airspace_update() { |
@@ -2612,10 +2612,10 @@ discard block |
||
2612 | 2612 | try { |
2613 | 2613 | $Connection = new Connection(); |
2614 | 2614 | $sth = $Connection->db->prepare($query); |
2615 | - $sth->execute(); |
|
2616 | - } catch(PDOException $e) { |
|
2617 | - return "error : ".$e->getMessage(); |
|
2618 | - } |
|
2615 | + $sth->execute(); |
|
2616 | + } catch(PDOException $e) { |
|
2617 | + return "error : ".$e->getMessage(); |
|
2618 | + } |
|
2619 | 2619 | } |
2620 | 2620 | |
2621 | 2621 | public static function check_last_geoid_update() { |
@@ -2628,13 +2628,13 @@ discard block |
||
2628 | 2628 | try { |
2629 | 2629 | $Connection = new Connection(); |
2630 | 2630 | $sth = $Connection->db->prepare($query); |
2631 | - $sth->execute(); |
|
2632 | - } catch(PDOException $e) { |
|
2633 | - return "error : ".$e->getMessage(); |
|
2634 | - } |
|
2635 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2636 | - if ($row['nb'] > 0) return false; |
|
2637 | - else return true; |
|
2631 | + $sth->execute(); |
|
2632 | + } catch(PDOException $e) { |
|
2633 | + return "error : ".$e->getMessage(); |
|
2634 | + } |
|
2635 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2636 | + if ($row['nb'] > 0) return false; |
|
2637 | + else return true; |
|
2638 | 2638 | } |
2639 | 2639 | |
2640 | 2640 | public static function insert_last_geoid_update() { |
@@ -2643,10 +2643,10 @@ discard block |
||
2643 | 2643 | try { |
2644 | 2644 | $Connection = new Connection(); |
2645 | 2645 | $sth = $Connection->db->prepare($query); |
2646 | - $sth->execute(); |
|
2647 | - } catch(PDOException $e) { |
|
2648 | - return "error : ".$e->getMessage(); |
|
2649 | - } |
|
2646 | + $sth->execute(); |
|
2647 | + } catch(PDOException $e) { |
|
2648 | + return "error : ".$e->getMessage(); |
|
2649 | + } |
|
2650 | 2650 | } |
2651 | 2651 | |
2652 | 2652 | public static function check_last_owner_update() { |
@@ -2659,13 +2659,13 @@ discard block |
||
2659 | 2659 | try { |
2660 | 2660 | $Connection = new Connection(); |
2661 | 2661 | $sth = $Connection->db->prepare($query); |
2662 | - $sth->execute(); |
|
2663 | - } catch(PDOException $e) { |
|
2664 | - return "error : ".$e->getMessage(); |
|
2665 | - } |
|
2666 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2667 | - if ($row['nb'] > 0) return false; |
|
2668 | - else return true; |
|
2662 | + $sth->execute(); |
|
2663 | + } catch(PDOException $e) { |
|
2664 | + return "error : ".$e->getMessage(); |
|
2665 | + } |
|
2666 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2667 | + if ($row['nb'] > 0) return false; |
|
2668 | + else return true; |
|
2669 | 2669 | } |
2670 | 2670 | |
2671 | 2671 | public static function insert_last_owner_update() { |
@@ -2674,10 +2674,10 @@ discard block |
||
2674 | 2674 | try { |
2675 | 2675 | $Connection = new Connection(); |
2676 | 2676 | $sth = $Connection->db->prepare($query); |
2677 | - $sth->execute(); |
|
2678 | - } catch(PDOException $e) { |
|
2679 | - return "error : ".$e->getMessage(); |
|
2680 | - } |
|
2677 | + $sth->execute(); |
|
2678 | + } catch(PDOException $e) { |
|
2679 | + return "error : ".$e->getMessage(); |
|
2680 | + } |
|
2681 | 2681 | } |
2682 | 2682 | public static function check_last_schedules_update() { |
2683 | 2683 | global $globalDBdriver; |
@@ -2689,13 +2689,13 @@ discard block |
||
2689 | 2689 | try { |
2690 | 2690 | $Connection = new Connection(); |
2691 | 2691 | $sth = $Connection->db->prepare($query); |
2692 | - $sth->execute(); |
|
2693 | - } catch(PDOException $e) { |
|
2694 | - return "error : ".$e->getMessage(); |
|
2695 | - } |
|
2696 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2697 | - if ($row['nb'] > 0) return false; |
|
2698 | - else return true; |
|
2692 | + $sth->execute(); |
|
2693 | + } catch(PDOException $e) { |
|
2694 | + return "error : ".$e->getMessage(); |
|
2695 | + } |
|
2696 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2697 | + if ($row['nb'] > 0) return false; |
|
2698 | + else return true; |
|
2699 | 2699 | } |
2700 | 2700 | |
2701 | 2701 | public static function insert_last_schedules_update() { |
@@ -2704,10 +2704,10 @@ discard block |
||
2704 | 2704 | try { |
2705 | 2705 | $Connection = new Connection(); |
2706 | 2706 | $sth = $Connection->db->prepare($query); |
2707 | - $sth->execute(); |
|
2708 | - } catch(PDOException $e) { |
|
2709 | - return "error : ".$e->getMessage(); |
|
2710 | - } |
|
2707 | + $sth->execute(); |
|
2708 | + } catch(PDOException $e) { |
|
2709 | + return "error : ".$e->getMessage(); |
|
2710 | + } |
|
2711 | 2711 | } |
2712 | 2712 | public static function check_last_tle_update() { |
2713 | 2713 | global $globalDBdriver; |
@@ -2719,13 +2719,13 @@ discard block |
||
2719 | 2719 | try { |
2720 | 2720 | $Connection = new Connection(); |
2721 | 2721 | $sth = $Connection->db->prepare($query); |
2722 | - $sth->execute(); |
|
2723 | - } catch(PDOException $e) { |
|
2724 | - return "error : ".$e->getMessage(); |
|
2725 | - } |
|
2726 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2727 | - if ($row['nb'] > 0) return false; |
|
2728 | - else return true; |
|
2722 | + $sth->execute(); |
|
2723 | + } catch(PDOException $e) { |
|
2724 | + return "error : ".$e->getMessage(); |
|
2725 | + } |
|
2726 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2727 | + if ($row['nb'] > 0) return false; |
|
2728 | + else return true; |
|
2729 | 2729 | } |
2730 | 2730 | |
2731 | 2731 | public static function insert_last_tle_update() { |
@@ -2734,10 +2734,10 @@ discard block |
||
2734 | 2734 | try { |
2735 | 2735 | $Connection = new Connection(); |
2736 | 2736 | $sth = $Connection->db->prepare($query); |
2737 | - $sth->execute(); |
|
2738 | - } catch(PDOException $e) { |
|
2739 | - return "error : ".$e->getMessage(); |
|
2740 | - } |
|
2737 | + $sth->execute(); |
|
2738 | + } catch(PDOException $e) { |
|
2739 | + return "error : ".$e->getMessage(); |
|
2740 | + } |
|
2741 | 2741 | } |
2742 | 2742 | public static function check_last_marine_identity_update() { |
2743 | 2743 | global $globalDBdriver; |
@@ -2749,13 +2749,13 @@ discard block |
||
2749 | 2749 | try { |
2750 | 2750 | $Connection = new Connection(); |
2751 | 2751 | $sth = $Connection->db->prepare($query); |
2752 | - $sth->execute(); |
|
2753 | - } catch(PDOException $e) { |
|
2754 | - return "error : ".$e->getMessage(); |
|
2755 | - } |
|
2756 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2757 | - if ($row['nb'] > 0) return false; |
|
2758 | - else return true; |
|
2752 | + $sth->execute(); |
|
2753 | + } catch(PDOException $e) { |
|
2754 | + return "error : ".$e->getMessage(); |
|
2755 | + } |
|
2756 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2757 | + if ($row['nb'] > 0) return false; |
|
2758 | + else return true; |
|
2759 | 2759 | } |
2760 | 2760 | |
2761 | 2761 | public static function insert_last_marine_identity_update() { |
@@ -2764,10 +2764,10 @@ discard block |
||
2764 | 2764 | try { |
2765 | 2765 | $Connection = new Connection(); |
2766 | 2766 | $sth = $Connection->db->prepare($query); |
2767 | - $sth->execute(); |
|
2768 | - } catch(PDOException $e) { |
|
2769 | - return "error : ".$e->getMessage(); |
|
2770 | - } |
|
2767 | + $sth->execute(); |
|
2768 | + } catch(PDOException $e) { |
|
2769 | + return "error : ".$e->getMessage(); |
|
2770 | + } |
|
2771 | 2771 | } |
2772 | 2772 | public static function delete_duplicatemodes() { |
2773 | 2773 | global $globalDBdriver; |
@@ -2779,10 +2779,10 @@ discard block |
||
2779 | 2779 | try { |
2780 | 2780 | $Connection = new Connection(); |
2781 | 2781 | $sth = $Connection->db->prepare($query); |
2782 | - $sth->execute(); |
|
2783 | - } catch(PDOException $e) { |
|
2784 | - return "error : ".$e->getMessage(); |
|
2785 | - } |
|
2782 | + $sth->execute(); |
|
2783 | + } catch(PDOException $e) { |
|
2784 | + return "error : ".$e->getMessage(); |
|
2785 | + } |
|
2786 | 2786 | } |
2787 | 2787 | public static function delete_duplicateowner() { |
2788 | 2788 | global $globalDBdriver; |
@@ -2794,10 +2794,10 @@ discard block |
||
2794 | 2794 | try { |
2795 | 2795 | $Connection = new Connection(); |
2796 | 2796 | $sth = $Connection->db->prepare($query); |
2797 | - $sth->execute(); |
|
2798 | - } catch(PDOException $e) { |
|
2799 | - return "error : ".$e->getMessage(); |
|
2800 | - } |
|
2797 | + $sth->execute(); |
|
2798 | + } catch(PDOException $e) { |
|
2799 | + return "error : ".$e->getMessage(); |
|
2800 | + } |
|
2801 | 2801 | } |
2802 | 2802 | |
2803 | 2803 | public static function update_all() { |
@@ -25,20 +25,20 @@ discard block |
||
25 | 25 | fclose($fp); |
26 | 26 | } |
27 | 27 | |
28 | - public static function gunzip($in_file,$out_file_name = '') { |
|
28 | + public static function gunzip($in_file, $out_file_name = '') { |
|
29 | 29 | //echo $in_file.' -> '.$out_file_name."\n"; |
30 | 30 | $buffer_size = 4096; // read 4kb at a time |
31 | 31 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
32 | 32 | if ($in_file != '' && file_exists($in_file)) { |
33 | 33 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
34 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
35 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
34 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
35 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
36 | 36 | else { |
37 | 37 | echo 'gzopen not available'; |
38 | 38 | die; |
39 | 39 | } |
40 | 40 | $out_file = fopen($out_file_name, 'wb'); |
41 | - while(!gzeof($file)) { |
|
41 | + while (!gzeof($file)) { |
|
42 | 42 | fwrite($out_file, gzread($file, $buffer_size)); |
43 | 43 | } |
44 | 44 | fclose($out_file); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | try { |
63 | 63 | self::$db_sqlite = new PDO('sqlite:'.$database); |
64 | 64 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
65 | - } catch(PDOException $e) { |
|
65 | + } catch (PDOException $e) { |
|
66 | 66 | return "error : ".$e->getMessage(); |
67 | 67 | } |
68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | //$Connection = new Connection(); |
78 | 78 | $sth = $Connection->db->prepare($query); |
79 | 79 | $sth->execute(array(':source' => $database_file)); |
80 | - } catch(PDOException $e) { |
|
80 | + } catch (PDOException $e) { |
|
81 | 81 | return "error : ".$e->getMessage(); |
82 | 82 | } |
83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | try { |
89 | 89 | $sth = update_db::$db_sqlite->prepare($query); |
90 | 90 | $sth->execute(); |
91 | - } catch(PDOException $e) { |
|
91 | + } catch (PDOException $e) { |
|
92 | 92 | return "error : ".$e->getMessage(); |
93 | 93 | } |
94 | 94 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | if ($globalTransaction) $Connection->db->beginTransaction(); |
100 | 100 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
101 | 101 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
102 | - $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
|
102 | + $query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file); |
|
103 | 103 | $sth_dest->execute($query_dest_values); |
104 | 104 | } |
105 | 105 | if ($globalTransaction) $Connection->db->commit(); |
106 | - } catch(PDOException $e) { |
|
106 | + } catch (PDOException $e) { |
|
107 | 107 | if ($globalTransaction) $Connection->db->rollBack(); |
108 | 108 | return "error : ".$e->getMessage(); |
109 | 109 | } |
@@ -119,26 +119,26 @@ discard block |
||
119 | 119 | //$Connection = new Connection(); |
120 | 120 | $sth = $Connection->db->prepare($query); |
121 | 121 | $sth->execute(array(':source' => 'oneworld')); |
122 | - } catch(PDOException $e) { |
|
122 | + } catch (PDOException $e) { |
|
123 | 123 | return "error : ".$e->getMessage(); |
124 | 124 | } |
125 | 125 | |
126 | 126 | if ($globalDebug) echo " - Add routes to DB -"; |
127 | 127 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
128 | 128 | $Spotter = new Spotter(); |
129 | - if ($fh = fopen($database_file,"r")) { |
|
129 | + if ($fh = fopen($database_file, "r")) { |
|
130 | 130 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
131 | 131 | $Connection = new Connection(); |
132 | 132 | $sth_dest = $Connection->db->prepare($query_dest); |
133 | 133 | if ($globalTransaction) $Connection->db->beginTransaction(); |
134 | 134 | while (!feof($fh)) { |
135 | - $line = fgetcsv($fh,9999,','); |
|
135 | + $line = fgetcsv($fh, 9999, ','); |
|
136 | 136 | if ($line[0] != '') { |
137 | 137 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
138 | 138 | try { |
139 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
|
139 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld'); |
|
140 | 140 | $sth_dest->execute($query_dest_values); |
141 | - } catch(PDOException $e) { |
|
141 | + } catch (PDOException $e) { |
|
142 | 142 | if ($globalTransaction) $Connection->db->rollBack(); |
143 | 143 | return "error : ".$e->getMessage(); |
144 | 144 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | //$Connection = new Connection(); |
161 | 161 | $sth = $Connection->db->prepare($query); |
162 | 162 | $sth->execute(array(':source' => 'skyteam')); |
163 | - } catch(PDOException $e) { |
|
163 | + } catch (PDOException $e) { |
|
164 | 164 | return "error : ".$e->getMessage(); |
165 | 165 | } |
166 | 166 | |
@@ -168,24 +168,24 @@ discard block |
||
168 | 168 | |
169 | 169 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
170 | 170 | $Spotter = new Spotter(); |
171 | - if ($fh = fopen($database_file,"r")) { |
|
171 | + if ($fh = fopen($database_file, "r")) { |
|
172 | 172 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
173 | 173 | $Connection = new Connection(); |
174 | 174 | $sth_dest = $Connection->db->prepare($query_dest); |
175 | 175 | try { |
176 | 176 | if ($globalTransaction) $Connection->db->beginTransaction(); |
177 | 177 | while (!feof($fh)) { |
178 | - $line = fgetcsv($fh,9999,','); |
|
178 | + $line = fgetcsv($fh, 9999, ','); |
|
179 | 179 | if ($line[0] != '') { |
180 | - $datebe = explode(' - ',$line[2]); |
|
180 | + $datebe = explode(' - ', $line[2]); |
|
181 | 181 | if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
182 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); |
|
182 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); |
|
183 | 183 | $sth_dest->execute($query_dest_values); |
184 | 184 | } |
185 | 185 | } |
186 | 186 | } |
187 | 187 | if ($globalTransaction) $Connection->db->commit(); |
188 | - } catch(PDOException $e) { |
|
188 | + } catch (PDOException $e) { |
|
189 | 189 | if ($globalTransaction) $Connection->db->rollBack(); |
190 | 190 | return "error : ".$e->getMessage(); |
191 | 191 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $Connection = new Connection(); |
201 | 201 | $sth = $Connection->db->prepare($query); |
202 | 202 | $sth->execute(array(':source' => $database_file)); |
203 | - } catch(PDOException $e) { |
|
203 | + } catch (PDOException $e) { |
|
204 | 204 | return "error : ".$e->getMessage(); |
205 | 205 | } |
206 | 206 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $Connection = new Connection(); |
209 | 209 | $sth = $Connection->db->prepare($query); |
210 | 210 | $sth->execute(array(':source' => $database_file)); |
211 | - } catch(PDOException $e) { |
|
211 | + } catch (PDOException $e) { |
|
212 | 212 | return "error : ".$e->getMessage(); |
213 | 213 | } |
214 | 214 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | try { |
218 | 218 | $sth = update_db::$db_sqlite->prepare($query); |
219 | 219 | $sth->execute(); |
220 | - } catch(PDOException $e) { |
|
220 | + } catch (PDOException $e) { |
|
221 | 221 | return "error : ".$e->getMessage(); |
222 | 222 | } |
223 | 223 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -234,15 +234,15 @@ discard block |
||
234 | 234 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
235 | 235 | if ($values['UserString4'] == 'M') $type = 'military'; |
236 | 236 | else $type = null; |
237 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
237 | + $query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); |
|
238 | 238 | $sth_dest->execute($query_dest_values); |
239 | 239 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
240 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
240 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
241 | 241 | $sth_dest_owner->execute($query_dest_owner_values); |
242 | 242 | } |
243 | 243 | } |
244 | 244 | if ($globalTransaction) $Connection->db->commit(); |
245 | - } catch(PDOException $e) { |
|
245 | + } catch (PDOException $e) { |
|
246 | 246 | return "error : ".$e->getMessage(); |
247 | 247 | } |
248 | 248 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $Connection = new Connection(); |
253 | 253 | $sth = $Connection->db->prepare($query); |
254 | 254 | $sth->execute(array(':source' => $database_file)); |
255 | - } catch(PDOException $e) { |
|
255 | + } catch (PDOException $e) { |
|
256 | 256 | return "error : ".$e->getMessage(); |
257 | 257 | } |
258 | 258 | return ''; |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | $Connection = new Connection(); |
268 | 268 | $sth = $Connection->db->prepare($query); |
269 | 269 | $sth->execute(array(':source' => $database_file)); |
270 | - } catch(PDOException $e) { |
|
270 | + } catch (PDOException $e) { |
|
271 | 271 | return "error : ".$e->getMessage(); |
272 | 272 | } |
273 | 273 | |
274 | - if ($fh = fopen($database_file,"r")) { |
|
274 | + if ($fh = fopen($database_file, "r")) { |
|
275 | 275 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
276 | 276 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
277 | 277 | |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | if ($globalTransaction) $Connection->db->beginTransaction(); |
282 | 282 | while (!feof($fh)) { |
283 | 283 | $values = array(); |
284 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
284 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
285 | 285 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
286 | - $values['ModeS'] = substr($line,0,6); |
|
287 | - $values['Registration'] = trim(substr($line,69,6)); |
|
288 | - $aircraft_name = trim(substr($line,48,6)); |
|
286 | + $values['ModeS'] = substr($line, 0, 6); |
|
287 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
288 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
289 | 289 | // Check if we can find ICAO, else set it to GLID |
290 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
290 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
291 | 291 | $search_more = ''; |
292 | 292 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
293 | 293 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -299,20 +299,20 @@ discard block |
||
299 | 299 | if (isset($result['icao']) && $result['icao'] != '') { |
300 | 300 | $values['ICAOTypeCode'] = $result['icao']; |
301 | 301 | } |
302 | - } catch(PDOException $e) { |
|
302 | + } catch (PDOException $e) { |
|
303 | 303 | return "error : ".$e->getMessage(); |
304 | 304 | } |
305 | 305 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
306 | 306 | // Add data to db |
307 | 307 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
308 | 308 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
309 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
309 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
310 | 310 | //print_r($query_dest_values); |
311 | 311 | $sth_dest->execute($query_dest_values); |
312 | 312 | } |
313 | 313 | } |
314 | 314 | if ($globalTransaction) $Connection->db->commit(); |
315 | - } catch(PDOException $e) { |
|
315 | + } catch (PDOException $e) { |
|
316 | 316 | return "error : ".$e->getMessage(); |
317 | 317 | } |
318 | 318 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $Connection = new Connection(); |
323 | 323 | $sth = $Connection->db->prepare($query); |
324 | 324 | $sth->execute(array(':source' => $database_file)); |
325 | - } catch(PDOException $e) { |
|
325 | + } catch (PDOException $e) { |
|
326 | 326 | return "error : ".$e->getMessage(); |
327 | 327 | } |
328 | 328 | return ''; |
@@ -336,11 +336,11 @@ discard block |
||
336 | 336 | $Connection = new Connection(); |
337 | 337 | $sth = $Connection->db->prepare($query); |
338 | 338 | $sth->execute(array(':source' => $database_file)); |
339 | - } catch(PDOException $e) { |
|
339 | + } catch (PDOException $e) { |
|
340 | 340 | return "error : ".$e->getMessage(); |
341 | 341 | } |
342 | 342 | |
343 | - if ($fh = fopen($database_file,"r")) { |
|
343 | + if ($fh = fopen($database_file, "r")) { |
|
344 | 344 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
345 | 345 | $query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
346 | 346 | |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | $sth_dest = $Connection->db->prepare($query_dest); |
349 | 349 | try { |
350 | 350 | if ($globalTransaction) $Connection->db->beginTransaction(); |
351 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
351 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
352 | 352 | while (!feof($fh)) { |
353 | - $line = fgetcsv($fh,9999,',',"'"); |
|
353 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
354 | 354 | |
355 | 355 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
356 | 356 | //print_r($line); |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $values['ICAOTypeCode'] = ''; |
360 | 360 | $aircraft_name = $line[2]; |
361 | 361 | // Check if we can find ICAO, else set it to GLID |
362 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
362 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
363 | 363 | $search_more = ''; |
364 | 364 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
365 | 365 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -368,20 +368,20 @@ discard block |
||
368 | 368 | $sth_search->execute(); |
369 | 369 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
370 | 370 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
371 | - } catch(PDOException $e) { |
|
371 | + } catch (PDOException $e) { |
|
372 | 372 | return "error : ".$e->getMessage(); |
373 | 373 | } |
374 | 374 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
375 | 375 | // Add data to db |
376 | 376 | if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
377 | 377 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
378 | - $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
378 | + $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
379 | 379 | //print_r($query_dest_values); |
380 | 380 | $sth_dest->execute($query_dest_values); |
381 | 381 | } |
382 | 382 | } |
383 | 383 | if ($globalTransaction) $Connection->db->commit(); |
384 | - } catch(PDOException $e) { |
|
384 | + } catch (PDOException $e) { |
|
385 | 385 | return "error : ".$e->getMessage(); |
386 | 386 | } |
387 | 387 | } |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | $Connection = new Connection(); |
392 | 392 | $sth = $Connection->db->prepare($query); |
393 | 393 | $sth->execute(array(':source' => $database_file)); |
394 | - } catch(PDOException $e) { |
|
394 | + } catch (PDOException $e) { |
|
395 | 395 | return "error : ".$e->getMessage(); |
396 | 396 | } |
397 | 397 | return ''; |
398 | 398 | } |
399 | 399 | |
400 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
400 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
401 | 401 | global $globalTransaction, $globalMasterSource; |
402 | 402 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
403 | 403 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;"; |
@@ -405,12 +405,12 @@ discard block |
||
405 | 405 | $Connection = new Connection(); |
406 | 406 | $sth = $Connection->db->prepare($query); |
407 | 407 | $sth->execute(array(':source' => $database_file)); |
408 | - } catch(PDOException $e) { |
|
408 | + } catch (PDOException $e) { |
|
409 | 409 | return "error : ".$e->getMessage(); |
410 | 410 | } |
411 | 411 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
412 | 412 | $Spotter = new Spotter(); |
413 | - if ($fh = fopen($database_file,"r")) { |
|
413 | + if ($fh = fopen($database_file, "r")) { |
|
414 | 414 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
415 | 415 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
416 | 416 | $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
@@ -420,9 +420,9 @@ discard block |
||
420 | 420 | $sth_modes = $Connection->db->prepare($query_modes); |
421 | 421 | try { |
422 | 422 | if ($globalTransaction) $Connection->db->beginTransaction(); |
423 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
423 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
424 | 424 | while (!feof($fh)) { |
425 | - $line = fgetcsv($fh,9999,',','"'); |
|
425 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
426 | 426 | $values = array(); |
427 | 427 | //print_r($line); |
428 | 428 | if ($country == 'F') { |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $values['base'] = $line[4]; |
431 | 431 | $values['owner'] = $line[5]; |
432 | 432 | if ($line[6] == '') $values['date_first_reg'] = null; |
433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
433 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
434 | 434 | $values['cancel'] = $line[7]; |
435 | 435 | } elseif ($country == 'EI') { |
436 | 436 | // TODO : add modeS & reg to aircraft_modes |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $values['base'] = $line[3]; |
439 | 439 | $values['owner'] = $line[2]; |
440 | 440 | if ($line[1] == '') $values['date_first_reg'] = null; |
441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
441 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
442 | 442 | $values['cancel'] = ''; |
443 | 443 | $values['modes'] = $line[7]; |
444 | 444 | $values['icao'] = $line[8]; |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $values['base'] = null; |
459 | 459 | $values['owner'] = $line[5]; |
460 | 460 | if ($line[18] == '') $values['date_first_reg'] = null; |
461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
461 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
462 | 462 | $values['cancel'] = ''; |
463 | 463 | } elseif ($country == 'VH') { |
464 | 464 | // TODO : add modeS & reg to aircraft_modes |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | $values['base'] = null; |
467 | 467 | $values['owner'] = $line[12]; |
468 | 468 | if ($line[28] == '') $values['date_first_reg'] = null; |
469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
469 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
470 | 470 | |
471 | 471 | $values['cancel'] = $line[39]; |
472 | 472 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -486,28 +486,28 @@ discard block |
||
486 | 486 | $values['base'] = null; |
487 | 487 | $values['owner'] = $line[8]; |
488 | 488 | if ($line[7] == '') $values['date_first_reg'] = null; |
489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
489 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
490 | 490 | $values['cancel'] = ''; |
491 | 491 | } elseif ($country == 'PP') { |
492 | 492 | $values['registration'] = $line[0]; |
493 | 493 | $values['base'] = null; |
494 | 494 | $values['owner'] = $line[4]; |
495 | 495 | if ($line[6] == '') $values['date_first_reg'] = null; |
496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
496 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
497 | 497 | $values['cancel'] = $line[7]; |
498 | 498 | } elseif ($country == 'E7') { |
499 | 499 | $values['registration'] = $line[0]; |
500 | 500 | $values['base'] = null; |
501 | 501 | $values['owner'] = $line[4]; |
502 | 502 | if ($line[5] == '') $values['date_first_reg'] = null; |
503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
503 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
504 | 504 | $values['cancel'] = ''; |
505 | 505 | } elseif ($country == '8Q') { |
506 | 506 | $values['registration'] = $line[0]; |
507 | 507 | $values['base'] = null; |
508 | 508 | $values['owner'] = $line[3]; |
509 | 509 | if ($line[7] == '') $values['date_first_reg'] = null; |
510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
510 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
511 | 511 | $values['cancel'] = ''; |
512 | 512 | } elseif ($country == 'ZK') { |
513 | 513 | $values['registration'] = $line[0]; |
@@ -521,18 +521,18 @@ discard block |
||
521 | 521 | $values['registration'] = $line[0]; |
522 | 522 | $values['base'] = null; |
523 | 523 | $values['owner'] = $line[6]; |
524 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
525 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
524 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
525 | + $values['cancel'] = date("Y-m-d", strtotime($line[8])); |
|
526 | 526 | $values['modes'] = $line[4]; |
527 | 527 | $values['icao'] = $line[10]; |
528 | 528 | } elseif ($country == 'OY') { |
529 | 529 | $values['registration'] = $line[0]; |
530 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
530 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[4])); |
|
531 | 531 | $values['modes'] = $line[5]; |
532 | 532 | $values['icao'] = $line[6]; |
533 | 533 | } elseif ($country == 'PH') { |
534 | 534 | $values['registration'] = $line[0]; |
535 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
535 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[3])); |
|
536 | 536 | $values['modes'] = $line[4]; |
537 | 537 | $values['icao'] = $line[5]; |
538 | 538 | } elseif ($country == 'OM' || $country == 'TF') { |
@@ -543,17 +543,17 @@ discard block |
||
543 | 543 | $values['cancel'] = ''; |
544 | 544 | } |
545 | 545 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
546 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
546 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
547 | 547 | $sth_dest->execute($query_dest_values); |
548 | 548 | } |
549 | 549 | if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') { |
550 | 550 | $modescountry = $Spotter->countryFromAircraftRegistration($values['registration']); |
551 | - $query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file); |
|
551 | + $query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file); |
|
552 | 552 | $sth_modes->execute($query_modes_values); |
553 | 553 | } |
554 | 554 | } |
555 | 555 | if ($globalTransaction) $Connection->db->commit(); |
556 | - } catch(PDOException $e) { |
|
556 | + } catch (PDOException $e) { |
|
557 | 557 | return "error : ".$e->getMessage(); |
558 | 558 | } |
559 | 559 | } |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | if ($globalTransaction) $Connection->db->beginTransaction(); |
692 | 692 | |
693 | 693 | $i = 0; |
694 | - while($row = sparql_fetch_array($result)) |
|
694 | + while ($row = sparql_fetch_array($result)) |
|
695 | 695 | { |
696 | 696 | if ($i >= 1) { |
697 | 697 | //print_r($row); |
@@ -711,33 +711,33 @@ discard block |
||
711 | 711 | $row['image'] = ''; |
712 | 712 | $row['image_thumb'] = ''; |
713 | 713 | } else { |
714 | - $image = str_replace(' ','_',$row['image']); |
|
714 | + $image = str_replace(' ', '_', $row['image']); |
|
715 | 715 | $digest = md5($image); |
716 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
717 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
718 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
719 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
716 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
717 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
718 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
719 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
720 | 720 | } |
721 | 721 | |
722 | - $country = explode('-',$row['country']); |
|
722 | + $country = explode('-', $row['country']); |
|
723 | 723 | $row['country'] = $country[0]; |
724 | 724 | |
725 | 725 | $row['type'] = trim($row['type']); |
726 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
726 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
727 | 727 | $row['type'] = 'military'; |
728 | 728 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
729 | 729 | $row['type'] = 'small_airport'; |
730 | 730 | } |
731 | 731 | |
732 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
733 | - $query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
732 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
733 | + $query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
734 | 734 | //print_r($query_dest_values); |
735 | 735 | |
736 | 736 | if ($row['icao'] != '') { |
737 | 737 | try { |
738 | 738 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
739 | 739 | $sth->execute(array(':icao' => $row['icao'])); |
740 | - } catch(PDOException $e) { |
|
740 | + } catch (PDOException $e) { |
|
741 | 741 | return "error : ".$e->getMessage(); |
742 | 742 | } |
743 | 743 | if ($sth->fetchColumn() > 0) { |
@@ -745,15 +745,15 @@ discard block |
||
745 | 745 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
746 | 746 | try { |
747 | 747 | $sth = $Connection->db->prepare($query); |
748 | - $sth->execute(array(':icao' => $row['icao'],':type' => $row['type'])); |
|
749 | - } catch(PDOException $e) { |
|
748 | + $sth->execute(array(':icao' => $row['icao'], ':type' => $row['type'])); |
|
749 | + } catch (PDOException $e) { |
|
750 | 750 | return "error : ".$e->getMessage(); |
751 | 751 | } |
752 | 752 | echo $row['icao'].' : '.$row['type']."\n"; |
753 | 753 | } else { |
754 | 754 | try { |
755 | 755 | $sth_dest->execute($query_dest_values); |
756 | - } catch(PDOException $e) { |
|
756 | + } catch (PDOException $e) { |
|
757 | 757 | return "error : ".$e->getMessage(); |
758 | 758 | } |
759 | 759 | } |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | echo "Download data from ourairports.com...\n"; |
805 | 805 | $delimiter = ','; |
806 | 806 | $out_file = $tmp_dir.'airports.csv'; |
807 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
807 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
808 | 808 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
809 | 809 | echo "Add data from ourairports.com...\n"; |
810 | 810 | |
@@ -815,33 +815,33 @@ discard block |
||
815 | 815 | //$Connection->db->beginTransaction(); |
816 | 816 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
817 | 817 | { |
818 | - if(!$header) $header = $row; |
|
818 | + if (!$header) $header = $row; |
|
819 | 819 | else { |
820 | 820 | $data = array(); |
821 | 821 | $data = array_combine($header, $row); |
822 | 822 | try { |
823 | 823 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
824 | 824 | $sth->execute(array(':icao' => $data['ident'])); |
825 | - } catch(PDOException $e) { |
|
825 | + } catch (PDOException $e) { |
|
826 | 826 | return "error : ".$e->getMessage(); |
827 | 827 | } |
828 | 828 | if ($sth->fetchColumn() > 0) { |
829 | 829 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
830 | 830 | try { |
831 | 831 | $sth = $Connection->db->prepare($query); |
832 | - $sth->execute(array(':icao' => $data['ident'],':type' => $data['type'])); |
|
833 | - } catch(PDOException $e) { |
|
832 | + $sth->execute(array(':icao' => $data['ident'], ':type' => $data['type'])); |
|
833 | + } catch (PDOException $e) { |
|
834 | 834 | return "error : ".$e->getMessage(); |
835 | 835 | } |
836 | 836 | } else { |
837 | 837 | if ($data['gps_code'] == $data['ident']) { |
838 | 838 | $query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link) |
839 | 839 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
840 | - $query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
840 | + $query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
841 | 841 | try { |
842 | 842 | $sth = $Connection->db->prepare($query); |
843 | 843 | $sth->execute($query_values); |
844 | - } catch(PDOException $e) { |
|
844 | + } catch (PDOException $e) { |
|
845 | 845 | return "error : ".$e->getMessage(); |
846 | 846 | } |
847 | 847 | $i++; |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | |
857 | 857 | echo "Download data from another free database...\n"; |
858 | 858 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
859 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
859 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
860 | 860 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
861 | 861 | update_db::unzip($out_file); |
862 | 862 | $header = NULL; |
@@ -868,15 +868,15 @@ discard block |
||
868 | 868 | //$Connection->db->beginTransaction(); |
869 | 869 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
870 | 870 | { |
871 | - if(!$header) $header = $row; |
|
871 | + if (!$header) $header = $row; |
|
872 | 872 | else { |
873 | 873 | $data = $row; |
874 | 874 | |
875 | 875 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
876 | 876 | try { |
877 | 877 | $sth = $Connection->db->prepare($query); |
878 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
879 | - } catch(PDOException $e) { |
|
878 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
879 | + } catch (PDOException $e) { |
|
880 | 880 | return "error : ".$e->getMessage(); |
881 | 881 | } |
882 | 882 | } |
@@ -890,15 +890,15 @@ discard block |
||
890 | 890 | try { |
891 | 891 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'"); |
892 | 892 | $sth->execute(); |
893 | - } catch(PDOException $e) { |
|
893 | + } catch (PDOException $e) { |
|
894 | 894 | return "error : ".$e->getMessage(); |
895 | 895 | } |
896 | 896 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
897 | 897 | $query2 = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
898 | 898 | try { |
899 | 899 | $sth2 = $Connection->db->prepare($query2); |
900 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
901 | - } catch(PDOException $e) { |
|
900 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
901 | + } catch (PDOException $e) { |
|
902 | 902 | return "error : ".$e->getMessage(); |
903 | 903 | } |
904 | 904 | } |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | $Connection = new Connection(); |
920 | 920 | $sth = $Connection->db->prepare($query); |
921 | 921 | $sth->execute(array(':source' => 'translation.csv')); |
922 | - } catch(PDOException $e) { |
|
922 | + } catch (PDOException $e) { |
|
923 | 923 | return "error : ".$e->getMessage(); |
924 | 924 | } |
925 | 925 | |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
937 | 937 | { |
938 | 938 | $i++; |
939 | - if($i > 12) { |
|
939 | + if ($i > 12) { |
|
940 | 940 | $data = $row; |
941 | 941 | $operator = $data[2]; |
942 | 942 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | //echo substr($operator, 0, 2)."\n";; |
945 | 945 | if (count($airline_array) > 0) { |
946 | 946 | //print_r($airline_array); |
947 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
947 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
948 | 948 | } |
949 | 949 | } |
950 | 950 | |
@@ -952,14 +952,14 @@ discard block |
||
952 | 952 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
953 | 953 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
954 | 954 | if (count($airline_array) > 0) { |
955 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
955 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
956 | 956 | } |
957 | 957 | } |
958 | 958 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
959 | 959 | try { |
960 | 960 | $sth = $Connection->db->prepare($query); |
961 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
962 | - } catch(PDOException $e) { |
|
961 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
962 | + } catch (PDOException $e) { |
|
963 | 963 | return "error : ".$e->getMessage(); |
964 | 964 | } |
965 | 965 | } |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | $Connection = new Connection(); |
980 | 980 | $sth = $Connection->db->prepare($query); |
981 | 981 | $sth->execute(array(':source' => 'website_fam')); |
982 | - } catch(PDOException $e) { |
|
982 | + } catch (PDOException $e) { |
|
983 | 983 | return "error : ".$e->getMessage(); |
984 | 984 | } |
985 | 985 | |
@@ -999,8 +999,8 @@ discard block |
||
999 | 999 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
1000 | 1000 | try { |
1001 | 1001 | $sth = $Connection->db->prepare($query); |
1002 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
1003 | - } catch(PDOException $e) { |
|
1002 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
1003 | + } catch (PDOException $e) { |
|
1004 | 1004 | return "error : ".$e->getMessage(); |
1005 | 1005 | } |
1006 | 1006 | } |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | $Connection = new Connection(); |
1024 | 1024 | $sth = $Connection->db->prepare($query); |
1025 | 1025 | $sth->execute(array(':source' => 'website_faa')); |
1026 | - } catch(PDOException $e) { |
|
1026 | + } catch (PDOException $e) { |
|
1027 | 1027 | return "error : ".$e->getMessage(); |
1028 | 1028 | } |
1029 | 1029 | |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | $Connection = new Connection(); |
1033 | 1033 | $sth = $Connection->db->prepare($query); |
1034 | 1034 | $sth->execute(array(':source' => 'website_faa')); |
1035 | - } catch(PDOException $e) { |
|
1035 | + } catch (PDOException $e) { |
|
1036 | 1036 | return "error : ".$e->getMessage(); |
1037 | 1037 | } |
1038 | 1038 | |
@@ -1049,8 +1049,8 @@ discard block |
||
1049 | 1049 | $query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1'; |
1050 | 1050 | try { |
1051 | 1051 | $sths = $Connection->db->prepare($query_search); |
1052 | - $sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); |
|
1053 | - } catch(PDOException $e) { |
|
1052 | + $sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa')); |
|
1053 | + } catch (PDOException $e) { |
|
1054 | 1054 | return "error s : ".$e->getMessage(); |
1055 | 1055 | } |
1056 | 1056 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
@@ -1063,8 +1063,8 @@ discard block |
||
1063 | 1063 | //} |
1064 | 1064 | try { |
1065 | 1065 | $sthi = $Connection->db->prepare($queryi); |
1066 | - $sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); |
|
1067 | - } catch(PDOException $e) { |
|
1066 | + $sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode'])); |
|
1067 | + } catch (PDOException $e) { |
|
1068 | 1068 | return "error u : ".$e->getMessage(); |
1069 | 1069 | } |
1070 | 1070 | } else { |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | try { |
1073 | 1073 | $sthsm = $Connection->db->prepare($query_search_mfr); |
1074 | 1074 | $sthsm->execute(array(':mfr' => $data[2])); |
1075 | - } catch(PDOException $e) { |
|
1075 | + } catch (PDOException $e) { |
|
1076 | 1076 | return "error mfr : ".$e->getMessage(); |
1077 | 1077 | } |
1078 | 1078 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
@@ -1082,8 +1082,8 @@ discard block |
||
1082 | 1082 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1083 | 1083 | try { |
1084 | 1084 | $sthf = $Connection->db->prepare($queryf); |
1085 | - $sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa')); |
|
1086 | - } catch(PDOException $e) { |
|
1085 | + $sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa')); |
|
1086 | + } catch (PDOException $e) { |
|
1087 | 1087 | return "error f : ".$e->getMessage(); |
1088 | 1088 | } |
1089 | 1089 | } |
@@ -1093,13 +1093,13 @@ discard block |
||
1093 | 1093 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1094 | 1094 | try { |
1095 | 1095 | $sth = $Connection->db->prepare($query); |
1096 | - $sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa')); |
|
1097 | - } catch(PDOException $e) { |
|
1096 | + $sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa')); |
|
1097 | + } catch (PDOException $e) { |
|
1098 | 1098 | return "error i : ".$e->getMessage(); |
1099 | 1099 | } |
1100 | 1100 | } |
1101 | 1101 | } |
1102 | - if ($i % 90 == 0) { |
|
1102 | + if ($i%90 == 0) { |
|
1103 | 1103 | if ($globalTransaction) $Connection->db->commit(); |
1104 | 1104 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1105 | 1105 | } |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | $Connection = new Connection(); |
1119 | 1119 | $sth = $Connection->db->prepare($query); |
1120 | 1120 | $sth->execute(array(':source' => 'website_fam')); |
1121 | - } catch(PDOException $e) { |
|
1121 | + } catch (PDOException $e) { |
|
1122 | 1122 | return "error : ".$e->getMessage(); |
1123 | 1123 | } |
1124 | 1124 | |
@@ -1139,8 +1139,8 @@ discard block |
||
1139 | 1139 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1140 | 1140 | try { |
1141 | 1141 | $sth = $Connection->db->prepare($query); |
1142 | - $sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam')); |
|
1143 | - } catch(PDOException $e) { |
|
1142 | + $sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam')); |
|
1143 | + } catch (PDOException $e) { |
|
1144 | 1144 | return "error : ".$e->getMessage(); |
1145 | 1145 | } |
1146 | 1146 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | $Connection = new Connection(); |
1160 | 1160 | $sth = $Connection->db->prepare($query); |
1161 | 1161 | $sth->execute(array(':source' => 'website_fam')); |
1162 | - } catch(PDOException $e) { |
|
1162 | + } catch (PDOException $e) { |
|
1163 | 1163 | return "error : ".$e->getMessage(); |
1164 | 1164 | } |
1165 | 1165 | |
@@ -1175,8 +1175,8 @@ discard block |
||
1175 | 1175 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)'; |
1176 | 1176 | try { |
1177 | 1177 | $sth = $Connection->db->prepare($query); |
1178 | - $sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); |
|
1179 | - } catch(PDOException $e) { |
|
1178 | + $sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam')); |
|
1179 | + } catch (PDOException $e) { |
|
1180 | 1180 | print_r($data); |
1181 | 1181 | return "error : ".$e->getMessage(); |
1182 | 1182 | } |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | $Connection = new Connection(); |
1197 | 1197 | $sth = $Connection->db->prepare($query); |
1198 | 1198 | $sth->execute(array(':source' => 'website_fam')); |
1199 | - } catch(PDOException $e) { |
|
1199 | + } catch (PDOException $e) { |
|
1200 | 1200 | return "error : ".$e->getMessage(); |
1201 | 1201 | } |
1202 | 1202 | |
@@ -1216,8 +1216,8 @@ discard block |
||
1216 | 1216 | $query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)'; |
1217 | 1217 | try { |
1218 | 1218 | $sth = $Connection->db->prepare($query); |
1219 | - $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
|
1220 | - } catch(PDOException $e) { |
|
1219 | + $sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam')); |
|
1220 | + } catch (PDOException $e) { |
|
1221 | 1221 | return "error : ".$e->getMessage(); |
1222 | 1222 | } |
1223 | 1223 | } |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | $Connection = new Connection(); |
1237 | 1237 | $sth = $Connection->db->prepare($query); |
1238 | 1238 | $sth->execute(); |
1239 | - } catch(PDOException $e) { |
|
1239 | + } catch (PDOException $e) { |
|
1240 | 1240 | return "error : ".$e->getMessage(); |
1241 | 1241 | } |
1242 | 1242 | |
@@ -1257,8 +1257,8 @@ discard block |
||
1257 | 1257 | $query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)'; |
1258 | 1258 | try { |
1259 | 1259 | $sth = $Connection->db->prepare($query); |
1260 | - $sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10])); |
|
1261 | - } catch(PDOException $e) { |
|
1260 | + $sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10])); |
|
1261 | + } catch (PDOException $e) { |
|
1262 | 1262 | return "error : ".$e->getMessage(); |
1263 | 1263 | } |
1264 | 1264 | } |
@@ -1277,7 +1277,7 @@ discard block |
||
1277 | 1277 | $Connection = new Connection(); |
1278 | 1278 | $sth = $Connection->db->prepare($query); |
1279 | 1279 | $sth->execute(); |
1280 | - } catch(PDOException $e) { |
|
1280 | + } catch (PDOException $e) { |
|
1281 | 1281 | return "error : ".$e->getMessage(); |
1282 | 1282 | } |
1283 | 1283 | |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | try { |
1294 | 1294 | $sth = $Connection->db->prepare($query); |
1295 | 1295 | $sth->execute(array(':icao' => $icao)); |
1296 | - } catch(PDOException $e) { |
|
1296 | + } catch (PDOException $e) { |
|
1297 | 1297 | return "error : ".$e->getMessage(); |
1298 | 1298 | } |
1299 | 1299 | } |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | return ''; |
1305 | 1305 | } |
1306 | 1306 | |
1307 | - public static function tle($filename,$tletype) { |
|
1307 | + public static function tle($filename, $tletype) { |
|
1308 | 1308 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
1309 | 1309 | global $tmp_dir, $globalTransaction; |
1310 | 1310 | //$Spotter = new Spotter(); |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | $Connection = new Connection(); |
1315 | 1315 | $sth = $Connection->db->prepare($query); |
1316 | 1316 | $sth->execute(array(':source' => $filename)); |
1317 | - } catch(PDOException $e) { |
|
1317 | + } catch (PDOException $e) { |
|
1318 | 1318 | return "error : ".$e->getMessage(); |
1319 | 1319 | } |
1320 | 1320 | |
@@ -1339,8 +1339,8 @@ discard block |
||
1339 | 1339 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
1340 | 1340 | try { |
1341 | 1341 | $sth = $Connection->db->prepare($query); |
1342 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
1343 | - } catch(PDOException $e) { |
|
1342 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
1343 | + } catch (PDOException $e) { |
|
1344 | 1344 | return "error : ".$e->getMessage(); |
1345 | 1345 | } |
1346 | 1346 | |
@@ -1360,28 +1360,28 @@ discard block |
||
1360 | 1360 | */ |
1361 | 1361 | private static function table2array($data) { |
1362 | 1362 | $html = str_get_html($data); |
1363 | - $tabledata=array(); |
|
1364 | - foreach($html->find('tr') as $element) |
|
1363 | + $tabledata = array(); |
|
1364 | + foreach ($html->find('tr') as $element) |
|
1365 | 1365 | { |
1366 | 1366 | $td = array(); |
1367 | - foreach( $element->find('th') as $row) |
|
1367 | + foreach ($element->find('th') as $row) |
|
1368 | 1368 | { |
1369 | 1369 | $td [] = trim($row->plaintext); |
1370 | 1370 | } |
1371 | - $td=array_filter($td); |
|
1371 | + $td = array_filter($td); |
|
1372 | 1372 | $tabledata[] = $td; |
1373 | 1373 | |
1374 | 1374 | $td = array(); |
1375 | 1375 | $tdi = array(); |
1376 | - foreach( $element->find('td') as $row) |
|
1376 | + foreach ($element->find('td') as $row) |
|
1377 | 1377 | { |
1378 | 1378 | $td [] = trim($row->plaintext); |
1379 | 1379 | $tdi [] = trim($row->innertext); |
1380 | 1380 | } |
1381 | - $td=array_filter($td); |
|
1382 | - $tdi=array_filter($tdi); |
|
1381 | + $td = array_filter($td); |
|
1382 | + $tdi = array_filter($tdi); |
|
1383 | 1383 | // $tabledata[]=array_merge($td,$tdi); |
1384 | - $tabledata[]=$td; |
|
1384 | + $tabledata[] = $td; |
|
1385 | 1385 | } |
1386 | 1386 | return(array_filter($tabledata)); |
1387 | 1387 | } |
@@ -1454,13 +1454,13 @@ discard block |
||
1454 | 1454 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1455 | 1455 | { |
1456 | 1456 | $i++; |
1457 | - if($i > 3 && count($row) > 2) { |
|
1457 | + if ($i > 3 && count($row) > 2) { |
|
1458 | 1458 | $data = array_values(array_filter($row)); |
1459 | 1459 | $cntdata = count($data); |
1460 | 1460 | if ($cntdata > 10) { |
1461 | 1461 | $value = $data[9]; |
1462 | 1462 | |
1463 | - for ($i =10;$i < $cntdata;$i++) { |
|
1463 | + for ($i = 10; $i < $cntdata; $i++) { |
|
1464 | 1464 | $value .= ' '.$data[$i]; |
1465 | 1465 | } |
1466 | 1466 | $data[9] = $value; |
@@ -1470,8 +1470,8 @@ discard block |
||
1470 | 1470 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
1471 | 1471 | try { |
1472 | 1472 | $sth = $Connection->db->prepare($query); |
1473 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
1474 | - } catch(PDOException $e) { |
|
1473 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
1474 | + } catch (PDOException $e) { |
|
1475 | 1475 | return "error : ".$e->getMessage(); |
1476 | 1476 | } |
1477 | 1477 | } |
@@ -1492,7 +1492,7 @@ discard block |
||
1492 | 1492 | $Connection = new Connection(); |
1493 | 1493 | $sth = $Connection->db->prepare($query); |
1494 | 1494 | $sth->execute(); |
1495 | - } catch(PDOException $e) { |
|
1495 | + } catch (PDOException $e) { |
|
1496 | 1496 | return "error : ".$e->getMessage(); |
1497 | 1497 | } |
1498 | 1498 | |
@@ -1504,12 +1504,12 @@ discard block |
||
1504 | 1504 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1505 | 1505 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1506 | 1506 | { |
1507 | - if(count($row) > 1) { |
|
1507 | + if (count($row) > 1) { |
|
1508 | 1508 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
1509 | 1509 | try { |
1510 | 1510 | $sth = $Connection->db->prepare($query); |
1511 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
1512 | - } catch(PDOException $e) { |
|
1511 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
1512 | + } catch (PDOException $e) { |
|
1513 | 1513 | return "error : ".$e->getMessage(); |
1514 | 1514 | } |
1515 | 1515 | } |
@@ -1529,21 +1529,21 @@ discard block |
||
1529 | 1529 | try { |
1530 | 1530 | $sth = $Connection->db->prepare($query); |
1531 | 1531 | $sth->execute(); |
1532 | - } catch(PDOException $e) { |
|
1532 | + } catch (PDOException $e) { |
|
1533 | 1533 | return "error : ".$e->getMessage(); |
1534 | 1534 | } |
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | |
1538 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1538 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1539 | 1539 | else { |
1540 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1540 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1541 | 1541 | $query = "CREATE EXTENSION postgis"; |
1542 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
1542 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
1543 | 1543 | try { |
1544 | 1544 | $sth = $Connection->db->prepare($query); |
1545 | 1545 | $sth->execute(); |
1546 | - } catch(PDOException $e) { |
|
1546 | + } catch (PDOException $e) { |
|
1547 | 1547 | return "error : ".$e->getMessage(); |
1548 | 1548 | } |
1549 | 1549 | } |
@@ -1556,7 +1556,7 @@ discard block |
||
1556 | 1556 | include_once('class.create_db.php'); |
1557 | 1557 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1558 | 1558 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
1559 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
1559 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
1560 | 1560 | $error = ''; |
1561 | 1561 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1562 | 1562 | if ($globalDebug) echo "Gunzip..."; |
@@ -1588,14 +1588,14 @@ discard block |
||
1588 | 1588 | try { |
1589 | 1589 | $sth = $Connection->db->prepare($query); |
1590 | 1590 | $sth->execute(); |
1591 | - } catch(PDOException $e) { |
|
1591 | + } catch (PDOException $e) { |
|
1592 | 1592 | echo "error : ".$e->getMessage(); |
1593 | 1593 | } |
1594 | 1594 | } |
1595 | 1595 | if ($globalDBdriver == 'mysql') { |
1596 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1596 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1597 | 1597 | } else { |
1598 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1598 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1599 | 1599 | } |
1600 | 1600 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
1601 | 1601 | return $error; |
@@ -1608,7 +1608,7 @@ discard block |
||
1608 | 1608 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
1609 | 1609 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
1610 | 1610 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
1611 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
1611 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
1612 | 1612 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
1613 | 1613 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
1614 | 1614 | return $error; |
@@ -1628,7 +1628,7 @@ discard block |
||
1628 | 1628 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1629 | 1629 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
1630 | 1630 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1631 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1631 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1632 | 1632 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
1633 | 1633 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
1634 | 1634 | if ($error != '') { |
@@ -1641,7 +1641,7 @@ discard block |
||
1641 | 1641 | global $tmp_dir, $globalDebug; |
1642 | 1642 | $error = ''; |
1643 | 1643 | if ($globalDebug) echo "Routes : Download..."; |
1644 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
1644 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
1645 | 1645 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1646 | 1646 | if ($globalDebug) echo "Gunzip..."; |
1647 | 1647 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1657,7 +1657,7 @@ discard block |
||
1657 | 1657 | global $tmp_dir, $globalDebug; |
1658 | 1658 | $error = ''; |
1659 | 1659 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
1660 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
1660 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
1661 | 1661 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1662 | 1662 | if ($globalDebug) echo "Gunzip..."; |
1663 | 1663 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1673,7 +1673,7 @@ discard block |
||
1673 | 1673 | global $tmp_dir, $globalDebug; |
1674 | 1674 | $error = ''; |
1675 | 1675 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
1676 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
1676 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
1677 | 1677 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1678 | 1678 | if ($globalDebug) echo "Gunzip..."; |
1679 | 1679 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1701,7 +1701,7 @@ discard block |
||
1701 | 1701 | */ |
1702 | 1702 | if ($globalDebug) echo "Modes : Download..."; |
1703 | 1703 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
1704 | - update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
|
1704 | + update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); |
|
1705 | 1705 | |
1706 | 1706 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1707 | 1707 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
@@ -1721,7 +1721,7 @@ discard block |
||
1721 | 1721 | public static function update_ModeS_faa() { |
1722 | 1722 | global $tmp_dir, $globalDebug; |
1723 | 1723 | if ($globalDebug) echo "Modes FAA: Download..."; |
1724 | - update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
|
1724 | + update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip'); |
|
1725 | 1725 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
1726 | 1726 | if ($globalDebug) echo "Unzip..."; |
1727 | 1727 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
@@ -1737,7 +1737,7 @@ discard block |
||
1737 | 1737 | public static function update_ModeS_flarm() { |
1738 | 1738 | global $tmp_dir, $globalDebug; |
1739 | 1739 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
1740 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
1740 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
1741 | 1741 | if (file_exists($tmp_dir.'data.fln')) { |
1742 | 1742 | if ($globalDebug) echo "Add to DB..."; |
1743 | 1743 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1751,7 +1751,7 @@ discard block |
||
1751 | 1751 | public static function update_ModeS_ogn() { |
1752 | 1752 | global $tmp_dir, $globalDebug; |
1753 | 1753 | if ($globalDebug) echo "Modes OGN: Download..."; |
1754 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
1754 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
1755 | 1755 | if (file_exists($tmp_dir.'ogn.csv')) { |
1756 | 1756 | if ($globalDebug) echo "Add to DB..."; |
1757 | 1757 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1766,201 +1766,201 @@ discard block |
||
1766 | 1766 | global $tmp_dir, $globalDebug, $globalMasterSource; |
1767 | 1767 | |
1768 | 1768 | if ($globalDebug) echo "Owner France: Download..."; |
1769 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
1769 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
1770 | 1770 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1771 | 1771 | if ($globalDebug) echo "Add to DB..."; |
1772 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
1772 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
1773 | 1773 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
1774 | 1774 | if ($error != '') { |
1775 | 1775 | return $error; |
1776 | 1776 | } elseif ($globalDebug) echo "Done\n"; |
1777 | 1777 | |
1778 | 1778 | if ($globalDebug) echo "Owner Ireland: Download..."; |
1779 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
1779 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
1780 | 1780 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1781 | 1781 | if ($globalDebug) echo "Add to DB..."; |
1782 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
1782 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
1783 | 1783 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
1784 | 1784 | if ($error != '') { |
1785 | 1785 | return $error; |
1786 | 1786 | } elseif ($globalDebug) echo "Done\n"; |
1787 | 1787 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
1788 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
1788 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
1789 | 1789 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1790 | 1790 | if ($globalDebug) echo "Add to DB..."; |
1791 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
1791 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
1792 | 1792 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
1793 | 1793 | if ($error != '') { |
1794 | 1794 | return $error; |
1795 | 1795 | } elseif ($globalDebug) echo "Done\n"; |
1796 | 1796 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
1797 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
1797 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
1798 | 1798 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1799 | 1799 | if ($globalDebug) echo "Add to DB..."; |
1800 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
1800 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
1801 | 1801 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
1802 | 1802 | if ($error != '') { |
1803 | 1803 | return $error; |
1804 | 1804 | } elseif ($globalDebug) echo "Done\n"; |
1805 | 1805 | if ($globalDebug) echo "Owner Australia: Download..."; |
1806 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
1806 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
1807 | 1807 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1808 | 1808 | if ($globalDebug) echo "Add to DB..."; |
1809 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
1809 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
1810 | 1810 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
1811 | 1811 | if ($error != '') { |
1812 | 1812 | return $error; |
1813 | 1813 | } elseif ($globalDebug) echo "Done\n"; |
1814 | 1814 | if ($globalDebug) echo "Owner Austria: Download..."; |
1815 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
1815 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
1816 | 1816 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1817 | 1817 | if ($globalDebug) echo "Add to DB..."; |
1818 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
1818 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
1819 | 1819 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
1820 | 1820 | if ($error != '') { |
1821 | 1821 | return $error; |
1822 | 1822 | } elseif ($globalDebug) echo "Done\n"; |
1823 | 1823 | if ($globalDebug) echo "Owner Chile: Download..."; |
1824 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
1824 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
1825 | 1825 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1826 | 1826 | if ($globalDebug) echo "Add to DB..."; |
1827 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
1827 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
1828 | 1828 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
1829 | 1829 | if ($error != '') { |
1830 | 1830 | return $error; |
1831 | 1831 | } elseif ($globalDebug) echo "Done\n"; |
1832 | 1832 | if ($globalDebug) echo "Owner Colombia: Download..."; |
1833 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
1833 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
1834 | 1834 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1835 | 1835 | if ($globalDebug) echo "Add to DB..."; |
1836 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
1836 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
1837 | 1837 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
1838 | 1838 | if ($error != '') { |
1839 | 1839 | return $error; |
1840 | 1840 | } elseif ($globalDebug) echo "Done\n"; |
1841 | 1841 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
1842 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
1842 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
1843 | 1843 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1844 | 1844 | if ($globalDebug) echo "Add to DB..."; |
1845 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
1845 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
1846 | 1846 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
1847 | 1847 | if ($error != '') { |
1848 | 1848 | return $error; |
1849 | 1849 | } elseif ($globalDebug) echo "Done\n"; |
1850 | 1850 | if ($globalDebug) echo "Owner Brazil: Download..."; |
1851 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
1851 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
1852 | 1852 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1853 | 1853 | if ($globalDebug) echo "Add to DB..."; |
1854 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
1854 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
1855 | 1855 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
1856 | 1856 | if ($error != '') { |
1857 | 1857 | return $error; |
1858 | 1858 | } elseif ($globalDebug) echo "Done\n"; |
1859 | 1859 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
1860 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
1860 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
1861 | 1861 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1862 | 1862 | if ($globalDebug) echo "Add to DB..."; |
1863 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
1863 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
1864 | 1864 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
1865 | 1865 | if ($error != '') { |
1866 | 1866 | return $error; |
1867 | 1867 | } elseif ($globalDebug) echo "Done\n"; |
1868 | 1868 | if ($globalDebug) echo "Owner Croatia: Download..."; |
1869 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
1869 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
1870 | 1870 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1871 | 1871 | if ($globalDebug) echo "Add to DB..."; |
1872 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
1872 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
1873 | 1873 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
1874 | 1874 | if ($error != '') { |
1875 | 1875 | return $error; |
1876 | 1876 | } elseif ($globalDebug) echo "Done\n"; |
1877 | 1877 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
1878 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
1878 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
1879 | 1879 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1880 | 1880 | if ($globalDebug) echo "Add to DB..."; |
1881 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
1881 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
1882 | 1882 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
1883 | 1883 | if ($error != '') { |
1884 | 1884 | return $error; |
1885 | 1885 | } elseif ($globalDebug) echo "Done\n"; |
1886 | 1886 | if ($globalDebug) echo "Owner Maldives: Download..."; |
1887 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
1887 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
1888 | 1888 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1889 | 1889 | if ($globalDebug) echo "Add to DB..."; |
1890 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
1890 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
1891 | 1891 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
1892 | 1892 | if ($error != '') { |
1893 | 1893 | return $error; |
1894 | 1894 | } elseif ($globalDebug) echo "Done\n"; |
1895 | 1895 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
1896 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
1896 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
1897 | 1897 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1898 | 1898 | if ($globalDebug) echo "Add to DB..."; |
1899 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
1899 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
1900 | 1900 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
1901 | 1901 | if ($error != '') { |
1902 | 1902 | return $error; |
1903 | 1903 | } elseif ($globalDebug) echo "Done\n"; |
1904 | 1904 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
1905 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
1905 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
1906 | 1906 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1907 | 1907 | if ($globalDebug) echo "Add to DB..."; |
1908 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
1908 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
1909 | 1909 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
1910 | 1910 | if ($error != '') { |
1911 | 1911 | return $error; |
1912 | 1912 | } elseif ($globalDebug) echo "Done\n"; |
1913 | 1913 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
1914 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
1914 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
1915 | 1915 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1916 | 1916 | if ($globalDebug) echo "Add to DB..."; |
1917 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
1917 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
1918 | 1918 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
1919 | 1919 | if ($error != '') { |
1920 | 1920 | return $error; |
1921 | 1921 | } elseif ($globalDebug) echo "Done\n"; |
1922 | 1922 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
1923 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
1923 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
1924 | 1924 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1925 | 1925 | if ($globalDebug) echo "Add to DB..."; |
1926 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
1926 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
1927 | 1927 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
1928 | 1928 | if ($error != '') { |
1929 | 1929 | return $error; |
1930 | 1930 | } elseif ($globalDebug) echo "Done\n"; |
1931 | 1931 | if ($globalDebug) echo "Owner Iceland: Download..."; |
1932 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
1932 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
1933 | 1933 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1934 | 1934 | if ($globalDebug) echo "Add to DB..."; |
1935 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
1935 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
1936 | 1936 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
1937 | 1937 | if ($error != '') { |
1938 | 1938 | return $error; |
1939 | 1939 | } elseif ($globalDebug) echo "Done\n"; |
1940 | 1940 | if ($globalDebug) echo "Owner Isle of Man: Download..."; |
1941 | - update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
|
1941 | + update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv'); |
|
1942 | 1942 | if (file_exists($tmp_dir.'owner_m.csv')) { |
1943 | 1943 | if ($globalDebug) echo "Add to DB..."; |
1944 | - $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
|
1944 | + $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M'); |
|
1945 | 1945 | } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
1946 | 1946 | if ($error != '') { |
1947 | 1947 | return $error; |
1948 | 1948 | } elseif ($globalDebug) echo "Done\n"; |
1949 | 1949 | if ($globalMasterSource) { |
1950 | 1950 | if ($globalDebug) echo "ModeS Netherlands: Download..."; |
1951 | - update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
|
1951 | + update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv'); |
|
1952 | 1952 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
1953 | 1953 | if ($globalDebug) echo "Add to DB..."; |
1954 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
|
1954 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH'); |
|
1955 | 1955 | } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
1956 | 1956 | if ($error != '') { |
1957 | 1957 | return $error; |
1958 | 1958 | } elseif ($globalDebug) echo "Done\n"; |
1959 | 1959 | if ($globalDebug) echo "ModeS Denmark: Download..."; |
1960 | - update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
|
1960 | + update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv'); |
|
1961 | 1961 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
1962 | 1962 | if ($globalDebug) echo "Add to DB..."; |
1963 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
|
1963 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY'); |
|
1964 | 1964 | } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
1965 | 1965 | if ($error != '') { |
1966 | 1966 | return $error; |
@@ -1973,7 +1973,7 @@ discard block |
||
1973 | 1973 | global $tmp_dir, $globalDebug; |
1974 | 1974 | $error = ''; |
1975 | 1975 | if ($globalDebug) echo "Translation : Download..."; |
1976 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
1976 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
1977 | 1977 | if (file_exists($tmp_dir.'translation.zip')) { |
1978 | 1978 | if ($globalDebug) echo "Unzip..."; |
1979 | 1979 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1989,7 +1989,7 @@ discard block |
||
1989 | 1989 | public static function update_translation_fam() { |
1990 | 1990 | global $tmp_dir, $globalDebug; |
1991 | 1991 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
1992 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
1992 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
1993 | 1993 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1994 | 1994 | if ($globalDebug) echo "Gunzip..."; |
1995 | 1995 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -2004,7 +2004,7 @@ discard block |
||
2004 | 2004 | public static function update_ModeS_fam() { |
2005 | 2005 | global $tmp_dir, $globalDebug; |
2006 | 2006 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
2007 | - update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
|
2007 | + update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); |
|
2008 | 2008 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
2009 | 2009 | if ($globalDebug) echo "Gunzip..."; |
2010 | 2010 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
@@ -2020,9 +2020,9 @@ discard block |
||
2020 | 2020 | global $tmp_dir, $globalDebug, $globalOwner; |
2021 | 2021 | if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
2022 | 2022 | if ($globalOwner === TRUE) { |
2023 | - update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
2023 | + update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
2024 | 2024 | } else { |
2025 | - update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
2025 | + update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
2026 | 2026 | } |
2027 | 2027 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
2028 | 2028 | if ($globalDebug) echo "Gunzip..."; |
@@ -2038,7 +2038,7 @@ discard block |
||
2038 | 2038 | public static function update_routes_fam() { |
2039 | 2039 | global $tmp_dir, $globalDebug; |
2040 | 2040 | if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
2041 | - update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
|
2041 | + update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz'); |
|
2042 | 2042 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
2043 | 2043 | if ($globalDebug) echo "Gunzip..."; |
2044 | 2044 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
@@ -2052,13 +2052,13 @@ discard block |
||
2052 | 2052 | } |
2053 | 2053 | public static function update_marine_identity_fam() { |
2054 | 2054 | global $tmp_dir, $globalDebug; |
2055 | - update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5'); |
|
2055 | + update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5'); |
|
2056 | 2056 | if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) { |
2057 | - $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
2057 | + $marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
2058 | 2058 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
2059 | 2059 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
2060 | 2060 | if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
2061 | - update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
|
2061 | + update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz'); |
|
2062 | 2062 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
2063 | 2063 | if ($globalDebug) echo "Gunzip..."; |
2064 | 2064 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
@@ -2078,7 +2078,7 @@ discard block |
||
2078 | 2078 | public static function update_banned_fam() { |
2079 | 2079 | global $tmp_dir, $globalDebug; |
2080 | 2080 | if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
2081 | - update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
|
2081 | + update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv'); |
|
2082 | 2082 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
2083 | 2083 | //if ($globalDebug) echo "Gunzip..."; |
2084 | 2084 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
@@ -2097,18 +2097,18 @@ discard block |
||
2097 | 2097 | $error = ''; |
2098 | 2098 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
2099 | 2099 | if ($globalDBdriver == 'mysql') { |
2100 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
2100 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
2101 | 2101 | } else { |
2102 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
2102 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
2103 | 2103 | } |
2104 | 2104 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
2105 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
2105 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
2106 | 2106 | $airspace_md5 = $airspace_md5_file[0]; |
2107 | 2107 | if (!update_db::check_airspace_version($airspace_md5)) { |
2108 | 2108 | if ($globalDBdriver == 'mysql') { |
2109 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
2109 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
2110 | 2110 | } else { |
2111 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
2111 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
2112 | 2112 | } |
2113 | 2113 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2114 | 2114 | if ($globalDebug) echo "Gunzip..."; |
@@ -2120,7 +2120,7 @@ discard block |
||
2120 | 2120 | try { |
2121 | 2121 | $sth = $Connection->db->prepare($query); |
2122 | 2122 | $sth->execute(); |
2123 | - } catch(PDOException $e) { |
|
2123 | + } catch (PDOException $e) { |
|
2124 | 2124 | return "error : ".$e->getMessage(); |
2125 | 2125 | } |
2126 | 2126 | } |
@@ -2139,15 +2139,15 @@ discard block |
||
2139 | 2139 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
2140 | 2140 | $error = ''; |
2141 | 2141 | if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
2142 | - update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
2142 | + update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
2143 | 2143 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
2144 | - $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
2144 | + $geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
2145 | 2145 | $geoid_md5 = $geoid_md5_file[0]; |
2146 | 2146 | if (!update_db::check_geoid_version($geoid_md5)) { |
2147 | - update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
2147 | + update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
2148 | 2148 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
2149 | 2149 | if ($globalDebug) echo "Gunzip..."; |
2150 | - update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
2150 | + update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
2151 | 2151 | update_db::insert_geoid_version($geoid_md5); |
2152 | 2152 | } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
2153 | 2153 | } |
@@ -2161,15 +2161,15 @@ discard block |
||
2161 | 2161 | public static function update_tle() { |
2162 | 2162 | global $tmp_dir, $globalDebug; |
2163 | 2163 | if ($globalDebug) echo "Download TLE : Download..."; |
2164 | - $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
|
2165 | - 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
|
2166 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
2164 | + $alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt', |
|
2165 | + 'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt', |
|
2166 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
2167 | 2167 | foreach ($alltle as $filename) { |
2168 | 2168 | if ($globalDebug) echo "downloading ".$filename.'...'; |
2169 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
2169 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
2170 | 2170 | if (file_exists($tmp_dir.$filename)) { |
2171 | 2171 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
2172 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
2172 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
2173 | 2173 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
2174 | 2174 | if ($error != '') { |
2175 | 2175 | echo $error."\n"; |
@@ -2182,32 +2182,32 @@ discard block |
||
2182 | 2182 | global $tmp_dir, $globalDebug; |
2183 | 2183 | $error = ''; |
2184 | 2184 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
2185 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
2185 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
2186 | 2186 | if (file_exists($tmp_dir.'models.md5sum')) { |
2187 | 2187 | if ($globalDebug) echo "Check files...\n"; |
2188 | 2188 | $newmodelsdb = array(); |
2189 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
2190 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2189 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
2190 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2191 | 2191 | $model = trim($row[2]); |
2192 | 2192 | $newmodelsdb[$model] = trim($row[0]); |
2193 | 2193 | } |
2194 | 2194 | } |
2195 | 2195 | $modelsdb = array(); |
2196 | 2196 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
2197 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
2198 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2197 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
2198 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2199 | 2199 | $model = trim($row[2]); |
2200 | 2200 | $modelsdb[$model] = trim($row[0]); |
2201 | 2201 | } |
2202 | 2202 | } |
2203 | 2203 | } |
2204 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2204 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2205 | 2205 | foreach ($diff as $key => $value) { |
2206 | 2206 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
2207 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
2207 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
2208 | 2208 | |
2209 | 2209 | } |
2210 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
2210 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
2211 | 2211 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2212 | 2212 | if ($error != '') { |
2213 | 2213 | return $error; |
@@ -2219,32 +2219,32 @@ discard block |
||
2219 | 2219 | global $tmp_dir, $globalDebug; |
2220 | 2220 | $error = ''; |
2221 | 2221 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
2222 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
2222 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
2223 | 2223 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2224 | 2224 | if ($globalDebug) echo "Check files...\n"; |
2225 | 2225 | $newmodelsdb = array(); |
2226 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
2227 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2226 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
2227 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2228 | 2228 | $model = trim($row[2]); |
2229 | 2229 | $newmodelsdb[$model] = trim($row[0]); |
2230 | 2230 | } |
2231 | 2231 | } |
2232 | 2232 | $modelsdb = array(); |
2233 | 2233 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
2234 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
2235 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2234 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
2235 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2236 | 2236 | $model = trim($row[2]); |
2237 | 2237 | $modelsdb[$model] = trim($row[0]); |
2238 | 2238 | } |
2239 | 2239 | } |
2240 | 2240 | } |
2241 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2241 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2242 | 2242 | foreach ($diff as $key => $value) { |
2243 | 2243 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
2244 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
2244 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
2245 | 2245 | |
2246 | 2246 | } |
2247 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
2247 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
2248 | 2248 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2249 | 2249 | if ($error != '') { |
2250 | 2250 | return $error; |
@@ -2256,32 +2256,32 @@ discard block |
||
2256 | 2256 | global $tmp_dir, $globalDebug; |
2257 | 2257 | $error = ''; |
2258 | 2258 | if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
2259 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
|
2259 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum'); |
|
2260 | 2260 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
2261 | 2261 | if ($globalDebug) echo "Check files...\n"; |
2262 | 2262 | $newmodelsdb = array(); |
2263 | - if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
|
2264 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2263 | + if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) { |
|
2264 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2265 | 2265 | $model = trim($row[2]); |
2266 | 2266 | $newmodelsdb[$model] = trim($row[0]); |
2267 | 2267 | } |
2268 | 2268 | } |
2269 | 2269 | $modelsdb = array(); |
2270 | 2270 | if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) { |
2271 | - if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) { |
|
2272 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2271 | + if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) { |
|
2272 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2273 | 2273 | $model = trim($row[2]); |
2274 | 2274 | $modelsdb[$model] = trim($row[0]); |
2275 | 2275 | } |
2276 | 2276 | } |
2277 | 2277 | } |
2278 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2278 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2279 | 2279 | foreach ($diff as $key => $value) { |
2280 | 2280 | if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
2281 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
|
2281 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key); |
|
2282 | 2282 | |
2283 | 2283 | } |
2284 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
2284 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
2285 | 2285 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2286 | 2286 | if ($error != '') { |
2287 | 2287 | return $error; |
@@ -2304,8 +2304,8 @@ discard block |
||
2304 | 2304 | */ |
2305 | 2305 | if (file_exists($tmp_dir.'aircrafts.html')) { |
2306 | 2306 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
2307 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2308 | - $result = fread($fh,100000000); |
|
2307 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
2308 | + $result = fread($fh, 100000000); |
|
2309 | 2309 | //echo $result; |
2310 | 2310 | //var_dump(str_get_html($result)); |
2311 | 2311 | //print_r(self::table2array($result)); |
@@ -2323,23 +2323,23 @@ discard block |
||
2323 | 2323 | $Connection = new Connection(); |
2324 | 2324 | $sth = $Connection->db->prepare($query); |
2325 | 2325 | $sth->execute(); |
2326 | - } catch(PDOException $e) { |
|
2326 | + } catch (PDOException $e) { |
|
2327 | 2327 | return "error : ".$e->getMessage(); |
2328 | 2328 | } |
2329 | 2329 | |
2330 | 2330 | $error = ''; |
2331 | 2331 | if ($globalDebug) echo "Notam : Download..."; |
2332 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
2332 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
2333 | 2333 | if (file_exists($tmp_dir.'notam.rss')) { |
2334 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
2334 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
2335 | 2335 | foreach ($notams['channel']['item'] as $notam) { |
2336 | - $title = explode(':',$notam['title']); |
|
2336 | + $title = explode(':', $notam['title']); |
|
2337 | 2337 | $data['ref'] = trim($title[0]); |
2338 | 2338 | unset($title[0]); |
2339 | - $data['title'] = trim(implode(':',$title)); |
|
2340 | - $description = strip_tags($notam['description'],'<pre>'); |
|
2341 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
2342 | - $q = explode('/',$match[1]); |
|
2339 | + $data['title'] = trim(implode(':', $title)); |
|
2340 | + $description = strip_tags($notam['description'], '<pre>'); |
|
2341 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
2342 | + $q = explode('/', $match[1]); |
|
2343 | 2343 | $data['fir'] = $q[0]; |
2344 | 2344 | $data['code'] = $q[1]; |
2345 | 2345 | $ifrvfr = $q[2]; |
@@ -2355,30 +2355,30 @@ discard block |
||
2355 | 2355 | $data['lower_limit'] = $q[5]; |
2356 | 2356 | $data['upper_limit'] = $q[6]; |
2357 | 2357 | $latlonrad = $q[7]; |
2358 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
2359 | - $latitude = $Common->convertDec($las,'latitude'); |
|
2360 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
2358 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
2359 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
2360 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
2361 | 2361 | if ($lac == 'S') $latitude = '-'.$latitude; |
2362 | 2362 | if ($lnc == 'W') $longitude = '-'.$longitude; |
2363 | 2363 | $data['center_latitude'] = $latitude; |
2364 | 2364 | $data['center_longitude'] = $longitude; |
2365 | 2365 | $data['radius'] = intval($radius); |
2366 | 2366 | |
2367 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
2367 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
2368 | 2368 | $data['text'] = $match[1]; |
2369 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
2369 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
2370 | 2370 | $fromto = $match[1]; |
2371 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
2371 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
2372 | 2372 | $fromall = trim($match[1]); |
2373 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
2373 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
2374 | 2374 | $from = trim($match[1]); |
2375 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
2376 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
2375 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
2376 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
2377 | 2377 | $toall = trim($match[1]); |
2378 | - if (!preg_match(':Permanent:',$toall)) { |
|
2379 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
2378 | + if (!preg_match(':Permanent:', $toall)) { |
|
2379 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
2380 | 2380 | $to = trim($match[1]); |
2381 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
2381 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
2382 | 2382 | $data['permanent'] = 0; |
2383 | 2383 | } else { |
2384 | 2384 | $data['date_end'] = NULL; |
@@ -2386,7 +2386,7 @@ discard block |
||
2386 | 2386 | } |
2387 | 2387 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
2388 | 2388 | $NOTAM = new NOTAM(); |
2389 | - $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
2389 | + $NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
2390 | 2390 | unset($data); |
2391 | 2391 | } |
2392 | 2392 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -2409,16 +2409,16 @@ discard block |
||
2409 | 2409 | $Connection = new Connection(); |
2410 | 2410 | $sth = $Connection->db->prepare($query); |
2411 | 2411 | $sth->execute(); |
2412 | - } catch(PDOException $e) { |
|
2412 | + } catch (PDOException $e) { |
|
2413 | 2413 | return "error : ".$e->getMessage(); |
2414 | 2414 | } |
2415 | 2415 | } |
2416 | 2416 | $Common = new Common(); |
2417 | 2417 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
2418 | - $airspace_json = json_decode($airspace_lst,true); |
|
2418 | + $airspace_json = json_decode($airspace_lst, true); |
|
2419 | 2419 | foreach ($airspace_json['records'] as $airspace) { |
2420 | 2420 | if ($globalDebug) echo $airspace['name']."...\n"; |
2421 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
2421 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
2422 | 2422 | if (file_exists($tmp_dir.$airspace['name'])) { |
2423 | 2423 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
2424 | 2424 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -2440,7 +2440,7 @@ discard block |
||
2440 | 2440 | $Connection = new Connection(); |
2441 | 2441 | $sth = $Connection->db->prepare($query); |
2442 | 2442 | $sth->execute(array(':new' => $new, ':old' => $old)); |
2443 | - } catch(PDOException $e) { |
|
2443 | + } catch (PDOException $e) { |
|
2444 | 2444 | return "error : ".$e->getMessage(); |
2445 | 2445 | } |
2446 | 2446 | } |
@@ -2457,7 +2457,7 @@ discard block |
||
2457 | 2457 | $Connection = new Connection(); |
2458 | 2458 | $sth = $Connection->db->prepare($query); |
2459 | 2459 | $sth->execute(); |
2460 | - } catch(PDOException $e) { |
|
2460 | + } catch (PDOException $e) { |
|
2461 | 2461 | return "error : ".$e->getMessage(); |
2462 | 2462 | } |
2463 | 2463 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2472,7 +2472,7 @@ discard block |
||
2472 | 2472 | $Connection = new Connection(); |
2473 | 2473 | $sth = $Connection->db->prepare($query); |
2474 | 2474 | $sth->execute(); |
2475 | - } catch(PDOException $e) { |
|
2475 | + } catch (PDOException $e) { |
|
2476 | 2476 | return "error : ".$e->getMessage(); |
2477 | 2477 | } |
2478 | 2478 | } |
@@ -2483,7 +2483,7 @@ discard block |
||
2483 | 2483 | $Connection = new Connection(); |
2484 | 2484 | $sth = $Connection->db->prepare($query); |
2485 | 2485 | $sth->execute(array(':version' => $version)); |
2486 | - } catch(PDOException $e) { |
|
2486 | + } catch (PDOException $e) { |
|
2487 | 2487 | return "error : ".$e->getMessage(); |
2488 | 2488 | } |
2489 | 2489 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2497,7 +2497,7 @@ discard block |
||
2497 | 2497 | $Connection = new Connection(); |
2498 | 2498 | $sth = $Connection->db->prepare($query); |
2499 | 2499 | $sth->execute(array(':version' => $version)); |
2500 | - } catch(PDOException $e) { |
|
2500 | + } catch (PDOException $e) { |
|
2501 | 2501 | return "error : ".$e->getMessage(); |
2502 | 2502 | } |
2503 | 2503 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2511,7 +2511,7 @@ discard block |
||
2511 | 2511 | $Connection = new Connection(); |
2512 | 2512 | $sth = $Connection->db->prepare($query); |
2513 | 2513 | $sth->execute(array(':version' => $version)); |
2514 | - } catch(PDOException $e) { |
|
2514 | + } catch (PDOException $e) { |
|
2515 | 2515 | return "error : ".$e->getMessage(); |
2516 | 2516 | } |
2517 | 2517 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2527,7 +2527,7 @@ discard block |
||
2527 | 2527 | $Connection = new Connection(); |
2528 | 2528 | $sth = $Connection->db->prepare($query); |
2529 | 2529 | $sth->execute(array(':version' => $version)); |
2530 | - } catch(PDOException $e) { |
|
2530 | + } catch (PDOException $e) { |
|
2531 | 2531 | return "error : ".$e->getMessage(); |
2532 | 2532 | } |
2533 | 2533 | } |
@@ -2539,7 +2539,7 @@ discard block |
||
2539 | 2539 | $Connection = new Connection(); |
2540 | 2540 | $sth = $Connection->db->prepare($query); |
2541 | 2541 | $sth->execute(array(':version' => $version)); |
2542 | - } catch(PDOException $e) { |
|
2542 | + } catch (PDOException $e) { |
|
2543 | 2543 | return "error : ".$e->getMessage(); |
2544 | 2544 | } |
2545 | 2545 | } |
@@ -2551,7 +2551,7 @@ discard block |
||
2551 | 2551 | $Connection = new Connection(); |
2552 | 2552 | $sth = $Connection->db->prepare($query); |
2553 | 2553 | $sth->execute(array(':version' => $version)); |
2554 | - } catch(PDOException $e) { |
|
2554 | + } catch (PDOException $e) { |
|
2555 | 2555 | return "error : ".$e->getMessage(); |
2556 | 2556 | } |
2557 | 2557 | } |
@@ -2567,7 +2567,7 @@ discard block |
||
2567 | 2567 | $Connection = new Connection(); |
2568 | 2568 | $sth = $Connection->db->prepare($query); |
2569 | 2569 | $sth->execute(); |
2570 | - } catch(PDOException $e) { |
|
2570 | + } catch (PDOException $e) { |
|
2571 | 2571 | return "error : ".$e->getMessage(); |
2572 | 2572 | } |
2573 | 2573 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2582,7 +2582,7 @@ discard block |
||
2582 | 2582 | $Connection = new Connection(); |
2583 | 2583 | $sth = $Connection->db->prepare($query); |
2584 | 2584 | $sth->execute(); |
2585 | - } catch(PDOException $e) { |
|
2585 | + } catch (PDOException $e) { |
|
2586 | 2586 | return "error : ".$e->getMessage(); |
2587 | 2587 | } |
2588 | 2588 | } |
@@ -2598,7 +2598,7 @@ discard block |
||
2598 | 2598 | $Connection = new Connection(); |
2599 | 2599 | $sth = $Connection->db->prepare($query); |
2600 | 2600 | $sth->execute(); |
2601 | - } catch(PDOException $e) { |
|
2601 | + } catch (PDOException $e) { |
|
2602 | 2602 | return "error : ".$e->getMessage(); |
2603 | 2603 | } |
2604 | 2604 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2613,7 +2613,7 @@ discard block |
||
2613 | 2613 | $Connection = new Connection(); |
2614 | 2614 | $sth = $Connection->db->prepare($query); |
2615 | 2615 | $sth->execute(); |
2616 | - } catch(PDOException $e) { |
|
2616 | + } catch (PDOException $e) { |
|
2617 | 2617 | return "error : ".$e->getMessage(); |
2618 | 2618 | } |
2619 | 2619 | } |
@@ -2629,7 +2629,7 @@ discard block |
||
2629 | 2629 | $Connection = new Connection(); |
2630 | 2630 | $sth = $Connection->db->prepare($query); |
2631 | 2631 | $sth->execute(); |
2632 | - } catch(PDOException $e) { |
|
2632 | + } catch (PDOException $e) { |
|
2633 | 2633 | return "error : ".$e->getMessage(); |
2634 | 2634 | } |
2635 | 2635 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2644,7 +2644,7 @@ discard block |
||
2644 | 2644 | $Connection = new Connection(); |
2645 | 2645 | $sth = $Connection->db->prepare($query); |
2646 | 2646 | $sth->execute(); |
2647 | - } catch(PDOException $e) { |
|
2647 | + } catch (PDOException $e) { |
|
2648 | 2648 | return "error : ".$e->getMessage(); |
2649 | 2649 | } |
2650 | 2650 | } |
@@ -2660,7 +2660,7 @@ discard block |
||
2660 | 2660 | $Connection = new Connection(); |
2661 | 2661 | $sth = $Connection->db->prepare($query); |
2662 | 2662 | $sth->execute(); |
2663 | - } catch(PDOException $e) { |
|
2663 | + } catch (PDOException $e) { |
|
2664 | 2664 | return "error : ".$e->getMessage(); |
2665 | 2665 | } |
2666 | 2666 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2675,7 +2675,7 @@ discard block |
||
2675 | 2675 | $Connection = new Connection(); |
2676 | 2676 | $sth = $Connection->db->prepare($query); |
2677 | 2677 | $sth->execute(); |
2678 | - } catch(PDOException $e) { |
|
2678 | + } catch (PDOException $e) { |
|
2679 | 2679 | return "error : ".$e->getMessage(); |
2680 | 2680 | } |
2681 | 2681 | } |
@@ -2690,7 +2690,7 @@ discard block |
||
2690 | 2690 | $Connection = new Connection(); |
2691 | 2691 | $sth = $Connection->db->prepare($query); |
2692 | 2692 | $sth->execute(); |
2693 | - } catch(PDOException $e) { |
|
2693 | + } catch (PDOException $e) { |
|
2694 | 2694 | return "error : ".$e->getMessage(); |
2695 | 2695 | } |
2696 | 2696 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2705,7 +2705,7 @@ discard block |
||
2705 | 2705 | $Connection = new Connection(); |
2706 | 2706 | $sth = $Connection->db->prepare($query); |
2707 | 2707 | $sth->execute(); |
2708 | - } catch(PDOException $e) { |
|
2708 | + } catch (PDOException $e) { |
|
2709 | 2709 | return "error : ".$e->getMessage(); |
2710 | 2710 | } |
2711 | 2711 | } |
@@ -2720,7 +2720,7 @@ discard block |
||
2720 | 2720 | $Connection = new Connection(); |
2721 | 2721 | $sth = $Connection->db->prepare($query); |
2722 | 2722 | $sth->execute(); |
2723 | - } catch(PDOException $e) { |
|
2723 | + } catch (PDOException $e) { |
|
2724 | 2724 | return "error : ".$e->getMessage(); |
2725 | 2725 | } |
2726 | 2726 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2735,7 +2735,7 @@ discard block |
||
2735 | 2735 | $Connection = new Connection(); |
2736 | 2736 | $sth = $Connection->db->prepare($query); |
2737 | 2737 | $sth->execute(); |
2738 | - } catch(PDOException $e) { |
|
2738 | + } catch (PDOException $e) { |
|
2739 | 2739 | return "error : ".$e->getMessage(); |
2740 | 2740 | } |
2741 | 2741 | } |
@@ -2750,7 +2750,7 @@ discard block |
||
2750 | 2750 | $Connection = new Connection(); |
2751 | 2751 | $sth = $Connection->db->prepare($query); |
2752 | 2752 | $sth->execute(); |
2753 | - } catch(PDOException $e) { |
|
2753 | + } catch (PDOException $e) { |
|
2754 | 2754 | return "error : ".$e->getMessage(); |
2755 | 2755 | } |
2756 | 2756 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2765,7 +2765,7 @@ discard block |
||
2765 | 2765 | $Connection = new Connection(); |
2766 | 2766 | $sth = $Connection->db->prepare($query); |
2767 | 2767 | $sth->execute(); |
2768 | - } catch(PDOException $e) { |
|
2768 | + } catch (PDOException $e) { |
|
2769 | 2769 | return "error : ".$e->getMessage(); |
2770 | 2770 | } |
2771 | 2771 | } |
@@ -2780,7 +2780,7 @@ discard block |
||
2780 | 2780 | $Connection = new Connection(); |
2781 | 2781 | $sth = $Connection->db->prepare($query); |
2782 | 2782 | $sth->execute(); |
2783 | - } catch(PDOException $e) { |
|
2783 | + } catch (PDOException $e) { |
|
2784 | 2784 | return "error : ".$e->getMessage(); |
2785 | 2785 | } |
2786 | 2786 | } |
@@ -2795,7 +2795,7 @@ discard block |
||
2795 | 2795 | $Connection = new Connection(); |
2796 | 2796 | $sth = $Connection->db->prepare($query); |
2797 | 2797 | $sth->execute(); |
2798 | - } catch(PDOException $e) { |
|
2798 | + } catch (PDOException $e) { |
|
2799 | 2799 | return "error : ".$e->getMessage(); |
2800 | 2800 | } |
2801 | 2801 | } |
@@ -17,7 +17,9 @@ discard block |
||
17 | 17 | curl_setopt($ch, CURLOPT_URL, $url); |
18 | 18 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
19 | 19 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
20 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
20 | + if ($referer != '') { |
|
21 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
22 | + } |
|
21 | 23 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
22 | 24 | curl_setopt($ch, CURLOPT_FILE, $fp); |
23 | 25 | curl_exec($ch); |
@@ -28,12 +30,16 @@ discard block |
||
28 | 30 | public static function gunzip($in_file,$out_file_name = '') { |
29 | 31 | //echo $in_file.' -> '.$out_file_name."\n"; |
30 | 32 | $buffer_size = 4096; // read 4kb at a time |
31 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
33 | + if ($out_file_name == '') { |
|
34 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
35 | + } |
|
32 | 36 | if ($in_file != '' && file_exists($in_file)) { |
33 | 37 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
34 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
35 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
36 | - else { |
|
38 | + if (function_exists('gzopen')) { |
|
39 | + $file = gzopen($in_file,'rb'); |
|
40 | + } elseif (function_exists('gzopen64')) { |
|
41 | + $file = gzopen64($in_file,'rb'); |
|
42 | + } else { |
|
37 | 43 | echo 'gzopen not available'; |
38 | 44 | die; |
39 | 45 | } |
@@ -54,8 +60,12 @@ discard block |
||
54 | 60 | if ($res === TRUE) { |
55 | 61 | $zip->extractTo($path); |
56 | 62 | $zip->close(); |
57 | - } else return false; |
|
58 | - } else return false; |
|
63 | + } else { |
|
64 | + return false; |
|
65 | + } |
|
66 | + } else { |
|
67 | + return false; |
|
68 | + } |
|
59 | 69 | } |
60 | 70 | |
61 | 71 | public static function connect_sqlite($database) { |
@@ -70,7 +80,9 @@ discard block |
||
70 | 80 | public static function retrieve_route_sqlite_to_dest($database_file) { |
71 | 81 | global $globalDebug, $globalTransaction; |
72 | 82 | //$query = 'TRUNCATE TABLE routes'; |
73 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
83 | + if ($globalDebug) { |
|
84 | + echo " - Delete previous routes from DB -"; |
|
85 | + } |
|
74 | 86 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
75 | 87 | $Connection = new Connection(); |
76 | 88 | try { |
@@ -81,7 +93,9 @@ discard block |
||
81 | 93 | return "error : ".$e->getMessage(); |
82 | 94 | } |
83 | 95 | |
84 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
96 | + if ($globalDebug) { |
|
97 | + echo " - Add routes to DB -"; |
|
98 | + } |
|
85 | 99 | update_db::connect_sqlite($database_file); |
86 | 100 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
87 | 101 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -96,15 +110,21 @@ discard block |
||
96 | 110 | $Connection = new Connection(); |
97 | 111 | $sth_dest = $Connection->db->prepare($query_dest); |
98 | 112 | try { |
99 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
113 | + if ($globalTransaction) { |
|
114 | + $Connection->db->beginTransaction(); |
|
115 | + } |
|
100 | 116 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
101 | 117 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
102 | 118 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
103 | 119 | $sth_dest->execute($query_dest_values); |
104 | 120 | } |
105 | - if ($globalTransaction) $Connection->db->commit(); |
|
121 | + if ($globalTransaction) { |
|
122 | + $Connection->db->commit(); |
|
123 | + } |
|
106 | 124 | } catch(PDOException $e) { |
107 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
125 | + if ($globalTransaction) { |
|
126 | + $Connection->db->rollBack(); |
|
127 | + } |
|
108 | 128 | return "error : ".$e->getMessage(); |
109 | 129 | } |
110 | 130 | return ''; |
@@ -112,7 +132,9 @@ discard block |
||
112 | 132 | public static function retrieve_route_oneworld($database_file) { |
113 | 133 | global $globalDebug, $globalTransaction; |
114 | 134 | //$query = 'TRUNCATE TABLE routes'; |
115 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
135 | + if ($globalDebug) { |
|
136 | + echo " - Delete previous routes from DB -"; |
|
137 | + } |
|
116 | 138 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
117 | 139 | $Connection = new Connection(); |
118 | 140 | try { |
@@ -123,14 +145,18 @@ discard block |
||
123 | 145 | return "error : ".$e->getMessage(); |
124 | 146 | } |
125 | 147 | |
126 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
148 | + if ($globalDebug) { |
|
149 | + echo " - Add routes to DB -"; |
|
150 | + } |
|
127 | 151 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
128 | 152 | $Spotter = new Spotter(); |
129 | 153 | if ($fh = fopen($database_file,"r")) { |
130 | 154 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
131 | 155 | $Connection = new Connection(); |
132 | 156 | $sth_dest = $Connection->db->prepare($query_dest); |
133 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
157 | + if ($globalTransaction) { |
|
158 | + $Connection->db->beginTransaction(); |
|
159 | + } |
|
134 | 160 | while (!feof($fh)) { |
135 | 161 | $line = fgetcsv($fh,9999,','); |
136 | 162 | if ($line[0] != '') { |
@@ -139,13 +165,17 @@ discard block |
||
139 | 165 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
140 | 166 | $sth_dest->execute($query_dest_values); |
141 | 167 | } catch(PDOException $e) { |
142 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
168 | + if ($globalTransaction) { |
|
169 | + $Connection->db->rollBack(); |
|
170 | + } |
|
143 | 171 | return "error : ".$e->getMessage(); |
144 | 172 | } |
145 | 173 | } |
146 | 174 | } |
147 | 175 | } |
148 | - if ($globalTransaction) $Connection->db->commit(); |
|
176 | + if ($globalTransaction) { |
|
177 | + $Connection->db->commit(); |
|
178 | + } |
|
149 | 179 | } |
150 | 180 | return ''; |
151 | 181 | } |
@@ -153,7 +183,9 @@ discard block |
||
153 | 183 | public static function retrieve_route_skyteam($database_file) { |
154 | 184 | global $globalDebug, $globalTransaction; |
155 | 185 | //$query = 'TRUNCATE TABLE routes'; |
156 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
186 | + if ($globalDebug) { |
|
187 | + echo " - Delete previous routes from DB -"; |
|
188 | + } |
|
157 | 189 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
158 | 190 | $Connection = new Connection(); |
159 | 191 | try { |
@@ -164,7 +196,9 @@ discard block |
||
164 | 196 | return "error : ".$e->getMessage(); |
165 | 197 | } |
166 | 198 | |
167 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
199 | + if ($globalDebug) { |
|
200 | + echo " - Add routes to DB -"; |
|
201 | + } |
|
168 | 202 | |
169 | 203 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
170 | 204 | $Spotter = new Spotter(); |
@@ -173,7 +207,9 @@ discard block |
||
173 | 207 | $Connection = new Connection(); |
174 | 208 | $sth_dest = $Connection->db->prepare($query_dest); |
175 | 209 | try { |
176 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
210 | + if ($globalTransaction) { |
|
211 | + $Connection->db->beginTransaction(); |
|
212 | + } |
|
177 | 213 | while (!feof($fh)) { |
178 | 214 | $line = fgetcsv($fh,9999,','); |
179 | 215 | if ($line[0] != '') { |
@@ -184,9 +220,13 @@ discard block |
||
184 | 220 | } |
185 | 221 | } |
186 | 222 | } |
187 | - if ($globalTransaction) $Connection->db->commit(); |
|
223 | + if ($globalTransaction) { |
|
224 | + $Connection->db->commit(); |
|
225 | + } |
|
188 | 226 | } catch(PDOException $e) { |
189 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
227 | + if ($globalTransaction) { |
|
228 | + $Connection->db->rollBack(); |
|
229 | + } |
|
190 | 230 | return "error : ".$e->getMessage(); |
191 | 231 | } |
192 | 232 | } |
@@ -229,11 +269,16 @@ discard block |
||
229 | 269 | $sth_dest = $Connection->db->prepare($query_dest); |
230 | 270 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
231 | 271 | try { |
232 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
272 | + if ($globalTransaction) { |
|
273 | + $Connection->db->beginTransaction(); |
|
274 | + } |
|
233 | 275 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
234 | 276 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
235 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
236 | - else $type = null; |
|
277 | + if ($values['UserString4'] == 'M') { |
|
278 | + $type = 'military'; |
|
279 | + } else { |
|
280 | + $type = null; |
|
281 | + } |
|
237 | 282 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
238 | 283 | $sth_dest->execute($query_dest_values); |
239 | 284 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -241,7 +286,9 @@ discard block |
||
241 | 286 | $sth_dest_owner->execute($query_dest_owner_values); |
242 | 287 | } |
243 | 288 | } |
244 | - if ($globalTransaction) $Connection->db->commit(); |
|
289 | + if ($globalTransaction) { |
|
290 | + $Connection->db->commit(); |
|
291 | + } |
|
245 | 292 | } catch(PDOException $e) { |
246 | 293 | return "error : ".$e->getMessage(); |
247 | 294 | } |
@@ -278,7 +325,9 @@ discard block |
||
278 | 325 | $Connection = new Connection(); |
279 | 326 | $sth_dest = $Connection->db->prepare($query_dest); |
280 | 327 | try { |
281 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
328 | + if ($globalTransaction) { |
|
329 | + $Connection->db->beginTransaction(); |
|
330 | + } |
|
282 | 331 | while (!feof($fh)) { |
283 | 332 | $values = array(); |
284 | 333 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -289,7 +338,9 @@ discard block |
||
289 | 338 | // Check if we can find ICAO, else set it to GLID |
290 | 339 | $aircraft_name_split = explode(' ',$aircraft_name); |
291 | 340 | $search_more = ''; |
292 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
341 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
342 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
343 | + } |
|
293 | 344 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
294 | 345 | $sth_search = $Connection->db->prepare($query_search); |
295 | 346 | try { |
@@ -302,7 +353,9 @@ discard block |
||
302 | 353 | } catch(PDOException $e) { |
303 | 354 | return "error : ".$e->getMessage(); |
304 | 355 | } |
305 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
356 | + if (!isset($values['ICAOTypeCode'])) { |
|
357 | + $values['ICAOTypeCode'] = 'GLID'; |
|
358 | + } |
|
306 | 359 | // Add data to db |
307 | 360 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
308 | 361 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -311,7 +364,9 @@ discard block |
||
311 | 364 | $sth_dest->execute($query_dest_values); |
312 | 365 | } |
313 | 366 | } |
314 | - if ($globalTransaction) $Connection->db->commit(); |
|
367 | + if ($globalTransaction) { |
|
368 | + $Connection->db->commit(); |
|
369 | + } |
|
315 | 370 | } catch(PDOException $e) { |
316 | 371 | return "error : ".$e->getMessage(); |
317 | 372 | } |
@@ -347,7 +402,9 @@ discard block |
||
347 | 402 | $Connection = new Connection(); |
348 | 403 | $sth_dest = $Connection->db->prepare($query_dest); |
349 | 404 | try { |
350 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
405 | + if ($globalTransaction) { |
|
406 | + $Connection->db->beginTransaction(); |
|
407 | + } |
|
351 | 408 | $tmp = fgetcsv($fh,9999,',',"'"); |
352 | 409 | while (!feof($fh)) { |
353 | 410 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -361,13 +418,17 @@ discard block |
||
361 | 418 | // Check if we can find ICAO, else set it to GLID |
362 | 419 | $aircraft_name_split = explode(' ',$aircraft_name); |
363 | 420 | $search_more = ''; |
364 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
421 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
422 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
423 | + } |
|
365 | 424 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
366 | 425 | $sth_search = $Connection->db->prepare($query_search); |
367 | 426 | try { |
368 | 427 | $sth_search->execute(); |
369 | 428 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
370 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
429 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
430 | + $values['ICAOTypeCode'] = $result['icao']; |
|
431 | + } |
|
371 | 432 | } catch(PDOException $e) { |
372 | 433 | return "error : ".$e->getMessage(); |
373 | 434 | } |
@@ -380,7 +441,9 @@ discard block |
||
380 | 441 | $sth_dest->execute($query_dest_values); |
381 | 442 | } |
382 | 443 | } |
383 | - if ($globalTransaction) $Connection->db->commit(); |
|
444 | + if ($globalTransaction) { |
|
445 | + $Connection->db->commit(); |
|
446 | + } |
|
384 | 447 | } catch(PDOException $e) { |
385 | 448 | return "error : ".$e->getMessage(); |
386 | 449 | } |
@@ -419,7 +482,9 @@ discard block |
||
419 | 482 | $sth_dest = $Connection->db->prepare($query_dest); |
420 | 483 | $sth_modes = $Connection->db->prepare($query_modes); |
421 | 484 | try { |
422 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
485 | + if ($globalTransaction) { |
|
486 | + $Connection->db->beginTransaction(); |
|
487 | + } |
|
423 | 488 | $tmp = fgetcsv($fh,9999,',','"'); |
424 | 489 | while (!feof($fh)) { |
425 | 490 | $line = fgetcsv($fh,9999,',','"'); |
@@ -429,16 +494,22 @@ discard block |
||
429 | 494 | $values['registration'] = $line[0]; |
430 | 495 | $values['base'] = $line[4]; |
431 | 496 | $values['owner'] = $line[5]; |
432 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
497 | + if ($line[6] == '') { |
|
498 | + $values['date_first_reg'] = null; |
|
499 | + } else { |
|
500 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
501 | + } |
|
434 | 502 | $values['cancel'] = $line[7]; |
435 | 503 | } elseif ($country == 'EI') { |
436 | 504 | // TODO : add modeS & reg to aircraft_modes |
437 | 505 | $values['registration'] = $line[0]; |
438 | 506 | $values['base'] = $line[3]; |
439 | 507 | $values['owner'] = $line[2]; |
440 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
508 | + if ($line[1] == '') { |
|
509 | + $values['date_first_reg'] = null; |
|
510 | + } else { |
|
511 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
512 | + } |
|
442 | 513 | $values['cancel'] = ''; |
443 | 514 | $values['modes'] = $line[7]; |
444 | 515 | $values['icao'] = $line[8]; |
@@ -457,16 +528,22 @@ discard block |
||
457 | 528 | $values['registration'] = $line[3]; |
458 | 529 | $values['base'] = null; |
459 | 530 | $values['owner'] = $line[5]; |
460 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
531 | + if ($line[18] == '') { |
|
532 | + $values['date_first_reg'] = null; |
|
533 | + } else { |
|
534 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
535 | + } |
|
462 | 536 | $values['cancel'] = ''; |
463 | 537 | } elseif ($country == 'VH') { |
464 | 538 | // TODO : add modeS & reg to aircraft_modes |
465 | 539 | $values['registration'] = $line[0]; |
466 | 540 | $values['base'] = null; |
467 | 541 | $values['owner'] = $line[12]; |
468 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
542 | + if ($line[28] == '') { |
|
543 | + $values['date_first_reg'] = null; |
|
544 | + } else { |
|
545 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
546 | + } |
|
470 | 547 | |
471 | 548 | $values['cancel'] = $line[39]; |
472 | 549 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -485,29 +562,41 @@ discard block |
||
485 | 562 | $values['registration'] = $line[0]; |
486 | 563 | $values['base'] = null; |
487 | 564 | $values['owner'] = $line[8]; |
488 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
565 | + if ($line[7] == '') { |
|
566 | + $values['date_first_reg'] = null; |
|
567 | + } else { |
|
568 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
569 | + } |
|
490 | 570 | $values['cancel'] = ''; |
491 | 571 | } elseif ($country == 'PP') { |
492 | 572 | $values['registration'] = $line[0]; |
493 | 573 | $values['base'] = null; |
494 | 574 | $values['owner'] = $line[4]; |
495 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
575 | + if ($line[6] == '') { |
|
576 | + $values['date_first_reg'] = null; |
|
577 | + } else { |
|
578 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
579 | + } |
|
497 | 580 | $values['cancel'] = $line[7]; |
498 | 581 | } elseif ($country == 'E7') { |
499 | 582 | $values['registration'] = $line[0]; |
500 | 583 | $values['base'] = null; |
501 | 584 | $values['owner'] = $line[4]; |
502 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
585 | + if ($line[5] == '') { |
|
586 | + $values['date_first_reg'] = null; |
|
587 | + } else { |
|
588 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
589 | + } |
|
504 | 590 | $values['cancel'] = ''; |
505 | 591 | } elseif ($country == '8Q') { |
506 | 592 | $values['registration'] = $line[0]; |
507 | 593 | $values['base'] = null; |
508 | 594 | $values['owner'] = $line[3]; |
509 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
595 | + if ($line[7] == '') { |
|
596 | + $values['date_first_reg'] = null; |
|
597 | + } else { |
|
598 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
599 | + } |
|
511 | 600 | $values['cancel'] = ''; |
512 | 601 | } elseif ($country == 'ZK') { |
513 | 602 | $values['registration'] = $line[0]; |
@@ -552,7 +641,9 @@ discard block |
||
552 | 641 | $sth_modes->execute($query_modes_values); |
553 | 642 | } |
554 | 643 | } |
555 | - if ($globalTransaction) $Connection->db->commit(); |
|
644 | + if ($globalTransaction) { |
|
645 | + $Connection->db->commit(); |
|
646 | + } |
|
556 | 647 | } catch(PDOException $e) { |
557 | 648 | return "error : ".$e->getMessage(); |
558 | 649 | } |
@@ -688,25 +779,45 @@ discard block |
||
688 | 779 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
689 | 780 | $Connection = new Connection(); |
690 | 781 | $sth_dest = $Connection->db->prepare($query_dest); |
691 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
782 | + if ($globalTransaction) { |
|
783 | + $Connection->db->beginTransaction(); |
|
784 | + } |
|
692 | 785 | |
693 | 786 | $i = 0; |
694 | 787 | while($row = sparql_fetch_array($result)) |
695 | 788 | { |
696 | 789 | if ($i >= 1) { |
697 | 790 | //print_r($row); |
698 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
699 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
700 | - if (!isset($row['type'])) $row['type'] = ''; |
|
701 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
791 | + if (!isset($row['iata'])) { |
|
792 | + $row['iata'] = ''; |
|
793 | + } |
|
794 | + if (!isset($row['icao'])) { |
|
795 | + $row['icao'] = ''; |
|
796 | + } |
|
797 | + if (!isset($row['type'])) { |
|
798 | + $row['type'] = ''; |
|
799 | + } |
|
800 | + if (!isset($row['altitude'])) { |
|
801 | + $row['altitude'] = ''; |
|
802 | + } |
|
702 | 803 | if (isset($row['city_bis'])) { |
703 | 804 | $row['city'] = $row['city_bis']; |
704 | 805 | } |
705 | - if (!isset($row['city'])) $row['city'] = ''; |
|
706 | - if (!isset($row['country'])) $row['country'] = ''; |
|
707 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
708 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
709 | - if (!isset($row['name'])) continue; |
|
806 | + if (!isset($row['city'])) { |
|
807 | + $row['city'] = ''; |
|
808 | + } |
|
809 | + if (!isset($row['country'])) { |
|
810 | + $row['country'] = ''; |
|
811 | + } |
|
812 | + if (!isset($row['homepage'])) { |
|
813 | + $row['homepage'] = ''; |
|
814 | + } |
|
815 | + if (!isset($row['wikipedia_page'])) { |
|
816 | + $row['wikipedia_page'] = ''; |
|
817 | + } |
|
818 | + if (!isset($row['name'])) { |
|
819 | + continue; |
|
820 | + } |
|
710 | 821 | if (!isset($row['image'])) { |
711 | 822 | $row['image'] = ''; |
712 | 823 | $row['image_thumb'] = ''; |
@@ -762,7 +873,9 @@ discard block |
||
762 | 873 | |
763 | 874 | $i++; |
764 | 875 | } |
765 | - if ($globalTransaction) $Connection->db->commit(); |
|
876 | + if ($globalTransaction) { |
|
877 | + $Connection->db->commit(); |
|
878 | + } |
|
766 | 879 | /* |
767 | 880 | echo "Delete duplicate rows...\n"; |
768 | 881 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -805,7 +918,9 @@ discard block |
||
805 | 918 | $delimiter = ','; |
806 | 919 | $out_file = $tmp_dir.'airports.csv'; |
807 | 920 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
808 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
921 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
922 | + return FALSE; |
|
923 | + } |
|
809 | 924 | echo "Add data from ourairports.com...\n"; |
810 | 925 | |
811 | 926 | $header = NULL; |
@@ -815,8 +930,9 @@ discard block |
||
815 | 930 | //$Connection->db->beginTransaction(); |
816 | 931 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
817 | 932 | { |
818 | - if(!$header) $header = $row; |
|
819 | - else { |
|
933 | + if(!$header) { |
|
934 | + $header = $row; |
|
935 | + } else { |
|
820 | 936 | $data = array(); |
821 | 937 | $data = array_combine($header, $row); |
822 | 938 | try { |
@@ -857,7 +973,9 @@ discard block |
||
857 | 973 | echo "Download data from another free database...\n"; |
858 | 974 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
859 | 975 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
860 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
976 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
977 | + return FALSE; |
|
978 | + } |
|
861 | 979 | update_db::unzip($out_file); |
862 | 980 | $header = NULL; |
863 | 981 | echo "Add data from another free database...\n"; |
@@ -868,8 +986,9 @@ discard block |
||
868 | 986 | //$Connection->db->beginTransaction(); |
869 | 987 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
870 | 988 | { |
871 | - if(!$header) $header = $row; |
|
872 | - else { |
|
989 | + if(!$header) { |
|
990 | + $header = $row; |
|
991 | + } else { |
|
873 | 992 | $data = $row; |
874 | 993 | |
875 | 994 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1042,7 +1161,9 @@ discard block |
||
1042 | 1161 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
1043 | 1162 | { |
1044 | 1163 | $i = 0; |
1045 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1164 | + if ($globalTransaction) { |
|
1165 | + $Connection->db->beginTransaction(); |
|
1166 | + } |
|
1046 | 1167 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1047 | 1168 | { |
1048 | 1169 | if ($i > 0) { |
@@ -1055,7 +1176,9 @@ discard block |
||
1055 | 1176 | } |
1056 | 1177 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
1057 | 1178 | if (!empty($result_search)) { |
1058 | - if ($globalDebug) echo '.'; |
|
1179 | + if ($globalDebug) { |
|
1180 | + echo '.'; |
|
1181 | + } |
|
1059 | 1182 | //if ($globalDBdriver == 'mysql') { |
1060 | 1183 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
1061 | 1184 | //} else { |
@@ -1077,8 +1200,12 @@ discard block |
||
1077 | 1200 | } |
1078 | 1201 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
1079 | 1202 | if (!empty($result_search_mfr)) { |
1080 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
1081 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
1203 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
1204 | + $data[16] = $data[23]; |
|
1205 | + } |
|
1206 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
1207 | + $data[16] = $data[15]; |
|
1208 | + } |
|
1082 | 1209 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1083 | 1210 | try { |
1084 | 1211 | $sthf = $Connection->db->prepare($queryf); |
@@ -1089,7 +1216,9 @@ discard block |
||
1089 | 1216 | } |
1090 | 1217 | } |
1091 | 1218 | if (strtotime($data[29]) > time()) { |
1092 | - if ($globalDebug) echo 'i'; |
|
1219 | + if ($globalDebug) { |
|
1220 | + echo 'i'; |
|
1221 | + } |
|
1093 | 1222 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1094 | 1223 | try { |
1095 | 1224 | $sth = $Connection->db->prepare($query); |
@@ -1100,13 +1229,19 @@ discard block |
||
1100 | 1229 | } |
1101 | 1230 | } |
1102 | 1231 | if ($i % 90 == 0) { |
1103 | - if ($globalTransaction) $Connection->db->commit(); |
|
1104 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1232 | + if ($globalTransaction) { |
|
1233 | + $Connection->db->commit(); |
|
1234 | + } |
|
1235 | + if ($globalTransaction) { |
|
1236 | + $Connection->db->beginTransaction(); |
|
1237 | + } |
|
1105 | 1238 | } |
1106 | 1239 | $i++; |
1107 | 1240 | } |
1108 | 1241 | fclose($handle); |
1109 | - if ($globalTransaction) $Connection->db->commit(); |
|
1242 | + if ($globalTransaction) { |
|
1243 | + $Connection->db->commit(); |
|
1244 | + } |
|
1110 | 1245 | } |
1111 | 1246 | print_r($mfr); |
1112 | 1247 | return ''; |
@@ -1131,11 +1266,15 @@ discard block |
||
1131 | 1266 | $i = 0; |
1132 | 1267 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1133 | 1268 | //$Connection->db->beginTransaction(); |
1134 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1269 | + if ($globalTransaction) { |
|
1270 | + $Connection->db->beginTransaction(); |
|
1271 | + } |
|
1135 | 1272 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1136 | 1273 | { |
1137 | 1274 | if ($i > 0) { |
1138 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1275 | + if ($data[1] == 'NULL') { |
|
1276 | + $data[1] = $data[0]; |
|
1277 | + } |
|
1139 | 1278 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1140 | 1279 | try { |
1141 | 1280 | $sth = $Connection->db->prepare($query); |
@@ -1147,7 +1286,9 @@ discard block |
||
1147 | 1286 | $i++; |
1148 | 1287 | } |
1149 | 1288 | fclose($handle); |
1150 | - if ($globalTransaction) $Connection->db->commit(); |
|
1289 | + if ($globalTransaction) { |
|
1290 | + $Connection->db->commit(); |
|
1291 | + } |
|
1151 | 1292 | } |
1152 | 1293 | return ''; |
1153 | 1294 | } |
@@ -1168,7 +1309,9 @@ discard block |
||
1168 | 1309 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
1169 | 1310 | { |
1170 | 1311 | $i = 0; |
1171 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1312 | + if ($globalTransaction) { |
|
1313 | + $Connection->db->beginTransaction(); |
|
1314 | + } |
|
1172 | 1315 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1173 | 1316 | { |
1174 | 1317 | if ($i > 0) { |
@@ -1184,7 +1327,9 @@ discard block |
||
1184 | 1327 | $i++; |
1185 | 1328 | } |
1186 | 1329 | fclose($handle); |
1187 | - if ($globalTransaction) $Connection->db->commit(); |
|
1330 | + if ($globalTransaction) { |
|
1331 | + $Connection->db->commit(); |
|
1332 | + } |
|
1188 | 1333 | } |
1189 | 1334 | return ''; |
1190 | 1335 | } |
@@ -1209,7 +1354,9 @@ discard block |
||
1209 | 1354 | $i = 0; |
1210 | 1355 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1211 | 1356 | //$Connection->db->beginTransaction(); |
1212 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1357 | + if ($globalTransaction) { |
|
1358 | + $Connection->db->beginTransaction(); |
|
1359 | + } |
|
1213 | 1360 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1214 | 1361 | { |
1215 | 1362 | if ($i > 0) { |
@@ -1224,7 +1371,9 @@ discard block |
||
1224 | 1371 | $i++; |
1225 | 1372 | } |
1226 | 1373 | fclose($handle); |
1227 | - if ($globalTransaction) $Connection->db->commit(); |
|
1374 | + if ($globalTransaction) { |
|
1375 | + $Connection->db->commit(); |
|
1376 | + } |
|
1228 | 1377 | } |
1229 | 1378 | return ''; |
1230 | 1379 | } |
@@ -1249,7 +1398,9 @@ discard block |
||
1249 | 1398 | $i = 0; |
1250 | 1399 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1251 | 1400 | //$Connection->db->beginTransaction(); |
1252 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1401 | + if ($globalTransaction) { |
|
1402 | + $Connection->db->beginTransaction(); |
|
1403 | + } |
|
1253 | 1404 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1254 | 1405 | { |
1255 | 1406 | if ($i > 0) { |
@@ -1265,7 +1416,9 @@ discard block |
||
1265 | 1416 | $i++; |
1266 | 1417 | } |
1267 | 1418 | fclose($handle); |
1268 | - if ($globalTransaction) $Connection->db->commit(); |
|
1419 | + if ($globalTransaction) { |
|
1420 | + $Connection->db->commit(); |
|
1421 | + } |
|
1269 | 1422 | } |
1270 | 1423 | return ''; |
1271 | 1424 | } |
@@ -1284,7 +1437,9 @@ discard block |
||
1284 | 1437 | $Connection = new Connection(); |
1285 | 1438 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
1286 | 1439 | { |
1287 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1440 | + if ($globalTransaction) { |
|
1441 | + $Connection->db->beginTransaction(); |
|
1442 | + } |
|
1288 | 1443 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
1289 | 1444 | { |
1290 | 1445 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1299,7 +1454,9 @@ discard block |
||
1299 | 1454 | } |
1300 | 1455 | } |
1301 | 1456 | fclose($handle); |
1302 | - if ($globalTransaction) $Connection->db->commit(); |
|
1457 | + if ($globalTransaction) { |
|
1458 | + $Connection->db->commit(); |
|
1459 | + } |
|
1303 | 1460 | } |
1304 | 1461 | return ''; |
1305 | 1462 | } |
@@ -1450,7 +1607,9 @@ discard block |
||
1450 | 1607 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1451 | 1608 | { |
1452 | 1609 | $i = 0; |
1453 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1610 | + if ($globalTransaction) { |
|
1611 | + $Connection->db->beginTransaction(); |
|
1612 | + } |
|
1454 | 1613 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1455 | 1614 | { |
1456 | 1615 | $i++; |
@@ -1478,7 +1637,9 @@ discard block |
||
1478 | 1637 | } |
1479 | 1638 | } |
1480 | 1639 | fclose($handle); |
1481 | - if ($globalTransaction) $Connection->db->commit(); |
|
1640 | + if ($globalTransaction) { |
|
1641 | + $Connection->db->commit(); |
|
1642 | + } |
|
1482 | 1643 | } |
1483 | 1644 | return ''; |
1484 | 1645 | } |
@@ -1501,7 +1662,9 @@ discard block |
||
1501 | 1662 | $Connection = new Connection(); |
1502 | 1663 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1503 | 1664 | { |
1504 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1665 | + if ($globalTransaction) { |
|
1666 | + $Connection->db->beginTransaction(); |
|
1667 | + } |
|
1505 | 1668 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1506 | 1669 | { |
1507 | 1670 | if(count($row) > 1) { |
@@ -1515,7 +1678,9 @@ discard block |
||
1515 | 1678 | } |
1516 | 1679 | } |
1517 | 1680 | fclose($handle); |
1518 | - if ($globalTransaction) $Connection->db->commit(); |
|
1681 | + if ($globalTransaction) { |
|
1682 | + $Connection->db->commit(); |
|
1683 | + } |
|
1519 | 1684 | } |
1520 | 1685 | return ''; |
1521 | 1686 | } |
@@ -1535,8 +1700,9 @@ discard block |
||
1535 | 1700 | } |
1536 | 1701 | |
1537 | 1702 | |
1538 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1539 | - else { |
|
1703 | + if ($globalDBdriver == 'mysql') { |
|
1704 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1705 | + } else { |
|
1540 | 1706 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1541 | 1707 | $query = "CREATE EXTENSION postgis"; |
1542 | 1708 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1555,20 +1721,30 @@ discard block |
||
1555 | 1721 | global $tmp_dir, $globalDebug; |
1556 | 1722 | include_once('class.create_db.php'); |
1557 | 1723 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1558 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
1724 | + if ($globalDebug) { |
|
1725 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
1726 | + } |
|
1559 | 1727 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
1560 | 1728 | $error = ''; |
1561 | 1729 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1562 | - if ($globalDebug) echo "Gunzip..."; |
|
1730 | + if ($globalDebug) { |
|
1731 | + echo "Gunzip..."; |
|
1732 | + } |
|
1563 | 1733 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
1564 | - if ($globalDebug) echo "Add to DB..."; |
|
1734 | + if ($globalDebug) { |
|
1735 | + echo "Add to DB..."; |
|
1736 | + } |
|
1565 | 1737 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
1566 | 1738 | $NOTAM = new NOTAM(); |
1567 | 1739 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
1568 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1740 | + } else { |
|
1741 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1742 | + } |
|
1569 | 1743 | if ($error != '') { |
1570 | 1744 | return $error; |
1571 | - } elseif ($globalDebug) echo "Done\n"; |
|
1745 | + } elseif ($globalDebug) { |
|
1746 | + echo "Done\n"; |
|
1747 | + } |
|
1572 | 1748 | return ''; |
1573 | 1749 | } |
1574 | 1750 | |
@@ -1622,67 +1798,111 @@ discard block |
||
1622 | 1798 | //if ($globalDebug) echo "IVAO : Download..."; |
1623 | 1799 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
1624 | 1800 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
1625 | - if ($globalDebug) echo "Unzip..."; |
|
1801 | + if ($globalDebug) { |
|
1802 | + echo "Unzip..."; |
|
1803 | + } |
|
1626 | 1804 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
1627 | - if ($globalDebug) echo "Add to DB..."; |
|
1805 | + if ($globalDebug) { |
|
1806 | + echo "Add to DB..."; |
|
1807 | + } |
|
1628 | 1808 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1629 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
1809 | + if ($globalDebug) { |
|
1810 | + echo "Copy airlines logos to airlines images directory..."; |
|
1811 | + } |
|
1630 | 1812 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1631 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1632 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1633 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1813 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
1814 | + $error = "Failed to copy airlines logo."; |
|
1815 | + } |
|
1816 | + } else { |
|
1817 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1818 | + } |
|
1819 | + } else { |
|
1820 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1821 | + } |
|
1634 | 1822 | if ($error != '') { |
1635 | 1823 | return $error; |
1636 | - } elseif ($globalDebug) echo "Done\n"; |
|
1824 | + } elseif ($globalDebug) { |
|
1825 | + echo "Done\n"; |
|
1826 | + } |
|
1637 | 1827 | return ''; |
1638 | 1828 | } |
1639 | 1829 | |
1640 | 1830 | public static function update_routes() { |
1641 | 1831 | global $tmp_dir, $globalDebug; |
1642 | 1832 | $error = ''; |
1643 | - if ($globalDebug) echo "Routes : Download..."; |
|
1833 | + if ($globalDebug) { |
|
1834 | + echo "Routes : Download..."; |
|
1835 | + } |
|
1644 | 1836 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
1645 | 1837 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1646 | - if ($globalDebug) echo "Gunzip..."; |
|
1838 | + if ($globalDebug) { |
|
1839 | + echo "Gunzip..."; |
|
1840 | + } |
|
1647 | 1841 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
1648 | - if ($globalDebug) echo "Add to DB..."; |
|
1842 | + if ($globalDebug) { |
|
1843 | + echo "Add to DB..."; |
|
1844 | + } |
|
1649 | 1845 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
1650 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1846 | + } else { |
|
1847 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1848 | + } |
|
1651 | 1849 | if ($error != '') { |
1652 | 1850 | return $error; |
1653 | - } elseif ($globalDebug) echo "Done\n"; |
|
1851 | + } elseif ($globalDebug) { |
|
1852 | + echo "Done\n"; |
|
1853 | + } |
|
1654 | 1854 | return ''; |
1655 | 1855 | } |
1656 | 1856 | public static function update_oneworld() { |
1657 | 1857 | global $tmp_dir, $globalDebug; |
1658 | 1858 | $error = ''; |
1659 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
1859 | + if ($globalDebug) { |
|
1860 | + echo "Schedules Oneworld : Download..."; |
|
1861 | + } |
|
1660 | 1862 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
1661 | 1863 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1662 | - if ($globalDebug) echo "Gunzip..."; |
|
1864 | + if ($globalDebug) { |
|
1865 | + echo "Gunzip..."; |
|
1866 | + } |
|
1663 | 1867 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
1664 | - if ($globalDebug) echo "Add to DB..."; |
|
1868 | + if ($globalDebug) { |
|
1869 | + echo "Add to DB..."; |
|
1870 | + } |
|
1665 | 1871 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
1666 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1872 | + } else { |
|
1873 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1874 | + } |
|
1667 | 1875 | if ($error != '') { |
1668 | 1876 | return $error; |
1669 | - } elseif ($globalDebug) echo "Done\n"; |
|
1877 | + } elseif ($globalDebug) { |
|
1878 | + echo "Done\n"; |
|
1879 | + } |
|
1670 | 1880 | return ''; |
1671 | 1881 | } |
1672 | 1882 | public static function update_skyteam() { |
1673 | 1883 | global $tmp_dir, $globalDebug; |
1674 | 1884 | $error = ''; |
1675 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
1885 | + if ($globalDebug) { |
|
1886 | + echo "Schedules Skyteam : Download..."; |
|
1887 | + } |
|
1676 | 1888 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
1677 | 1889 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1678 | - if ($globalDebug) echo "Gunzip..."; |
|
1890 | + if ($globalDebug) { |
|
1891 | + echo "Gunzip..."; |
|
1892 | + } |
|
1679 | 1893 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
1680 | - if ($globalDebug) echo "Add to DB..."; |
|
1894 | + if ($globalDebug) { |
|
1895 | + echo "Add to DB..."; |
|
1896 | + } |
|
1681 | 1897 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
1682 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1898 | + } else { |
|
1899 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1900 | + } |
|
1683 | 1901 | if ($error != '') { |
1684 | 1902 | return $error; |
1685 | - } elseif ($globalDebug) echo "Done\n"; |
|
1903 | + } elseif ($globalDebug) { |
|
1904 | + echo "Done\n"; |
|
1905 | + } |
|
1686 | 1906 | return ''; |
1687 | 1907 | } |
1688 | 1908 | public static function update_ModeS() { |
@@ -1699,355 +1919,619 @@ discard block |
||
1699 | 1919 | exit; |
1700 | 1920 | } elseif ($globalDebug) echo "Done\n"; |
1701 | 1921 | */ |
1702 | - if ($globalDebug) echo "Modes : Download..."; |
|
1703 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1922 | + if ($globalDebug) { |
|
1923 | + echo "Modes : Download..."; |
|
1924 | + } |
|
1925 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1704 | 1926 | update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
1705 | 1927 | |
1706 | 1928 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1707 | 1929 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
1708 | - if ($globalDebug) echo "Unzip..."; |
|
1709 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1930 | + if ($globalDebug) { |
|
1931 | + echo "Unzip..."; |
|
1932 | + } |
|
1933 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1710 | 1934 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
1711 | - if ($globalDebug) echo "Add to DB..."; |
|
1935 | + if ($globalDebug) { |
|
1936 | + echo "Add to DB..."; |
|
1937 | + } |
|
1712 | 1938 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
1713 | 1939 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
1714 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1940 | + } else { |
|
1941 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1942 | + } |
|
1715 | 1943 | if ($error != '') { |
1716 | 1944 | return $error; |
1717 | - } elseif ($globalDebug) echo "Done\n"; |
|
1945 | + } elseif ($globalDebug) { |
|
1946 | + echo "Done\n"; |
|
1947 | + } |
|
1718 | 1948 | return ''; |
1719 | 1949 | } |
1720 | 1950 | |
1721 | 1951 | public static function update_ModeS_faa() { |
1722 | 1952 | global $tmp_dir, $globalDebug; |
1723 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
1953 | + if ($globalDebug) { |
|
1954 | + echo "Modes FAA: Download..."; |
|
1955 | + } |
|
1724 | 1956 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
1725 | 1957 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
1726 | - if ($globalDebug) echo "Unzip..."; |
|
1958 | + if ($globalDebug) { |
|
1959 | + echo "Unzip..."; |
|
1960 | + } |
|
1727 | 1961 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
1728 | - if ($globalDebug) echo "Add to DB..."; |
|
1962 | + if ($globalDebug) { |
|
1963 | + echo "Add to DB..."; |
|
1964 | + } |
|
1729 | 1965 | $error = update_db::modes_faa(); |
1730 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
1966 | + } else { |
|
1967 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
1968 | + } |
|
1731 | 1969 | if ($error != '') { |
1732 | 1970 | return $error; |
1733 | - } elseif ($globalDebug) echo "Done\n"; |
|
1971 | + } elseif ($globalDebug) { |
|
1972 | + echo "Done\n"; |
|
1973 | + } |
|
1734 | 1974 | return ''; |
1735 | 1975 | } |
1736 | 1976 | |
1737 | 1977 | public static function update_ModeS_flarm() { |
1738 | 1978 | global $tmp_dir, $globalDebug; |
1739 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
1979 | + if ($globalDebug) { |
|
1980 | + echo "Modes Flarmnet: Download..."; |
|
1981 | + } |
|
1740 | 1982 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
1741 | 1983 | if (file_exists($tmp_dir.'data.fln')) { |
1742 | - if ($globalDebug) echo "Add to DB..."; |
|
1984 | + if ($globalDebug) { |
|
1985 | + echo "Add to DB..."; |
|
1986 | + } |
|
1743 | 1987 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
1744 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1988 | + } else { |
|
1989 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1990 | + } |
|
1745 | 1991 | if ($error != '') { |
1746 | 1992 | return $error; |
1747 | - } elseif ($globalDebug) echo "Done\n"; |
|
1993 | + } elseif ($globalDebug) { |
|
1994 | + echo "Done\n"; |
|
1995 | + } |
|
1748 | 1996 | return ''; |
1749 | 1997 | } |
1750 | 1998 | |
1751 | 1999 | public static function update_ModeS_ogn() { |
1752 | 2000 | global $tmp_dir, $globalDebug; |
1753 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
2001 | + if ($globalDebug) { |
|
2002 | + echo "Modes OGN: Download..."; |
|
2003 | + } |
|
1754 | 2004 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
1755 | 2005 | if (file_exists($tmp_dir.'ogn.csv')) { |
1756 | - if ($globalDebug) echo "Add to DB..."; |
|
2006 | + if ($globalDebug) { |
|
2007 | + echo "Add to DB..."; |
|
2008 | + } |
|
1757 | 2009 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
1758 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2010 | + } else { |
|
2011 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2012 | + } |
|
1759 | 2013 | if ($error != '') { |
1760 | 2014 | return $error; |
1761 | - } elseif ($globalDebug) echo "Done\n"; |
|
2015 | + } elseif ($globalDebug) { |
|
2016 | + echo "Done\n"; |
|
2017 | + } |
|
1762 | 2018 | return ''; |
1763 | 2019 | } |
1764 | 2020 | |
1765 | 2021 | public static function update_owner() { |
1766 | 2022 | global $tmp_dir, $globalDebug, $globalMasterSource; |
1767 | 2023 | |
1768 | - if ($globalDebug) echo "Owner France: Download..."; |
|
2024 | + if ($globalDebug) { |
|
2025 | + echo "Owner France: Download..."; |
|
2026 | + } |
|
1769 | 2027 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
1770 | 2028 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1771 | - if ($globalDebug) echo "Add to DB..."; |
|
2029 | + if ($globalDebug) { |
|
2030 | + echo "Add to DB..."; |
|
2031 | + } |
|
1772 | 2032 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
1773 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2033 | + } else { |
|
2034 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2035 | + } |
|
1774 | 2036 | if ($error != '') { |
1775 | 2037 | return $error; |
1776 | - } elseif ($globalDebug) echo "Done\n"; |
|
2038 | + } elseif ($globalDebug) { |
|
2039 | + echo "Done\n"; |
|
2040 | + } |
|
1777 | 2041 | |
1778 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
2042 | + if ($globalDebug) { |
|
2043 | + echo "Owner Ireland: Download..."; |
|
2044 | + } |
|
1779 | 2045 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
1780 | 2046 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1781 | - if ($globalDebug) echo "Add to DB..."; |
|
2047 | + if ($globalDebug) { |
|
2048 | + echo "Add to DB..."; |
|
2049 | + } |
|
1782 | 2050 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
1783 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2051 | + } else { |
|
2052 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2053 | + } |
|
1784 | 2054 | if ($error != '') { |
1785 | 2055 | return $error; |
1786 | - } elseif ($globalDebug) echo "Done\n"; |
|
1787 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
2056 | + } elseif ($globalDebug) { |
|
2057 | + echo "Done\n"; |
|
2058 | + } |
|
2059 | + if ($globalDebug) { |
|
2060 | + echo "Owner Switzerland: Download..."; |
|
2061 | + } |
|
1788 | 2062 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
1789 | 2063 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1790 | - if ($globalDebug) echo "Add to DB..."; |
|
2064 | + if ($globalDebug) { |
|
2065 | + echo "Add to DB..."; |
|
2066 | + } |
|
1791 | 2067 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
1792 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2068 | + } else { |
|
2069 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2070 | + } |
|
1793 | 2071 | if ($error != '') { |
1794 | 2072 | return $error; |
1795 | - } elseif ($globalDebug) echo "Done\n"; |
|
1796 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
2073 | + } elseif ($globalDebug) { |
|
2074 | + echo "Done\n"; |
|
2075 | + } |
|
2076 | + if ($globalDebug) { |
|
2077 | + echo "Owner Czech Republic: Download..."; |
|
2078 | + } |
|
1797 | 2079 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
1798 | 2080 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1799 | - if ($globalDebug) echo "Add to DB..."; |
|
2081 | + if ($globalDebug) { |
|
2082 | + echo "Add to DB..."; |
|
2083 | + } |
|
1800 | 2084 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
1801 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2085 | + } else { |
|
2086 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2087 | + } |
|
1802 | 2088 | if ($error != '') { |
1803 | 2089 | return $error; |
1804 | - } elseif ($globalDebug) echo "Done\n"; |
|
1805 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
2090 | + } elseif ($globalDebug) { |
|
2091 | + echo "Done\n"; |
|
2092 | + } |
|
2093 | + if ($globalDebug) { |
|
2094 | + echo "Owner Australia: Download..."; |
|
2095 | + } |
|
1806 | 2096 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
1807 | 2097 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1808 | - if ($globalDebug) echo "Add to DB..."; |
|
2098 | + if ($globalDebug) { |
|
2099 | + echo "Add to DB..."; |
|
2100 | + } |
|
1809 | 2101 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
1810 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2102 | + } else { |
|
2103 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2104 | + } |
|
1811 | 2105 | if ($error != '') { |
1812 | 2106 | return $error; |
1813 | - } elseif ($globalDebug) echo "Done\n"; |
|
1814 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
2107 | + } elseif ($globalDebug) { |
|
2108 | + echo "Done\n"; |
|
2109 | + } |
|
2110 | + if ($globalDebug) { |
|
2111 | + echo "Owner Austria: Download..."; |
|
2112 | + } |
|
1815 | 2113 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
1816 | 2114 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1817 | - if ($globalDebug) echo "Add to DB..."; |
|
2115 | + if ($globalDebug) { |
|
2116 | + echo "Add to DB..."; |
|
2117 | + } |
|
1818 | 2118 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
1819 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2119 | + } else { |
|
2120 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2121 | + } |
|
1820 | 2122 | if ($error != '') { |
1821 | 2123 | return $error; |
1822 | - } elseif ($globalDebug) echo "Done\n"; |
|
1823 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
2124 | + } elseif ($globalDebug) { |
|
2125 | + echo "Done\n"; |
|
2126 | + } |
|
2127 | + if ($globalDebug) { |
|
2128 | + echo "Owner Chile: Download..."; |
|
2129 | + } |
|
1824 | 2130 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
1825 | 2131 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1826 | - if ($globalDebug) echo "Add to DB..."; |
|
2132 | + if ($globalDebug) { |
|
2133 | + echo "Add to DB..."; |
|
2134 | + } |
|
1827 | 2135 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
1828 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2136 | + } else { |
|
2137 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2138 | + } |
|
1829 | 2139 | if ($error != '') { |
1830 | 2140 | return $error; |
1831 | - } elseif ($globalDebug) echo "Done\n"; |
|
1832 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
2141 | + } elseif ($globalDebug) { |
|
2142 | + echo "Done\n"; |
|
2143 | + } |
|
2144 | + if ($globalDebug) { |
|
2145 | + echo "Owner Colombia: Download..."; |
|
2146 | + } |
|
1833 | 2147 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
1834 | 2148 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1835 | - if ($globalDebug) echo "Add to DB..."; |
|
2149 | + if ($globalDebug) { |
|
2150 | + echo "Add to DB..."; |
|
2151 | + } |
|
1836 | 2152 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
1837 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2153 | + } else { |
|
2154 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2155 | + } |
|
1838 | 2156 | if ($error != '') { |
1839 | 2157 | return $error; |
1840 | - } elseif ($globalDebug) echo "Done\n"; |
|
1841 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
2158 | + } elseif ($globalDebug) { |
|
2159 | + echo "Done\n"; |
|
2160 | + } |
|
2161 | + if ($globalDebug) { |
|
2162 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
2163 | + } |
|
1842 | 2164 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
1843 | 2165 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1844 | - if ($globalDebug) echo "Add to DB..."; |
|
2166 | + if ($globalDebug) { |
|
2167 | + echo "Add to DB..."; |
|
2168 | + } |
|
1845 | 2169 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
1846 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2170 | + } else { |
|
2171 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2172 | + } |
|
1847 | 2173 | if ($error != '') { |
1848 | 2174 | return $error; |
1849 | - } elseif ($globalDebug) echo "Done\n"; |
|
1850 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
2175 | + } elseif ($globalDebug) { |
|
2176 | + echo "Done\n"; |
|
2177 | + } |
|
2178 | + if ($globalDebug) { |
|
2179 | + echo "Owner Brazil: Download..."; |
|
2180 | + } |
|
1851 | 2181 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
1852 | 2182 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1853 | - if ($globalDebug) echo "Add to DB..."; |
|
2183 | + if ($globalDebug) { |
|
2184 | + echo "Add to DB..."; |
|
2185 | + } |
|
1854 | 2186 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
1855 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2187 | + } else { |
|
2188 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2189 | + } |
|
1856 | 2190 | if ($error != '') { |
1857 | 2191 | return $error; |
1858 | - } elseif ($globalDebug) echo "Done\n"; |
|
1859 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
2192 | + } elseif ($globalDebug) { |
|
2193 | + echo "Done\n"; |
|
2194 | + } |
|
2195 | + if ($globalDebug) { |
|
2196 | + echo "Owner Cayman Islands: Download..."; |
|
2197 | + } |
|
1860 | 2198 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
1861 | 2199 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1862 | - if ($globalDebug) echo "Add to DB..."; |
|
2200 | + if ($globalDebug) { |
|
2201 | + echo "Add to DB..."; |
|
2202 | + } |
|
1863 | 2203 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
1864 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2204 | + } else { |
|
2205 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2206 | + } |
|
1865 | 2207 | if ($error != '') { |
1866 | 2208 | return $error; |
1867 | - } elseif ($globalDebug) echo "Done\n"; |
|
1868 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
2209 | + } elseif ($globalDebug) { |
|
2210 | + echo "Done\n"; |
|
2211 | + } |
|
2212 | + if ($globalDebug) { |
|
2213 | + echo "Owner Croatia: Download..."; |
|
2214 | + } |
|
1869 | 2215 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
1870 | 2216 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1871 | - if ($globalDebug) echo "Add to DB..."; |
|
2217 | + if ($globalDebug) { |
|
2218 | + echo "Add to DB..."; |
|
2219 | + } |
|
1872 | 2220 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
1873 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2221 | + } else { |
|
2222 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2223 | + } |
|
1874 | 2224 | if ($error != '') { |
1875 | 2225 | return $error; |
1876 | - } elseif ($globalDebug) echo "Done\n"; |
|
1877 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
2226 | + } elseif ($globalDebug) { |
|
2227 | + echo "Done\n"; |
|
2228 | + } |
|
2229 | + if ($globalDebug) { |
|
2230 | + echo "Owner Luxembourg: Download..."; |
|
2231 | + } |
|
1878 | 2232 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
1879 | 2233 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1880 | - if ($globalDebug) echo "Add to DB..."; |
|
2234 | + if ($globalDebug) { |
|
2235 | + echo "Add to DB..."; |
|
2236 | + } |
|
1881 | 2237 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
1882 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2238 | + } else { |
|
2239 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2240 | + } |
|
1883 | 2241 | if ($error != '') { |
1884 | 2242 | return $error; |
1885 | - } elseif ($globalDebug) echo "Done\n"; |
|
1886 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
2243 | + } elseif ($globalDebug) { |
|
2244 | + echo "Done\n"; |
|
2245 | + } |
|
2246 | + if ($globalDebug) { |
|
2247 | + echo "Owner Maldives: Download..."; |
|
2248 | + } |
|
1887 | 2249 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
1888 | 2250 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1889 | - if ($globalDebug) echo "Add to DB..."; |
|
2251 | + if ($globalDebug) { |
|
2252 | + echo "Add to DB..."; |
|
2253 | + } |
|
1890 | 2254 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
1891 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2255 | + } else { |
|
2256 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2257 | + } |
|
1892 | 2258 | if ($error != '') { |
1893 | 2259 | return $error; |
1894 | - } elseif ($globalDebug) echo "Done\n"; |
|
1895 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
2260 | + } elseif ($globalDebug) { |
|
2261 | + echo "Done\n"; |
|
2262 | + } |
|
2263 | + if ($globalDebug) { |
|
2264 | + echo "Owner New Zealand: Download..."; |
|
2265 | + } |
|
1896 | 2266 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
1897 | 2267 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1898 | - if ($globalDebug) echo "Add to DB..."; |
|
2268 | + if ($globalDebug) { |
|
2269 | + echo "Add to DB..."; |
|
2270 | + } |
|
1899 | 2271 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
1900 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2272 | + } else { |
|
2273 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2274 | + } |
|
1901 | 2275 | if ($error != '') { |
1902 | 2276 | return $error; |
1903 | - } elseif ($globalDebug) echo "Done\n"; |
|
1904 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
2277 | + } elseif ($globalDebug) { |
|
2278 | + echo "Done\n"; |
|
2279 | + } |
|
2280 | + if ($globalDebug) { |
|
2281 | + echo "Owner Papua New Guinea: Download..."; |
|
2282 | + } |
|
1905 | 2283 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
1906 | 2284 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1907 | - if ($globalDebug) echo "Add to DB..."; |
|
2285 | + if ($globalDebug) { |
|
2286 | + echo "Add to DB..."; |
|
2287 | + } |
|
1908 | 2288 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
1909 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2289 | + } else { |
|
2290 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2291 | + } |
|
1910 | 2292 | if ($error != '') { |
1911 | 2293 | return $error; |
1912 | - } elseif ($globalDebug) echo "Done\n"; |
|
1913 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
2294 | + } elseif ($globalDebug) { |
|
2295 | + echo "Done\n"; |
|
2296 | + } |
|
2297 | + if ($globalDebug) { |
|
2298 | + echo "Owner Slovakia: Download..."; |
|
2299 | + } |
|
1914 | 2300 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
1915 | 2301 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1916 | - if ($globalDebug) echo "Add to DB..."; |
|
2302 | + if ($globalDebug) { |
|
2303 | + echo "Add to DB..."; |
|
2304 | + } |
|
1917 | 2305 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
1918 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2306 | + } else { |
|
2307 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2308 | + } |
|
1919 | 2309 | if ($error != '') { |
1920 | 2310 | return $error; |
1921 | - } elseif ($globalDebug) echo "Done\n"; |
|
1922 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
2311 | + } elseif ($globalDebug) { |
|
2312 | + echo "Done\n"; |
|
2313 | + } |
|
2314 | + if ($globalDebug) { |
|
2315 | + echo "Owner Ecuador: Download..."; |
|
2316 | + } |
|
1923 | 2317 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
1924 | 2318 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1925 | - if ($globalDebug) echo "Add to DB..."; |
|
2319 | + if ($globalDebug) { |
|
2320 | + echo "Add to DB..."; |
|
2321 | + } |
|
1926 | 2322 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
1927 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2323 | + } else { |
|
2324 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2325 | + } |
|
1928 | 2326 | if ($error != '') { |
1929 | 2327 | return $error; |
1930 | - } elseif ($globalDebug) echo "Done\n"; |
|
1931 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
2328 | + } elseif ($globalDebug) { |
|
2329 | + echo "Done\n"; |
|
2330 | + } |
|
2331 | + if ($globalDebug) { |
|
2332 | + echo "Owner Iceland: Download..."; |
|
2333 | + } |
|
1932 | 2334 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
1933 | 2335 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1934 | - if ($globalDebug) echo "Add to DB..."; |
|
2336 | + if ($globalDebug) { |
|
2337 | + echo "Add to DB..."; |
|
2338 | + } |
|
1935 | 2339 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
1936 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2340 | + } else { |
|
2341 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2342 | + } |
|
1937 | 2343 | if ($error != '') { |
1938 | 2344 | return $error; |
1939 | - } elseif ($globalDebug) echo "Done\n"; |
|
1940 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
2345 | + } elseif ($globalDebug) { |
|
2346 | + echo "Done\n"; |
|
2347 | + } |
|
2348 | + if ($globalDebug) { |
|
2349 | + echo "Owner Isle of Man: Download..."; |
|
2350 | + } |
|
1941 | 2351 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
1942 | 2352 | if (file_exists($tmp_dir.'owner_m.csv')) { |
1943 | - if ($globalDebug) echo "Add to DB..."; |
|
2353 | + if ($globalDebug) { |
|
2354 | + echo "Add to DB..."; |
|
2355 | + } |
|
1944 | 2356 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
1945 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2357 | + } else { |
|
2358 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2359 | + } |
|
1946 | 2360 | if ($error != '') { |
1947 | 2361 | return $error; |
1948 | - } elseif ($globalDebug) echo "Done\n"; |
|
2362 | + } elseif ($globalDebug) { |
|
2363 | + echo "Done\n"; |
|
2364 | + } |
|
1949 | 2365 | if ($globalMasterSource) { |
1950 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
2366 | + if ($globalDebug) { |
|
2367 | + echo "ModeS Netherlands: Download..."; |
|
2368 | + } |
|
1951 | 2369 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
1952 | 2370 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
1953 | - if ($globalDebug) echo "Add to DB..."; |
|
2371 | + if ($globalDebug) { |
|
2372 | + echo "Add to DB..."; |
|
2373 | + } |
|
1954 | 2374 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
1955 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2375 | + } else { |
|
2376 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2377 | + } |
|
1956 | 2378 | if ($error != '') { |
1957 | 2379 | return $error; |
1958 | - } elseif ($globalDebug) echo "Done\n"; |
|
1959 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
2380 | + } elseif ($globalDebug) { |
|
2381 | + echo "Done\n"; |
|
2382 | + } |
|
2383 | + if ($globalDebug) { |
|
2384 | + echo "ModeS Denmark: Download..."; |
|
2385 | + } |
|
1960 | 2386 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
1961 | 2387 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
1962 | - if ($globalDebug) echo "Add to DB..."; |
|
2388 | + if ($globalDebug) { |
|
2389 | + echo "Add to DB..."; |
|
2390 | + } |
|
1963 | 2391 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
1964 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2392 | + } else { |
|
2393 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2394 | + } |
|
1965 | 2395 | if ($error != '') { |
1966 | 2396 | return $error; |
1967 | - } elseif ($globalDebug) echo "Done\n"; |
|
1968 | - } elseif ($globalDebug) echo "Done\n"; |
|
2397 | + } elseif ($globalDebug) { |
|
2398 | + echo "Done\n"; |
|
2399 | + } |
|
2400 | + } elseif ($globalDebug) { |
|
2401 | + echo "Done\n"; |
|
2402 | + } |
|
1969 | 2403 | return ''; |
1970 | 2404 | } |
1971 | 2405 | |
1972 | 2406 | public static function update_translation() { |
1973 | 2407 | global $tmp_dir, $globalDebug; |
1974 | 2408 | $error = ''; |
1975 | - if ($globalDebug) echo "Translation : Download..."; |
|
2409 | + if ($globalDebug) { |
|
2410 | + echo "Translation : Download..."; |
|
2411 | + } |
|
1976 | 2412 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
1977 | 2413 | if (file_exists($tmp_dir.'translation.zip')) { |
1978 | - if ($globalDebug) echo "Unzip..."; |
|
2414 | + if ($globalDebug) { |
|
2415 | + echo "Unzip..."; |
|
2416 | + } |
|
1979 | 2417 | update_db::unzip($tmp_dir.'translation.zip'); |
1980 | - if ($globalDebug) echo "Add to DB..."; |
|
2418 | + if ($globalDebug) { |
|
2419 | + echo "Add to DB..."; |
|
2420 | + } |
|
1981 | 2421 | $error = update_db::translation(); |
1982 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2422 | + } else { |
|
2423 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2424 | + } |
|
1983 | 2425 | if ($error != '') { |
1984 | 2426 | return $error; |
1985 | - } elseif ($globalDebug) echo "Done\n"; |
|
2427 | + } elseif ($globalDebug) { |
|
2428 | + echo "Done\n"; |
|
2429 | + } |
|
1986 | 2430 | return ''; |
1987 | 2431 | } |
1988 | 2432 | |
1989 | 2433 | public static function update_translation_fam() { |
1990 | 2434 | global $tmp_dir, $globalDebug; |
1991 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2435 | + if ($globalDebug) { |
|
2436 | + echo "Translation from FlightAirMap website : Download..."; |
|
2437 | + } |
|
1992 | 2438 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
1993 | 2439 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1994 | - if ($globalDebug) echo "Gunzip..."; |
|
2440 | + if ($globalDebug) { |
|
2441 | + echo "Gunzip..."; |
|
2442 | + } |
|
1995 | 2443 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
1996 | - if ($globalDebug) echo "Add to DB..."; |
|
2444 | + if ($globalDebug) { |
|
2445 | + echo "Add to DB..."; |
|
2446 | + } |
|
1997 | 2447 | $error = update_db::translation_fam(); |
1998 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2448 | + } else { |
|
2449 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2450 | + } |
|
1999 | 2451 | if ($error != '') { |
2000 | 2452 | return $error; |
2001 | - } elseif ($globalDebug) echo "Done\n"; |
|
2453 | + } elseif ($globalDebug) { |
|
2454 | + echo "Done\n"; |
|
2455 | + } |
|
2002 | 2456 | return ''; |
2003 | 2457 | } |
2004 | 2458 | public static function update_ModeS_fam() { |
2005 | 2459 | global $tmp_dir, $globalDebug; |
2006 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
2460 | + if ($globalDebug) { |
|
2461 | + echo "ModeS from FlightAirMap website : Download..."; |
|
2462 | + } |
|
2007 | 2463 | update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
2008 | 2464 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
2009 | - if ($globalDebug) echo "Gunzip..."; |
|
2465 | + if ($globalDebug) { |
|
2466 | + echo "Gunzip..."; |
|
2467 | + } |
|
2010 | 2468 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
2011 | - if ($globalDebug) echo "Add to DB..."; |
|
2469 | + if ($globalDebug) { |
|
2470 | + echo "Add to DB..."; |
|
2471 | + } |
|
2012 | 2472 | $error = update_db::modes_fam(); |
2013 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2473 | + } else { |
|
2474 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2475 | + } |
|
2014 | 2476 | if ($error != '') { |
2015 | 2477 | return $error; |
2016 | - } elseif ($globalDebug) echo "Done\n"; |
|
2478 | + } elseif ($globalDebug) { |
|
2479 | + echo "Done\n"; |
|
2480 | + } |
|
2017 | 2481 | return ''; |
2018 | 2482 | } |
2019 | 2483 | public static function update_owner_fam() { |
2020 | 2484 | global $tmp_dir, $globalDebug, $globalOwner; |
2021 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
2485 | + if ($globalDebug) { |
|
2486 | + echo "owner from FlightAirMap website : Download..."; |
|
2487 | + } |
|
2022 | 2488 | if ($globalOwner === TRUE) { |
2023 | 2489 | update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
2024 | 2490 | } else { |
2025 | 2491 | update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
2026 | 2492 | } |
2027 | 2493 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
2028 | - if ($globalDebug) echo "Gunzip..."; |
|
2494 | + if ($globalDebug) { |
|
2495 | + echo "Gunzip..."; |
|
2496 | + } |
|
2029 | 2497 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
2030 | - if ($globalDebug) echo "Add to DB..."; |
|
2498 | + if ($globalDebug) { |
|
2499 | + echo "Add to DB..."; |
|
2500 | + } |
|
2031 | 2501 | $error = update_db::owner_fam(); |
2032 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
2502 | + } else { |
|
2503 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
2504 | + } |
|
2033 | 2505 | if ($error != '') { |
2034 | 2506 | return $error; |
2035 | - } elseif ($globalDebug) echo "Done\n"; |
|
2507 | + } elseif ($globalDebug) { |
|
2508 | + echo "Done\n"; |
|
2509 | + } |
|
2036 | 2510 | return ''; |
2037 | 2511 | } |
2038 | 2512 | public static function update_routes_fam() { |
2039 | 2513 | global $tmp_dir, $globalDebug; |
2040 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
2514 | + if ($globalDebug) { |
|
2515 | + echo "Routes from FlightAirMap website : Download..."; |
|
2516 | + } |
|
2041 | 2517 | update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
2042 | 2518 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
2043 | - if ($globalDebug) echo "Gunzip..."; |
|
2519 | + if ($globalDebug) { |
|
2520 | + echo "Gunzip..."; |
|
2521 | + } |
|
2044 | 2522 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
2045 | - if ($globalDebug) echo "Add to DB..."; |
|
2523 | + if ($globalDebug) { |
|
2524 | + echo "Add to DB..."; |
|
2525 | + } |
|
2046 | 2526 | $error = update_db::routes_fam(); |
2047 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2527 | + } else { |
|
2528 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2529 | + } |
|
2048 | 2530 | if ($error != '') { |
2049 | 2531 | return $error; |
2050 | - } elseif ($globalDebug) echo "Done\n"; |
|
2532 | + } elseif ($globalDebug) { |
|
2533 | + echo "Done\n"; |
|
2534 | + } |
|
2051 | 2535 | return ''; |
2052 | 2536 | } |
2053 | 2537 | public static function update_marine_identity_fam() { |
@@ -2057,14 +2541,22 @@ discard block |
||
2057 | 2541 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
2058 | 2542 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
2059 | 2543 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
2060 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
2544 | + if ($globalDebug) { |
|
2545 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
2546 | + } |
|
2061 | 2547 | update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
2062 | 2548 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
2063 | - if ($globalDebug) echo "Gunzip..."; |
|
2549 | + if ($globalDebug) { |
|
2550 | + echo "Gunzip..."; |
|
2551 | + } |
|
2064 | 2552 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
2065 | - if ($globalDebug) echo "Add to DB..."; |
|
2553 | + if ($globalDebug) { |
|
2554 | + echo "Add to DB..."; |
|
2555 | + } |
|
2066 | 2556 | $error = update_db::marine_identity_fam(); |
2067 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
2557 | + } else { |
|
2558 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
2559 | + } |
|
2068 | 2560 | if ($error != '') { |
2069 | 2561 | return $error; |
2070 | 2562 | } elseif ($globalDebug) { |
@@ -2077,17 +2569,25 @@ discard block |
||
2077 | 2569 | } |
2078 | 2570 | public static function update_banned_fam() { |
2079 | 2571 | global $tmp_dir, $globalDebug; |
2080 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
2572 | + if ($globalDebug) { |
|
2573 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
2574 | + } |
|
2081 | 2575 | update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
2082 | 2576 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
2083 | 2577 | //if ($globalDebug) echo "Gunzip..."; |
2084 | 2578 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
2085 | - if ($globalDebug) echo "Add to DB..."; |
|
2579 | + if ($globalDebug) { |
|
2580 | + echo "Add to DB..."; |
|
2581 | + } |
|
2086 | 2582 | $error = update_db::banned_fam(); |
2087 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
2583 | + } else { |
|
2584 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
2585 | + } |
|
2088 | 2586 | if ($error != '') { |
2089 | 2587 | return $error; |
2090 | - } elseif ($globalDebug) echo "Done\n"; |
|
2588 | + } elseif ($globalDebug) { |
|
2589 | + echo "Done\n"; |
|
2590 | + } |
|
2091 | 2591 | return ''; |
2092 | 2592 | } |
2093 | 2593 | |
@@ -2095,7 +2595,9 @@ discard block |
||
2095 | 2595 | global $tmp_dir, $globalDebug, $globalDBdriver; |
2096 | 2596 | include_once('class.create_db.php'); |
2097 | 2597 | $error = ''; |
2098 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
2598 | + if ($globalDebug) { |
|
2599 | + echo "Airspace from FlightAirMap website : Download..."; |
|
2600 | + } |
|
2099 | 2601 | if ($globalDBdriver == 'mysql') { |
2100 | 2602 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
2101 | 2603 | } else { |
@@ -2111,9 +2613,13 @@ discard block |
||
2111 | 2613 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
2112 | 2614 | } |
2113 | 2615 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2114 | - if ($globalDebug) echo "Gunzip..."; |
|
2616 | + if ($globalDebug) { |
|
2617 | + echo "Gunzip..."; |
|
2618 | + } |
|
2115 | 2619 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
2116 | - if ($globalDebug) echo "Add to DB..."; |
|
2620 | + if ($globalDebug) { |
|
2621 | + echo "Add to DB..."; |
|
2622 | + } |
|
2117 | 2623 | $Connection = new Connection(); |
2118 | 2624 | if ($Connection->tableExists('airspace')) { |
2119 | 2625 | $query = 'DROP TABLE airspace'; |
@@ -2126,19 +2632,27 @@ discard block |
||
2126 | 2632 | } |
2127 | 2633 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2128 | 2634 | update_db::insert_airspace_version($airspace_md5); |
2129 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2635 | + } else { |
|
2636 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2637 | + } |
|
2130 | 2638 | } |
2131 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2639 | + } else { |
|
2640 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2641 | + } |
|
2132 | 2642 | if ($error != '') { |
2133 | 2643 | return $error; |
2134 | - } elseif ($globalDebug) echo "Done\n"; |
|
2644 | + } elseif ($globalDebug) { |
|
2645 | + echo "Done\n"; |
|
2646 | + } |
|
2135 | 2647 | return ''; |
2136 | 2648 | } |
2137 | 2649 | |
2138 | 2650 | public static function update_geoid_fam() { |
2139 | 2651 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
2140 | 2652 | $error = ''; |
2141 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
2653 | + if ($globalDebug) { |
|
2654 | + echo "Geoid from FlightAirMap website : Download..."; |
|
2655 | + } |
|
2142 | 2656 | update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
2143 | 2657 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
2144 | 2658 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2146,34 +2660,52 @@ discard block |
||
2146 | 2660 | if (!update_db::check_geoid_version($geoid_md5)) { |
2147 | 2661 | update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
2148 | 2662 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
2149 | - if ($globalDebug) echo "Gunzip..."; |
|
2663 | + if ($globalDebug) { |
|
2664 | + echo "Gunzip..."; |
|
2665 | + } |
|
2150 | 2666 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
2151 | 2667 | update_db::insert_geoid_version($geoid_md5); |
2152 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
2668 | + } else { |
|
2669 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
2670 | + } |
|
2153 | 2671 | } |
2154 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
2672 | + } else { |
|
2673 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
2674 | + } |
|
2155 | 2675 | if ($error != '') { |
2156 | 2676 | return $error; |
2157 | - } elseif ($globalDebug) echo "Done\n"; |
|
2677 | + } elseif ($globalDebug) { |
|
2678 | + echo "Done\n"; |
|
2679 | + } |
|
2158 | 2680 | return ''; |
2159 | 2681 | } |
2160 | 2682 | |
2161 | 2683 | public static function update_tle() { |
2162 | 2684 | global $tmp_dir, $globalDebug; |
2163 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
2685 | + if ($globalDebug) { |
|
2686 | + echo "Download TLE : Download..."; |
|
2687 | + } |
|
2164 | 2688 | $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
2165 | 2689 | 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
2166 | 2690 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
2167 | 2691 | foreach ($alltle as $filename) { |
2168 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
2692 | + if ($globalDebug) { |
|
2693 | + echo "downloading ".$filename.'...'; |
|
2694 | + } |
|
2169 | 2695 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
2170 | 2696 | if (file_exists($tmp_dir.$filename)) { |
2171 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
2697 | + if ($globalDebug) { |
|
2698 | + echo "Add to DB ".$filename."..."; |
|
2699 | + } |
|
2172 | 2700 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
2173 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2701 | + } else { |
|
2702 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2703 | + } |
|
2174 | 2704 | if ($error != '') { |
2175 | 2705 | echo $error."\n"; |
2176 | - } elseif ($globalDebug) echo "Done\n"; |
|
2706 | + } elseif ($globalDebug) { |
|
2707 | + echo "Done\n"; |
|
2708 | + } |
|
2177 | 2709 | } |
2178 | 2710 | return ''; |
2179 | 2711 | } |
@@ -2181,10 +2713,14 @@ discard block |
||
2181 | 2713 | public static function update_models() { |
2182 | 2714 | global $tmp_dir, $globalDebug; |
2183 | 2715 | $error = ''; |
2184 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
2716 | + if ($globalDebug) { |
|
2717 | + echo "Models from FlightAirMap website : Download..."; |
|
2718 | + } |
|
2185 | 2719 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
2186 | 2720 | if (file_exists($tmp_dir.'models.md5sum')) { |
2187 | - if ($globalDebug) echo "Check files...\n"; |
|
2721 | + if ($globalDebug) { |
|
2722 | + echo "Check files...\n"; |
|
2723 | + } |
|
2188 | 2724 | $newmodelsdb = array(); |
2189 | 2725 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
2190 | 2726 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2203,25 +2739,35 @@ discard block |
||
2203 | 2739 | } |
2204 | 2740 | $diff = array_diff($newmodelsdb,$modelsdb); |
2205 | 2741 | foreach ($diff as $key => $value) { |
2206 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
2742 | + if ($globalDebug) { |
|
2743 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
2744 | + } |
|
2207 | 2745 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
2208 | 2746 | |
2209 | 2747 | } |
2210 | 2748 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
2211 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2749 | + } else { |
|
2750 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2751 | + } |
|
2212 | 2752 | if ($error != '') { |
2213 | 2753 | return $error; |
2214 | - } elseif ($globalDebug) echo "Done\n"; |
|
2754 | + } elseif ($globalDebug) { |
|
2755 | + echo "Done\n"; |
|
2756 | + } |
|
2215 | 2757 | return ''; |
2216 | 2758 | } |
2217 | 2759 | |
2218 | 2760 | public static function update_space_models() { |
2219 | 2761 | global $tmp_dir, $globalDebug; |
2220 | 2762 | $error = ''; |
2221 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
2763 | + if ($globalDebug) { |
|
2764 | + echo "Space models from FlightAirMap website : Download..."; |
|
2765 | + } |
|
2222 | 2766 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
2223 | 2767 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2224 | - if ($globalDebug) echo "Check files...\n"; |
|
2768 | + if ($globalDebug) { |
|
2769 | + echo "Check files...\n"; |
|
2770 | + } |
|
2225 | 2771 | $newmodelsdb = array(); |
2226 | 2772 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
2227 | 2773 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2240,25 +2786,35 @@ discard block |
||
2240 | 2786 | } |
2241 | 2787 | $diff = array_diff($newmodelsdb,$modelsdb); |
2242 | 2788 | foreach ($diff as $key => $value) { |
2243 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
2789 | + if ($globalDebug) { |
|
2790 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
2791 | + } |
|
2244 | 2792 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
2245 | 2793 | |
2246 | 2794 | } |
2247 | 2795 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
2248 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2796 | + } else { |
|
2797 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2798 | + } |
|
2249 | 2799 | if ($error != '') { |
2250 | 2800 | return $error; |
2251 | - } elseif ($globalDebug) echo "Done\n"; |
|
2801 | + } elseif ($globalDebug) { |
|
2802 | + echo "Done\n"; |
|
2803 | + } |
|
2252 | 2804 | return ''; |
2253 | 2805 | } |
2254 | 2806 | |
2255 | 2807 | public static function update_vehicules_models() { |
2256 | 2808 | global $tmp_dir, $globalDebug; |
2257 | 2809 | $error = ''; |
2258 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
2810 | + if ($globalDebug) { |
|
2811 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
2812 | + } |
|
2259 | 2813 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
2260 | 2814 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
2261 | - if ($globalDebug) echo "Check files...\n"; |
|
2815 | + if ($globalDebug) { |
|
2816 | + echo "Check files...\n"; |
|
2817 | + } |
|
2262 | 2818 | $newmodelsdb = array(); |
2263 | 2819 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
2264 | 2820 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2277,15 +2833,21 @@ discard block |
||
2277 | 2833 | } |
2278 | 2834 | $diff = array_diff($newmodelsdb,$modelsdb); |
2279 | 2835 | foreach ($diff as $key => $value) { |
2280 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
2836 | + if ($globalDebug) { |
|
2837 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
2838 | + } |
|
2281 | 2839 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
2282 | 2840 | |
2283 | 2841 | } |
2284 | 2842 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
2285 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2843 | + } else { |
|
2844 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2845 | + } |
|
2286 | 2846 | if ($error != '') { |
2287 | 2847 | return $error; |
2288 | - } elseif ($globalDebug) echo "Done\n"; |
|
2848 | + } elseif ($globalDebug) { |
|
2849 | + echo "Done\n"; |
|
2850 | + } |
|
2289 | 2851 | return ''; |
2290 | 2852 | } |
2291 | 2853 | |
@@ -2328,7 +2890,9 @@ discard block |
||
2328 | 2890 | } |
2329 | 2891 | |
2330 | 2892 | $error = ''; |
2331 | - if ($globalDebug) echo "Notam : Download..."; |
|
2893 | + if ($globalDebug) { |
|
2894 | + echo "Notam : Download..."; |
|
2895 | + } |
|
2332 | 2896 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
2333 | 2897 | if (file_exists($tmp_dir.'notam.rss')) { |
2334 | 2898 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2343,14 +2907,30 @@ discard block |
||
2343 | 2907 | $data['fir'] = $q[0]; |
2344 | 2908 | $data['code'] = $q[1]; |
2345 | 2909 | $ifrvfr = $q[2]; |
2346 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
2347 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
2348 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
2349 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
2350 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
2351 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
2352 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
2353 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
2910 | + if ($ifrvfr == 'IV') { |
|
2911 | + $data['rules'] = 'IFR/VFR'; |
|
2912 | + } |
|
2913 | + if ($ifrvfr == 'I') { |
|
2914 | + $data['rules'] = 'IFR'; |
|
2915 | + } |
|
2916 | + if ($ifrvfr == 'V') { |
|
2917 | + $data['rules'] = 'VFR'; |
|
2918 | + } |
|
2919 | + if ($q[4] == 'A') { |
|
2920 | + $data['scope'] = 'Airport warning'; |
|
2921 | + } |
|
2922 | + if ($q[4] == 'E') { |
|
2923 | + $data['scope'] = 'Enroute warning'; |
|
2924 | + } |
|
2925 | + if ($q[4] == 'W') { |
|
2926 | + $data['scope'] = 'Navigation warning'; |
|
2927 | + } |
|
2928 | + if ($q[4] == 'AE') { |
|
2929 | + $data['scope'] = 'Airport/Enroute warning'; |
|
2930 | + } |
|
2931 | + if ($q[4] == 'AW') { |
|
2932 | + $data['scope'] = 'Airport/Navigation warning'; |
|
2933 | + } |
|
2354 | 2934 | //$data['scope'] = $q[4]; |
2355 | 2935 | $data['lower_limit'] = $q[5]; |
2356 | 2936 | $data['upper_limit'] = $q[6]; |
@@ -2358,8 +2938,12 @@ discard block |
||
2358 | 2938 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
2359 | 2939 | $latitude = $Common->convertDec($las,'latitude'); |
2360 | 2940 | $longitude = $Common->convertDec($lns,'longitude'); |
2361 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
2362 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
2941 | + if ($lac == 'S') { |
|
2942 | + $latitude = '-'.$latitude; |
|
2943 | + } |
|
2944 | + if ($lnc == 'W') { |
|
2945 | + $longitude = '-'.$longitude; |
|
2946 | + } |
|
2363 | 2947 | $data['center_latitude'] = $latitude; |
2364 | 2948 | $data['center_longitude'] = $longitude; |
2365 | 2949 | $data['radius'] = intval($radius); |
@@ -2389,10 +2973,14 @@ discard block |
||
2389 | 2973 | $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
2390 | 2974 | unset($data); |
2391 | 2975 | } |
2392 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2976 | + } else { |
|
2977 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2978 | + } |
|
2393 | 2979 | if ($error != '') { |
2394 | 2980 | return $error; |
2395 | - } elseif ($globalDebug) echo "Done\n"; |
|
2981 | + } elseif ($globalDebug) { |
|
2982 | + echo "Done\n"; |
|
2983 | + } |
|
2396 | 2984 | return ''; |
2397 | 2985 | } |
2398 | 2986 | |
@@ -2417,7 +3005,9 @@ discard block |
||
2417 | 3005 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
2418 | 3006 | $airspace_json = json_decode($airspace_lst,true); |
2419 | 3007 | foreach ($airspace_json['records'] as $airspace) { |
2420 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
3008 | + if ($globalDebug) { |
|
3009 | + echo $airspace['name']."...\n"; |
|
3010 | + } |
|
2421 | 3011 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
2422 | 3012 | if (file_exists($tmp_dir.$airspace['name'])) { |
2423 | 3013 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -2461,8 +3051,11 @@ discard block |
||
2461 | 3051 | return "error : ".$e->getMessage(); |
2462 | 3052 | } |
2463 | 3053 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2464 | - if ($row['nb'] > 0) return false; |
|
2465 | - else return true; |
|
3054 | + if ($row['nb'] > 0) { |
|
3055 | + return false; |
|
3056 | + } else { |
|
3057 | + return true; |
|
3058 | + } |
|
2466 | 3059 | } |
2467 | 3060 | |
2468 | 3061 | public static function insert_last_update() { |
@@ -2487,8 +3080,11 @@ discard block |
||
2487 | 3080 | return "error : ".$e->getMessage(); |
2488 | 3081 | } |
2489 | 3082 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2490 | - if ($row['nb'] > 0) return true; |
|
2491 | - else return false; |
|
3083 | + if ($row['nb'] > 0) { |
|
3084 | + return true; |
|
3085 | + } else { |
|
3086 | + return false; |
|
3087 | + } |
|
2492 | 3088 | } |
2493 | 3089 | |
2494 | 3090 | public static function check_geoid_version($version) { |
@@ -2501,8 +3097,11 @@ discard block |
||
2501 | 3097 | return "error : ".$e->getMessage(); |
2502 | 3098 | } |
2503 | 3099 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2504 | - if ($row['nb'] > 0) return true; |
|
2505 | - else return false; |
|
3100 | + if ($row['nb'] > 0) { |
|
3101 | + return true; |
|
3102 | + } else { |
|
3103 | + return false; |
|
3104 | + } |
|
2506 | 3105 | } |
2507 | 3106 | |
2508 | 3107 | public static function check_marine_identity_version($version) { |
@@ -2515,8 +3114,11 @@ discard block |
||
2515 | 3114 | return "error : ".$e->getMessage(); |
2516 | 3115 | } |
2517 | 3116 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2518 | - if ($row['nb'] > 0) return true; |
|
2519 | - else return false; |
|
3117 | + if ($row['nb'] > 0) { |
|
3118 | + return true; |
|
3119 | + } else { |
|
3120 | + return false; |
|
3121 | + } |
|
2520 | 3122 | } |
2521 | 3123 | |
2522 | 3124 | |
@@ -2571,8 +3173,11 @@ discard block |
||
2571 | 3173 | return "error : ".$e->getMessage(); |
2572 | 3174 | } |
2573 | 3175 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2574 | - if ($row['nb'] > 0) return false; |
|
2575 | - else return true; |
|
3176 | + if ($row['nb'] > 0) { |
|
3177 | + return false; |
|
3178 | + } else { |
|
3179 | + return true; |
|
3180 | + } |
|
2576 | 3181 | } |
2577 | 3182 | |
2578 | 3183 | public static function insert_last_notam_update() { |
@@ -2602,8 +3207,11 @@ discard block |
||
2602 | 3207 | return "error : ".$e->getMessage(); |
2603 | 3208 | } |
2604 | 3209 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2605 | - if ($row['nb'] > 0) return false; |
|
2606 | - else return true; |
|
3210 | + if ($row['nb'] > 0) { |
|
3211 | + return false; |
|
3212 | + } else { |
|
3213 | + return true; |
|
3214 | + } |
|
2607 | 3215 | } |
2608 | 3216 | |
2609 | 3217 | public static function insert_last_airspace_update() { |
@@ -2633,8 +3241,11 @@ discard block |
||
2633 | 3241 | return "error : ".$e->getMessage(); |
2634 | 3242 | } |
2635 | 3243 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2636 | - if ($row['nb'] > 0) return false; |
|
2637 | - else return true; |
|
3244 | + if ($row['nb'] > 0) { |
|
3245 | + return false; |
|
3246 | + } else { |
|
3247 | + return true; |
|
3248 | + } |
|
2638 | 3249 | } |
2639 | 3250 | |
2640 | 3251 | public static function insert_last_geoid_update() { |
@@ -2664,8 +3275,11 @@ discard block |
||
2664 | 3275 | return "error : ".$e->getMessage(); |
2665 | 3276 | } |
2666 | 3277 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2667 | - if ($row['nb'] > 0) return false; |
|
2668 | - else return true; |
|
3278 | + if ($row['nb'] > 0) { |
|
3279 | + return false; |
|
3280 | + } else { |
|
3281 | + return true; |
|
3282 | + } |
|
2669 | 3283 | } |
2670 | 3284 | |
2671 | 3285 | public static function insert_last_owner_update() { |
@@ -2694,8 +3308,11 @@ discard block |
||
2694 | 3308 | return "error : ".$e->getMessage(); |
2695 | 3309 | } |
2696 | 3310 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2697 | - if ($row['nb'] > 0) return false; |
|
2698 | - else return true; |
|
3311 | + if ($row['nb'] > 0) { |
|
3312 | + return false; |
|
3313 | + } else { |
|
3314 | + return true; |
|
3315 | + } |
|
2699 | 3316 | } |
2700 | 3317 | |
2701 | 3318 | public static function insert_last_schedules_update() { |
@@ -2724,8 +3341,11 @@ discard block |
||
2724 | 3341 | return "error : ".$e->getMessage(); |
2725 | 3342 | } |
2726 | 3343 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2727 | - if ($row['nb'] > 0) return false; |
|
2728 | - else return true; |
|
3344 | + if ($row['nb'] > 0) { |
|
3345 | + return false; |
|
3346 | + } else { |
|
3347 | + return true; |
|
3348 | + } |
|
2729 | 3349 | } |
2730 | 3350 | |
2731 | 3351 | public static function insert_last_tle_update() { |
@@ -2754,8 +3374,11 @@ discard block |
||
2754 | 3374 | return "error : ".$e->getMessage(); |
2755 | 3375 | } |
2756 | 3376 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2757 | - if ($row['nb'] > 0) return false; |
|
2758 | - else return true; |
|
3377 | + if ($row['nb'] > 0) { |
|
3378 | + return false; |
|
3379 | + } else { |
|
3380 | + return true; |
|
3381 | + } |
|
2759 | 3382 | } |
2760 | 3383 | |
2761 | 3384 | public static function insert_last_marine_identity_update() { |