@@ -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'] < $globalAircraftMinupdate) $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'] < $globalAircraftMinupdate) $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) { |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | * @return Array the images list |
18 | 18 | * |
19 | 19 | */ |
20 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
20 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
21 | 21 | { |
22 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
23 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
24 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
22 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
23 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
24 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
25 | 25 | $reg = $registration; |
26 | 26 | if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
27 | 27 | $reg = trim($reg); |
28 | - $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
28 | + $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
29 | 29 | FROM spotter_image |
30 | 30 | WHERE spotter_image.registration = :registration LIMIT 1"; |
31 | 31 | $sth = $this->db->prepare($query); |
32 | 32 | $sth->execute(array(':registration' => $reg)); |
33 | 33 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
34 | 34 | if (!empty($result)) return $result; |
35 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
35 | + elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
36 | 36 | else return array(); |
37 | 37 | } |
38 | 38 | |
@@ -42,23 +42,23 @@ discard block |
||
42 | 42 | * @return Array the images list |
43 | 43 | * |
44 | 44 | */ |
45 | - public function getMarineImage($mmsi,$imo = '',$name = '') |
|
45 | + public function getMarineImage($mmsi, $imo = '', $name = '') |
|
46 | 46 | { |
47 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
48 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
49 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
47 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
48 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
49 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
50 | 50 | $name = trim($name); |
51 | - $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
51 | + $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
52 | 52 | FROM marine_image |
53 | 53 | WHERE marine_image.mmsi = :mmsi"; |
54 | 54 | $query_data = array(':mmsi' => $mmsi); |
55 | 55 | if ($imo != '') { |
56 | 56 | $query .= " AND marine_image.imo = :imo"; |
57 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
57 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
58 | 58 | } |
59 | 59 | if ($name != '') { |
60 | 60 | $query .= " AND marine_image.name = :name"; |
61 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
61 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
62 | 62 | } |
63 | 63 | $query .= " LIMIT 1"; |
64 | 64 | $sth = $this->db->prepare($query); |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
80 | 80 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
81 | 81 | if ($copyright != '') { |
82 | - $copyright = str_replace('Copyright ','',$copyright); |
|
83 | - $copyright = str_replace('© ','',$copyright); |
|
84 | - $copyright = str_replace('(c) ','',$copyright); |
|
82 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
83 | + $copyright = str_replace('© ', '', $copyright); |
|
84 | + $copyright = str_replace('(c) ', '', $copyright); |
|
85 | 85 | } |
86 | 86 | return $copyright; |
87 | 87 | } |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | * @return String either success or error |
93 | 93 | * |
94 | 94 | */ |
95 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
95 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
96 | 96 | { |
97 | - global $globalDebug,$globalAircraftImageFetch; |
|
97 | + global $globalDebug, $globalAircraftImageFetch; |
|
98 | 98 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
99 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
99 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
100 | 100 | $registration = trim($registration); |
101 | 101 | //getting the aircraft image |
102 | 102 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
103 | 103 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
104 | 104 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
105 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
105 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
106 | 106 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
107 | 107 | if ($image_url['original'] != '') { |
108 | 108 | if ($globalDebug) echo 'Found !'."\n"; |
109 | - $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
109 | + $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
110 | 110 | try { |
111 | 111 | $sth = $this->db->prepare($query); |
112 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
113 | - } catch(PDOException $e) { |
|
112 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | echo $e->getMessage()."\n"; |
115 | 115 | return "error"; |
116 | 116 | } |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * @return String either success or error |
125 | 125 | * |
126 | 126 | */ |
127 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
127 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
128 | 128 | { |
129 | - global $globalDebug,$globalMarineImageFetch; |
|
129 | + global $globalDebug, $globalMarineImageFetch; |
|
130 | 130 | if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
131 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
132 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
133 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
131 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
132 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
133 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
134 | 134 | $name = trim($name); |
135 | 135 | $Marine = new Marine($this->db); |
136 | 136 | if ($imo == '' || $name == '') { |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | |
145 | 145 | //getting the aircraft image |
146 | 146 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
147 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
147 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
148 | 148 | if ($image_url['original'] != '') { |
149 | 149 | if ($globalDebug) echo 'Found !'."\n"; |
150 | - $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
150 | + $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
151 | 151 | try { |
152 | 152 | $sth = $this->db->prepare($query); |
153 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
154 | - } catch(PDOException $e) { |
|
153 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
154 | + } catch (PDOException $e) { |
|
155 | 155 | echo $e->getMessage()."\n"; |
156 | 156 | return "error"; |
157 | 157 | } |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
172 | 172 | $Spotter = new Spotter($this->db); |
173 | 173 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
174 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
174 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
175 | 175 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
176 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
176 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
177 | 177 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
178 | 178 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
179 | 179 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -187,25 +187,25 @@ discard block |
||
187 | 187 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
188 | 188 | else $aircraft_name = ''; |
189 | 189 | $aircraft_registration = $aircraft_icao; |
190 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
190 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
191 | 191 | unset($Spotter); |
192 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
192 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
193 | 193 | foreach ($globalAircraftImageSources as $source) { |
194 | 194 | $source = strtolower($source); |
195 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
196 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
197 | - if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
195 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao); |
|
196 | + if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name); |
|
197 | + if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name); |
|
198 | + if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name); |
|
199 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name); |
|
200 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name); |
|
201 | + if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name); |
|
202 | + if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name); |
|
203 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name); |
|
204 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name); |
|
205 | 205 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
206 | 206 | } |
207 | 207 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
208 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
208 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | * @return Array the aircraft thumbnail, orignal url and copyright |
218 | 218 | * |
219 | 219 | */ |
220 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
220 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
221 | 221 | { |
222 | 222 | global $globalMarineImageSources; |
223 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
223 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
224 | 224 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
225 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
225 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
226 | 226 | $name = trim($name); |
227 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
227 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
228 | 228 | /* |
229 | 229 | $Marine = new Marine($this->db); |
230 | 230 | if ($imo == '' || $name == '') { |
@@ -236,17 +236,17 @@ discard block |
||
236 | 236 | } |
237 | 237 | unset($Marine); |
238 | 238 | */ |
239 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
239 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
240 | 240 | foreach ($globalMarineImageSources as $source) { |
241 | 241 | $source = strtolower($source); |
242 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
243 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
244 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
245 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
246 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
242 | + if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name); |
|
243 | + if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name); |
|
244 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name); |
|
245 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name); |
|
246 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name); |
|
247 | 247 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
248 | 248 | } |
249 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
249 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -257,24 +257,24 @@ discard block |
||
257 | 257 | * @return Array the aircraft thumbnail, orignal url and copyright |
258 | 258 | * |
259 | 259 | */ |
260 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
260 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
261 | 261 | $Common = new Common(); |
262 | 262 | // If aircraft registration is only number, also check with aircraft model |
263 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
264 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
263 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
264 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
265 | 265 | } else { |
266 | 266 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
267 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
267 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
268 | 268 | } |
269 | 269 | $data = $Common->getData($url); |
270 | 270 | if ($xml = simplexml_load_string($data)) { |
271 | 271 | if (isset($xml->channel->item)) { |
272 | 272 | $image_url = array(); |
273 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
273 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
274 | 274 | $image_url['thumbnail'] = $thumbnail_url; |
275 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
276 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
277 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
275 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
276 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
277 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
278 | 278 | $image_url['source'] = 'planespotters'; |
279 | 279 | return $image_url; |
280 | 280 | } |
@@ -290,30 +290,30 @@ discard block |
||
290 | 290 | * @return Array the aircraft thumbnail, orignal url and copyright |
291 | 291 | * |
292 | 292 | */ |
293 | - public function fromDeviantart($type,$registration, $name='') { |
|
293 | + public function fromDeviantart($type, $registration, $name = '') { |
|
294 | 294 | $Common = new Common(); |
295 | 295 | if ($type == 'aircraft') { |
296 | 296 | // If aircraft registration is only number, also check with aircraft model |
297 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
298 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
297 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
298 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
299 | 299 | } else { |
300 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
300 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
301 | 301 | } |
302 | 302 | } elseif ($type == 'marine') { |
303 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
303 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
304 | 304 | } else { |
305 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
305 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
306 | 306 | } |
307 | 307 | $data = $Common->getData($url); |
308 | 308 | if ($xml = simplexml_load_string($data)) { |
309 | 309 | if (isset($xml->channel->item->link)) { |
310 | 310 | $image_url = array(); |
311 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
311 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
312 | 312 | $image_url['thumbnail'] = $thumbnail_url; |
313 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
313 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
314 | 314 | $image_url['original'] = $original_url; |
315 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
316 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
315 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
316 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
317 | 317 | $image_url['source'] = 'deviantart'; |
318 | 318 | return $image_url; |
319 | 319 | } |
@@ -329,32 +329,32 @@ discard block |
||
329 | 329 | * @return Array the aircraft thumbnail, orignal url and copyright |
330 | 330 | * |
331 | 331 | */ |
332 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
332 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
333 | 333 | $Common = new Common(); |
334 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
334 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
335 | 335 | $data = $Common->getData($url); |
336 | 336 | $dom = new DOMDocument(); |
337 | 337 | @$dom->loadHTML($data); |
338 | 338 | $all_pics = array(); |
339 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
339 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
340 | 340 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
341 | 341 | $all_pics[] = $image->getAttribute('src'); |
342 | 342 | } |
343 | 343 | } |
344 | 344 | $all_authors = array(); |
345 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
345 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
346 | 346 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
347 | 347 | $all_authors[] = $author->getAttribute('content'); |
348 | 348 | } |
349 | 349 | } |
350 | 350 | $all_ref = array(); |
351 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
351 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
352 | 352 | $all_ref[] = $link->getAttribute('href'); |
353 | 353 | } |
354 | 354 | if (isset($all_pics[0])) { |
355 | 355 | $image_url = array(); |
356 | 356 | $image_url['thumbnail'] = $all_pics[0]; |
357 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
357 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
358 | 358 | $image_url['copyright'] = $all_authors[0]; |
359 | 359 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
360 | 360 | $image_url['source'] = 'JetPhotos'; |
@@ -371,24 +371,24 @@ discard block |
||
371 | 371 | * @return Array the aircraft thumbnail, orignal url and copyright |
372 | 372 | * |
373 | 373 | */ |
374 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
374 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
375 | 375 | $Common = new Common(); |
376 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
376 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
377 | 377 | $data = $Common->getData($url); |
378 | 378 | $dom = new DOMDocument(); |
379 | 379 | @$dom->loadHTML($data); |
380 | 380 | $all_pics = array(); |
381 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
381 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
382 | 382 | $all_pics[] = $image->getAttribute('src'); |
383 | 383 | } |
384 | 384 | $all_links = array(); |
385 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
386 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
385 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
386 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
387 | 387 | } |
388 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
388 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
389 | 389 | $image_url = array(); |
390 | 390 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
391 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
391 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
392 | 392 | $image_url['copyright'] = $all_links[6]['text']; |
393 | 393 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
394 | 394 | $image_url['source'] = 'PlanePictures'; |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @return Array the aircraft thumbnail, orignal url and copyright |
406 | 406 | * |
407 | 407 | */ |
408 | - public function fromFlickr($type,$registration,$name='') { |
|
408 | + public function fromFlickr($type, $registration, $name = '') { |
|
409 | 409 | $Common = new Common(); |
410 | 410 | if ($type == 'aircraft') { |
411 | 411 | if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
@@ -417,12 +417,12 @@ discard block |
||
417 | 417 | $data = $Common->getData($url); |
418 | 418 | if ($xml = simplexml_load_string($data)) { |
419 | 419 | if (isset($xml->channel->item)) { |
420 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
420 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
421 | 421 | $image_url = array(); |
422 | 422 | $image_url['thumbnail'] = $original_url; |
423 | 423 | $image_url['original'] = $original_url; |
424 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
425 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
424 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
425 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
426 | 426 | $image_url['source'] = 'flickr'; |
427 | 427 | return $image_url; |
428 | 428 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | return false; |
431 | 431 | } |
432 | 432 | |
433 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
433 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
434 | 434 | $Common = new Common(); |
435 | 435 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
436 | 436 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * @return Array the aircraft thumbnail, orignal url and copyright |
455 | 455 | * |
456 | 456 | */ |
457 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
457 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
458 | 458 | global $globalImageBingKey; |
459 | 459 | $Common = new Common(); |
460 | 460 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
466 | 466 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
467 | 467 | } |
468 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
469 | - $data = $Common->getData($url,'get','',$headers); |
|
468 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
469 | + $data = $Common->getData($url, 'get', '', $headers); |
|
470 | 470 | $result = json_decode($data); |
471 | 471 | if (isset($result->d->results[0]->MediaUrl)) { |
472 | 472 | $image_url = array(); |
@@ -491,14 +491,14 @@ discard block |
||
491 | 491 | * @return Array the aircraft thumbnail, orignal url and copyright |
492 | 492 | * |
493 | 493 | */ |
494 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
494 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
495 | 495 | $Common = new Common(); |
496 | 496 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
497 | 497 | $data = $Common->getData($url); |
498 | 498 | $result = json_decode($data); |
499 | 499 | if (isset($result->count) && $result->count > 0) { |
500 | 500 | $image_url = array(); |
501 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
501 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
502 | 502 | $image_url['source_website'] = $result->data[0]->link; |
503 | 503 | $image_url['thumbnail'] = $result->data[0]->image; |
504 | 504 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | * @return Array the aircraft thumbnail, orignal url and copyright |
517 | 517 | * |
518 | 518 | */ |
519 | - public function fromWikimedia($type,$registration,$name='') { |
|
519 | + public function fromWikimedia($type, $registration, $name = '') { |
|
520 | 520 | $Common = new Common(); |
521 | 521 | if ($type == 'aircraft') { |
522 | 522 | if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | $result = json_decode($data); |
530 | 530 | if (isset($result->query->search[0]->title)) { |
531 | 531 | $fileo = $result->query->search[0]->title; |
532 | - if (substr($fileo,-3) == 'pdf') return false; |
|
532 | + if (substr($fileo, -3) == 'pdf') return false; |
|
533 | 533 | $file = urlencode($fileo); |
534 | 534 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
535 | 535 | $data2 = $Common->getData($url2); |
@@ -554,11 +554,11 @@ discard block |
||
554 | 554 | if (isset($result2->query->pages)) { |
555 | 555 | foreach ($result2->query->pages as $page) { |
556 | 556 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
557 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
557 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
558 | 558 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
559 | 559 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
560 | 560 | } |
561 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
561 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
562 | 562 | return $image_url; |
563 | 563 | } |
564 | 564 | } |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @return Array the aircraft thumbnail, orignal url and copyright |
578 | 578 | * |
579 | 579 | */ |
580 | - public function fromCustomSource($type,$registration,$name='') { |
|
580 | + public function fromCustomSource($type, $registration, $name = '') { |
|
581 | 581 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
582 | 582 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
583 | 583 | if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') { |
@@ -594,15 +594,15 @@ discard block |
||
594 | 594 | print_r($source); |
595 | 595 | print_r($customsources); |
596 | 596 | } |
597 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
598 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
597 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
598 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
599 | 599 | if ($Common->urlexist($url)) { |
600 | 600 | $image_url = array(); |
601 | 601 | $image_url['thumbnail'] = $url_thumbnail; |
602 | 602 | $image_url['original'] = $url; |
603 | 603 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
604 | 604 | else $exifCopyright = ''; |
605 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
605 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
606 | 606 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
607 | 607 | else $image_url['copyright'] = $source['source_website']; |
608 | 608 | $image_url['source_website'] = $source['source_website']; |
@@ -626,19 +626,19 @@ discard block |
||
626 | 626 | print_r($source); |
627 | 627 | print_r($customsources); |
628 | 628 | } |
629 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
630 | - $url = str_replace('{mmsi}',$registration,$url); |
|
631 | - $url = str_replace('{name}',$name,$url); |
|
632 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
633 | - $url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail); |
|
634 | - $url_thumbnail = str_replace('{name}',$name,$url_thumbnail); |
|
629 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
630 | + $url = str_replace('{mmsi}', $registration, $url); |
|
631 | + $url = str_replace('{name}', $name, $url); |
|
632 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
633 | + $url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail); |
|
634 | + $url_thumbnail = str_replace('{name}', $name, $url_thumbnail); |
|
635 | 635 | if ($Common->urlexist($url)) { |
636 | 636 | $image_url = array(); |
637 | 637 | $image_url['thumbnail'] = $url_thumbnail; |
638 | 638 | $image_url['original'] = $url; |
639 | 639 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
640 | 640 | else $exifCopyright = ''; |
641 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
641 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
642 | 642 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
643 | 643 | else $image_url['copyright'] = $source['source_website']; |
644 | 644 | $image_url['source_website'] = $source['source_website']; |
@@ -11,14 +11,14 @@ discard block |
||
11 | 11 | |
12 | 12 | $from_archive = false; |
13 | 13 | if (isset($_GET['ident'])) { |
14 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
14 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
15 | 15 | if (isset($_GET['currenttime'])) { |
16 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
16 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
17 | 17 | $currenttime = round($currenttime/1000); |
18 | - $spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime); |
|
18 | + $spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident, $currenttime); |
|
19 | 19 | if (empty($spotter_array)) { |
20 | 20 | $from_archive = true; |
21 | - $spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime); |
|
21 | + $spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident, $currenttime); |
|
22 | 22 | } |
23 | 23 | } else { |
24 | 24 | $spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident); |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | } |
30 | 30 | } |
31 | 31 | if (isset($_GET['flightaware_id'])) { |
32 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
32 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
33 | 33 | if (isset($_GET['currenttime'])) { |
34 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
34 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
35 | 35 | $currenttime = round($currenttime/1000); |
36 | - $spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime); |
|
36 | + $spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id, $currenttime); |
|
37 | 37 | if (empty($spotter_array)) { |
38 | 38 | $from_archive = true; |
39 | 39 | // $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id); |
40 | - $spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime); |
|
40 | + $spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id, $currenttime); |
|
41 | 41 | } |
42 | 42 | } else { |
43 | 43 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
57 | 57 | { |
58 | 58 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
59 | - $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
59 | + $image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
60 | 60 | } else $image = $spotter_item['image_thumbnail']; |
61 | 61 | |
62 | 62 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country']; |
78 | 78 | if (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') { |
79 | 79 | if ($spotter_item['departure_airport_time'] > 2460) { |
80 | - print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>'; |
|
80 | + print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>'; |
|
81 | 81 | } else { |
82 | 82 | print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>'; |
83 | 83 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country']; |
87 | 87 | if (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') { |
88 | 88 | if ($spotter_item['arrival_airport_time'] > 2460) { |
89 | - print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>'; |
|
89 | + print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>'; |
|
90 | 90 | } else { |
91 | 91 | print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>'; |
92 | 92 | } |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | print '<div id ="altitude"><span>'._("Altitude").'</span>'; |
112 | 112 | if (isset($globalGroundAltitude) && $globalGroundAltitude) { |
113 | 113 | try { |
114 | - $groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']); |
|
115 | - } catch(Exception $e) { |
|
114 | + $groundAltitude = $Elevation->getElevation($spotter_item['latitude'], $spotter_item['longitude']); |
|
115 | + } catch (Exception $e) { |
|
116 | 116 | // If catched not exist |
117 | 117 | } |
118 | 118 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
184 | 184 | if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
185 | -if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
185 | +if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br/>', $spotter_item['acars']['message'])).'</div>'; |
|
186 | 186 | if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
187 | 187 | print '</div>'; |
188 | 188 | ?> |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | die(); |
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | -$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
|
11 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
10 | +$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'country', FILTER_SANITIZE_STRING))); |
|
11 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
12 | 12 | if (isset($_GET['sort'])) { |
13 | 13 | $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort); |
14 | 14 | } else { |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | |
18 | 18 | if (!empty($spotter_array)) |
19 | 19 | { |
20 | - $title = sprintf(_("Most Common Aircraft Manufacturer from %s"),$country); |
|
20 | + $title = sprintf(_("Most Common Aircraft Manufacturer from %s"), $country); |
|
21 | 21 | require_once('header.php'); |
22 | 22 | print '<div class="select-item">'; |
23 | 23 | print '<form action="'.$globalURL.'/country" method="post">'; |
24 | 24 | print '<select name="country" class="selectpicker" data-live-search="true">'; |
25 | 25 | print '<option></option>'; |
26 | 26 | $all_countries = $Spotter->getAllCountries(); |
27 | - foreach($all_countries as $all_country) |
|
27 | + foreach ($all_countries as $all_country) |
|
28 | 28 | { |
29 | - if($country == $all_country['country']) |
|
29 | + if ($country == $all_country['country']) |
|
30 | 30 | { |
31 | 31 | print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>'; |
32 | 32 | } else { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | if ($_GET['country'] != "NA") |
42 | 42 | { |
43 | 43 | print '<div class="info column">'; |
44 | - print '<h1>'.sprintf(_("Airports & Airlines from %s"),$country).'</h1>'; |
|
44 | + print '<h1>'.sprintf(_("Airports & Airlines from %s"), $country).'</h1>'; |
|
45 | 45 | print '</div>'; |
46 | 46 | } else { |
47 | 47 | print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>'; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | include('country-sub-menu.php'); |
51 | 51 | print '<div class="column">'; |
52 | 52 | print '<h2>'._("Most Common Aircraft Manufacturer").'</h2>'; |
53 | - print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of airlines or departure/arrival airports from <strong>%s</strong>."),$country).'</p>'; |
|
53 | + print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of airlines or departure/arrival airports from <strong>%s</strong>."), $country).'</p>'; |
|
54 | 54 | $manufacturers_array = $Spotter->countAllAircraftManufacturerByCountry($country); |
55 | 55 | if (!empty($manufacturers_array)) |
56 | 56 | { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | print '</thead>'; |
64 | 64 | print '<tbody>'; |
65 | 65 | $i = 1; |
66 | - foreach($manufacturers_array as $manufacturer_item) |
|
66 | + foreach ($manufacturers_array as $manufacturer_item) |
|
67 | 67 | { |
68 | 68 | print '<tr>'; |
69 | 69 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | $this->db = $Connection->db(); |
19 | 19 | } |
20 | 20 | |
21 | - public function addLastStatsUpdate($type,$stats_date) { |
|
21 | + public function addLastStatsUpdate($type, $stats_date) { |
|
22 | 22 | $query = "DELETE FROM config WHERE name = :type; |
23 | 23 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
24 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
25 | 25 | try { |
26 | 26 | $sth = $this->db->prepare($query); |
27 | 27 | $sth->execute($query_values); |
28 | - } catch(PDOException $e) { |
|
28 | + } catch (PDOException $e) { |
|
29 | 29 | return "error : ".$e->getMessage(); |
30 | 30 | } |
31 | 31 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | try { |
36 | 36 | $sth = $this->db->prepare($query); |
37 | 37 | $sth->execute(array(':type' => $type)); |
38 | - } catch(PDOException $e) { |
|
38 | + } catch (PDOException $e) { |
|
39 | 39 | echo "error : ".$e->getMessage(); |
40 | 40 | } |
41 | 41 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | try { |
57 | 57 | $sth = $this->db->prepare($query); |
58 | 58 | $sth->execute(array(':filter_name' => $filter_name)); |
59 | - } catch(PDOException $e) { |
|
59 | + } catch (PDOException $e) { |
|
60 | 60 | return "error : ".$e->getMessage(); |
61 | 61 | } |
62 | 62 | } |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | try { |
70 | 70 | $sth = $this->db->prepare($query); |
71 | 71 | $sth->execute(); |
72 | - } catch(PDOException $e) { |
|
72 | + } catch (PDOException $e) { |
|
73 | 73 | return "error : ".$e->getMessage(); |
74 | 74 | } |
75 | 75 | $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
76 | 76 | try { |
77 | 77 | $sth = $this->db->prepare($query); |
78 | 78 | $sth->execute(array(':filter_name' => $filter_name)); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error : ".$e->getMessage(); |
81 | 81 | } |
82 | 82 | } |
@@ -88,77 +88,77 @@ discard block |
||
88 | 88 | try { |
89 | 89 | $sth = $this->db->prepare($query); |
90 | 90 | $sth->execute(array(':filter_name' => $filter_name)); |
91 | - } catch(PDOException $e) { |
|
91 | + } catch (PDOException $e) { |
|
92 | 92 | echo "error : ".$e->getMessage(); |
93 | 93 | } |
94 | 94 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
95 | 95 | if (empty($all)) { |
96 | 96 | $filters = array(); |
97 | 97 | if ($filter_name != '') { |
98 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
98 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
99 | 99 | } |
100 | 100 | $Spotter = new Spotter($this->db); |
101 | - $all = $Spotter->getAllAirlineNames('',NULL,$filters); |
|
101 | + $all = $Spotter->getAllAirlineNames('', NULL, $filters); |
|
102 | 102 | } |
103 | 103 | return $all; |
104 | 104 | } |
105 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
105 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
106 | 106 | if ($filter_name == '') $filter_name = $this->filter_name; |
107 | 107 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
108 | 108 | try { |
109 | 109 | $sth = $this->db->prepare($query); |
110 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
111 | - } catch(PDOException $e) { |
|
110 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
111 | + } catch (PDOException $e) { |
|
112 | 112 | echo "error : ".$e->getMessage(); |
113 | 113 | } |
114 | 114 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
115 | 115 | return $all; |
116 | 116 | } |
117 | - public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
|
117 | + public function getAllManufacturers($stats_airline = '', $filter_name = '') { |
|
118 | 118 | if ($filter_name == '') $filter_name = $this->filter_name; |
119 | 119 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
120 | 120 | try { |
121 | 121 | $sth = $this->db->prepare($query); |
122 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
123 | - } catch(PDOException $e) { |
|
122 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
123 | + } catch (PDOException $e) { |
|
124 | 124 | echo "error : ".$e->getMessage(); |
125 | 125 | } |
126 | 126 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
127 | 127 | return $all; |
128 | 128 | } |
129 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
129 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
130 | 130 | if ($filter_name == '') $filter_name = $this->filter_name; |
131 | 131 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
132 | 132 | try { |
133 | 133 | $sth = $this->db->prepare($query); |
134 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
135 | - } catch(PDOException $e) { |
|
134 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
135 | + } catch (PDOException $e) { |
|
136 | 136 | echo "error : ".$e->getMessage(); |
137 | 137 | } |
138 | 138 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
139 | 139 | return $all; |
140 | 140 | } |
141 | 141 | |
142 | - public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
|
142 | + public function getAllOwnerNames($stats_airline = '', $filter_name = '') { |
|
143 | 143 | if ($filter_name == '') $filter_name = $this->filter_name; |
144 | 144 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
145 | 145 | try { |
146 | 146 | $sth = $this->db->prepare($query); |
147 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
148 | - } catch(PDOException $e) { |
|
147 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
148 | + } catch (PDOException $e) { |
|
149 | 149 | echo "error : ".$e->getMessage(); |
150 | 150 | } |
151 | 151 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
152 | 152 | return $all; |
153 | 153 | } |
154 | 154 | |
155 | - public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
|
155 | + public function getAllPilotNames($stats_airline = '', $filter_name = '') { |
|
156 | 156 | if ($filter_name == '') $filter_name = $this->filter_name; |
157 | 157 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
158 | 158 | try { |
159 | 159 | $sth = $this->db->prepare($query); |
160 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
161 | - } catch(PDOException $e) { |
|
160 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
161 | + } catch (PDOException $e) { |
|
162 | 162 | echo "error : ".$e->getMessage(); |
163 | 163 | } |
164 | 164 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -166,23 +166,23 @@ discard block |
||
166 | 166 | } |
167 | 167 | |
168 | 168 | |
169 | - public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
169 | + public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
170 | 170 | global $globalStatsFilters; |
171 | 171 | if ($filter_name == '') $filter_name = $this->filter_name; |
172 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
172 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
173 | 173 | $Spotter = new Spotter($this->db); |
174 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
174 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
175 | 175 | $alliance_airlines = array(); |
176 | 176 | foreach ($airlines as $airline) { |
177 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
177 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
178 | 178 | } |
179 | 179 | if ($year == '' && $month == '') { |
180 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
181 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
180 | + if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
181 | + else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
182 | 182 | try { |
183 | 183 | $sth = $this->db->prepare($query); |
184 | 184 | $sth->execute(array(':filter_name' => $filter_name)); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch (PDOException $e) { |
|
186 | 186 | echo "error : ".$e->getMessage(); |
187 | 187 | } |
188 | 188 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -193,29 +193,29 @@ discard block |
||
193 | 193 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
194 | 194 | try { |
195 | 195 | $sth = $this->db->prepare($query); |
196 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
197 | - } catch(PDOException $e) { |
|
196 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
197 | + } catch (PDOException $e) { |
|
198 | 198 | echo "error : ".$e->getMessage(); |
199 | 199 | } |
200 | 200 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
201 | 201 | } else $all = array(); |
202 | 202 | } |
203 | 203 | if (empty($all)) { |
204 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
205 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
204 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
205 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
206 | 206 | } else { |
207 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
207 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
208 | 208 | } |
209 | 209 | if ($filter_name != '') { |
210 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
210 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
211 | 211 | } |
212 | 212 | $Spotter = new Spotter($this->db); |
213 | 213 | //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
214 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
214 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters); |
|
215 | 215 | } |
216 | 216 | return $all; |
217 | 217 | } |
218 | - public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
|
218 | + public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
219 | 219 | global $globalStatsFilters; |
220 | 220 | if ($filter_name == '') $filter_name = $this->filter_name; |
221 | 221 | if ($year == '' && $month == '') { |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | try { |
225 | 225 | $sth = $this->db->prepare($query); |
226 | 226 | $sth->execute(array(':filter_name' => $filter_name)); |
227 | - } catch(PDOException $e) { |
|
227 | + } catch (PDOException $e) { |
|
228 | 228 | echo "error : ".$e->getMessage(); |
229 | 229 | } |
230 | 230 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -232,32 +232,32 @@ discard block |
||
232 | 232 | if (empty($all)) { |
233 | 233 | $Spotter = new Spotter($this->db); |
234 | 234 | $filters = array(); |
235 | - $filters = array('year' => $year,'month' => $month); |
|
235 | + $filters = array('year' => $year, 'month' => $month); |
|
236 | 236 | if ($filter_name != '') { |
237 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
237 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
238 | 238 | } |
239 | 239 | //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
240 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
240 | + $all = $Spotter->countAllAirlineCountries($limit, $filters); |
|
241 | 241 | } |
242 | 242 | return $all; |
243 | 243 | } |
244 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
244 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
245 | 245 | global $globalStatsFilters; |
246 | 246 | if ($filter_name == '') $filter_name = $this->filter_name; |
247 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
247 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
248 | 248 | $Spotter = new Spotter($this->db); |
249 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
249 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
250 | 250 | $alliance_airlines = array(); |
251 | 251 | foreach ($airlines as $airline) { |
252 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
252 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
253 | 253 | } |
254 | 254 | if ($year == '' && $month == '') { |
255 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
256 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
255 | + if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
256 | + else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
257 | 257 | try { |
258 | 258 | $sth = $this->db->prepare($query); |
259 | 259 | $sth->execute(array(':filter_name' => $filter_name)); |
260 | - } catch(PDOException $e) { |
|
260 | + } catch (PDOException $e) { |
|
261 | 261 | echo "error : ".$e->getMessage(); |
262 | 262 | } |
263 | 263 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -268,21 +268,21 @@ discard block |
||
268 | 268 | else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
269 | 269 | try { |
270 | 270 | $sth = $this->db->prepare($query); |
271 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
272 | - } catch(PDOException $e) { |
|
271 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
272 | + } catch (PDOException $e) { |
|
273 | 273 | echo "error : ".$e->getMessage(); |
274 | 274 | } |
275 | 275 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
276 | 276 | } else $all = array(); |
277 | 277 | } |
278 | 278 | if (empty($all)) { |
279 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
280 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
279 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
280 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
281 | 281 | } else { |
282 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
282 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
283 | 283 | } |
284 | 284 | if ($filter_name != '') { |
285 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
285 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
286 | 286 | } |
287 | 287 | $Spotter = new Spotter($this->db); |
288 | 288 | //$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month); |
@@ -291,23 +291,23 @@ discard block |
||
291 | 291 | return $all; |
292 | 292 | } |
293 | 293 | |
294 | - public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
294 | + public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
295 | 295 | global $globalStatsFilters; |
296 | 296 | if ($filter_name == '') $filter_name = $this->filter_name; |
297 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
297 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
298 | 298 | $Spotter = new Spotter($this->db); |
299 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
299 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
300 | 300 | $alliance_airlines = array(); |
301 | 301 | foreach ($airlines as $airline) { |
302 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
302 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
303 | 303 | } |
304 | 304 | if ($year == '' && $month == '') { |
305 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
306 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
305 | + if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
306 | + else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
307 | 307 | try { |
308 | 308 | $sth = $this->db->prepare($query); |
309 | 309 | $sth->execute(array(':filter_name' => $filter_name)); |
310 | - } catch(PDOException $e) { |
|
310 | + } catch (PDOException $e) { |
|
311 | 311 | echo "error : ".$e->getMessage(); |
312 | 312 | } |
313 | 313 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -318,61 +318,61 @@ discard block |
||
318 | 318 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
319 | 319 | try { |
320 | 320 | $sth = $this->db->prepare($query); |
321 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
322 | - } catch(PDOException $e) { |
|
321 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
322 | + } catch (PDOException $e) { |
|
323 | 323 | echo "error : ".$e->getMessage(); |
324 | 324 | } |
325 | 325 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
326 | 326 | } else $all = array(); |
327 | 327 | } |
328 | 328 | if (empty($all)) { |
329 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
330 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
329 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
330 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
331 | 331 | } else { |
332 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
332 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
333 | 333 | } |
334 | 334 | if ($filter_name != '') { |
335 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
335 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
336 | 336 | } |
337 | 337 | $Spotter = new Spotter($this->db); |
338 | 338 | //$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
339 | - $all = $Spotter->countAllArrivalCountries($limit,$filters); |
|
339 | + $all = $Spotter->countAllArrivalCountries($limit, $filters); |
|
340 | 340 | } |
341 | 341 | return $all; |
342 | 342 | } |
343 | 343 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
344 | 344 | global $globalStatsFilters; |
345 | 345 | if ($filter_name == '') $filter_name = $this->filter_name; |
346 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
346 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
347 | 347 | $Spotter = new Spotter($this->db); |
348 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
348 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
349 | 349 | $alliance_airlines = array(); |
350 | 350 | foreach ($airlines as $airline) { |
351 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
351 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
352 | 352 | } |
353 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
354 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
353 | + if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
354 | + else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
355 | 355 | $query_values = array(':filter_name' => $filter_name); |
356 | 356 | } else { |
357 | 357 | if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
358 | 358 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
359 | - $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
359 | + $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
360 | 360 | } |
361 | 361 | try { |
362 | 362 | $sth = $this->db->prepare($query); |
363 | 363 | $sth->execute($query_values); |
364 | - } catch(PDOException $e) { |
|
364 | + } catch (PDOException $e) { |
|
365 | 365 | echo "error : ".$e->getMessage(); |
366 | 366 | } |
367 | 367 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
368 | 368 | if (empty($all)) { |
369 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
370 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
369 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
370 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
371 | 371 | } else { |
372 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
372 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
373 | 373 | } |
374 | 374 | if ($filter_name != '') { |
375 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
375 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
376 | 376 | } |
377 | 377 | $Spotter = new Spotter($this->db); |
378 | 378 | //$all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | return $all; |
382 | 382 | } |
383 | 383 | |
384 | - public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
|
384 | + public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') { |
|
385 | 385 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
386 | 386 | if ($filter_name == '') $filter_name = $this->filter_name; |
387 | 387 | if ($year == '' && $month == '') { |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | if (isset($forsource)) { |
391 | 391 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
392 | 392 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
393 | - $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
|
393 | + $query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource); |
|
394 | 394 | } else { |
395 | 395 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
396 | 396 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | try { |
400 | 400 | $sth = $this->db->prepare($query); |
401 | 401 | $sth->execute($query_values); |
402 | - } catch(PDOException $e) { |
|
402 | + } catch (PDOException $e) { |
|
403 | 403 | echo "error : ".$e->getMessage(); |
404 | 404 | } |
405 | 405 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -407,32 +407,32 @@ discard block |
||
407 | 407 | if (empty($all)) { |
408 | 408 | $Spotter = new Spotter($this->db); |
409 | 409 | $filters = array(); |
410 | - $filters = array('year' => $year,'month' => $month); |
|
410 | + $filters = array('year' => $year, 'month' => $month); |
|
411 | 411 | if ($filter_name != '') { |
412 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
412 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
413 | 413 | } |
414 | 414 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
415 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
415 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters); |
|
416 | 416 | } |
417 | 417 | return $all; |
418 | 418 | } |
419 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
419 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
420 | 420 | global $globalStatsFilters; |
421 | 421 | if ($filter_name == '') $filter_name = $this->filter_name; |
422 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
422 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
423 | 423 | $Spotter = new Spotter($this->db); |
424 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
424 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
425 | 425 | $alliance_airlines = array(); |
426 | 426 | foreach ($airlines as $airline) { |
427 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
427 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
428 | 428 | } |
429 | 429 | if ($year == '' && $month == '') { |
430 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
431 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
430 | + if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
431 | + else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
432 | 432 | try { |
433 | 433 | $sth = $this->db->prepare($query); |
434 | 434 | $sth->execute(array(':filter_name' => $filter_name)); |
435 | - } catch(PDOException $e) { |
|
435 | + } catch (PDOException $e) { |
|
436 | 436 | echo "error : ".$e->getMessage(); |
437 | 437 | } |
438 | 438 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -443,45 +443,45 @@ discard block |
||
443 | 443 | else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
444 | 444 | try { |
445 | 445 | $sth = $this->db->prepare($query); |
446 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
447 | - } catch(PDOException $e) { |
|
446 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
447 | + } catch (PDOException $e) { |
|
448 | 448 | echo "error : ".$e->getMessage(); |
449 | 449 | } |
450 | 450 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
451 | 451 | } else $all = array(); |
452 | 452 | } |
453 | 453 | if (empty($all)) { |
454 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
455 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
454 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
455 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
456 | 456 | } else { |
457 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
457 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
458 | 458 | } |
459 | 459 | if ($filter_name != '') { |
460 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
460 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
461 | 461 | } |
462 | 462 | $Spotter = new Spotter($this->db); |
463 | 463 | //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
464 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
464 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters); |
|
465 | 465 | } |
466 | 466 | return $all; |
467 | 467 | } |
468 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
468 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
469 | 469 | global $globalStatsFilters; |
470 | 470 | if ($filter_name == '') $filter_name = $this->filter_name; |
471 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
471 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
472 | 472 | $Spotter = new Spotter($this->db); |
473 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
473 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
474 | 474 | $alliance_airlines = array(); |
475 | 475 | foreach ($airlines as $airline) { |
476 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
476 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
477 | 477 | } |
478 | 478 | if ($year == '' && $month == '') { |
479 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
480 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
479 | + if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
480 | + else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
481 | 481 | try { |
482 | 482 | $sth = $this->db->prepare($query); |
483 | 483 | $sth->execute(array(':filter_name' => $filter_name)); |
484 | - } catch(PDOException $e) { |
|
484 | + } catch (PDOException $e) { |
|
485 | 485 | echo "error : ".$e->getMessage(); |
486 | 486 | } |
487 | 487 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -492,46 +492,46 @@ discard block |
||
492 | 492 | else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
493 | 493 | try { |
494 | 494 | $sth = $this->db->prepare($query); |
495 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
496 | - } catch(PDOException $e) { |
|
495 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
496 | + } catch (PDOException $e) { |
|
497 | 497 | echo "error : ".$e->getMessage(); |
498 | 498 | } |
499 | 499 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
500 | 500 | } else $all = array(); |
501 | 501 | } |
502 | 502 | if (empty($all)) { |
503 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
504 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
503 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
504 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
505 | 505 | } else { |
506 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
506 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
507 | 507 | } |
508 | 508 | if ($filter_name != '') { |
509 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
509 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
510 | 510 | } |
511 | 511 | $Spotter = new Spotter($this->db); |
512 | 512 | //$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month); |
513 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters); |
|
513 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters); |
|
514 | 514 | } |
515 | 515 | return $all; |
516 | 516 | } |
517 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
517 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
518 | 518 | $Connection = new Connection(); |
519 | 519 | if ($filter_name == '') $filter_name = $this->filter_name; |
520 | 520 | if ($Connection->tableExists('countries')) { |
521 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
521 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
522 | 522 | $Spotter = new Spotter($this->db); |
523 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
523 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
524 | 524 | if ($year == '' && $month == '') { |
525 | 525 | $alliance_airlines = array(); |
526 | 526 | foreach ($airlines as $airline) { |
527 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
527 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
528 | 528 | } |
529 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
530 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
529 | + if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
530 | + else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
531 | 531 | try { |
532 | 532 | $sth = $this->db->prepare($query); |
533 | 533 | $sth->execute(array(':filter_name' => $filter_name)); |
534 | - } catch(PDOException $e) { |
|
534 | + } catch (PDOException $e) { |
|
535 | 535 | echo "error : ".$e->getMessage(); |
536 | 536 | } |
537 | 537 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -543,8 +543,8 @@ discard block |
||
543 | 543 | else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
544 | 544 | try { |
545 | 545 | $sth = $this->db->prepare($query); |
546 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
547 | - } catch(PDOException $e) { |
|
546 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
547 | + } catch (PDOException $e) { |
|
548 | 548 | echo "error : ".$e->getMessage(); |
549 | 549 | } |
550 | 550 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | return array(); |
562 | 562 | } |
563 | 563 | } |
564 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
|
564 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
565 | 565 | global $globalStatsFilters; |
566 | 566 | if ($filter_name == '') $filter_name = $this->filter_name; |
567 | 567 | if ($year == '' && $month == '') { |
@@ -569,41 +569,41 @@ discard block |
||
569 | 569 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
570 | 570 | try { |
571 | 571 | $sth = $this->db->prepare($query); |
572 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
573 | - } catch(PDOException $e) { |
|
572 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
573 | + } catch (PDOException $e) { |
|
574 | 574 | echo "error : ".$e->getMessage(); |
575 | 575 | } |
576 | 576 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
577 | 577 | } else $all = array(); |
578 | 578 | if (empty($all)) { |
579 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
579 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
580 | 580 | if ($filter_name != '') { |
581 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
581 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
582 | 582 | } |
583 | 583 | $Spotter = new Spotter($this->db); |
584 | 584 | //$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month); |
585 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
585 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters); |
|
586 | 586 | } |
587 | 587 | return $all; |
588 | 588 | } |
589 | 589 | |
590 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
590 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
591 | 591 | global $globalStatsFilters; |
592 | 592 | if ($filter_name == '') $filter_name = $this->filter_name; |
593 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
593 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
594 | 594 | $Spotter = new Spotter($this->db); |
595 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
595 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
596 | 596 | if ($year == '' && $month == '') { |
597 | 597 | $alliance_airlines = array(); |
598 | 598 | foreach ($airlines as $airline) { |
599 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
599 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
600 | 600 | } |
601 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
602 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
601 | + if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
602 | + else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
603 | 603 | try { |
604 | 604 | $sth = $this->db->prepare($query); |
605 | 605 | $sth->execute(array(':filter_name' => $filter_name)); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | echo "error : ".$e->getMessage(); |
608 | 608 | } |
609 | 609 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -614,45 +614,45 @@ discard block |
||
614 | 614 | else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
615 | 615 | try { |
616 | 616 | $sth = $this->db->prepare($query); |
617 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
618 | - } catch(PDOException $e) { |
|
617 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
618 | + } catch (PDOException $e) { |
|
619 | 619 | echo "error : ".$e->getMessage(); |
620 | 620 | } |
621 | 621 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
622 | 622 | } else $all = array(); |
623 | 623 | } |
624 | 624 | if (empty($all)) { |
625 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
626 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
625 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
626 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
627 | 627 | } else { |
628 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
628 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
629 | 629 | } |
630 | 630 | if ($filter_name != '') { |
631 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
631 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
632 | 632 | } |
633 | 633 | $Spotter = new Spotter($this->db); |
634 | 634 | //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
635 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
635 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters); |
|
636 | 636 | } |
637 | 637 | return $all; |
638 | 638 | } |
639 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
639 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
640 | 640 | global $globalStatsFilters; |
641 | 641 | if ($filter_name == '') $filter_name = $this->filter_name; |
642 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
642 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
643 | 643 | $Spotter = new Spotter($this->db); |
644 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
644 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
645 | 645 | if ($year == '' && $month == '') { |
646 | 646 | $alliance_airlines = array(); |
647 | 647 | foreach ($airlines as $airline) { |
648 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
648 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
649 | 649 | } |
650 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
651 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
650 | + if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
651 | + else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
652 | 652 | try { |
653 | 653 | $sth = $this->db->prepare($query); |
654 | 654 | $sth->execute(array(':filter_name' => $filter_name)); |
655 | - } catch(PDOException $e) { |
|
655 | + } catch (PDOException $e) { |
|
656 | 656 | echo "error : ".$e->getMessage(); |
657 | 657 | } |
658 | 658 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -663,27 +663,27 @@ discard block |
||
663 | 663 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
664 | 664 | try { |
665 | 665 | $sth = $this->db->prepare($query); |
666 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
667 | - } catch(PDOException $e) { |
|
666 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
667 | + } catch (PDOException $e) { |
|
668 | 668 | echo "error : ".$e->getMessage(); |
669 | 669 | } |
670 | 670 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
671 | 671 | } else $all = array(); |
672 | 672 | } |
673 | 673 | if (empty($all)) { |
674 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
675 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
674 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
675 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
676 | 676 | } else { |
677 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
677 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
678 | 678 | } |
679 | 679 | if ($filter_name != '') { |
680 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
680 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
681 | 681 | } |
682 | 682 | $Spotter = new Spotter($this->db); |
683 | 683 | // $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
684 | 684 | // $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
685 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
686 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
685 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters); |
|
686 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters); |
|
687 | 687 | $all = array(); |
688 | 688 | foreach ($pall as $value) { |
689 | 689 | $icao = $value['airport_departure_icao']; |
@@ -699,27 +699,27 @@ discard block |
||
699 | 699 | foreach ($all as $key => $row) { |
700 | 700 | $count[$key] = $row['airport_departure_icao_count']; |
701 | 701 | } |
702 | - array_multisort($count,SORT_DESC,$all); |
|
702 | + array_multisort($count, SORT_DESC, $all); |
|
703 | 703 | } |
704 | 704 | return $all; |
705 | 705 | } |
706 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
706 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
707 | 707 | global $globalStatsFilters; |
708 | 708 | if ($filter_name == '') $filter_name = $this->filter_name; |
709 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
709 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
710 | 710 | $Spotter = new Spotter($this->db); |
711 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
711 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
712 | 712 | if ($year == '' && $month == '') { |
713 | 713 | $alliance_airlines = array(); |
714 | 714 | foreach ($airlines as $airline) { |
715 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
715 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
716 | 716 | } |
717 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
718 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
717 | + if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
718 | + else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
719 | 719 | try { |
720 | 720 | $sth = $this->db->prepare($query); |
721 | 721 | $sth->execute(array(':filter_name' => $filter_name)); |
722 | - } catch(PDOException $e) { |
|
722 | + } catch (PDOException $e) { |
|
723 | 723 | echo "error : ".$e->getMessage(); |
724 | 724 | } |
725 | 725 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -730,27 +730,27 @@ discard block |
||
730 | 730 | else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
731 | 731 | try { |
732 | 732 | $sth = $this->db->prepare($query); |
733 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
734 | - } catch(PDOException $e) { |
|
733 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
734 | + } catch (PDOException $e) { |
|
735 | 735 | echo "error : ".$e->getMessage(); |
736 | 736 | } |
737 | 737 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
738 | 738 | } else $all = array(); |
739 | 739 | } |
740 | 740 | if (empty($all)) { |
741 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
742 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
741 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
742 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
743 | 743 | } else { |
744 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
744 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
745 | 745 | } |
746 | 746 | if ($filter_name != '') { |
747 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
747 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
748 | 748 | } |
749 | 749 | $Spotter = new Spotter($this->db); |
750 | 750 | // $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month); |
751 | 751 | // $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
752 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
|
753 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
|
752 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters); |
|
753 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters); |
|
754 | 754 | $all = array(); |
755 | 755 | foreach ($pall as $value) { |
756 | 756 | $icao = $value['airport_arrival_icao']; |
@@ -766,26 +766,26 @@ discard block |
||
766 | 766 | foreach ($all as $key => $row) { |
767 | 767 | $count[$key] = $row['airport_arrival_icao_count']; |
768 | 768 | } |
769 | - array_multisort($count,SORT_DESC,$all); |
|
769 | + array_multisort($count, SORT_DESC, $all); |
|
770 | 770 | } |
771 | 771 | return $all; |
772 | 772 | } |
773 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
773 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
774 | 774 | global $globalDBdriver, $globalStatsFilters; |
775 | 775 | if ($filter_name == '') $filter_name = $this->filter_name; |
776 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
776 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
777 | 777 | $Spotter = new Spotter($this->db); |
778 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
778 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
779 | 779 | $alliance_airlines = array(); |
780 | 780 | foreach ($airlines as $airline) { |
781 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
781 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
782 | 782 | } |
783 | 783 | if ($globalDBdriver == 'mysql') { |
784 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
785 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
784 | + if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
785 | + else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
786 | 786 | } else { |
787 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
788 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
787 | + if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
788 | + else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
789 | 789 | } |
790 | 790 | $query_data = array(':filter_name' => $filter_name); |
791 | 791 | } else { |
@@ -796,23 +796,23 @@ discard block |
||
796 | 796 | if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
797 | 797 | else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
798 | 798 | } |
799 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
799 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
800 | 800 | } |
801 | 801 | try { |
802 | 802 | $sth = $this->db->prepare($query); |
803 | 803 | $sth->execute($query_data); |
804 | - } catch(PDOException $e) { |
|
804 | + } catch (PDOException $e) { |
|
805 | 805 | echo "error : ".$e->getMessage(); |
806 | 806 | } |
807 | 807 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
808 | 808 | if (empty($all)) { |
809 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
810 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
809 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
810 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
811 | 811 | } else { |
812 | 812 | $filters = array('airlines' => array($stats_airline)); |
813 | 813 | } |
814 | 814 | if ($filter_name != '') { |
815 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
815 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
816 | 816 | } |
817 | 817 | $Spotter = new Spotter($this->db); |
818 | 818 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -820,57 +820,57 @@ discard block |
||
820 | 820 | return $all; |
821 | 821 | } |
822 | 822 | |
823 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
823 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
824 | 824 | global $globalStatsFilters; |
825 | 825 | if ($filter_name == '') $filter_name = $this->filter_name; |
826 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
826 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
827 | 827 | $Spotter = new Spotter($this->db); |
828 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
828 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
829 | 829 | $alliance_airlines = array(); |
830 | 830 | foreach ($airlines as $airline) { |
831 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
831 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
832 | 832 | } |
833 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
833 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
834 | 834 | $query_data = array(':filter_name' => $filter_name); |
835 | 835 | } else { |
836 | 836 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
837 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
837 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
838 | 838 | } |
839 | 839 | try { |
840 | 840 | $sth = $this->db->prepare($query); |
841 | 841 | $sth->execute($query_data); |
842 | - } catch(PDOException $e) { |
|
842 | + } catch (PDOException $e) { |
|
843 | 843 | echo "error : ".$e->getMessage(); |
844 | 844 | } |
845 | 845 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
846 | 846 | if (empty($all)) { |
847 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
848 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
847 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
848 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
849 | 849 | } else { |
850 | 850 | $filters = array('airlines' => array($stats_airline)); |
851 | 851 | } |
852 | 852 | if ($filter_name != '') { |
853 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
853 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
854 | 854 | } |
855 | 855 | $Spotter = new Spotter($this->db); |
856 | 856 | $all = $Spotter->countAllDatesLastMonth($filters); |
857 | 857 | } |
858 | 858 | return $all; |
859 | 859 | } |
860 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
860 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
861 | 861 | global $globalDBdriver, $globalStatsFilters; |
862 | 862 | if ($filter_name == '') $filter_name = $this->filter_name; |
863 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
863 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
864 | 864 | $Spotter = new Spotter($this->db); |
865 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
865 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
866 | 866 | $alliance_airlines = array(); |
867 | 867 | foreach ($airlines as $airline) { |
868 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
868 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
869 | 869 | } |
870 | 870 | if ($globalDBdriver == 'mysql') { |
871 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
871 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
872 | 872 | } else { |
873 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
873 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
874 | 874 | } |
875 | 875 | $query_data = array(':filter_name' => $filter_name); |
876 | 876 | } else { |
@@ -879,60 +879,60 @@ discard block |
||
879 | 879 | } else { |
880 | 880 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
881 | 881 | } |
882 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
882 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
883 | 883 | } |
884 | 884 | try { |
885 | 885 | $sth = $this->db->prepare($query); |
886 | 886 | $sth->execute($query_data); |
887 | - } catch(PDOException $e) { |
|
887 | + } catch (PDOException $e) { |
|
888 | 888 | echo "error : ".$e->getMessage(); |
889 | 889 | } |
890 | 890 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
891 | 891 | if (empty($all)) { |
892 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
893 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
892 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
893 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
894 | 894 | } else { |
895 | 895 | $filters = array('airlines' => array($stats_airline)); |
896 | 896 | } |
897 | 897 | if ($filter_name != '') { |
898 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
898 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
899 | 899 | } |
900 | 900 | $Spotter = new Spotter($this->db); |
901 | 901 | $all = $Spotter->countAllDatesLast7Days($filters); |
902 | 902 | } |
903 | 903 | return $all; |
904 | 904 | } |
905 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
905 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
906 | 906 | global $globalStatsFilters; |
907 | 907 | if ($filter_name == '') $filter_name = $this->filter_name; |
908 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
908 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
909 | 909 | $Spotter = new Spotter($this->db); |
910 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
910 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
911 | 911 | $alliance_airlines = array(); |
912 | 912 | foreach ($airlines as $airline) { |
913 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
913 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
914 | 914 | } |
915 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC"; |
|
915 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC"; |
|
916 | 916 | $query_data = array(':filter_name' => $filter_name); |
917 | 917 | } else { |
918 | 918 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC"; |
919 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
919 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
920 | 920 | } |
921 | 921 | try { |
922 | 922 | $sth = $this->db->prepare($query); |
923 | 923 | $sth->execute($query_data); |
924 | - } catch(PDOException $e) { |
|
924 | + } catch (PDOException $e) { |
|
925 | 925 | echo "error : ".$e->getMessage(); |
926 | 926 | } |
927 | 927 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
928 | 928 | if (empty($all)) { |
929 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
930 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
929 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
930 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
931 | 931 | } else { |
932 | 932 | $filters = array('airlines' => array($stats_airline)); |
933 | 933 | } |
934 | 934 | if ($filter_name != '') { |
935 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
935 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
936 | 936 | } |
937 | 937 | $Spotter = new Spotter($this->db); |
938 | 938 | $all = $Spotter->countAllDates($filters); |
@@ -947,34 +947,34 @@ discard block |
||
947 | 947 | try { |
948 | 948 | $sth = $this->db->prepare($query); |
949 | 949 | $sth->execute($query_data); |
950 | - } catch(PDOException $e) { |
|
950 | + } catch (PDOException $e) { |
|
951 | 951 | echo "error : ".$e->getMessage(); |
952 | 952 | } |
953 | 953 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
954 | 954 | if (empty($all)) { |
955 | 955 | $filters = array(); |
956 | 956 | if ($filter_name != '') { |
957 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
957 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
958 | 958 | } |
959 | 959 | $Spotter = new Spotter($this->db); |
960 | 960 | $all = $Spotter->countAllDatesByAirlines($filters); |
961 | 961 | } |
962 | 962 | return $all; |
963 | 963 | } |
964 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
964 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
965 | 965 | global $globalStatsFilters, $globalDBdriver; |
966 | 966 | if ($filter_name == '') $filter_name = $this->filter_name; |
967 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
967 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
968 | 968 | $Spotter = new Spotter($this->db); |
969 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
969 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
970 | 970 | $alliance_airlines = array(); |
971 | 971 | foreach ($airlines as $airline) { |
972 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
972 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
973 | 973 | } |
974 | 974 | if ($globalDBdriver == 'mysql') { |
975 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
975 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
976 | 976 | } else { |
977 | - $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
977 | + $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
978 | 978 | } |
979 | 979 | $query_data = array(':filter_name' => $filter_name); |
980 | 980 | } else { |
@@ -988,18 +988,18 @@ discard block |
||
988 | 988 | try { |
989 | 989 | $sth = $this->db->prepare($query); |
990 | 990 | $sth->execute($query_data); |
991 | - } catch(PDOException $e) { |
|
991 | + } catch (PDOException $e) { |
|
992 | 992 | echo "error : ".$e->getMessage(); |
993 | 993 | } |
994 | 994 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
995 | 995 | if (empty($all)) { |
996 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
997 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
996 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
997 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
998 | 998 | } else { |
999 | 999 | $filters = array('airlines' => array($stats_airline)); |
1000 | 1000 | } |
1001 | 1001 | if ($filter_name != '') { |
1002 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1002 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1003 | 1003 | } |
1004 | 1004 | $Spotter = new Spotter($this->db); |
1005 | 1005 | $all = $Spotter->countAllMonths($filters); |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | try { |
1017 | 1017 | $sth = $this->db->prepare($query); |
1018 | 1018 | $sth->execute(); |
1019 | - } catch(PDOException $e) { |
|
1019 | + } catch (PDOException $e) { |
|
1020 | 1020 | echo "error : ".$e->getMessage(); |
1021 | 1021 | } |
1022 | 1022 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | try { |
1037 | 1037 | $sth = $this->db->prepare($query); |
1038 | 1038 | $sth->execute(); |
1039 | - } catch(PDOException $e) { |
|
1039 | + } catch (PDOException $e) { |
|
1040 | 1040 | echo "error : ".$e->getMessage(); |
1041 | 1041 | } |
1042 | 1042 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1053,32 +1053,32 @@ discard block |
||
1053 | 1053 | try { |
1054 | 1054 | $sth = $this->db->prepare($query); |
1055 | 1055 | $sth->execute(array(':filter_name' => $filter_name)); |
1056 | - } catch(PDOException $e) { |
|
1056 | + } catch (PDOException $e) { |
|
1057 | 1057 | echo "error : ".$e->getMessage(); |
1058 | 1058 | } |
1059 | 1059 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1060 | 1060 | if (empty($all)) { |
1061 | 1061 | $filters = array(); |
1062 | 1062 | if ($filter_name != '') { |
1063 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1063 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1064 | 1064 | } |
1065 | 1065 | $Spotter = new Spotter($this->db); |
1066 | 1066 | $all = $Spotter->countAllMilitaryMonths($filters); |
1067 | 1067 | } |
1068 | 1068 | return $all; |
1069 | 1069 | } |
1070 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
1070 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
1071 | 1071 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
1072 | 1072 | if ($filter_name == '') $filter_name = $this->filter_name; |
1073 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1073 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1074 | 1074 | $Spotter = new Spotter($this->db); |
1075 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1075 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1076 | 1076 | $alliance_airlines = array(); |
1077 | 1077 | foreach ($airlines as $airline) { |
1078 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1078 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1079 | 1079 | } |
1080 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1081 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1080 | + if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1081 | + else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1082 | 1082 | $query_data = array(':filter_name' => $filter_name); |
1083 | 1083 | } else { |
1084 | 1084 | if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1096,37 +1096,37 @@ discard block |
||
1096 | 1096 | try { |
1097 | 1097 | $sth = $this->db->prepare($query); |
1098 | 1098 | $sth->execute($query_data); |
1099 | - } catch(PDOException $e) { |
|
1099 | + } catch (PDOException $e) { |
|
1100 | 1100 | echo "error : ".$e->getMessage(); |
1101 | 1101 | } |
1102 | 1102 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1103 | 1103 | if (empty($all)) { |
1104 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1105 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1104 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1105 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1106 | 1106 | } else { |
1107 | 1107 | $filters = array('airlines' => array($stats_airline)); |
1108 | 1108 | } |
1109 | 1109 | if ($filter_name != '') { |
1110 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1110 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1111 | 1111 | } |
1112 | 1112 | $Spotter = new Spotter($this->db); |
1113 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
1113 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
1114 | 1114 | } |
1115 | 1115 | return $all; |
1116 | 1116 | } |
1117 | - public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
1117 | + public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
1118 | 1118 | global $globalStatsFilters; |
1119 | 1119 | if ($filter_name == '') $filter_name = $this->filter_name; |
1120 | 1120 | if ($year == '') $year = date('Y'); |
1121 | - $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1121 | + $all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1122 | 1122 | if (empty($all)) { |
1123 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1124 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
1123 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1124 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
1125 | 1125 | } else { |
1126 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
1126 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
1127 | 1127 | } |
1128 | 1128 | if ($filter_name != '') { |
1129 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1129 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1130 | 1130 | } |
1131 | 1131 | $Spotter = new Spotter($this->db); |
1132 | 1132 | //$all = $Spotter->countOverallFlights($filters,$year,$month); |
@@ -1134,16 +1134,16 @@ discard block |
||
1134 | 1134 | } |
1135 | 1135 | return $all; |
1136 | 1136 | } |
1137 | - public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
|
1137 | + public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') { |
|
1138 | 1138 | global $globalStatsFilters; |
1139 | 1139 | if ($filter_name == '') $filter_name = $this->filter_name; |
1140 | 1140 | if ($year == '') $year = date('Y'); |
1141 | - $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
|
1141 | + $all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month); |
|
1142 | 1142 | if (empty($all)) { |
1143 | 1143 | $filters = array(); |
1144 | - $filters = array('year' => $year,'month' => $month); |
|
1144 | + $filters = array('year' => $year, 'month' => $month); |
|
1145 | 1145 | if ($filter_name != '') { |
1146 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1146 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1147 | 1147 | } |
1148 | 1148 | $Spotter = new Spotter($this->db); |
1149 | 1149 | //$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
@@ -1151,19 +1151,19 @@ discard block |
||
1151 | 1151 | } |
1152 | 1152 | return $all; |
1153 | 1153 | } |
1154 | - public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
|
1154 | + public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
1155 | 1155 | global $globalStatsFilters; |
1156 | 1156 | if ($filter_name == '') $filter_name = $this->filter_name; |
1157 | 1157 | if ($year == '') $year = date('Y'); |
1158 | - $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1158 | + $all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1159 | 1159 | if (empty($all)) { |
1160 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1161 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
1160 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1161 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
1162 | 1162 | } else { |
1163 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
1163 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
1164 | 1164 | } |
1165 | 1165 | if ($filter_name != '') { |
1166 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1166 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1167 | 1167 | } |
1168 | 1168 | $Spotter = new Spotter($this->db); |
1169 | 1169 | //$all = $Spotter->countOverallArrival($filters,$year,$month); |
@@ -1171,48 +1171,48 @@ discard block |
||
1171 | 1171 | } |
1172 | 1172 | return $all; |
1173 | 1173 | } |
1174 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
1174 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
1175 | 1175 | global $globalStatsFilters; |
1176 | 1176 | if ($filter_name == '') $filter_name = $this->filter_name; |
1177 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1177 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1178 | 1178 | $Spotter = new Spotter($this->db); |
1179 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1179 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1180 | 1180 | if ($year == '' && $month == '') { |
1181 | 1181 | $alliance_airlines = array(); |
1182 | 1182 | foreach ($airlines as $airline) { |
1183 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1183 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1184 | 1184 | } |
1185 | - $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1185 | + $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1186 | 1186 | try { |
1187 | 1187 | $sth = $this->db->prepare($query); |
1188 | 1188 | $sth->execute(array(':filter_name' => $filter_name)); |
1189 | - } catch(PDOException $e) { |
|
1189 | + } catch (PDOException $e) { |
|
1190 | 1190 | echo "error : ".$e->getMessage(); |
1191 | 1191 | } |
1192 | 1192 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1193 | 1193 | $all = $result[0]['nb']; |
1194 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1194 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1195 | 1195 | } else { |
1196 | 1196 | if ($year == '' && $month == '') { |
1197 | 1197 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
1198 | 1198 | try { |
1199 | 1199 | $sth = $this->db->prepare($query); |
1200 | - $sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline)); |
|
1201 | - } catch(PDOException $e) { |
|
1200 | + $sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline)); |
|
1201 | + } catch (PDOException $e) { |
|
1202 | 1202 | echo "error : ".$e->getMessage(); |
1203 | 1203 | } |
1204 | 1204 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1205 | 1205 | $all = $result[0]['nb']; |
1206 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1206 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1207 | 1207 | } |
1208 | 1208 | if (empty($all)) { |
1209 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1210 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
1209 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1210 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
1211 | 1211 | } else { |
1212 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
1212 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
1213 | 1213 | } |
1214 | 1214 | if ($filter_name != '') { |
1215 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1215 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1216 | 1216 | } |
1217 | 1217 | $Spotter = new Spotter($this->db); |
1218 | 1218 | //$all = $Spotter->countOverallAircrafts($filters,$year,$month); |
@@ -1220,7 +1220,7 @@ discard block |
||
1220 | 1220 | } |
1221 | 1221 | return $all; |
1222 | 1222 | } |
1223 | - public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
|
1223 | + public function countOverallAirlines($filter_name = '', $year = '', $month = '') { |
|
1224 | 1224 | global $globalStatsFilters; |
1225 | 1225 | if ($filter_name == '') $filter_name = $this->filter_name; |
1226 | 1226 | if ($year == '' && $month == '') { |
@@ -1228,17 +1228,17 @@ discard block |
||
1228 | 1228 | try { |
1229 | 1229 | $sth = $this->db->prepare($query); |
1230 | 1230 | $sth->execute(array(':filter_name' => $filter_name)); |
1231 | - } catch(PDOException $e) { |
|
1231 | + } catch (PDOException $e) { |
|
1232 | 1232 | echo "error : ".$e->getMessage(); |
1233 | 1233 | } |
1234 | 1234 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1235 | 1235 | $all = $result[0]['nb_airline']; |
1236 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1236 | + } else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month); |
|
1237 | 1237 | if (empty($all)) { |
1238 | 1238 | $filters = array(); |
1239 | - $filters = array('year' => $year,'month' => $month); |
|
1239 | + $filters = array('year' => $year, 'month' => $month); |
|
1240 | 1240 | if ($filter_name != '') { |
1241 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1241 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1242 | 1242 | } |
1243 | 1243 | $Spotter = new Spotter($this->db); |
1244 | 1244 | //$all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -1246,29 +1246,29 @@ discard block |
||
1246 | 1246 | } |
1247 | 1247 | return $all; |
1248 | 1248 | } |
1249 | - public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
1249 | + public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
1250 | 1250 | global $globalStatsFilters; |
1251 | 1251 | if ($filter_name == '') $filter_name = $this->filter_name; |
1252 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1252 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1253 | 1253 | $Spotter = new Spotter($this->db); |
1254 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1254 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1255 | 1255 | if ($year == '' && $month == '') { |
1256 | 1256 | $alliance_airlines = array(); |
1257 | 1257 | foreach ($airlines as $airline) { |
1258 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1258 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1259 | 1259 | } |
1260 | - $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1260 | + $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1261 | 1261 | $query_values = array(':filter_name' => $filter_name); |
1262 | 1262 | try { |
1263 | 1263 | $sth = $this->db->prepare($query); |
1264 | 1264 | $sth->execute($query_values); |
1265 | - } catch(PDOException $e) { |
|
1265 | + } catch (PDOException $e) { |
|
1266 | 1266 | echo "error : ".$e->getMessage(); |
1267 | 1267 | } |
1268 | 1268 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1269 | 1269 | $all = $result[0]['nb']; |
1270 | 1270 | } else { |
1271 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1271 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1272 | 1272 | } |
1273 | 1273 | } else { |
1274 | 1274 | if ($year == '' && $month == '') { |
@@ -1277,23 +1277,23 @@ discard block |
||
1277 | 1277 | try { |
1278 | 1278 | $sth = $this->db->prepare($query); |
1279 | 1279 | $sth->execute($query_values); |
1280 | - } catch(PDOException $e) { |
|
1280 | + } catch (PDOException $e) { |
|
1281 | 1281 | echo "error : ".$e->getMessage(); |
1282 | 1282 | } |
1283 | 1283 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1284 | 1284 | $all = $result[0]['nb']; |
1285 | 1285 | } else { |
1286 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1286 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1287 | 1287 | } |
1288 | 1288 | } |
1289 | 1289 | if (empty($all)) { |
1290 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1291 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
1290 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1291 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
1292 | 1292 | } else { |
1293 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
1293 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
1294 | 1294 | } |
1295 | 1295 | if ($filter_name != '') { |
1296 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1296 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1297 | 1297 | } |
1298 | 1298 | $Spotter = new Spotter($this->db); |
1299 | 1299 | //$all = $Spotter->countOverallOwners($filters,$year,$month); |
@@ -1301,7 +1301,7 @@ discard block |
||
1301 | 1301 | } |
1302 | 1302 | return $all; |
1303 | 1303 | } |
1304 | - public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
1304 | + public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
1305 | 1305 | global $globalStatsFilters; |
1306 | 1306 | if ($filter_name == '') $filter_name = $this->filter_name; |
1307 | 1307 | //if ($year == '') $year = date('Y'); |
@@ -1311,18 +1311,18 @@ discard block |
||
1311 | 1311 | try { |
1312 | 1312 | $sth = $this->db->prepare($query); |
1313 | 1313 | $sth->execute($query_values); |
1314 | - } catch(PDOException $e) { |
|
1314 | + } catch (PDOException $e) { |
|
1315 | 1315 | echo "error : ".$e->getMessage(); |
1316 | 1316 | } |
1317 | 1317 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1318 | 1318 | $all = $result[0]['nb']; |
1319 | 1319 | } else { |
1320 | - $all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1320 | + $all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1321 | 1321 | } |
1322 | 1322 | if (empty($all)) { |
1323 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
1323 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
1324 | 1324 | if ($filter_name != '') { |
1325 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1325 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1326 | 1326 | } |
1327 | 1327 | $Spotter = new Spotter($this->db); |
1328 | 1328 | //$all = $Spotter->countOverallPilots($filters,$year,$month); |
@@ -1331,104 +1331,104 @@ discard block |
||
1331 | 1331 | return $all; |
1332 | 1332 | } |
1333 | 1333 | |
1334 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
1334 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
1335 | 1335 | if ($filter_name == '') $filter_name = $this->filter_name; |
1336 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1336 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1337 | 1337 | $Spotter = new Spotter($this->db); |
1338 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1338 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1339 | 1339 | $alliance_airlines = array(); |
1340 | 1340 | foreach ($airlines as $airline) { |
1341 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1341 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1342 | 1342 | } |
1343 | - $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY date"; |
|
1344 | - $query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name); |
|
1343 | + $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY date"; |
|
1344 | + $query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name); |
|
1345 | 1345 | } else { |
1346 | 1346 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
1347 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1347 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1348 | 1348 | } |
1349 | 1349 | try { |
1350 | 1350 | $sth = $this->db->prepare($query); |
1351 | 1351 | $sth->execute($query_values); |
1352 | - } catch(PDOException $e) { |
|
1352 | + } catch (PDOException $e) { |
|
1353 | 1353 | echo "error : ".$e->getMessage(); |
1354 | 1354 | } |
1355 | 1355 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1356 | 1356 | return $all; |
1357 | 1357 | } |
1358 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
1358 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
1359 | 1359 | if ($filter_name == '') $filter_name = $this->filter_name; |
1360 | 1360 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
1361 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1361 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1362 | 1362 | try { |
1363 | 1363 | $sth = $this->db->prepare($query); |
1364 | 1364 | $sth->execute($query_values); |
1365 | - } catch(PDOException $e) { |
|
1365 | + } catch (PDOException $e) { |
|
1366 | 1366 | echo "error : ".$e->getMessage(); |
1367 | 1367 | } |
1368 | 1368 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1369 | 1369 | return $all; |
1370 | 1370 | } |
1371 | - public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
|
1371 | + public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') { |
|
1372 | 1372 | if ($filter_name == '') $filter_name = $this->filter_name; |
1373 | 1373 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1374 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1374 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1375 | 1375 | try { |
1376 | 1376 | $sth = $this->db->prepare($query); |
1377 | 1377 | $sth->execute($query_values); |
1378 | - } catch(PDOException $e) { |
|
1378 | + } catch (PDOException $e) { |
|
1379 | 1379 | echo "error : ".$e->getMessage(); |
1380 | 1380 | } |
1381 | 1381 | } |
1382 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
|
1382 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') { |
|
1383 | 1383 | if ($filter_name == '') $filter_name = $this->filter_name; |
1384 | 1384 | global $globalArchiveMonths, $globalDBdriver; |
1385 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1385 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1386 | 1386 | $Spotter = new Spotter($this->db); |
1387 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1387 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1388 | 1388 | $alliance_airlines = array(); |
1389 | 1389 | foreach ($airlines as $airline) { |
1390 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1390 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1391 | 1391 | } |
1392 | 1392 | if ($globalDBdriver == 'mysql') { |
1393 | 1393 | if ($month == '') { |
1394 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1394 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1395 | 1395 | $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name); |
1396 | 1396 | } else { |
1397 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1398 | - $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month); |
|
1397 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1398 | + $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month); |
|
1399 | 1399 | } |
1400 | 1400 | } else { |
1401 | 1401 | if ($month == '') { |
1402 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1402 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1403 | 1403 | $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name); |
1404 | 1404 | } else { |
1405 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1406 | - $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month); |
|
1405 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1406 | + $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month); |
|
1407 | 1407 | } |
1408 | 1408 | } |
1409 | 1409 | } else { |
1410 | 1410 | if ($globalDBdriver == 'mysql') { |
1411 | 1411 | if ($month == '') { |
1412 | 1412 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1413 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1413 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1414 | 1414 | } else { |
1415 | 1415 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1416 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
1416 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
1417 | 1417 | } |
1418 | 1418 | } else { |
1419 | 1419 | if ($month == '') { |
1420 | 1420 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1421 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1421 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1422 | 1422 | } else { |
1423 | 1423 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1424 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
1424 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
1425 | 1425 | } |
1426 | 1426 | } |
1427 | 1427 | } |
1428 | 1428 | try { |
1429 | 1429 | $sth = $this->db->prepare($query); |
1430 | 1430 | $sth->execute($query_values); |
1431 | - } catch(PDOException $e) { |
|
1431 | + } catch (PDOException $e) { |
|
1432 | 1432 | echo "error : ".$e->getMessage(); |
1433 | 1433 | } |
1434 | 1434 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1437,17 +1437,17 @@ discard block |
||
1437 | 1437 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
1438 | 1438 | global $globalArchiveMonths, $globalDBdriver; |
1439 | 1439 | if ($filter_name == '') $filter_name = $this->filter_name; |
1440 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1440 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1441 | 1441 | $Spotter = new Spotter($this->db); |
1442 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1442 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1443 | 1443 | $alliance_airlines = array(); |
1444 | 1444 | foreach ($airlines as $airline) { |
1445 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1445 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1446 | 1446 | } |
1447 | 1447 | if ($globalDBdriver == 'mysql') { |
1448 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1448 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1449 | 1449 | } else { |
1450 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1450 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1451 | 1451 | } |
1452 | 1452 | $query_values = array(':type' => $type, ':filter_name' => $filter_name); |
1453 | 1453 | } else { |
@@ -1461,7 +1461,7 @@ discard block |
||
1461 | 1461 | try { |
1462 | 1462 | $sth = $this->db->prepare($query); |
1463 | 1463 | $sth->execute($query_values); |
1464 | - } catch(PDOException $e) { |
|
1464 | + } catch (PDOException $e) { |
|
1465 | 1465 | echo "error : ".$e->getMessage(); |
1466 | 1466 | } |
1467 | 1467 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1470,17 +1470,17 @@ discard block |
||
1470 | 1470 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
1471 | 1471 | global $globalArchiveMonths, $globalDBdriver; |
1472 | 1472 | if ($filter_name == '') $filter_name = $this->filter_name; |
1473 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1473 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1474 | 1474 | $Spotter = new Spotter($this->db); |
1475 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1475 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1476 | 1476 | $alliance_airlines = array(); |
1477 | 1477 | foreach ($airlines as $airline) { |
1478 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1478 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1479 | 1479 | } |
1480 | 1480 | if ($globalDBdriver == 'mysql') { |
1481 | - $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1481 | + $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1482 | 1482 | } else { |
1483 | - $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1483 | + $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1484 | 1484 | } |
1485 | 1485 | } else { |
1486 | 1486 | if ($globalDBdriver == 'mysql') { |
@@ -1492,7 +1492,7 @@ discard block |
||
1492 | 1492 | try { |
1493 | 1493 | $sth = $this->db->prepare($query); |
1494 | 1494 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
1495 | - } catch(PDOException $e) { |
|
1495 | + } catch (PDOException $e) { |
|
1496 | 1496 | echo "error : ".$e->getMessage(); |
1497 | 1497 | } |
1498 | 1498 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1509,7 +1509,7 @@ discard block |
||
1509 | 1509 | try { |
1510 | 1510 | $sth = $this->db->prepare($query); |
1511 | 1511 | $sth->execute(array(':filter_name' => $filter_name)); |
1512 | - } catch(PDOException $e) { |
|
1512 | + } catch (PDOException $e) { |
|
1513 | 1513 | echo "error : ".$e->getMessage(); |
1514 | 1514 | } |
1515 | 1515 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1526,20 +1526,20 @@ discard block |
||
1526 | 1526 | try { |
1527 | 1527 | $sth = $this->db->prepare($query); |
1528 | 1528 | $sth->execute(array(':filter_name' => $filter_name)); |
1529 | - } catch(PDOException $e) { |
|
1529 | + } catch (PDOException $e) { |
|
1530 | 1530 | echo "error : ".$e->getMessage(); |
1531 | 1531 | } |
1532 | 1532 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1533 | 1533 | return $all[0]['total']; |
1534 | 1534 | } |
1535 | - public function getStatsOwner($owner_name,$filter_name = '') { |
|
1535 | + public function getStatsOwner($owner_name, $filter_name = '') { |
|
1536 | 1536 | global $globalArchiveMonths, $globalDBdriver; |
1537 | 1537 | if ($filter_name == '') $filter_name = $this->filter_name; |
1538 | 1538 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1539 | 1539 | try { |
1540 | 1540 | $sth = $this->db->prepare($query); |
1541 | - $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
1542 | - } catch(PDOException $e) { |
|
1541 | + $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name)); |
|
1542 | + } catch (PDOException $e) { |
|
1543 | 1543 | echo "error : ".$e->getMessage(); |
1544 | 1544 | } |
1545 | 1545 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1557,20 +1557,20 @@ discard block |
||
1557 | 1557 | try { |
1558 | 1558 | $sth = $this->db->prepare($query); |
1559 | 1559 | $sth->execute(array(':filter_name' => $filter_name)); |
1560 | - } catch(PDOException $e) { |
|
1560 | + } catch (PDOException $e) { |
|
1561 | 1561 | echo "error : ".$e->getMessage(); |
1562 | 1562 | } |
1563 | 1563 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1564 | 1564 | return $all[0]['total']; |
1565 | 1565 | } |
1566 | - public function getStatsPilot($pilot,$filter_name = '') { |
|
1566 | + public function getStatsPilot($pilot, $filter_name = '') { |
|
1567 | 1567 | global $globalArchiveMonths, $globalDBdriver; |
1568 | 1568 | if ($filter_name == '') $filter_name = $this->filter_name; |
1569 | 1569 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1570 | 1570 | try { |
1571 | 1571 | $sth = $this->db->prepare($query); |
1572 | - $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
1573 | - } catch(PDOException $e) { |
|
1572 | + $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot)); |
|
1573 | + } catch (PDOException $e) { |
|
1574 | 1574 | echo "error : ".$e->getMessage(); |
1575 | 1575 | } |
1576 | 1576 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1578,7 +1578,7 @@ discard block |
||
1578 | 1578 | else return 0; |
1579 | 1579 | } |
1580 | 1580 | |
1581 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
1581 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
1582 | 1582 | global $globalDBdriver; |
1583 | 1583 | if ($filter_name == '') $filter_name = $this->filter_name; |
1584 | 1584 | if ($globalDBdriver == 'mysql') { |
@@ -1586,15 +1586,15 @@ discard block |
||
1586 | 1586 | } else { |
1587 | 1587 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1588 | 1588 | } |
1589 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1589 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1590 | 1590 | try { |
1591 | 1591 | $sth = $this->db->prepare($query); |
1592 | 1592 | $sth->execute($query_values); |
1593 | - } catch(PDOException $e) { |
|
1593 | + } catch (PDOException $e) { |
|
1594 | 1594 | return "error : ".$e->getMessage(); |
1595 | 1595 | } |
1596 | 1596 | } |
1597 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
1597 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
1598 | 1598 | global $globalDBdriver; |
1599 | 1599 | if ($filter_name == '') $filter_name = $this->filter_name; |
1600 | 1600 | if ($globalDBdriver == 'mysql') { |
@@ -1603,11 +1603,11 @@ discard block |
||
1603 | 1603 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
1604 | 1604 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1605 | 1605 | } |
1606 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1606 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1607 | 1607 | try { |
1608 | 1608 | $sth = $this->db->prepare($query); |
1609 | 1609 | $sth->execute($query_values); |
1610 | - } catch(PDOException $e) { |
|
1610 | + } catch (PDOException $e) { |
|
1611 | 1611 | return "error : ".$e->getMessage(); |
1612 | 1612 | } |
1613 | 1613 | } |
@@ -1631,75 +1631,75 @@ discard block |
||
1631 | 1631 | } |
1632 | 1632 | */ |
1633 | 1633 | |
1634 | - public function getStatsSource($stats_type,$year = '',$month = '',$day = '') { |
|
1634 | + public function getStatsSource($stats_type, $year = '', $month = '', $day = '') { |
|
1635 | 1635 | global $globalDBdriver; |
1636 | 1636 | $query = "SELECT * FROM stats_source WHERE stats_type = :stats_type"; |
1637 | 1637 | $query_values = array(); |
1638 | 1638 | if ($globalDBdriver == 'mysql') { |
1639 | 1639 | if ($year != '') { |
1640 | 1640 | $query .= ' AND YEAR(stats_date) = :year'; |
1641 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1641 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1642 | 1642 | } |
1643 | 1643 | if ($month != '') { |
1644 | 1644 | $query .= ' AND MONTH(stats_date) = :month'; |
1645 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1645 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1646 | 1646 | } |
1647 | 1647 | if ($day != '') { |
1648 | 1648 | $query .= ' AND DAY(stats_date) = :day'; |
1649 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1649 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1650 | 1650 | } |
1651 | 1651 | } else { |
1652 | 1652 | if ($year != '') { |
1653 | 1653 | $query .= ' AND EXTRACT(YEAR FROM stats_date) = :year'; |
1654 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1654 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1655 | 1655 | } |
1656 | 1656 | if ($month != '') { |
1657 | 1657 | $query .= ' AND EXTRACT(MONTH FROM stats_date) = :month'; |
1658 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1658 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1659 | 1659 | } |
1660 | 1660 | if ($day != '') { |
1661 | 1661 | $query .= ' AND EXTRACT(DAY FROM stats_date) = :day'; |
1662 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1662 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1663 | 1663 | } |
1664 | 1664 | } |
1665 | 1665 | $query .= " ORDER BY source_name"; |
1666 | - $query_values = array_merge($query_values,array(':stats_type' => $stats_type)); |
|
1666 | + $query_values = array_merge($query_values, array(':stats_type' => $stats_type)); |
|
1667 | 1667 | try { |
1668 | 1668 | $sth = $this->db->prepare($query); |
1669 | 1669 | $sth->execute($query_values); |
1670 | - } catch(PDOException $e) { |
|
1670 | + } catch (PDOException $e) { |
|
1671 | 1671 | echo "error : ".$e->getMessage(); |
1672 | 1672 | } |
1673 | 1673 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1674 | 1674 | return $all; |
1675 | 1675 | } |
1676 | 1676 | |
1677 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
1677 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
1678 | 1678 | global $globalDBdriver; |
1679 | 1679 | if ($globalDBdriver == 'mysql') { |
1680 | 1680 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
1681 | 1681 | } else { |
1682 | 1682 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
1683 | 1683 | } |
1684 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
1684 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
1685 | 1685 | try { |
1686 | 1686 | $sth = $this->db->prepare($query); |
1687 | 1687 | $sth->execute($query_values); |
1688 | - } catch(PDOException $e) { |
|
1688 | + } catch (PDOException $e) { |
|
1689 | 1689 | return "error : ".$e->getMessage(); |
1690 | 1690 | } |
1691 | 1691 | } |
1692 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
1692 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
1693 | 1693 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
1694 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1694 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1695 | 1695 | try { |
1696 | 1696 | $sth = $this->db->prepare($query); |
1697 | 1697 | $sth->execute($query_values); |
1698 | - } catch(PDOException $e) { |
|
1698 | + } catch (PDOException $e) { |
|
1699 | 1699 | return "error : ".$e->getMessage(); |
1700 | 1700 | } |
1701 | 1701 | } |
1702 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
|
1702 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
1703 | 1703 | global $globalDBdriver; |
1704 | 1704 | if ($globalDBdriver == 'mysql') { |
1705 | 1705 | if ($reset) { |
@@ -1714,15 +1714,15 @@ discard block |
||
1714 | 1714 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1715 | 1715 | } |
1716 | 1716 | } |
1717 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1717 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1718 | 1718 | try { |
1719 | 1719 | $sth = $this->db->prepare($query); |
1720 | 1720 | $sth->execute($query_values); |
1721 | - } catch(PDOException $e) { |
|
1721 | + } catch (PDOException $e) { |
|
1722 | 1722 | return "error : ".$e->getMessage(); |
1723 | 1723 | } |
1724 | 1724 | } |
1725 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
|
1725 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1726 | 1726 | global $globalDBdriver; |
1727 | 1727 | if ($globalDBdriver == 'mysql') { |
1728 | 1728 | if ($reset) { |
@@ -1737,15 +1737,15 @@ discard block |
||
1737 | 1737 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
1738 | 1738 | } |
1739 | 1739 | } |
1740 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1740 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1741 | 1741 | try { |
1742 | 1742 | $sth = $this->db->prepare($query); |
1743 | 1743 | $sth->execute($query_values); |
1744 | - } catch(PDOException $e) { |
|
1744 | + } catch (PDOException $e) { |
|
1745 | 1745 | return "error : ".$e->getMessage(); |
1746 | 1746 | } |
1747 | 1747 | } |
1748 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
|
1748 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1749 | 1749 | global $globalDBdriver; |
1750 | 1750 | if ($globalDBdriver == 'mysql') { |
1751 | 1751 | if ($reset) { |
@@ -1760,15 +1760,15 @@ discard block |
||
1760 | 1760 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; |
1761 | 1761 | } |
1762 | 1762 | } |
1763 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
1763 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao); |
|
1764 | 1764 | try { |
1765 | 1765 | $sth = $this->db->prepare($query); |
1766 | 1766 | $sth->execute($query_values); |
1767 | - } catch(PDOException $e) { |
|
1767 | + } catch (PDOException $e) { |
|
1768 | 1768 | return "error : ".$e->getMessage(); |
1769 | 1769 | } |
1770 | 1770 | } |
1771 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
1771 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
1772 | 1772 | global $globalDBdriver; |
1773 | 1773 | if ($globalDBdriver == 'mysql') { |
1774 | 1774 | if ($reset) { |
@@ -1783,15 +1783,15 @@ discard block |
||
1783 | 1783 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1784 | 1784 | } |
1785 | 1785 | } |
1786 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1786 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1787 | 1787 | try { |
1788 | 1788 | $sth = $this->db->prepare($query); |
1789 | 1789 | $sth->execute($query_values); |
1790 | - } catch(PDOException $e) { |
|
1790 | + } catch (PDOException $e) { |
|
1791 | 1791 | return "error : ".$e->getMessage(); |
1792 | 1792 | } |
1793 | 1793 | } |
1794 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
|
1794 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) { |
|
1795 | 1795 | global $globalDBdriver; |
1796 | 1796 | if ($globalDBdriver == 'mysql') { |
1797 | 1797 | if ($reset) { |
@@ -1806,15 +1806,15 @@ discard block |
||
1806 | 1806 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
1807 | 1807 | } |
1808 | 1808 | } |
1809 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1809 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1810 | 1810 | try { |
1811 | 1811 | $sth = $this->db->prepare($query); |
1812 | 1812 | $sth->execute($query_values); |
1813 | - } catch(PDOException $e) { |
|
1813 | + } catch (PDOException $e) { |
|
1814 | 1814 | return "error : ".$e->getMessage(); |
1815 | 1815 | } |
1816 | 1816 | } |
1817 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
|
1817 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) { |
|
1818 | 1818 | global $globalDBdriver; |
1819 | 1819 | if ($globalDBdriver == 'mysql') { |
1820 | 1820 | if ($reset) { |
@@ -1829,15 +1829,15 @@ discard block |
||
1829 | 1829 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1830 | 1830 | } |
1831 | 1831 | } |
1832 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1832 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1833 | 1833 | try { |
1834 | 1834 | $sth = $this->db->prepare($query); |
1835 | 1835 | $sth->execute($query_values); |
1836 | - } catch(PDOException $e) { |
|
1836 | + } catch (PDOException $e) { |
|
1837 | 1837 | return "error : ".$e->getMessage(); |
1838 | 1838 | } |
1839 | 1839 | } |
1840 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
|
1840 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) { |
|
1841 | 1841 | global $globalDBdriver; |
1842 | 1842 | if ($globalDBdriver == 'mysql') { |
1843 | 1843 | if ($reset) { |
@@ -1852,15 +1852,15 @@ discard block |
||
1852 | 1852 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1853 | 1853 | } |
1854 | 1854 | } |
1855 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1855 | + $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source); |
|
1856 | 1856 | try { |
1857 | 1857 | $sth = $this->db->prepare($query); |
1858 | 1858 | $sth->execute($query_values); |
1859 | - } catch(PDOException $e) { |
|
1859 | + } catch (PDOException $e) { |
|
1860 | 1860 | return "error : ".$e->getMessage(); |
1861 | 1861 | } |
1862 | 1862 | } |
1863 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
|
1863 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1864 | 1864 | global $globalDBdriver; |
1865 | 1865 | if ($airport_icao != '') { |
1866 | 1866 | if ($globalDBdriver == 'mysql') { |
@@ -1876,16 +1876,16 @@ discard block |
||
1876 | 1876 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1877 | 1877 | } |
1878 | 1878 | } |
1879 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1879 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1880 | 1880 | try { |
1881 | 1881 | $sth = $this->db->prepare($query); |
1882 | 1882 | $sth->execute($query_values); |
1883 | - } catch(PDOException $e) { |
|
1883 | + } catch (PDOException $e) { |
|
1884 | 1884 | return "error : ".$e->getMessage(); |
1885 | 1885 | } |
1886 | 1886 | } |
1887 | 1887 | } |
1888 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1888 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1889 | 1889 | global $globalDBdriver; |
1890 | 1890 | if ($airport_icao != '') { |
1891 | 1891 | if ($globalDBdriver == 'mysql') { |
@@ -1893,16 +1893,16 @@ discard block |
||
1893 | 1893 | } else { |
1894 | 1894 | $query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1895 | 1895 | } |
1896 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1896 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1897 | 1897 | try { |
1898 | 1898 | $sth = $this->db->prepare($query); |
1899 | 1899 | $sth->execute($query_values); |
1900 | - } catch(PDOException $e) { |
|
1900 | + } catch (PDOException $e) { |
|
1901 | 1901 | return "error : ".$e->getMessage(); |
1902 | 1902 | } |
1903 | 1903 | } |
1904 | 1904 | } |
1905 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
|
1905 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1906 | 1906 | global $globalDBdriver; |
1907 | 1907 | if ($airport_icao != '') { |
1908 | 1908 | if ($globalDBdriver == 'mysql') { |
@@ -1918,16 +1918,16 @@ discard block |
||
1918 | 1918 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1919 | 1919 | } |
1920 | 1920 | } |
1921 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1921 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1922 | 1922 | try { |
1923 | 1923 | $sth = $this->db->prepare($query); |
1924 | 1924 | $sth->execute($query_values); |
1925 | - } catch(PDOException $e) { |
|
1925 | + } catch (PDOException $e) { |
|
1926 | 1926 | return "error : ".$e->getMessage(); |
1927 | 1927 | } |
1928 | 1928 | } |
1929 | 1929 | } |
1930 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1930 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1931 | 1931 | global $globalDBdriver; |
1932 | 1932 | if ($airport_icao != '') { |
1933 | 1933 | if ($globalDBdriver == 'mysql') { |
@@ -1935,11 +1935,11 @@ discard block |
||
1935 | 1935 | } else { |
1936 | 1936 | $query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1937 | 1937 | } |
1938 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1938 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1939 | 1939 | try { |
1940 | 1940 | $sth = $this->db->prepare($query); |
1941 | 1941 | $sth->execute($query_values); |
1942 | - } catch(PDOException $e) { |
|
1942 | + } catch (PDOException $e) { |
|
1943 | 1943 | return "error : ".$e->getMessage(); |
1944 | 1944 | } |
1945 | 1945 | } |
@@ -1951,7 +1951,7 @@ discard block |
||
1951 | 1951 | try { |
1952 | 1952 | $sth = $this->db->prepare($query); |
1953 | 1953 | $sth->execute($query_values); |
1954 | - } catch(PDOException $e) { |
|
1954 | + } catch (PDOException $e) { |
|
1955 | 1955 | return "error : ".$e->getMessage(); |
1956 | 1956 | } |
1957 | 1957 | } |
@@ -1961,7 +1961,7 @@ discard block |
||
1961 | 1961 | try { |
1962 | 1962 | $sth = $this->db->prepare($query); |
1963 | 1963 | $sth->execute($query_values); |
1964 | - } catch(PDOException $e) { |
|
1964 | + } catch (PDOException $e) { |
|
1965 | 1965 | return "error : ".$e->getMessage(); |
1966 | 1966 | } |
1967 | 1967 | } |
@@ -1971,13 +1971,13 @@ discard block |
||
1971 | 1971 | try { |
1972 | 1972 | $sth = $this->db->prepare($query); |
1973 | 1973 | $sth->execute($query_values); |
1974 | - } catch(PDOException $e) { |
|
1974 | + } catch (PDOException $e) { |
|
1975 | 1975 | return "error : ".$e->getMessage(); |
1976 | 1976 | } |
1977 | 1977 | } |
1978 | 1978 | |
1979 | 1979 | public function addOldStats() { |
1980 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents; |
|
1980 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents; |
|
1981 | 1981 | $Common = new Common(); |
1982 | 1982 | $Connection = new Connection(); |
1983 | 1983 | date_default_timezone_set('UTC'); |
@@ -1995,41 +1995,41 @@ discard block |
||
1995 | 1995 | $Spotter = new Spotter($this->db); |
1996 | 1996 | |
1997 | 1997 | if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
1998 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
1998 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
1999 | 1999 | foreach ($alldata as $number) { |
2000 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
|
2000 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset); |
|
2001 | 2001 | } |
2002 | 2002 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
2003 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
2003 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
2004 | 2004 | foreach ($alldata as $number) { |
2005 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
|
2005 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset); |
|
2006 | 2006 | } |
2007 | 2007 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
2008 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
2008 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
2009 | 2009 | foreach ($alldata as $number) { |
2010 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
|
2010 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset); |
|
2011 | 2011 | } |
2012 | 2012 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
2013 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
2013 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
2014 | 2014 | foreach ($alldata as $number) { |
2015 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
2015 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
2016 | 2016 | } |
2017 | 2017 | if ($globalDebug) echo 'Count all owners...'."\n"; |
2018 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
2018 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
2019 | 2019 | foreach ($alldata as $number) { |
2020 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
|
2020 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset); |
|
2021 | 2021 | } |
2022 | 2022 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
2023 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
2023 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
2024 | 2024 | foreach ($alldata as $number) { |
2025 | 2025 | if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
2026 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
|
2026 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset); |
|
2027 | 2027 | } |
2028 | 2028 | |
2029 | 2029 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
2030 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
2030 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
2031 | 2031 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
2032 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
2032 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
2033 | 2033 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
2034 | 2034 | $alldata = array(); |
2035 | 2035 | foreach ($pall as $value) { |
@@ -2046,14 +2046,14 @@ discard block |
||
2046 | 2046 | foreach ($alldata as $key => $row) { |
2047 | 2047 | $count[$key] = $row['airport_departure_icao_count']; |
2048 | 2048 | } |
2049 | - array_multisort($count,SORT_DESC,$alldata); |
|
2049 | + array_multisort($count, SORT_DESC, $alldata); |
|
2050 | 2050 | foreach ($alldata as $number) { |
2051 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
|
2051 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset); |
|
2052 | 2052 | } |
2053 | 2053 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
2054 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
2054 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
2055 | 2055 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
2056 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
2056 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
2057 | 2057 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
2058 | 2058 | $alldata = array(); |
2059 | 2059 | foreach ($pall as $value) { |
@@ -2070,18 +2070,18 @@ discard block |
||
2070 | 2070 | foreach ($alldata as $key => $row) { |
2071 | 2071 | $count[$key] = $row['airport_arrival_icao_count']; |
2072 | 2072 | } |
2073 | - array_multisort($count,SORT_DESC,$alldata); |
|
2073 | + array_multisort($count, SORT_DESC, $alldata); |
|
2074 | 2074 | foreach ($alldata as $number) { |
2075 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
|
2075 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset); |
|
2076 | 2076 | } |
2077 | 2077 | if ($Connection->tableExists('countries')) { |
2078 | 2078 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
2079 | 2079 | //$SpotterArchive = new SpotterArchive(); |
2080 | 2080 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
2081 | 2081 | $Spotter = new Spotter($this->db); |
2082 | - $alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day); |
|
2082 | + $alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day); |
|
2083 | 2083 | foreach ($alldata as $number) { |
2084 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset); |
|
2084 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset); |
|
2085 | 2085 | } |
2086 | 2086 | } |
2087 | 2087 | |
@@ -2091,12 +2091,12 @@ discard block |
||
2091 | 2091 | $this->deleteStatsByType('fatalities_byyear'); |
2092 | 2092 | $alldata = $Accident->countFatalitiesByYear(); |
2093 | 2093 | foreach ($alldata as $number) { |
2094 | - $this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year']))); |
|
2094 | + $this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year']))); |
|
2095 | 2095 | } |
2096 | 2096 | $this->deleteStatsByType('fatalities_bymonth'); |
2097 | 2097 | $alldata = $Accident->countFatalitiesLast12Months(); |
2098 | 2098 | foreach ($alldata as $number) { |
2099 | - $this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year']))); |
|
2099 | + $this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year']))); |
|
2100 | 2100 | } |
2101 | 2101 | } |
2102 | 2102 | |
@@ -2110,37 +2110,37 @@ discard block |
||
2110 | 2110 | $lastyear = false; |
2111 | 2111 | foreach ($alldata as $number) { |
2112 | 2112 | if ($number['year_name'] != date('Y')) $lastyear = true; |
2113 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
2113 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
2114 | 2114 | } |
2115 | 2115 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
2116 | 2116 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
2117 | 2117 | foreach ($alldata as $number) { |
2118 | - $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
2118 | + $this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
2119 | 2119 | } |
2120 | 2120 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
2121 | 2121 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
2122 | 2122 | foreach ($alldata as $number) { |
2123 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
2123 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
2124 | 2124 | } |
2125 | 2125 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
2126 | 2126 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
2127 | 2127 | foreach ($alldata as $number) { |
2128 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
2128 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
2129 | 2129 | } |
2130 | 2130 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
2131 | 2131 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
2132 | 2132 | foreach ($alldata as $number) { |
2133 | - $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
2133 | + $this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
2134 | 2134 | } |
2135 | 2135 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
2136 | 2136 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
2137 | 2137 | foreach ($alldata as $number) { |
2138 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
2138 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
2139 | 2139 | } |
2140 | 2140 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
2141 | 2141 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
2142 | 2142 | foreach ($alldata as $number) { |
2143 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
2143 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
2144 | 2144 | } |
2145 | 2145 | if ($globalDebug) echo 'Airports data...'."\n"; |
2146 | 2146 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -2185,7 +2185,7 @@ discard block |
||
2185 | 2185 | } |
2186 | 2186 | $alldata = $pall; |
2187 | 2187 | foreach ($alldata as $number) { |
2188 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
2188 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
2189 | 2189 | } |
2190 | 2190 | echo '...Arrival'."\n"; |
2191 | 2191 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -2226,7 +2226,7 @@ discard block |
||
2226 | 2226 | } |
2227 | 2227 | $alldata = $pall; |
2228 | 2228 | foreach ($alldata as $number) { |
2229 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
2229 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
2230 | 2230 | } |
2231 | 2231 | |
2232 | 2232 | echo 'Flights data...'."\n"; |
@@ -2234,28 +2234,28 @@ discard block |
||
2234 | 2234 | echo '-> countAllDatesLastMonth...'."\n"; |
2235 | 2235 | $alldata = $Spotter->countAllDatesLastMonth($filter_last_month); |
2236 | 2236 | foreach ($alldata as $number) { |
2237 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
2237 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
2238 | 2238 | } |
2239 | 2239 | echo '-> countAllDates...'."\n"; |
2240 | 2240 | $previousdata = $this->countAllDates(); |
2241 | 2241 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
2242 | 2242 | $this->deleteStatFlight('date'); |
2243 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month)); |
|
2243 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month)); |
|
2244 | 2244 | $values = array(); |
2245 | 2245 | foreach ($alldata as $cnt) { |
2246 | 2246 | $values[] = $cnt['date_count']; |
2247 | 2247 | } |
2248 | - array_multisort($values,SORT_DESC,$alldata); |
|
2249 | - array_splice($alldata,11); |
|
2248 | + array_multisort($values, SORT_DESC, $alldata); |
|
2249 | + array_splice($alldata, 11); |
|
2250 | 2250 | foreach ($alldata as $number) { |
2251 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
2251 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
2252 | 2252 | } |
2253 | 2253 | |
2254 | 2254 | $this->deleteStatFlight('hour'); |
2255 | 2255 | echo '-> countAllHours...'."\n"; |
2256 | - $alldata = $Spotter->countAllHours('hour',$filter_last_month); |
|
2256 | + $alldata = $Spotter->countAllHours('hour', $filter_last_month); |
|
2257 | 2257 | foreach ($alldata as $number) { |
2258 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
2258 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
2259 | 2259 | } |
2260 | 2260 | |
2261 | 2261 | // Count by airlines |
@@ -2264,42 +2264,42 @@ discard block |
||
2264 | 2264 | if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
2265 | 2265 | $SpotterArchive = new SpotterArchive(); |
2266 | 2266 | //$Spotter = new Spotter($this->db); |
2267 | - $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
|
2267 | + $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day); |
|
2268 | 2268 | //$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
2269 | 2269 | foreach ($alldata as $number) { |
2270 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
|
2270 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset); |
|
2271 | 2271 | } |
2272 | 2272 | } |
2273 | 2273 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
2274 | 2274 | $Spotter = new Spotter($this->db); |
2275 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
2275 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
2276 | 2276 | foreach ($alldata as $number) { |
2277 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
|
2277 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset); |
|
2278 | 2278 | } |
2279 | 2279 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
2280 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
2280 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
2281 | 2281 | foreach ($alldata as $number) { |
2282 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
|
2282 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset); |
|
2283 | 2283 | } |
2284 | 2284 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
2285 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
2285 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
2286 | 2286 | foreach ($alldata as $number) { |
2287 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
2287 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
2288 | 2288 | } |
2289 | 2289 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
2290 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
2290 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
2291 | 2291 | foreach ($alldata as $number) { |
2292 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
|
2292 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset); |
|
2293 | 2293 | } |
2294 | 2294 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
2295 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
2295 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
2296 | 2296 | foreach ($alldata as $number) { |
2297 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
|
2297 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset); |
|
2298 | 2298 | } |
2299 | 2299 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
2300 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
2300 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
2301 | 2301 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
2302 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
2302 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
2303 | 2303 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
2304 | 2304 | //$alldata = array(); |
2305 | 2305 | foreach ($dall as $value) { |
@@ -2319,12 +2319,12 @@ discard block |
||
2319 | 2319 | } |
2320 | 2320 | $alldata = $pall; |
2321 | 2321 | foreach ($alldata as $number) { |
2322 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
|
2322 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset); |
|
2323 | 2323 | } |
2324 | 2324 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
2325 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
2325 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
2326 | 2326 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
2327 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
2327 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
2328 | 2328 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
2329 | 2329 | //$alldata = array(); |
2330 | 2330 | foreach ($dall as $value) { |
@@ -2344,7 +2344,7 @@ discard block |
||
2344 | 2344 | } |
2345 | 2345 | $alldata = $pall; |
2346 | 2346 | foreach ($alldata as $number) { |
2347 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
2347 | + if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset); |
|
2348 | 2348 | } |
2349 | 2349 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
2350 | 2350 | $Spotter = new Spotter($this->db); |
@@ -2352,27 +2352,27 @@ discard block |
||
2352 | 2352 | $lastyear = false; |
2353 | 2353 | foreach ($alldata as $number) { |
2354 | 2354 | if ($number['year_name'] != date('Y')) $lastyear = true; |
2355 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
2355 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
2356 | 2356 | } |
2357 | 2357 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
2358 | 2358 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
2359 | 2359 | foreach ($alldata as $number) { |
2360 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
2360 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
2361 | 2361 | } |
2362 | 2362 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
2363 | 2363 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
2364 | 2364 | foreach ($alldata as $number) { |
2365 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
2365 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
2366 | 2366 | } |
2367 | 2367 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
2368 | 2368 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
2369 | 2369 | foreach ($alldata as $number) { |
2370 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
2370 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
2371 | 2371 | } |
2372 | 2372 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
2373 | 2373 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
2374 | 2374 | foreach ($alldata as $number) { |
2375 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
2375 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
2376 | 2376 | } |
2377 | 2377 | if ($globalDebug) echo '...Departure'."\n"; |
2378 | 2378 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -2395,7 +2395,7 @@ discard block |
||
2395 | 2395 | } |
2396 | 2396 | $alldata = $pall; |
2397 | 2397 | foreach ($alldata as $number) { |
2398 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
|
2398 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']); |
|
2399 | 2399 | } |
2400 | 2400 | if ($globalDebug) echo '...Arrival'."\n"; |
2401 | 2401 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -2418,32 +2418,32 @@ discard block |
||
2418 | 2418 | } |
2419 | 2419 | $alldata = $pall; |
2420 | 2420 | foreach ($alldata as $number) { |
2421 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
|
2421 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']); |
|
2422 | 2422 | } |
2423 | 2423 | |
2424 | 2424 | if ($globalDebug) echo 'Flights data...'."\n"; |
2425 | 2425 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
2426 | 2426 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
2427 | 2427 | foreach ($alldata as $number) { |
2428 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
2428 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
2429 | 2429 | } |
2430 | 2430 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
2431 | 2431 | //$previousdata = $this->countAllDatesByAirlines(); |
2432 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
|
2432 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month)); |
|
2433 | 2433 | $values = array(); |
2434 | 2434 | foreach ($alldata as $cnt) { |
2435 | 2435 | $values[] = $cnt['date_count']; |
2436 | 2436 | } |
2437 | - array_multisort($values,SORT_DESC,$alldata); |
|
2438 | - array_splice($alldata,11); |
|
2437 | + array_multisort($values, SORT_DESC, $alldata); |
|
2438 | + array_splice($alldata, 11); |
|
2439 | 2439 | foreach ($alldata as $number) { |
2440 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
2440 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
2441 | 2441 | } |
2442 | 2442 | |
2443 | 2443 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
2444 | - $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
|
2444 | + $alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month); |
|
2445 | 2445 | foreach ($alldata as $number) { |
2446 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
2446 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
2447 | 2447 | } |
2448 | 2448 | |
2449 | 2449 | // Stats by filters |
@@ -2466,7 +2466,7 @@ discard block |
||
2466 | 2466 | $last_update_day = date('Y').'-01-01 00:00:00'; |
2467 | 2467 | } |
2468 | 2468 | } |
2469 | - if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) { |
|
2469 | + if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) { |
|
2470 | 2470 | $last_update_day = date('Y').'-01-01 00:00:00'; |
2471 | 2471 | $reset = true; |
2472 | 2472 | } |
@@ -2475,32 +2475,32 @@ discard block |
||
2475 | 2475 | // Count by filter |
2476 | 2476 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
2477 | 2477 | $Spotter = new Spotter($this->db); |
2478 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
2478 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
2479 | 2479 | foreach ($alldata as $number) { |
2480 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
|
2480 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset); |
|
2481 | 2481 | } |
2482 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
2482 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
2483 | 2483 | foreach ($alldata as $number) { |
2484 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
|
2484 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset); |
|
2485 | 2485 | } |
2486 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
2486 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
2487 | 2487 | foreach ($alldata as $number) { |
2488 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
|
2488 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset); |
|
2489 | 2489 | } |
2490 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
2490 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
2491 | 2491 | foreach ($alldata as $number) { |
2492 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
|
2492 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset); |
|
2493 | 2493 | } |
2494 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
2494 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
2495 | 2495 | foreach ($alldata as $number) { |
2496 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
|
2496 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset); |
|
2497 | 2497 | } |
2498 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
2498 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
2499 | 2499 | foreach ($alldata as $number) { |
2500 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
|
2500 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset); |
|
2501 | 2501 | } |
2502 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
2503 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
2502 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
2503 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
2504 | 2504 | $alldata = array(); |
2505 | 2505 | foreach ($pall as $value) { |
2506 | 2506 | $icao = $value['airport_departure_icao']; |
@@ -2516,12 +2516,12 @@ discard block |
||
2516 | 2516 | foreach ($alldata as $key => $row) { |
2517 | 2517 | $count[$key] = $row['airport_departure_icao_count']; |
2518 | 2518 | } |
2519 | - array_multisort($count,SORT_DESC,$alldata); |
|
2519 | + array_multisort($count, SORT_DESC, $alldata); |
|
2520 | 2520 | foreach ($alldata as $number) { |
2521 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
|
2521 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset); |
|
2522 | 2522 | } |
2523 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
|
2524 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
2523 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
2524 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
2525 | 2525 | $alldata = array(); |
2526 | 2526 | foreach ($pall as $value) { |
2527 | 2527 | $icao = $value['airport_arrival_icao']; |
@@ -2537,40 +2537,40 @@ discard block |
||
2537 | 2537 | foreach ($alldata as $key => $row) { |
2538 | 2538 | $count[$key] = $row['airport_arrival_icao_count']; |
2539 | 2539 | } |
2540 | - array_multisort($count,SORT_DESC,$alldata); |
|
2540 | + array_multisort($count, SORT_DESC, $alldata); |
|
2541 | 2541 | foreach ($alldata as $number) { |
2542 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
|
2542 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset); |
|
2543 | 2543 | } |
2544 | 2544 | $Spotter = new Spotter($this->db); |
2545 | 2545 | $alldata = $Spotter->countAllMonths($filter); |
2546 | 2546 | $lastyear = false; |
2547 | 2547 | foreach ($alldata as $number) { |
2548 | 2548 | if ($number['year_name'] != date('Y')) $lastyear = true; |
2549 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2549 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
2550 | 2550 | } |
2551 | 2551 | $alldata = $Spotter->countAllMonthsOwners($filter); |
2552 | 2552 | foreach ($alldata as $number) { |
2553 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2553 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
2554 | 2554 | } |
2555 | 2555 | $alldata = $Spotter->countAllMonthsPilots($filter); |
2556 | 2556 | foreach ($alldata as $number) { |
2557 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2557 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
2558 | 2558 | } |
2559 | 2559 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
2560 | 2560 | foreach ($alldata as $number) { |
2561 | - $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2561 | + $this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
2562 | 2562 | } |
2563 | 2563 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
2564 | 2564 | foreach ($alldata as $number) { |
2565 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2565 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
2566 | 2566 | } |
2567 | 2567 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
2568 | 2568 | foreach ($alldata as $number) { |
2569 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2569 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
2570 | 2570 | } |
2571 | 2571 | echo '...Departure'."\n"; |
2572 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
2573 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
2572 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
2573 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
2574 | 2574 | foreach ($dall as $value) { |
2575 | 2575 | $icao = $value['departure_airport_icao']; |
2576 | 2576 | $ddate = $value['date']; |
@@ -2588,11 +2588,11 @@ discard block |
||
2588 | 2588 | } |
2589 | 2589 | $alldata = $pall; |
2590 | 2590 | foreach ($alldata as $number) { |
2591 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
|
2591 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name); |
|
2592 | 2592 | } |
2593 | 2593 | echo '...Arrival'."\n"; |
2594 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
2595 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
2594 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
2595 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
2596 | 2596 | foreach ($dall as $value) { |
2597 | 2597 | $icao = $value['arrival_airport_icao']; |
2598 | 2598 | $ddate = $value['date']; |
@@ -2610,39 +2610,39 @@ discard block |
||
2610 | 2610 | } |
2611 | 2611 | $alldata = $pall; |
2612 | 2612 | foreach ($alldata as $number) { |
2613 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
|
2613 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name); |
|
2614 | 2614 | } |
2615 | 2615 | echo 'Flights data...'."\n"; |
2616 | 2616 | echo '-> countAllDatesLastMonth...'."\n"; |
2617 | 2617 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
2618 | 2618 | foreach ($alldata as $number) { |
2619 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
2619 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
2620 | 2620 | } |
2621 | 2621 | echo '-> countAllDates...'."\n"; |
2622 | - $previousdata = $this->countAllDates('',$filter_name); |
|
2623 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
2622 | + $previousdata = $this->countAllDates('', $filter_name); |
|
2623 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
2624 | 2624 | $values = array(); |
2625 | 2625 | foreach ($alldata as $cnt) { |
2626 | 2626 | $values[] = $cnt['date_count']; |
2627 | 2627 | } |
2628 | - array_multisort($values,SORT_DESC,$alldata); |
|
2629 | - array_splice($alldata,11); |
|
2628 | + array_multisort($values, SORT_DESC, $alldata); |
|
2629 | + array_splice($alldata, 11); |
|
2630 | 2630 | foreach ($alldata as $number) { |
2631 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
2631 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
2632 | 2632 | } |
2633 | 2633 | |
2634 | 2634 | echo '-> countAllHours...'."\n"; |
2635 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
2635 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
2636 | 2636 | foreach ($alldata as $number) { |
2637 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
2637 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
2638 | 2638 | } |
2639 | 2639 | echo 'Insert last stats update date...'."\n"; |
2640 | 2640 | date_default_timezone_set('UTC'); |
2641 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s')); |
|
2641 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s')); |
|
2642 | 2642 | if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) { |
2643 | - if (date('Y',strtotime($last_update_day)) != date('Y')) { |
|
2643 | + if (date('Y', strtotime($last_update_day)) != date('Y')) { |
|
2644 | 2644 | $this->deleteOldStats($filter_name); |
2645 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00'); |
|
2645 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00'); |
|
2646 | 2646 | } |
2647 | 2647 | } |
2648 | 2648 | } |
@@ -2653,16 +2653,16 @@ discard block |
||
2653 | 2653 | // SUM all previous month to put as year |
2654 | 2654 | $previous_year = date('Y'); |
2655 | 2655 | $previous_year--; |
2656 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2657 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2658 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2659 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2656 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2657 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2658 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2659 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2660 | 2660 | $allairlines = $this->getAllAirlineNames(); |
2661 | 2661 | foreach ($allairlines as $data) { |
2662 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2663 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2664 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2665 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2662 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2663 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2664 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2665 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2666 | 2666 | } |
2667 | 2667 | |
2668 | 2668 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -2671,7 +2671,7 @@ discard block |
||
2671 | 2671 | try { |
2672 | 2672 | $sth = $this->db->prepare($query); |
2673 | 2673 | $sth->execute(); |
2674 | - } catch(PDOException $e) { |
|
2674 | + } catch (PDOException $e) { |
|
2675 | 2675 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2676 | 2676 | } |
2677 | 2677 | } |
@@ -2680,15 +2680,15 @@ discard block |
||
2680 | 2680 | try { |
2681 | 2681 | $sth = $this->db->prepare($query); |
2682 | 2682 | $sth->execute(); |
2683 | - } catch(PDOException $e) { |
|
2683 | + } catch (PDOException $e) { |
|
2684 | 2684 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2685 | 2685 | } |
2686 | 2686 | } |
2687 | 2687 | if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) { |
2688 | 2688 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
2689 | - if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) { |
|
2689 | + if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) { |
|
2690 | 2690 | $this->deleteOldStats(); |
2691 | - $this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00'); |
|
2691 | + $this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00'); |
|
2692 | 2692 | $lastyearupdate = true; |
2693 | 2693 | } |
2694 | 2694 | } |
@@ -2710,7 +2710,7 @@ discard block |
||
2710 | 2710 | try { |
2711 | 2711 | $sth = $this->db->prepare($query); |
2712 | 2712 | $sth->execute(); |
2713 | - } catch(PDOException $e) { |
|
2713 | + } catch (PDOException $e) { |
|
2714 | 2714 | return "error : ".$e->getMessage(); |
2715 | 2715 | } |
2716 | 2716 | } |
@@ -2724,14 +2724,14 @@ discard block |
||
2724 | 2724 | try { |
2725 | 2725 | $sth = $this->db->prepare($query); |
2726 | 2726 | $sth->execute(); |
2727 | - } catch(PDOException $e) { |
|
2727 | + } catch (PDOException $e) { |
|
2728 | 2728 | return "error : ".$e->getMessage(); |
2729 | 2729 | } |
2730 | 2730 | } |
2731 | 2731 | if (!isset($lastyearupdate)) { |
2732 | 2732 | echo 'Insert last stats update date...'."\n"; |
2733 | 2733 | date_default_timezone_set('UTC'); |
2734 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
2734 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
2735 | 2735 | } |
2736 | 2736 | if ($globalStatsResetYear) { |
2737 | 2737 | require_once(dirname(__FILE__).'/../install/class.settings.php'); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | print '<div class="column">'; |
16 | 16 | print '<h1>'._("Airlines").'</h1>'; |
17 | 17 | if (isset($_POST['airline_type'])) { |
18 | - $airline_type = filter_input(INPUT_POST,'airline_type',FILTER_SANITIZE_STRING); |
|
18 | + $airline_type = filter_input(INPUT_POST, 'airline_type', FILTER_SANITIZE_STRING); |
|
19 | 19 | //$airline_names = $Spotter->getAllAirlineNames($airline_type); |
20 | 20 | } else { |
21 | 21 | //$airline_names = $Spotter->getAllAirlineNames(); |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | print '<div class="alphabet">'; |
28 | 28 | foreach ($alliances as $alliance) { |
29 | 29 | print '<div class="alphabet-airline alphabet-item">'; |
30 | - print '<a href="'.$globalURL.'/airline/alliance_'.str_replace(' ','_',$alliance['alliance']).'">'; |
|
31 | - if (@getimagesize('images/airlines/'.str_replace(' ','_',$alliance['alliance']).'.png') || @getimagesize($globalURL.'/images/airlines/'.str_replace(' ','_',$alliance['alliance']).'.png')) |
|
30 | + print '<a href="'.$globalURL.'/airline/alliance_'.str_replace(' ', '_', $alliance['alliance']).'">'; |
|
31 | + if (@getimagesize('images/airlines/'.str_replace(' ', '_', $alliance['alliance']).'.png') || @getimagesize($globalURL.'/images/airlines/'.str_replace(' ', '_', $alliance['alliance']).'.png')) |
|
32 | 32 | { |
33 | - print '<img src="'.$globalURL.'/images/airlines/'.str_replace(' ','_',$alliance['alliance']).'.png" alt="'._("Click to see alliance activity").'" title="'._("Click to see alliance activity").'" /> '; |
|
33 | + print '<img src="'.$globalURL.'/images/airlines/'.str_replace(' ', '_', $alliance['alliance']).'.png" alt="'._("Click to see alliance activity").'" title="'._("Click to see alliance activity").'" /> '; |
|
34 | 34 | } else print $alliance['alliance']; |
35 | 35 | print '</a>'; |
36 | 36 | print '</div>'; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $Stats = new Stats(); |
54 | 54 | if (isset($_POST['airline_type'])) |
55 | 55 | { |
56 | - $airline_type = filter_input(INPUT_POST,'airline_type',FILTER_SANITIZE_STRING); |
|
56 | + $airline_type = filter_input(INPUT_POST, 'airline_type', FILTER_SANITIZE_STRING); |
|
57 | 57 | //$airline_names = $Stats->getAllAirlineNames($airline_type); |
58 | 58 | $airline_names = $Spotter->getAllAirlineNames($airline_type); |
59 | 59 | } else { |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | } |
67 | 67 | $previous = null; |
68 | 68 | print '<div class="alphabet-legend">'; |
69 | - foreach($airline_names as $value) |
|
69 | + foreach ($airline_names as $value) |
|
70 | 70 | { |
71 | 71 | //echo $value['airline_name']."\n"; |
72 | 72 | //echo mb_substr($value['airline_name'],0,1).' - '.$value['airline_name']."\n"; |
73 | - $firstLetter = mb_strtoupper(mb_substr($value['airline_name'], 0, 1),'UTF-8'); |
|
74 | - if($previous !== $firstLetter) |
|
73 | + $firstLetter = mb_strtoupper(mb_substr($value['airline_name'], 0, 1), 'UTF-8'); |
|
74 | + if ($previous !== $firstLetter) |
|
75 | 75 | { |
76 | 76 | if ($previous !== null) print ' | '; |
77 | 77 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | } |
81 | 81 | print '</div>'; |
82 | 82 | $previous = null; |
83 | - foreach($airline_names as $value) { |
|
83 | + foreach ($airline_names as $value) { |
|
84 | 84 | $firstLetter = strtoupper(substr($value['airline_name'], 0, 1)); |
85 | 85 | if ($firstLetter != "") |
86 | 86 | { |
87 | - if($previous !== $firstLetter) |
|
87 | + if ($previous !== $firstLetter) |
|
88 | 88 | { |
89 | 89 | if ($previous !== null) print '</div>'; |
90 | 90 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | $Spotter = new Spotter(); |
24 | 24 | $alliances = $Spotter->getAllAllianceNames(); |
25 | 25 | if (!empty($alliances)) { |
26 | - foreach($alliances as $alliance) { |
|
27 | - if (isset($airline_icao) && str_replace('_',' ',str_replace('alliance_','',$airline_icao)) == $alliance['alliance']) { |
|
28 | - print '<option value="alliance_'.str_replace(' ','_',$alliance['alliance']).'" selected>'.$alliance['alliance'].'</option>'; |
|
26 | + foreach ($alliances as $alliance) { |
|
27 | + if (isset($airline_icao) && str_replace('_', ' ', str_replace('alliance_', '', $airline_icao)) == $alliance['alliance']) { |
|
28 | + print '<option value="alliance_'.str_replace(' ', '_', $alliance['alliance']).'" selected>'.$alliance['alliance'].'</option>'; |
|
29 | 29 | } else { |
30 | - print '<option value="alliance_'.str_replace(' ','_',$alliance['alliance']).'">'.$alliance['alliance'].'</option>'; |
|
30 | + print '<option value="alliance_'.str_replace(' ', '_', $alliance['alliance']).'">'.$alliance['alliance'].'</option>'; |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | print '<option disabled>──────────</option>'; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $Stats = new Stats(); |
36 | 36 | if (!isset($filter_name)) $filter_name = ''; |
37 | 37 | $airlines = $Stats->getAllAirlineNames($filter_name); |
38 | - foreach($airlines as $airline) { |
|
38 | + foreach ($airlines as $airline) { |
|
39 | 39 | if (isset($airline_icao) && $airline_icao == $airline['airline_icao']) { |
40 | 40 | print '<option value="'.$airline['airline_icao'].'" selected>'.$airline['airline_name'].'</option>'; |
41 | 41 | } else { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | if (!isset($type) || $type == 'aircraft') { |
59 | 59 | ?> |
60 | 60 | <li class="dropdown"> |
61 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
61 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
62 | 62 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
63 | 63 | </a> |
64 | 64 | <ul class="dropdown-menu"> |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | </ul> |
70 | 70 | </li> |
71 | 71 | <li class="dropdown"> |
72 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
72 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
73 | 73 | <?php echo _("Airline"); ?> <span class="caret"></span> |
74 | 74 | </a> |
75 | 75 | <ul class="dropdown-menu" role="menu"> |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | </ul> |
86 | 86 | </li> |
87 | 87 | <li class="dropdown"> |
88 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
88 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
89 | 89 | <?php echo _("Airport"); ?> <span class="caret"></span> |
90 | 90 | </a> |
91 | 91 | <ul class="dropdown-menu" role="menu"> |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | </ul> |
97 | 97 | </li> |
98 | 98 | <li class="dropdown"> |
99 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
99 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
100 | 100 | <?php echo _("Route"); ?> <span class="caret"></span> |
101 | 101 | </a> |
102 | 102 | <ul class="dropdown-menu" role="menu"> |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | </ul> |
106 | 106 | </li> |
107 | 107 | <li class="dropdown"> |
108 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
108 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
109 | 109 | <?php echo _("Date & Time"); ?> <span class="caret"></span> |
110 | 110 | </a> |
111 | 111 | <ul class="dropdown-menu" role="menu"> |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) { |
118 | 118 | ?> |
119 | 119 | <li class="dropdown"> |
120 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
120 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
121 | 121 | <?php echo _("Fatalities"); ?> <span class="caret"></span> |
122 | 122 | </a> |
123 | 123 | <ul class="dropdown-menu" role="menu"> |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } elseif ($type == 'marine' || $type == 'tracker') { |
133 | 133 | ?> |
134 | 134 | <li class="dropdown"> |
135 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
135 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
136 | 136 | <?php echo _("Date & Time"); ?> <span class="caret"></span> |
137 | 137 | </a> |
138 | 138 | <ul class="dropdown-menu" role="menu"> |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | if (!isset($type) || $type == 'aircraft') { |
155 | 155 | ?> |
156 | 156 | <li class="dropdown"> |
157 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
157 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
158 | 158 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
159 | 159 | </a> |
160 | 160 | <ul class="dropdown-menu"> |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | </ul> |
166 | 166 | </li> |
167 | 167 | <li class="dropdown"> |
168 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
168 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
169 | 169 | <?php echo _("Airline"); ?> <span class="caret"></span> |
170 | 170 | </a> |
171 | 171 | <ul class="dropdown-menu" role="menu"> |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | </ul> |
182 | 182 | </li> |
183 | 183 | <li class="dropdown"> |
184 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
184 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
185 | 185 | <?php echo _("Airport"); ?> <span class="caret"></span> |
186 | 186 | </a> |
187 | 187 | <ul class="dropdown-menu" role="menu"> |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | </li> |
194 | 194 | <!-- |
195 | 195 | <li class="dropdown"> |
196 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
196 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
197 | 197 | <?php echo _("Route"); ?> <span class="caret"></span> |
198 | 198 | </a> |
199 | 199 | <ul class="dropdown-menu" role="menu"> |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | --> |
205 | 205 | <!-- |
206 | 206 | <li class="dropdown"> |
207 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
207 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
208 | 208 | <?php echo _("Date & Time"); ?> <span class="caret"></span> |
209 | 209 | </a> |
210 | 210 | <ul class="dropdown-menu" role="menu"> |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | ?> |
219 | 219 | <!-- |
220 | 220 | <li class="dropdown"> |
221 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
221 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
222 | 222 | <?php echo _("Fatalities"); ?> <span class="caret"></span> |
223 | 223 | </a> |
224 | 224 | <ul class="dropdown-menu" role="menu"> |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | } elseif ($type == 'marine' || $type == 'tracker') { |
235 | 235 | ?> |
236 | 236 | <li class="dropdown"> |
237 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
237 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
238 | 238 | <?php echo _("Date & Time"); ?> <span class="caret"></span> |
239 | 239 | </a> |
240 | 240 | <ul class="dropdown-menu" role="menu"> |
@@ -7,21 +7,21 @@ discard block |
||
7 | 7 | header('Location: '.$globalURL.'/airline'); |
8 | 8 | die(); |
9 | 9 | } |
10 | -$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
10 | +$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
11 | 11 | $Spotter = new Spotter(); |
12 | 12 | $alliance = false; |
13 | -if (strpos($airline,'alliance_') !== FALSE) { |
|
13 | +if (strpos($airline, 'alliance_') !== FALSE) { |
|
14 | 14 | $alliance = true; |
15 | 15 | } else { |
16 | - $spotter_array = $Spotter->getSpotterDataByAirline($airline,"0,1",""); |
|
16 | + $spotter_array = $Spotter->getSpotterDataByAirline($airline, "0,1", ""); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | if (!empty($spotter_array) || $alliance === true) |
20 | 20 | { |
21 | 21 | if ($alliance) { |
22 | - $title = sprintf(_("Most Common Aircraft Manufacturer from %s"),str_replace('_',' ',str_replace('alliance_','',$airline))); |
|
22 | + $title = sprintf(_("Most Common Aircraft Manufacturer from %s"), str_replace('_', ' ', str_replace('alliance_', '', $airline))); |
|
23 | 23 | } else { |
24 | - $title = sprintf(_("Most Common Aircraft Manufacturer from %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']); |
|
24 | + $title = sprintf(_("Most Common Aircraft Manufacturer from %s (%s)"), $spotter_array[0]['airline_name'], $spotter_array[0]['airline_icao']); |
|
25 | 25 | } |
26 | 26 | require_once('header.php'); |
27 | 27 | print '<div class="select-item">'; |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $alliances = $Spotter->getAllAllianceNames(); |
32 | 32 | if (!empty($alliances)) { |
33 | 33 | foreach ($alliances as $al) { |
34 | - if ($alliance && str_replace('_',' ',str_replace('alliance_','',$airline)) == $al['alliance']) { |
|
35 | - print '<option value="'.str_replace(' ','_',$al['alliance']).'" selected>'.$al['alliance'].'</option>'; |
|
34 | + if ($alliance && str_replace('_', ' ', str_replace('alliance_', '', $airline)) == $al['alliance']) { |
|
35 | + print '<option value="'.str_replace(' ', '_', $al['alliance']).'" selected>'.$al['alliance'].'</option>'; |
|
36 | 36 | } else { |
37 | - print '<option value="'.str_replace(' ','_',$al['alliance']).'">'.$al['alliance'].'</option>'; |
|
37 | + print '<option value="'.str_replace(' ', '_', $al['alliance']).'">'.$al['alliance'].'</option>'; |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | print '<option disabled>───────────────────</option>'; |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | $Stats = new Stats(); |
43 | 43 | $airline_names = $Stats->getAllAirlineNames(); |
44 | 44 | if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames(); |
45 | - foreach($airline_names as $airline_name) |
|
45 | + foreach ($airline_names as $airline_name) |
|
46 | 46 | { |
47 | - if($airline == $airline_name['airline_icao']) |
|
47 | + if ($airline == $airline_name['airline_icao']) |
|
48 | 48 | { |
49 | 49 | print '<option value="'.$airline_name['airline_icao'].'" selected="selected">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>'; |
50 | 50 | } else { |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | print '</div>'; |
79 | 79 | } else { |
80 | 80 | print '<div class="info column">'; |
81 | - print '<h1>'.str_replace('_',' ',str_replace('alliance_','',$airline)).'</h1>'; |
|
82 | - if (@getimagesize($globalURL.'/images/airlines/'.str_replace('alliance_','',$airline).'.png') || @getimagesize('images/airlines/'.str_replace('alliance_','',$airline).'.png')) |
|
81 | + print '<h1>'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'</h1>'; |
|
82 | + if (@getimagesize($globalURL.'/images/airlines/'.str_replace('alliance_', '', $airline).'.png') || @getimagesize('images/airlines/'.str_replace('alliance_', '', $airline).'.png')) |
|
83 | 83 | { |
84 | - print '<img src="'.$globalURL.'/images/airlines/'.str_replace('alliance_','',$airline).'.png" alt="'.str_replace('_',' ',str_replace('alliance_','',$airline)).'" title="'.str_replace('_',' ',str_replace('alliance_','',$airline)).'" class="logo" />'; |
|
84 | + print '<img src="'.$globalURL.'/images/airlines/'.str_replace('alliance_', '', $airline).'.png" alt="'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'" title="'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'" class="logo" />'; |
|
85 | 85 | } |
86 | - print '<div><span class="label">'._("Name").'</span>'.str_replace('_',' ',str_replace('alliance_','',$airline)).'</div>'; |
|
86 | + print '<div><span class="label">'._("Name").'</span>'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'</div>'; |
|
87 | 87 | print '</div>'; |
88 | 88 | } |
89 | 89 | } else { |
@@ -94,16 +94,16 @@ discard block |
||
94 | 94 | print '<div class="column">'; |
95 | 95 | print '<h2>'._("Most Common Aircraft Manufacturer").'</h2>'; |
96 | 96 | if ($alliance) { |
97 | - print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of flights from <strong>%s</strong>."),str_replace('_',' ',str_replace('alliance_','',$airline))).'</p>'; |
|
97 | + print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of flights from <strong>%s</strong>."), str_replace('_', ' ', str_replace('alliance_', '', $airline))).'</p>'; |
|
98 | 98 | } else { |
99 | - print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of flights from <strong>%s</strong>."),$spotter_array[0]['airline_name']).'</p>'; |
|
99 | + print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of flights from <strong>%s</strong>."), $spotter_array[0]['airline_name']).'</p>'; |
|
100 | 100 | } |
101 | 101 | if ($alliance) { |
102 | - $manufacturers_array = $Spotter->countAllAircraftManufacturerByAirline('',array('alliance' => str_replace('_',' ',str_replace('alliance_','',$airline)))); |
|
102 | + $manufacturers_array = $Spotter->countAllAircraftManufacturerByAirline('', array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $airline)))); |
|
103 | 103 | } else { |
104 | 104 | $manufacturers_array = $Spotter->countAllAircraftManufacturerByAirline($airline); |
105 | 105 | } |
106 | - $manufacturers_array = $Stats->countAllAircraftManufacturers(true,$airline); |
|
106 | + $manufacturers_array = $Stats->countAllAircraftManufacturers(true, $airline); |
|
107 | 107 | if (!empty($manufacturers_array)) |
108 | 108 | { |
109 | 109 | print '<div class="table-responsive">'; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | print '</thead>'; |
117 | 117 | print '<tbody>'; |
118 | 118 | $i = 1; |
119 | - foreach($manufacturers_array as $manufacturer_item) |
|
119 | + foreach ($manufacturers_array as $manufacturer_item) |
|
120 | 120 | { |
121 | 121 | print '<tr>'; |
122 | 122 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -7,22 +7,22 @@ discard block |
||
7 | 7 | header('Location: '.$globalURL.'/airline'); |
8 | 8 | die(); |
9 | 9 | } |
10 | -$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
10 | +$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
11 | 11 | $Spotter = new Spotter(); |
12 | 12 | $alliance = false; |
13 | -if (strpos($airline,'alliance_') !== FALSE) { |
|
13 | +if (strpos($airline, 'alliance_') !== FALSE) { |
|
14 | 14 | // $spotter_array = $Spotter->getSpotterDataByAirline('',"0,1","",array('alliance' => str_replace('_',' ',str_replace('alliance_','',$airline)))); |
15 | 15 | $alliance = true; |
16 | 16 | } else { |
17 | - $spotter_array = $Spotter->getSpotterDataByAirline($airline,"0,1",""); |
|
17 | + $spotter_array = $Spotter->getSpotterDataByAirline($airline, "0,1", ""); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | if (!empty($spotter_array) || $alliance === true) |
21 | 21 | { |
22 | 22 | if ($alliance) { |
23 | - $title = sprintf(_("Most Common Aircraft from %s"),str_replace('_',' ',str_replace('alliance_','',$airline))); |
|
23 | + $title = sprintf(_("Most Common Aircraft from %s"), str_replace('_', ' ', str_replace('alliance_', '', $airline))); |
|
24 | 24 | } else { |
25 | - $title = sprintf(_("Most Common Aircraft from %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']); |
|
25 | + $title = sprintf(_("Most Common Aircraft from %s (%s)"), $spotter_array[0]['airline_name'], $spotter_array[0]['airline_icao']); |
|
26 | 26 | } |
27 | 27 | require_once('header.php'); |
28 | 28 | print '<div class="select-item">'; |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | $alliances = $Spotter->getAllAllianceNames(); |
33 | 33 | if (!empty($alliances)) { |
34 | 34 | foreach ($alliances as $al) { |
35 | - if ($alliance && str_replace('_',' ',str_replace('alliance_','',$airline)) == $al['alliance']) { |
|
36 | - print '<option value="'.str_replace(' ','_',$al['alliance']).'" selected>'.$al['alliance'].'</option>'; |
|
35 | + if ($alliance && str_replace('_', ' ', str_replace('alliance_', '', $airline)) == $al['alliance']) { |
|
36 | + print '<option value="'.str_replace(' ', '_', $al['alliance']).'" selected>'.$al['alliance'].'</option>'; |
|
37 | 37 | } else { |
38 | - print '<option value="'.str_replace(' ','_',$al['alliance']).'">'.$al['alliance'].'</option>'; |
|
38 | + print '<option value="'.str_replace(' ', '_', $al['alliance']).'">'.$al['alliance'].'</option>'; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | print '<option disabled>────────────────</option>'; |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | $Stats = new Stats(); |
44 | 44 | $airline_names = $Stats->getAllAirlineNames(); |
45 | 45 | if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames(); |
46 | - foreach($airline_names as $airline_name) |
|
46 | + foreach ($airline_names as $airline_name) |
|
47 | 47 | { |
48 | - if($airline == $airline_name['airline_icao']) |
|
48 | + if ($airline == $airline_name['airline_icao']) |
|
49 | 49 | { |
50 | 50 | print '<option value="'.$airline_name['airline_icao'].'" selected="selected">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>'; |
51 | 51 | } else { |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | print '</div>'; |
80 | 80 | } else { |
81 | 81 | print '<div class="info column">'; |
82 | - print '<h1>'.str_replace('_',' ',str_replace('alliance_','',$airline)).'</h1>'; |
|
83 | - if (@getimagesize($globalURL.'/images/airlines/'.str_replace('alliance_','',$airline).'.png') || @getimagesize('images/airlines/'.str_replace('alliance_','',$airline).'.png')) |
|
82 | + print '<h1>'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'</h1>'; |
|
83 | + if (@getimagesize($globalURL.'/images/airlines/'.str_replace('alliance_', '', $airline).'.png') || @getimagesize('images/airlines/'.str_replace('alliance_', '', $airline).'.png')) |
|
84 | 84 | { |
85 | - print '<img src="'.$globalURL.'/images/airlines/'.str_replace('alliance_','',$airline).'.png" alt="'.str_replace('_',' ',str_replace('alliance_','',$airline)).'" title="'.str_replace('_',' ',str_replace('alliance_','',$airline)).'" class="logo" />'; |
|
85 | + print '<img src="'.$globalURL.'/images/airlines/'.str_replace('alliance_', '', $airline).'.png" alt="'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'" title="'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'" class="logo" />'; |
|
86 | 86 | } |
87 | - print '<div><span class="label">'._("Name").'</span>'.str_replace('_',' ',str_replace('alliance_','',$airline)).'</div>'; |
|
87 | + print '<div><span class="label">'._("Name").'</span>'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'</div>'; |
|
88 | 88 | print '</div>'; |
89 | 89 | } |
90 | 90 | } else { |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | print '<div class="column">'; |
96 | 96 | print '<h2>'._("Most Common Aircraft").'</h2>'; |
97 | 97 | if ($alliance === false) { |
98 | - print '<p>'.sprintf(_("The statistic below shows the most common aircrafts of flights from <strong>%s</strong>."),$spotter_array[0]['airline_name']).'</p>'; |
|
98 | + print '<p>'.sprintf(_("The statistic below shows the most common aircrafts of flights from <strong>%s</strong>."), $spotter_array[0]['airline_name']).'</p>'; |
|
99 | 99 | } else { |
100 | - print '<p>'.sprintf(_("The statistic below shows the most common aircrafts of flights from <strong>%s</strong>."),str_replace('_',' ',str_replace('alliance_','',$airline))).'</p>'; |
|
100 | + print '<p>'.sprintf(_("The statistic below shows the most common aircrafts of flights from <strong>%s</strong>."), str_replace('_', ' ', str_replace('alliance_', '', $airline))).'</p>'; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /* |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $aircraft_array = $Spotter->countAllAircraftTypesByAirline($airline); |
108 | 108 | } |
109 | 109 | */ |
110 | - $aircraft_array = $Stats->countAllAircraftTypes(true,$airline); |
|
110 | + $aircraft_array = $Stats->countAllAircraftTypes(true, $airline); |
|
111 | 111 | if (!empty($aircraft_array)) |
112 | 112 | { |
113 | 113 | print '<div class="table-responsive">'; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | print '</thead>'; |
121 | 121 | print '<tbody>'; |
122 | 122 | $i = 1; |
123 | - foreach($aircraft_array as $aircraft_item) |
|
123 | + foreach ($aircraft_array as $aircraft_item) |
|
124 | 124 | { |
125 | 125 | print '<tr>'; |
126 | 126 | print '<td><strong>'.$i.'</strong></td>'; |