@@ -15,33 +15,33 @@ discard block  | 
                                                    ||
| 15 | 15 | if (isset($globalFilterName)) $this->filter_name = $globalFilterName;  | 
                                                        
| 16 | 16 | $Connection = new Connection($dbc);  | 
                                                        
| 17 | 17 | $this->db = $Connection->db();  | 
                                                        
| 18 | - }  | 
                                                        |
| 18 | + }  | 
                                                        |
| 19 | 19 | |
| 20 | 20 |  	public function addLastStatsUpdate($type,$stats_date) { | 
                                                        
| 21 | - $query = "DELETE FROM config WHERE name = :type;  | 
                                                        |
| 21 | + $query = "DELETE FROM config WHERE name = :type;  | 
                                                        |
| 22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);";  | 
                                                        
| 23 | -                $query_values = array('type' => $type,':stats_date' => $stats_date); | 
                                                        |
| 24 | -                 try { | 
                                                        |
| 25 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 26 | - $sth->execute($query_values);  | 
                                                        |
| 27 | -                } catch(PDOException $e) { | 
                                                        |
| 28 | - return "error : ".$e->getMessage();  | 
                                                        |
| 29 | - }  | 
                                                        |
| 30 | - }  | 
                                                        |
| 23 | +				$query_values = array('type' => $type,':stats_date' => $stats_date); | 
                                                        |
| 24 | +				 try { | 
                                                        |
| 25 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 26 | + $sth->execute($query_values);  | 
                                                        |
| 27 | +				} catch(PDOException $e) { | 
                                                        |
| 28 | + return "error : ".$e->getMessage();  | 
                                                        |
| 29 | + }  | 
                                                        |
| 30 | + }  | 
                                                        |
| 31 | 31 | |
| 32 | 32 |  	public function getLastStatsUpdate($type = 'last_update_stats') { | 
                                                        
| 33 | - $query = "SELECT value FROM config WHERE name = :type";  | 
                                                        |
| 34 | -                 try { | 
                                                        |
| 35 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 36 | -                        $sth->execute(array(':type' => $type)); | 
                                                        |
| 37 | -                } catch(PDOException $e) { | 
                                                        |
| 38 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 39 | - }  | 
                                                        |
| 40 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 41 | - return $all;  | 
                                                        |
| 42 | - }  | 
                                                        |
| 43 | -        public function deleteStats($filter_name = '') { | 
                                                        |
| 44 | - /*  | 
                                                        |
| 33 | + $query = "SELECT value FROM config WHERE name = :type";  | 
                                                        |
| 34 | +				 try { | 
                                                        |
| 35 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 36 | +						$sth->execute(array(':type' => $type)); | 
                                                        |
| 37 | +				} catch(PDOException $e) { | 
                                                        |
| 38 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 39 | + }  | 
                                                        |
| 40 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 41 | + return $all;  | 
                                                        |
| 42 | + }  | 
                                                        |
| 43 | +		public function deleteStats($filter_name = '') { | 
                                                        |
| 44 | + /*  | 
                                                        |
| 45 | 45 | $query = "DELETE FROM config WHERE name = 'last_update_stats'";  | 
                                                        
| 46 | 46 |                   try { | 
                                                        
| 47 | 47 | $sth = $this->db->prepare($query);  | 
                                                        
@@ -50,62 +50,62 @@ discard block  | 
                                                    ||
| 50 | 50 | return "error : ".$e->getMessage();  | 
                                                        
| 51 | 51 | }  | 
                                                        
| 52 | 52 | */  | 
                                                        
| 53 | - $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";  | 
                                                        |
| 54 | -                 try { | 
                                                        |
| 55 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 56 | -                        $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 57 | -                } catch(PDOException $e) { | 
                                                        |
| 58 | - return "error : ".$e->getMessage();  | 
                                                        |
| 59 | - }  | 
                                                        |
| 60 | - }  | 
                                                        |
| 53 | + $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";  | 
                                                        |
| 54 | +				 try { | 
                                                        |
| 55 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 56 | +						$sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 57 | +				} catch(PDOException $e) { | 
                                                        |
| 58 | + return "error : ".$e->getMessage();  | 
                                                        |
| 59 | + }  | 
                                                        |
| 60 | + }  | 
                                                        |
| 61 | 61 |  	public function getAllAirlineNames($filter_name = '') { | 
                                                        
| 62 | 62 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 63 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";  | 
                                                        |
| 64 | -                 try { | 
                                                        |
| 65 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 66 | -                        $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 67 | -                } catch(PDOException $e) { | 
                                                        |
| 68 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 69 | - }  | 
                                                        |
| 70 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 71 | - return $all;  | 
                                                        |
| 72 | - }  | 
                                                        |
| 63 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";  | 
                                                        |
| 64 | +				 try { | 
                                                        |
| 65 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 66 | +						$sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 67 | +				} catch(PDOException $e) { | 
                                                        |
| 68 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 69 | + }  | 
                                                        |
| 70 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 71 | + return $all;  | 
                                                        |
| 72 | + }  | 
                                                        |
| 73 | 73 |  	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { | 
                                                        
| 74 | 74 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 75 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";  | 
                                                        |
| 76 | -                 try { | 
                                                        |
| 77 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 78 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 79 | -                } catch(PDOException $e) { | 
                                                        |
| 80 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 81 | - }  | 
                                                        |
| 82 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 83 | - return $all;  | 
                                                        |
| 84 | - }  | 
                                                        |
| 75 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";  | 
                                                        |
| 76 | +				 try { | 
                                                        |
| 77 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 78 | +						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 79 | +				} catch(PDOException $e) { | 
                                                        |
| 80 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 81 | + }  | 
                                                        |
| 82 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 83 | + return $all;  | 
                                                        |
| 84 | + }  | 
                                                        |
| 85 | 85 |  	public function getAllManufacturers($stats_airline = '',$filter_name = '') { | 
                                                        
| 86 | 86 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 87 | - $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";  | 
                                                        |
| 88 | -                 try { | 
                                                        |
| 89 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 90 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 91 | -                } catch(PDOException $e) { | 
                                                        |
| 92 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 93 | - }  | 
                                                        |
| 94 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 95 | - return $all;  | 
                                                        |
| 96 | - }  | 
                                                        |
| 87 | + $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";  | 
                                                        |
| 88 | +				 try { | 
                                                        |
| 89 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 90 | +						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 91 | +				} catch(PDOException $e) { | 
                                                        |
| 92 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 93 | + }  | 
                                                        |
| 94 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 95 | + return $all;  | 
                                                        |
| 96 | + }  | 
                                                        |
| 97 | 97 |  	public function getAllAirportNames($stats_airline = '',$filter_name = '') { | 
                                                        
| 98 | 98 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 99 | - $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";  | 
                                                        |
| 100 | -                 try { | 
                                                        |
| 101 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 102 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 103 | -                } catch(PDOException $e) { | 
                                                        |
| 104 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 105 | - }  | 
                                                        |
| 106 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 107 | - return $all;  | 
                                                        |
| 108 | - }  | 
                                                        |
| 99 | + $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";  | 
                                                        |
| 100 | +				 try { | 
                                                        |
| 101 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 102 | +						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 103 | +				} catch(PDOException $e) { | 
                                                        |
| 104 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 105 | + }  | 
                                                        |
| 106 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 107 | + return $all;  | 
                                                        |
| 108 | + }  | 
                                                        |
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 |  	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        
@@ -113,66 +113,66 @@ discard block  | 
                                                    ||
| 113 | 113 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 114 | 114 | if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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 LIMIT 10 OFFSET 0";  | 
                                                        
| 115 | 115 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";  | 
                                                        
| 116 | -                 try { | 
                                                        |
| 117 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 118 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 119 | -                } catch(PDOException $e) { | 
                                                        |
| 120 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 121 | - }  | 
                                                        |
| 122 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 123 | -                if (empty($all)) { | 
                                                        |
| 124 | -            	    $filters = array('airlines' => array($stats_airline)); | 
                                                        |
| 125 | -            	    if ($filter_name != '') { | 
                                                        |
| 126 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 127 | - }  | 
                                                        |
| 128 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 129 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);  | 
                                                        |
| 130 | - }  | 
                                                        |
| 131 | - return $all;  | 
                                                        |
| 116 | +				 try { | 
                                                        |
| 117 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 118 | +						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 119 | +				} catch(PDOException $e) { | 
                                                        |
| 120 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 121 | + }  | 
                                                        |
| 122 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 123 | +				if (empty($all)) { | 
                                                        |
| 124 | +					$filters = array('airlines' => array($stats_airline)); | 
                                                        |
| 125 | +					if ($filter_name != '') { | 
                                                        |
| 126 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 127 | + }  | 
                                                        |
| 128 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 129 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);  | 
                                                        |
| 130 | + }  | 
                                                        |
| 131 | + return $all;  | 
                                                        |
| 132 | 132 | }  | 
                                                        
| 133 | 133 |  	public function countAllAirlineCountries($limit = true,$filter_name = '') { | 
                                                        
| 134 | 134 | global $globalStatsFilters;  | 
                                                        
| 135 | 135 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 136 | 136 | if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";  | 
                                                        
| 137 | 137 | else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";  | 
                                                        
| 138 | -                 try { | 
                                                        |
| 139 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 140 | -                        $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 141 | -                } catch(PDOException $e) { | 
                                                        |
| 142 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 143 | - }  | 
                                                        |
| 144 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 145 | -                if (empty($all)) { | 
                                                        |
| 146 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 147 | - $filters = array();  | 
                                                        |
| 148 | -            		if ($filter_name != '') { | 
                                                        |
| 149 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 150 | - }  | 
                                                        |
| 151 | - $all = $Spotter->countAllAirlineCountries($limit,$filters);  | 
                                                        |
| 152 | - }  | 
                                                        |
| 153 | - return $all;  | 
                                                        |
| 138 | +				 try { | 
                                                        |
| 139 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 140 | +						$sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 141 | +				} catch(PDOException $e) { | 
                                                        |
| 142 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 143 | + }  | 
                                                        |
| 144 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 145 | +				if (empty($all)) { | 
                                                        |
| 146 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 147 | + $filters = array();  | 
                                                        |
| 148 | +					if ($filter_name != '') { | 
                                                        |
| 149 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 150 | + }  | 
                                                        |
| 151 | + $all = $Spotter->countAllAirlineCountries($limit,$filters);  | 
                                                        |
| 152 | + }  | 
                                                        |
| 153 | + return $all;  | 
                                                        |
| 154 | 154 | }  | 
                                                        
| 155 | 155 |  	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { | 
                                                        
| 156 | 156 | global $globalStatsFilters;  | 
                                                        
| 157 | 157 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 158 | 158 | if ($limit) $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 LIMIT 10 OFFSET 0";  | 
                                                        
| 159 | 159 | 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";  | 
                                                        
| 160 | -                 try { | 
                                                        |
| 161 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 162 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 163 | -                } catch(PDOException $e) { | 
                                                        |
| 164 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 165 | - }  | 
                                                        |
| 166 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 167 | -                if (empty($all)) { | 
                                                        |
| 168 | -            		$filters = array('airlines' => array($stats_airline)); | 
                                                        |
| 169 | -            		if ($filter_name != '') { | 
                                                        |
| 170 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 160 | +				 try { | 
                                                        |
| 161 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 162 | +						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 163 | +				} catch(PDOException $e) { | 
                                                        |
| 164 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 165 | + }  | 
                                                        |
| 166 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 167 | +				if (empty($all)) { | 
                                                        |
| 168 | +					$filters = array('airlines' => array($stats_airline)); | 
                                                        |
| 169 | +					if ($filter_name != '') { | 
                                                        |
| 170 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 171 | 171 | }  | 
                                                        
| 172 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 172 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 173 | 173 | $all = $Spotter->countAllAircraftManufacturers($filters);  | 
                                                        
| 174 | - }  | 
                                                        |
| 175 | - return $all;  | 
                                                        |
| 174 | + }  | 
                                                        |
| 175 | + return $all;  | 
                                                        |
| 176 | 176 | }  | 
                                                        
| 177 | 177 | |
| 178 | 178 |  	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        
@@ -180,44 +180,44 @@ discard block  | 
                                                    ||
| 180 | 180 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 181 | 181 | if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";  | 
                                                        
| 182 | 182 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";  | 
                                                        
| 183 | -                 try { | 
                                                        |
| 184 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 185 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 186 | -                } catch(PDOException $e) { | 
                                                        |
| 187 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 188 | - }  | 
                                                        |
| 189 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 190 | -                if (empty($all)) { | 
                                                        |
| 183 | +				 try { | 
                                                        |
| 184 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 185 | +						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 186 | +				} catch(PDOException $e) { | 
                                                        |
| 187 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 188 | + }  | 
                                                        |
| 189 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 190 | +				if (empty($all)) { | 
                                                        |
| 191 | 191 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 192 | 192 |  			if ($filter_name != '') { | 
                                                        
| 193 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 193 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 194 | 194 | }  | 
                                                        
| 195 | 195 | $Spotter = new Spotter($this->db);  | 
                                                        
| 196 | 196 | $all = $Spotter->countAllArrivalCountries($limit,$filters);  | 
                                                        
| 197 | - }  | 
                                                        |
| 198 | - return $all;  | 
                                                        |
| 197 | + }  | 
                                                        |
| 198 | + return $all;  | 
                                                        |
| 199 | 199 | }  | 
                                                        
| 200 | 200 |  	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        
| 201 | 201 | global $globalStatsFilters;  | 
                                                        
| 202 | 202 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 203 | 203 | if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";  | 
                                                        
| 204 | 204 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";  | 
                                                        
| 205 | -                 try { | 
                                                        |
| 206 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 207 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 208 | -                } catch(PDOException $e) { | 
                                                        |
| 209 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 210 | - }  | 
                                                        |
| 211 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 212 | -                if (empty($all)) { | 
                                                        |
| 205 | +				 try { | 
                                                        |
| 206 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 207 | +						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 208 | +				} catch(PDOException $e) { | 
                                                        |
| 209 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 210 | + }  | 
                                                        |
| 211 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 212 | +				if (empty($all)) { | 
                                                        |
| 213 | 213 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 214 | 214 |  			if ($filter_name != '') { | 
                                                        
| 215 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 215 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 216 | 216 | }  | 
                                                        
| 217 | 217 | $Spotter = new Spotter($this->db);  | 
                                                        
| 218 | 218 | $all = $Spotter->countAllDepartureCountries($filters);  | 
                                                        
| 219 | - }  | 
                                                        |
| 220 | - return $all;  | 
                                                        |
| 219 | + }  | 
                                                        |
| 220 | + return $all;  | 
                                                        |
| 221 | 221 | }  | 
                                                        
| 222 | 222 | |
| 223 | 223 |  	public function countAllAirlines($limit = true,$filter_name = '') { | 
                                                        
@@ -225,45 +225,45 @@ discard block  | 
                                                    ||
| 225 | 225 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 226 | 226 | 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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0";  | 
                                                        
| 227 | 227 | 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 ORDER BY airline_count DESC";  | 
                                                        
| 228 | -                 try { | 
                                                        |
| 229 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 230 | -                        $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 231 | -                } catch(PDOException $e) { | 
                                                        |
| 232 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 233 | - }  | 
                                                        |
| 234 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 235 | -                if (empty($all)) { | 
                                                        |
| 236 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 237 | - $filters = array();  | 
                                                        |
| 238 | -            		if ($filter_name != '') { | 
                                                        |
| 239 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 228 | +				 try { | 
                                                        |
| 229 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 230 | +						$sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 231 | +				} catch(PDOException $e) { | 
                                                        |
| 232 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 233 | + }  | 
                                                        |
| 234 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 235 | +				if (empty($all)) { | 
                                                        |
| 236 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 237 | + $filters = array();  | 
                                                        |
| 238 | +					if ($filter_name != '') { | 
                                                        |
| 239 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 240 | 240 | }  | 
                                                        
| 241 | 241 | |
| 242 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters);  | 
                                                        |
| 243 | - }  | 
                                                        |
| 244 | - return $all;  | 
                                                        |
| 242 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters);  | 
                                                        |
| 243 | + }  | 
                                                        |
| 244 | + return $all;  | 
                                                        |
| 245 | 245 | }  | 
                                                        
| 246 | 246 |  	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 247 | 247 | global $globalStatsFilters;  | 
                                                        
| 248 | 248 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 249 | 249 | 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 = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";  | 
                                                        
| 250 | 250 | 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";  | 
                                                        
| 251 | -                 try { | 
                                                        |
| 252 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 253 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 254 | -                } catch(PDOException $e) { | 
                                                        |
| 255 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 256 | - }  | 
                                                        |
| 257 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 258 | -                if (empty($all)) { | 
                                                        |
| 251 | +				 try { | 
                                                        |
| 252 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 253 | +						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 254 | +				} catch(PDOException $e) { | 
                                                        |
| 255 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 256 | + }  | 
                                                        |
| 257 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 258 | +				if (empty($all)) { | 
                                                        |
| 259 | 259 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 260 | 260 |  			if ($filter_name != '') { | 
                                                        
| 261 | 261 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        
| 262 | 262 | }  | 
                                                        
| 263 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 264 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);  | 
                                                        |
| 265 | - }  | 
                                                        |
| 266 | - return $all;  | 
                                                        |
| 263 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 264 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);  | 
                                                        |
| 265 | + }  | 
                                                        |
| 266 | + return $all;  | 
                                                        |
| 267 | 267 | }  | 
                                                        
| 268 | 268 |  	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 269 | 269 | global $globalStatsFilters;  | 
                                                        
@@ -300,7 +300,7 @@ discard block  | 
                                                    ||
| 300 | 300 | echo "error : ".$e->getMessage();  | 
                                                        
| 301 | 301 | }  | 
                                                        
| 302 | 302 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 303 | - /*  | 
                                                        |
| 303 | + /*  | 
                                                        |
| 304 | 304 |                  if (empty($all)) { | 
                                                        
| 305 | 305 | $Spotter = new Spotter($this->db);  | 
                                                        
| 306 | 306 | $all = $Spotter->countAllFlightOverCountries($limit);  | 
                                                        
@@ -316,84 +316,84 @@ discard block  | 
                                                    ||
| 316 | 316 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 317 | 317 | if ($limit) $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 LIMIT 10 OFFSET 0";  | 
                                                        
| 318 | 318 | 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";  | 
                                                        
| 319 | -                 try { | 
                                                        |
| 320 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 321 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 322 | -                } catch(PDOException $e) { | 
                                                        |
| 323 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 324 | - }  | 
                                                        |
| 325 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 326 | -                if (empty($all)) { | 
                                                        |
| 319 | +				 try { | 
                                                        |
| 320 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 321 | +						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 322 | +				} catch(PDOException $e) { | 
                                                        |
| 323 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 324 | + }  | 
                                                        |
| 325 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 326 | +				if (empty($all)) { | 
                                                        |
| 327 | 327 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 328 | 328 |  			if ($filter_name != '') { | 
                                                        
| 329 | 329 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        
| 330 | 330 | }  | 
                                                        
| 331 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 332 | - $all = $Spotter->countAllPilots($limit,0,'',$filters);  | 
                                                        |
| 333 | - }  | 
                                                        |
| 334 | - return $all;  | 
                                                        |
| 331 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 332 | + $all = $Spotter->countAllPilots($limit,0,'',$filters);  | 
                                                        |
| 333 | + }  | 
                                                        |
| 334 | + return $all;  | 
                                                        |
| 335 | 335 | }  | 
                                                        
| 336 | 336 |  	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { | 
                                                        
| 337 | 337 | global $globalStatsFilters;  | 
                                                        
| 338 | 338 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 339 | 339 | if ($limit) $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 LIMIT 10 OFFSET 0";  | 
                                                        
| 340 | 340 | 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";  | 
                                                        
| 341 | -                 try { | 
                                                        |
| 342 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 343 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 344 | -                } catch(PDOException $e) { | 
                                                        |
| 345 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 346 | - }  | 
                                                        |
| 347 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 348 | -                if (empty($all)) { | 
                                                        |
| 341 | +				 try { | 
                                                        |
| 342 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 343 | +						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 344 | +				} catch(PDOException $e) { | 
                                                        |
| 345 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 346 | + }  | 
                                                        |
| 347 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 348 | +				if (empty($all)) { | 
                                                        |
| 349 | 349 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 350 | 350 |  			if ($filter_name != '') { | 
                                                        
| 351 | 351 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        
| 352 | 352 | }  | 
                                                        
| 353 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 354 | - $all = $Spotter->countAllOwners($limit,0,'',$filters);  | 
                                                        |
| 355 | - }  | 
                                                        |
| 356 | - return $all;  | 
                                                        |
| 353 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 354 | + $all = $Spotter->countAllOwners($limit,0,'',$filters);  | 
                                                        |
| 355 | + }  | 
                                                        |
| 356 | + return $all;  | 
                                                        |
| 357 | 357 | }  | 
                                                        
| 358 | 358 |  	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 359 | 359 | global $globalStatsFilters;  | 
                                                        
| 360 | 360 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 361 | 361 | 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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";  | 
                                                        
| 362 | 362 | 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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";  | 
                                                        
| 363 | -                 try { | 
                                                        |
| 364 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 365 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 366 | -                } catch(PDOException $e) { | 
                                                        |
| 367 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 368 | - }  | 
                                                        |
| 369 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 370 | -                if (empty($all)) { | 
                                                        |
| 363 | +				 try { | 
                                                        |
| 364 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 365 | +						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 366 | +				} catch(PDOException $e) { | 
                                                        |
| 367 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 368 | + }  | 
                                                        |
| 369 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 370 | +				if (empty($all)) { | 
                                                        |
| 371 | 371 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 372 | -            		if ($filter_name != '') { | 
                                                        |
| 373 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 374 | - }  | 
                                                        |
| 375 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 376 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);  | 
                                                        |
| 377 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);  | 
                                                        |
| 378 | - $all = array();  | 
                                                        |
| 379 | -        		foreach ($pall as $value) { | 
                                                        |
| 380 | - $icao = $value['airport_departure_icao'];  | 
                                                        |
| 381 | - $all[$icao] = $value;  | 
                                                        |
| 382 | - }  | 
                                                        |
| 372 | +					if ($filter_name != '') { | 
                                                        |
| 373 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 374 | + }  | 
                                                        |
| 375 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 376 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);  | 
                                                        |
| 377 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);  | 
                                                        |
| 378 | + $all = array();  | 
                                                        |
| 379 | +				foreach ($pall as $value) { | 
                                                        |
| 380 | + $icao = $value['airport_departure_icao'];  | 
                                                        |
| 381 | + $all[$icao] = $value;  | 
                                                        |
| 382 | + }  | 
                                                        |
| 383 | 383 | |
| 384 | -        		foreach ($dall as $value) { | 
                                                        |
| 385 | - $icao = $value['airport_departure_icao'];  | 
                                                        |
| 386 | -        			if (isset($all[$icao])) { | 
                                                        |
| 387 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];  | 
                                                        |
| 388 | - } else $all[$icao] = $value;  | 
                                                        |
| 389 | - }  | 
                                                        |
| 390 | - $count = array();  | 
                                                        |
| 391 | -        		foreach ($all as $key => $row) { | 
                                                        |
| 392 | - $count[$key] = $row['airport_departure_icao_count'];  | 
                                                        |
| 393 | - }  | 
                                                        |
| 394 | - array_multisort($count,SORT_DESC,$all);  | 
                                                        |
| 395 | - }  | 
                                                        |
| 396 | - return $all;  | 
                                                        |
| 384 | +				foreach ($dall as $value) { | 
                                                        |
| 385 | + $icao = $value['airport_departure_icao'];  | 
                                                        |
| 386 | +					if (isset($all[$icao])) { | 
                                                        |
| 387 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];  | 
                                                        |
| 388 | + } else $all[$icao] = $value;  | 
                                                        |
| 389 | + }  | 
                                                        |
| 390 | + $count = array();  | 
                                                        |
| 391 | +				foreach ($all as $key => $row) { | 
                                                        |
| 392 | + $count[$key] = $row['airport_departure_icao_count'];  | 
                                                        |
| 393 | + }  | 
                                                        |
| 394 | + array_multisort($count,SORT_DESC,$all);  | 
                                                        |
| 395 | + }  | 
                                                        |
| 396 | + return $all;  | 
                                                        |
| 397 | 397 | }  | 
                                                        
| 398 | 398 |  	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 399 | 399 | global $globalStatsFilters;  | 
                                                        
@@ -415,26 +415,26 @@ discard block  | 
                                                    ||
| 415 | 415 | $Spotter = new Spotter($this->db);  | 
                                                        
| 416 | 416 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);  | 
                                                        
| 417 | 417 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);  | 
                                                        
| 418 | - $all = array();  | 
                                                        |
| 419 | -        		foreach ($pall as $value) { | 
                                                        |
| 420 | - $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 421 | - $all[$icao] = $value;  | 
                                                        |
| 422 | - }  | 
                                                        |
| 418 | + $all = array();  | 
                                                        |
| 419 | +				foreach ($pall as $value) { | 
                                                        |
| 420 | + $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 421 | + $all[$icao] = $value;  | 
                                                        |
| 422 | + }  | 
                                                        |
| 423 | 423 | |
| 424 | -        		foreach ($dall as $value) { | 
                                                        |
| 425 | - $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 426 | -        			if (isset($all[$icao])) { | 
                                                        |
| 427 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];  | 
                                                        |
| 428 | - } else $all[$icao] = $value;  | 
                                                        |
| 429 | - }  | 
                                                        |
| 430 | - $count = array();  | 
                                                        |
| 431 | -        		foreach ($all as $key => $row) { | 
                                                        |
| 432 | - $count[$key] = $row['airport_arrival_icao_count'];  | 
                                                        |
| 433 | - }  | 
                                                        |
| 434 | - array_multisort($count,SORT_DESC,$all);  | 
                                                        |
| 435 | - }  | 
                                                        |
| 424 | +				foreach ($dall as $value) { | 
                                                        |
| 425 | + $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 426 | +					if (isset($all[$icao])) { | 
                                                        |
| 427 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];  | 
                                                        |
| 428 | + } else $all[$icao] = $value;  | 
                                                        |
| 429 | + }  | 
                                                        |
| 430 | + $count = array();  | 
                                                        |
| 431 | +				foreach ($all as $key => $row) { | 
                                                        |
| 432 | + $count[$key] = $row['airport_arrival_icao_count'];  | 
                                                        |
| 433 | + }  | 
                                                        |
| 434 | + array_multisort($count,SORT_DESC,$all);  | 
                                                        |
| 435 | + }  | 
                                                        |
| 436 | 436 | |
| 437 | - return $all;  | 
                                                        |
| 437 | + return $all;  | 
                                                        |
| 438 | 438 | }  | 
                                                        
| 439 | 439 |  	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 440 | 440 | global $globalDBdriver, $globalStatsFilters;  | 
                                                        
@@ -447,23 +447,23 @@ discard block  | 
                                                    ||
| 447 | 447 | 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";  | 
                                                        
| 448 | 448 | }  | 
                                                        
| 449 | 449 |  		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        
| 450 | -                 try { | 
                                                        |
| 451 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 452 | - $sth->execute($query_data);  | 
                                                        |
| 453 | -                } catch(PDOException $e) { | 
                                                        |
| 454 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 455 | - }  | 
                                                        |
| 456 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 457 | -                if (empty($all)) { | 
                                                        |
| 450 | +				 try { | 
                                                        |
| 451 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 452 | + $sth->execute($query_data);  | 
                                                        |
| 453 | +				} catch(PDOException $e) { | 
                                                        |
| 454 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 455 | + }  | 
                                                        |
| 456 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 457 | +				if (empty($all)) { | 
                                                        |
| 458 | 458 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 459 | 459 |  			if ($filter_name != '') { | 
                                                        
| 460 | 460 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        
| 461 | 461 | }  | 
                                                        
| 462 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 463 | - $all = $Spotter->countAllMonthsLastYear($filters);  | 
                                                        |
| 464 | - }  | 
                                                        |
| 462 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 463 | + $all = $Spotter->countAllMonthsLastYear($filters);  | 
                                                        |
| 464 | + }  | 
                                                        |
| 465 | 465 | |
| 466 | - return $all;  | 
                                                        |
| 466 | + return $all;  | 
                                                        |
| 467 | 467 | }  | 
                                                        
| 468 | 468 | |
| 469 | 469 |  	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { | 
                                                        
@@ -471,22 +471,22 @@ discard block  | 
                                                    ||
| 471 | 471 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 472 | 472 | $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";  | 
                                                        
| 473 | 473 |  		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        
| 474 | -                 try { | 
                                                        |
| 475 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 476 | - $sth->execute($query_data);  | 
                                                        |
| 477 | -                } catch(PDOException $e) { | 
                                                        |
| 478 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 479 | - }  | 
                                                        |
| 480 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 481 | -                if (empty($all)) { | 
                                                        |
| 474 | +				 try { | 
                                                        |
| 475 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 476 | + $sth->execute($query_data);  | 
                                                        |
| 477 | +				} catch(PDOException $e) { | 
                                                        |
| 478 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 479 | + }  | 
                                                        |
| 480 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 481 | +				if (empty($all)) { | 
                                                        |
| 482 | 482 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 483 | 483 |  			if ($filter_name != '') { | 
                                                        
| 484 | 484 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        
| 485 | 485 | }  | 
                                                        
| 486 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 487 | - $all = $Spotter->countAllDatesLastMonth($filters);  | 
                                                        |
| 488 | - }  | 
                                                        |
| 489 | - return $all;  | 
                                                        |
| 486 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 487 | + $all = $Spotter->countAllDatesLastMonth($filters);  | 
                                                        |
| 488 | + }  | 
                                                        |
| 489 | + return $all;  | 
                                                        |
| 490 | 490 | }  | 
                                                        
| 491 | 491 |  	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { | 
                                                        
| 492 | 492 | global $globalDBdriver, $globalStatsFilters;  | 
                                                        
@@ -497,108 +497,108 @@ discard block  | 
                                                    ||
| 497 | 497 | $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";  | 
                                                        
| 498 | 498 | }  | 
                                                        
| 499 | 499 |  		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        
| 500 | -                 try { | 
                                                        |
| 501 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 502 | - $sth->execute($query_data);  | 
                                                        |
| 503 | -                } catch(PDOException $e) { | 
                                                        |
| 504 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 505 | - }  | 
                                                        |
| 506 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 507 | -                if (empty($all)) { | 
                                                        |
| 500 | +				 try { | 
                                                        |
| 501 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 502 | + $sth->execute($query_data);  | 
                                                        |
| 503 | +				} catch(PDOException $e) { | 
                                                        |
| 504 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 505 | + }  | 
                                                        |
| 506 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 507 | +				if (empty($all)) { | 
                                                        |
| 508 | 508 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 509 | 509 |  			if ($filter_name != '') { | 
                                                        
| 510 | 510 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        
| 511 | 511 | }  | 
                                                        
| 512 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 513 | - $all = $Spotter->countAllDatesLast7Days($filters);  | 
                                                        |
| 514 | - }  | 
                                                        |
| 515 | - return $all;  | 
                                                        |
| 512 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 513 | + $all = $Spotter->countAllDatesLast7Days($filters);  | 
                                                        |
| 514 | + }  | 
                                                        |
| 515 | + return $all;  | 
                                                        |
| 516 | 516 | }  | 
                                                        
| 517 | 517 |  	public function countAllDates($stats_airline = '',$filter_name = '') { | 
                                                        
| 518 | 518 | global $globalStatsFilters;  | 
                                                        
| 519 | 519 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 520 | 520 | $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";  | 
                                                        
| 521 | 521 |  		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        
| 522 | -                 try { | 
                                                        |
| 523 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 524 | - $sth->execute($query_data);  | 
                                                        |
| 525 | -                } catch(PDOException $e) { | 
                                                        |
| 526 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 527 | - }  | 
                                                        |
| 528 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 529 | -                if (empty($all)) { | 
                                                        |
| 522 | +				 try { | 
                                                        |
| 523 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 524 | + $sth->execute($query_data);  | 
                                                        |
| 525 | +				} catch(PDOException $e) { | 
                                                        |
| 526 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 527 | + }  | 
                                                        |
| 528 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 529 | +				if (empty($all)) { | 
                                                        |
| 530 | 530 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 531 | 531 |  			if ($filter_name != '') { | 
                                                        
| 532 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 532 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 533 | 533 | }  | 
                                                        
| 534 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 535 | - $all = $Spotter->countAllDates($filters);  | 
                                                        |
| 536 | - }  | 
                                                        |
| 537 | - return $all;  | 
                                                        |
| 534 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 535 | + $all = $Spotter->countAllDates($filters);  | 
                                                        |
| 536 | + }  | 
                                                        |
| 537 | + return $all;  | 
                                                        |
| 538 | 538 | }  | 
                                                        
| 539 | 539 |  	public function countAllDatesByAirlines($filter_name = '') { | 
                                                        
| 540 | 540 | global $globalStatsFilters;  | 
                                                        
| 541 | 541 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 542 | 542 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";  | 
                                                        
| 543 | 543 |  		$query_data = array('filter_name' => $filter_name); | 
                                                        
| 544 | -                 try { | 
                                                        |
| 545 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 546 | - $sth->execute($query_data);  | 
                                                        |
| 547 | -                } catch(PDOException $e) { | 
                                                        |
| 548 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 549 | - }  | 
                                                        |
| 550 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 551 | -                if (empty($all)) { | 
                                                        |
| 552 | - $filters = array();  | 
                                                        |
| 553 | -            		if ($filter_name != '') { | 
                                                        |
| 554 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 555 | - }  | 
                                                        |
| 556 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 557 | - $all = $Spotter->countAllDatesByAirlines($filters);  | 
                                                        |
| 558 | - }  | 
                                                        |
| 559 | - return $all;  | 
                                                        |
| 544 | +				 try { | 
                                                        |
| 545 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 546 | + $sth->execute($query_data);  | 
                                                        |
| 547 | +				} catch(PDOException $e) { | 
                                                        |
| 548 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 549 | + }  | 
                                                        |
| 550 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 551 | +				if (empty($all)) { | 
                                                        |
| 552 | + $filters = array();  | 
                                                        |
| 553 | +					if ($filter_name != '') { | 
                                                        |
| 554 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 555 | + }  | 
                                                        |
| 556 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 557 | + $all = $Spotter->countAllDatesByAirlines($filters);  | 
                                                        |
| 558 | + }  | 
                                                        |
| 559 | + return $all;  | 
                                                        |
| 560 | 560 | }  | 
                                                        
| 561 | 561 |  	public function countAllMonths($stats_airline = '',$filter_name = '') { | 
                                                        
| 562 | 562 | global $globalStatsFilters;  | 
                                                        
| 563 | 563 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 564 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        |
| 565 | -                 try { | 
                                                        |
| 566 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 567 | -                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 568 | -                } catch(PDOException $e) { | 
                                                        |
| 569 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 570 | - }  | 
                                                        |
| 571 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 572 | -                if (empty($all)) { | 
                                                        |
| 564 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        |
| 565 | +				 try { | 
                                                        |
| 566 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 567 | +						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 568 | +				} catch(PDOException $e) { | 
                                                        |
| 569 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 570 | + }  | 
                                                        |
| 571 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 572 | +				if (empty($all)) { | 
                                                        |
| 573 | 573 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 574 | 574 |  			if ($filter_name != '') { | 
                                                        
| 575 | 575 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        
| 576 | 576 | }  | 
                                                        
| 577 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 578 | - $all = $Spotter->countAllMonths($filters);  | 
                                                        |
| 579 | - }  | 
                                                        |
| 580 | - return $all;  | 
                                                        |
| 577 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 578 | + $all = $Spotter->countAllMonths($filters);  | 
                                                        |
| 579 | + }  | 
                                                        |
| 580 | + return $all;  | 
                                                        |
| 581 | 581 | }  | 
                                                        
| 582 | 582 |  	public function countAllMilitaryMonths($filter_name = '') { | 
                                                        
| 583 | 583 | global $globalStatsFilters;  | 
                                                        
| 584 | 584 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 585 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";  | 
                                                        |
| 586 | -                 try { | 
                                                        |
| 587 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 588 | -                        $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 589 | -                } catch(PDOException $e) { | 
                                                        |
| 590 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 591 | - }  | 
                                                        |
| 592 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 593 | -                if (empty($all)) { | 
                                                        |
| 594 | - $filters = array();  | 
                                                        |
| 595 | -            		if ($filter_name != '') { | 
                                                        |
| 596 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 597 | - }  | 
                                                        |
| 598 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 599 | - $all = $Spotter->countAllMilitaryMonths($filters);  | 
                                                        |
| 600 | - }  | 
                                                        |
| 601 | - return $all;  | 
                                                        |
| 585 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";  | 
                                                        |
| 586 | +				 try { | 
                                                        |
| 587 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 588 | +						$sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 589 | +				} catch(PDOException $e) { | 
                                                        |
| 590 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 591 | + }  | 
                                                        |
| 592 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 593 | +				if (empty($all)) { | 
                                                        |
| 594 | + $filters = array();  | 
                                                        |
| 595 | +					if ($filter_name != '') { | 
                                                        |
| 596 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 597 | + }  | 
                                                        |
| 598 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 599 | + $all = $Spotter->countAllMilitaryMonths($filters);  | 
                                                        |
| 600 | + }  | 
                                                        |
| 601 | + return $all;  | 
                                                        |
| 602 | 602 | }  | 
                                                        
| 603 | 603 |  	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 604 | 604 | global $globalTimezone, $globalDBdriver, $globalStatsFilters;  | 
                                                        
@@ -614,22 +614,22 @@ discard block  | 
                                                    ||
| 614 | 614 | $query .= " ORDER BY CAST(flight_date AS integer) ASC";  | 
                                                        
| 615 | 615 | }  | 
                                                        
| 616 | 616 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";  | 
                                                        
| 617 | -                 try { | 
                                                        |
| 618 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 619 | -                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 620 | -                } catch(PDOException $e) { | 
                                                        |
| 621 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 622 | - }  | 
                                                        |
| 623 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 624 | -                if (empty($all)) { | 
                                                        |
| 617 | +				 try { | 
                                                        |
| 618 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 619 | +						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 620 | +				} catch(PDOException $e) { | 
                                                        |
| 621 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 622 | + }  | 
                                                        |
| 623 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 624 | +				if (empty($all)) { | 
                                                        |
| 625 | 625 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 626 | 626 |  			if ($filter_name != '') { | 
                                                        
| 627 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 627 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 628 | 628 | }  | 
                                                        
| 629 | - $Spotter = new Spotter($this->db);  | 
                                                        |
| 630 | - $all = $Spotter->countAllHours($orderby,$filters);  | 
                                                        |
| 631 | - }  | 
                                                        |
| 632 | - return $all;  | 
                                                        |
| 629 | + $Spotter = new Spotter($this->db);  | 
                                                        |
| 630 | + $all = $Spotter->countAllHours($orderby,$filters);  | 
                                                        |
| 631 | + }  | 
                                                        |
| 632 | + return $all;  | 
                                                        |
| 633 | 633 | }  | 
                                                        
| 634 | 634 | |
| 635 | 635 |  	public function countOverallFlights($stats_airline = '', $filter_name = '') { | 
                                                        
@@ -651,9 +651,9 @@ discard block  | 
                                                    ||
| 651 | 651 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 652 | 652 |  		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); | 
                                                        
| 653 | 653 |  		if (empty($all)) { | 
                                                        
| 654 | - $filters = array();  | 
                                                        |
| 655 | -            		if ($filter_name != '') { | 
                                                        |
| 656 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 654 | + $filters = array();  | 
                                                        |
| 655 | +					if ($filter_name != '') { | 
                                                        |
| 656 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 657 | 657 | }  | 
                                                        
| 658 | 658 | $Spotter = new Spotter($this->db);  | 
                                                        
| 659 | 659 | $all = $Spotter->countOverallMilitaryFlights($filters);  | 
                                                        
@@ -692,19 +692,19 @@ discard block  | 
                                                    ||
| 692 | 692 | global $globalStatsFilters;  | 
                                                        
| 693 | 693 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 694 | 694 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";  | 
                                                        
| 695 | -                 try { | 
                                                        |
| 696 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 697 | -                        $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 698 | -                } catch(PDOException $e) { | 
                                                        |
| 699 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 700 | - }  | 
                                                        |
| 701 | - $result = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 702 | - $all = $result[0]['nb_airline'];  | 
                                                        |
| 695 | +				 try { | 
                                                        |
| 696 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 697 | +						$sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 698 | +				} catch(PDOException $e) { | 
                                                        |
| 699 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 700 | + }  | 
                                                        |
| 701 | + $result = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 702 | + $all = $result[0]['nb_airline'];  | 
                                                        |
| 703 | 703 |  		//$all = $this->getSumStats('airlines_bymonth',date('Y')); | 
                                                        
| 704 | 704 |  		if (empty($all)) { | 
                                                        
| 705 | - $filters = array();  | 
                                                        |
| 706 | -            		if ($filter_name != '') { | 
                                                        |
| 707 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 705 | + $filters = array();  | 
                                                        |
| 706 | +					if ($filter_name != '') { | 
                                                        |
| 707 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 708 | 708 | }  | 
                                                        
| 709 | 709 | $Spotter = new Spotter($this->db);  | 
                                                        
| 710 | 710 | $all = $Spotter->countOverallAirlines($filters);  | 
                                                        
@@ -755,166 +755,166 @@ discard block  | 
                                                    ||
| 755 | 755 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 756 | 756 | $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";  | 
                                                        
| 757 | 757 |  		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        
| 758 | -                 try { | 
                                                        |
| 759 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 760 | - $sth->execute($query_values);  | 
                                                        |
| 761 | -                } catch(PDOException $e) { | 
                                                        |
| 762 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 763 | - }  | 
                                                        |
| 764 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 765 | - return $all;  | 
                                                        |
| 758 | +				 try { | 
                                                        |
| 759 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 760 | + $sth->execute($query_values);  | 
                                                        |
| 761 | +				} catch(PDOException $e) { | 
                                                        |
| 762 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 763 | + }  | 
                                                        |
| 764 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 765 | + return $all;  | 
                                                        |
| 766 | 766 | }  | 
                                                        
| 767 | 767 |  	public function getStats($type,$stats_airline = '', $filter_name = '') { | 
                                                        
| 768 | 768 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 769 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";  | 
                                                        |
| 770 | -                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 771 | -                 try { | 
                                                        |
| 772 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 773 | - $sth->execute($query_values);  | 
                                                        |
| 774 | -                } catch(PDOException $e) { | 
                                                        |
| 775 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 776 | - }  | 
                                                        |
| 777 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 778 | - return $all;  | 
                                                        |
| 779 | - }  | 
                                                        |
| 769 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";  | 
                                                        |
| 770 | +				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 771 | +				 try { | 
                                                        |
| 772 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 773 | + $sth->execute($query_values);  | 
                                                        |
| 774 | +				} catch(PDOException $e) { | 
                                                        |
| 775 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 776 | + }  | 
                                                        |
| 777 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 778 | + return $all;  | 
                                                        |
| 779 | + }  | 
                                                        |
| 780 | 780 |  	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { | 
                                                        
| 781 | 781 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 782 | - global $globalArchiveMonths, $globalDBdriver;  | 
                                                        |
| 783 | -    		if ($globalDBdriver == 'mysql') { | 
                                                        |
| 784 | - $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";  | 
                                                        |
| 785 | -	        } else { | 
                                                        |
| 786 | - $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";  | 
                                                        |
| 787 | - }  | 
                                                        |
| 788 | -                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 789 | -                 try { | 
                                                        |
| 790 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 791 | - $sth->execute($query_values);  | 
                                                        |
| 792 | -                } catch(PDOException $e) { | 
                                                        |
| 793 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 794 | - }  | 
                                                        |
| 795 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 796 | - return $all[0]['total'];  | 
                                                        |
| 797 | - }  | 
                                                        |
| 782 | + global $globalArchiveMonths, $globalDBdriver;  | 
                                                        |
| 783 | +			if ($globalDBdriver == 'mysql') { | 
                                                        |
| 784 | + $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";  | 
                                                        |
| 785 | +			} else { | 
                                                        |
| 786 | + $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";  | 
                                                        |
| 787 | + }  | 
                                                        |
| 788 | +				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 789 | +				 try { | 
                                                        |
| 790 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 791 | + $sth->execute($query_values);  | 
                                                        |
| 792 | +				} catch(PDOException $e) { | 
                                                        |
| 793 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 794 | + }  | 
                                                        |
| 795 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 796 | + return $all[0]['total'];  | 
                                                        |
| 797 | + }  | 
                                                        |
| 798 | 798 |  	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { | 
                                                        
| 799 | - global $globalArchiveMonths, $globalDBdriver;  | 
                                                        |
| 799 | + global $globalArchiveMonths, $globalDBdriver;  | 
                                                        |
| 800 | 800 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 801 | -    		if ($globalDBdriver == 'mysql') { | 
                                                        |
| 801 | +			if ($globalDBdriver == 'mysql') { | 
                                                        |
| 802 | 802 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        
| 803 | 803 |  		} else { | 
                                                        
| 804 | 804 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        
| 805 | - }  | 
                                                        |
| 806 | -                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 807 | -                 try { | 
                                                        |
| 808 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 809 | - $sth->execute($query_values);  | 
                                                        |
| 810 | -                } catch(PDOException $e) { | 
                                                        |
| 811 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 812 | - }  | 
                                                        |
| 813 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 814 | - return $all[0]['total'];  | 
                                                        |
| 815 | - }  | 
                                                        |
| 805 | + }  | 
                                                        |
| 806 | +				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 807 | +				 try { | 
                                                        |
| 808 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 809 | + $sth->execute($query_values);  | 
                                                        |
| 810 | +				} catch(PDOException $e) { | 
                                                        |
| 811 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 812 | + }  | 
                                                        |
| 813 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 814 | + return $all[0]['total'];  | 
                                                        |
| 815 | + }  | 
                                                        |
| 816 | 816 |  	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { | 
                                                        
| 817 | - global $globalArchiveMonths, $globalDBdriver;  | 
                                                        |
| 817 | + global $globalArchiveMonths, $globalDBdriver;  | 
                                                        |
| 818 | 818 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 819 | -    		if ($globalDBdriver == 'mysql') { | 
                                                        |
| 819 | +			if ($globalDBdriver == 'mysql') { | 
                                                        |
| 820 | 820 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        
| 821 | -                } else { | 
                                                        |
| 821 | +				} else { | 
                                                        |
| 822 | 822 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        
| 823 | - }  | 
                                                        |
| 824 | -                 try { | 
                                                        |
| 825 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 826 | -                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 827 | -                } catch(PDOException $e) { | 
                                                        |
| 828 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 829 | - }  | 
                                                        |
| 830 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 831 | - return $all[0]['total'];  | 
                                                        |
| 832 | - }  | 
                                                        |
| 823 | + }  | 
                                                        |
| 824 | +				 try { | 
                                                        |
| 825 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 826 | +						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 827 | +				} catch(PDOException $e) { | 
                                                        |
| 828 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 829 | + }  | 
                                                        |
| 830 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 831 | + return $all[0]['total'];  | 
                                                        |
| 832 | + }  | 
                                                        |
| 833 | 833 |  	public function getStatsAirlineTotal($filter_name = '') { | 
                                                        
| 834 | - global $globalArchiveMonths, $globalDBdriver;  | 
                                                        |
| 834 | + global $globalArchiveMonths, $globalDBdriver;  | 
                                                        |
| 835 | 835 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 836 | -    		if ($globalDBdriver == 'mysql') { | 
                                                        |
| 836 | +			if ($globalDBdriver == 'mysql') { | 
                                                        |
| 837 | 837 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";  | 
                                                        
| 838 | -                } else { | 
                                                        |
| 838 | +				} else { | 
                                                        |
| 839 | 839 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";  | 
                                                        
| 840 | - }  | 
                                                        |
| 841 | -                 try { | 
                                                        |
| 842 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 843 | -                        $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 844 | -                } catch(PDOException $e) { | 
                                                        |
| 845 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 846 | - }  | 
                                                        |
| 847 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 848 | - return $all[0]['total'];  | 
                                                        |
| 849 | - }  | 
                                                        |
| 840 | + }  | 
                                                        |
| 841 | +				 try { | 
                                                        |
| 842 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 843 | +						$sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 844 | +				} catch(PDOException $e) { | 
                                                        |
| 845 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 846 | + }  | 
                                                        |
| 847 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 848 | + return $all[0]['total'];  | 
                                                        |
| 849 | + }  | 
                                                        |
| 850 | 850 |  	public function getStatsOwnerTotal($filter_name = '') { | 
                                                        
| 851 | - global $globalArchiveMonths, $globalDBdriver;  | 
                                                        |
| 851 | + global $globalArchiveMonths, $globalDBdriver;  | 
                                                        |
| 852 | 852 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 853 | -    		if ($globalDBdriver == 'mysql') { | 
                                                        |
| 853 | +			if ($globalDBdriver == 'mysql') { | 
                                                        |
| 854 | 854 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";  | 
                                                        
| 855 | 855 |  		} else { | 
                                                        
| 856 | 856 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";  | 
                                                        
| 857 | - }  | 
                                                        |
| 858 | -                 try { | 
                                                        |
| 859 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 860 | -                        $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 861 | -                } catch(PDOException $e) { | 
                                                        |
| 862 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 863 | - }  | 
                                                        |
| 864 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 865 | - return $all[0]['total'];  | 
                                                        |
| 866 | - }  | 
                                                        |
| 857 | + }  | 
                                                        |
| 858 | +				 try { | 
                                                        |
| 859 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 860 | +						$sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 861 | +				} catch(PDOException $e) { | 
                                                        |
| 862 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 863 | + }  | 
                                                        |
| 864 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 865 | + return $all[0]['total'];  | 
                                                        |
| 866 | + }  | 
                                                        |
| 867 | 867 |  	public function getStatsPilotTotal($filter_name = '') { | 
                                                        
| 868 | - global $globalArchiveMonths, $globalDBdriver;  | 
                                                        |
| 868 | + global $globalArchiveMonths, $globalDBdriver;  | 
                                                        |
| 869 | 869 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 870 | -    		if ($globalDBdriver == 'mysql') { | 
                                                        |
| 871 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";  | 
                                                        |
| 872 | -            	} else { | 
                                                        |
| 873 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";  | 
                                                        |
| 874 | - }  | 
                                                        |
| 875 | -                 try { | 
                                                        |
| 876 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 877 | -                        $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 878 | -                } catch(PDOException $e) { | 
                                                        |
| 879 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 880 | - }  | 
                                                        |
| 881 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 882 | - return $all[0]['total'];  | 
                                                        |
| 883 | - }  | 
                                                        |
| 870 | +			if ($globalDBdriver == 'mysql') { | 
                                                        |
| 871 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";  | 
                                                        |
| 872 | +				} else { | 
                                                        |
| 873 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";  | 
                                                        |
| 874 | + }  | 
                                                        |
| 875 | +				 try { | 
                                                        |
| 876 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 877 | +						$sth->execute(array(':filter_name' => $filter_name)); | 
                                                        |
| 878 | +				} catch(PDOException $e) { | 
                                                        |
| 879 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 880 | + }  | 
                                                        |
| 881 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 882 | + return $all[0]['total'];  | 
                                                        |
| 883 | + }  | 
                                                        |
| 884 | 884 | |
| 885 | 885 |  	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { | 
                                                        
| 886 | 886 | global $globalDBdriver;  | 
                                                        
| 887 | 887 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 888 | 888 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 889 | 889 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";  | 
                                                        
| 890 | -                } else { | 
                                                        |
| 890 | +				} else { | 
                                                        |
| 891 | 891 | $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);";  | 
                                                        
| 892 | 892 | }  | 
                                                        
| 893 | -                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 894 | -                 try { | 
                                                        |
| 895 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 896 | - $sth->execute($query_values);  | 
                                                        |
| 897 | -                } catch(PDOException $e) { | 
                                                        |
| 898 | - return "error : ".$e->getMessage();  | 
                                                        |
| 899 | - }  | 
                                                        |
| 900 | - }  | 
                                                        |
| 893 | +				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 894 | +				 try { | 
                                                        |
| 895 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 896 | + $sth->execute($query_values);  | 
                                                        |
| 897 | +				} catch(PDOException $e) { | 
                                                        |
| 898 | + return "error : ".$e->getMessage();  | 
                                                        |
| 899 | + }  | 
                                                        |
| 900 | + }  | 
                                                        |
| 901 | 901 |  	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { | 
                                                        
| 902 | 902 | global $globalDBdriver;  | 
                                                        
| 903 | 903 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 904 | 904 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 905 | 905 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";  | 
                                                        
| 906 | 906 |  		} else { | 
                                                        
| 907 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";  | 
                                                        |
| 907 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";  | 
                                                        |
| 908 | 908 | $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);";  | 
                                                        
| 909 | - }  | 
                                                        |
| 910 | -                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 911 | -                 try { | 
                                                        |
| 912 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 913 | - $sth->execute($query_values);  | 
                                                        |
| 914 | -                } catch(PDOException $e) { | 
                                                        |
| 915 | - return "error : ".$e->getMessage();  | 
                                                        |
| 916 | - }  | 
                                                        |
| 917 | - }  | 
                                                        |
| 909 | + }  | 
                                                        |
| 910 | +				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 911 | +				 try { | 
                                                        |
| 912 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 913 | + $sth->execute($query_values);  | 
                                                        |
| 914 | +				} catch(PDOException $e) { | 
                                                        |
| 915 | + return "error : ".$e->getMessage();  | 
                                                        |
| 916 | + }  | 
                                                        |
| 917 | + }  | 
                                                        |
| 918 | 918 |  	public function getStatsSource($date,$stats_type = '') { | 
                                                        
| 919 | 919 |  		if ($stats_type == '') { | 
                                                        
| 920 | 920 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";  | 
                                                        
@@ -923,15 +923,15 @@ discard block  | 
                                                    ||
| 923 | 923 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";  | 
                                                        
| 924 | 924 |  			$query_values = array(':date' => $date,':stats_type' => $stats_type); | 
                                                        
| 925 | 925 | }  | 
                                                        
| 926 | -                 try { | 
                                                        |
| 927 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 928 | - $sth->execute($query_values);  | 
                                                        |
| 929 | -                } catch(PDOException $e) { | 
                                                        |
| 930 | - echo "error : ".$e->getMessage();  | 
                                                        |
| 931 | - }  | 
                                                        |
| 932 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 933 | - return $all;  | 
                                                        |
| 934 | - }  | 
                                                        |
| 926 | +				 try { | 
                                                        |
| 927 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 928 | + $sth->execute($query_values);  | 
                                                        |
| 929 | +				} catch(PDOException $e) { | 
                                                        |
| 930 | + echo "error : ".$e->getMessage();  | 
                                                        |
| 931 | + }  | 
                                                        |
| 932 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 933 | + return $all;  | 
                                                        |
| 934 | + }  | 
                                                        |
| 935 | 935 | |
| 936 | 936 |  	public function addStatSource($data,$source_name,$stats_type,$date) { | 
                                                        
| 937 | 937 | global $globalDBdriver;  | 
                                                        
@@ -939,25 +939,25 @@ discard block  | 
                                                    ||
| 939 | 939 | $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";  | 
                                                        
| 940 | 940 |  		} else { | 
                                                        
| 941 | 941 | $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);";  | 
                                                        
| 942 | - }  | 
                                                        |
| 943 | -                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); | 
                                                        |
| 944 | -                 try { | 
                                                        |
| 945 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 946 | - $sth->execute($query_values);  | 
                                                        |
| 947 | -                } catch(PDOException $e) { | 
                                                        |
| 948 | - return "error : ".$e->getMessage();  | 
                                                        |
| 949 | - }  | 
                                                        |
| 950 | - }  | 
                                                        |
| 942 | + }  | 
                                                        |
| 943 | +				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); | 
                                                        |
| 944 | +				 try { | 
                                                        |
| 945 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 946 | + $sth->execute($query_values);  | 
                                                        |
| 947 | +				} catch(PDOException $e) { | 
                                                        |
| 948 | + return "error : ".$e->getMessage();  | 
                                                        |
| 949 | + }  | 
                                                        |
| 950 | + }  | 
                                                        |
| 951 | 951 |  	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { | 
                                                        
| 952 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";  | 
                                                        |
| 953 | -                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 954 | -                 try { | 
                                                        |
| 955 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 956 | - $sth->execute($query_values);  | 
                                                        |
| 957 | -                } catch(PDOException $e) { | 
                                                        |
| 958 | - return "error : ".$e->getMessage();  | 
                                                        |
| 959 | - }  | 
                                                        |
| 960 | - }  | 
                                                        |
| 952 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";  | 
                                                        |
| 953 | +				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 954 | +				 try { | 
                                                        |
| 955 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 956 | + $sth->execute($query_values);  | 
                                                        |
| 957 | +				} catch(PDOException $e) { | 
                                                        |
| 958 | + return "error : ".$e->getMessage();  | 
                                                        |
| 959 | + }  | 
                                                        |
| 960 | + }  | 
                                                        |
| 961 | 961 |  	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { | 
                                                        
| 962 | 962 | global $globalDBdriver;  | 
                                                        
| 963 | 963 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -965,14 +965,14 @@ discard block  | 
                                                    ||
| 965 | 965 |  		} else { | 
                                                        
| 966 | 966 | $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);";  | 
                                                        
| 967 | 967 | }  | 
                                                        
| 968 | -                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); | 
                                                        |
| 969 | -                 try { | 
                                                        |
| 970 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 971 | - $sth->execute($query_values);  | 
                                                        |
| 972 | -                } catch(PDOException $e) { | 
                                                        |
| 973 | - return "error : ".$e->getMessage();  | 
                                                        |
| 974 | - }  | 
                                                        |
| 975 | - }  | 
                                                        |
| 968 | +				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); | 
                                                        |
| 969 | +				 try { | 
                                                        |
| 970 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 971 | + $sth->execute($query_values);  | 
                                                        |
| 972 | +				} catch(PDOException $e) { | 
                                                        |
| 973 | + return "error : ".$e->getMessage();  | 
                                                        |
| 974 | + }  | 
                                                        |
| 975 | + }  | 
                                                        |
| 976 | 976 |  	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { | 
                                                        
| 977 | 977 | global $globalDBdriver;  | 
                                                        
| 978 | 978 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -980,14 +980,14 @@ discard block  | 
                                                    ||
| 980 | 980 |  		} else { | 
                                                        
| 981 | 981 | $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);";  | 
                                                        
| 982 | 982 | }  | 
                                                        
| 983 | -                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); | 
                                                        |
| 984 | -                 try { | 
                                                        |
| 985 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 986 | - $sth->execute($query_values);  | 
                                                        |
| 987 | -                } catch(PDOException $e) { | 
                                                        |
| 988 | - return "error : ".$e->getMessage();  | 
                                                        |
| 989 | - }  | 
                                                        |
| 990 | - }  | 
                                                        |
| 983 | +				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); | 
                                                        |
| 984 | +				 try { | 
                                                        |
| 985 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 986 | + $sth->execute($query_values);  | 
                                                        |
| 987 | +				} catch(PDOException $e) { | 
                                                        |
| 988 | + return "error : ".$e->getMessage();  | 
                                                        |
| 989 | + }  | 
                                                        |
| 990 | + }  | 
                                                        |
| 991 | 991 |  	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { | 
                                                        
| 992 | 992 | global $globalDBdriver;  | 
                                                        
| 993 | 993 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -995,14 +995,14 @@ discard block  | 
                                                    ||
| 995 | 995 |  		} else { | 
                                                        
| 996 | 996 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);";  | 
                                                        
| 997 | 997 | }  | 
                                                        
| 998 | -                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); | 
                                                        |
| 999 | -                 try { | 
                                                        |
| 1000 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 1001 | - $sth->execute($query_values);  | 
                                                        |
| 1002 | -                } catch(PDOException $e) { | 
                                                        |
| 1003 | - return "error : ".$e->getMessage();  | 
                                                        |
| 1004 | - }  | 
                                                        |
| 1005 | - }  | 
                                                        |
| 998 | +				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); | 
                                                        |
| 999 | +				 try { | 
                                                        |
| 1000 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 1001 | + $sth->execute($query_values);  | 
                                                        |
| 1002 | +				} catch(PDOException $e) { | 
                                                        |
| 1003 | + return "error : ".$e->getMessage();  | 
                                                        |
| 1004 | + }  | 
                                                        |
| 1005 | + }  | 
                                                        |
| 1006 | 1006 |  	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { | 
                                                        
| 1007 | 1007 | global $globalDBdriver;  | 
                                                        
| 1008 | 1008 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -1010,14 +1010,14 @@ discard block  | 
                                                    ||
| 1010 | 1010 |  		} else { | 
                                                        
| 1011 | 1011 | $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);";  | 
                                                        
| 1012 | 1012 | }  | 
                                                        
| 1013 | -                $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); | 
                                                        |
| 1014 | -                 try { | 
                                                        |
| 1015 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 1016 | - $sth->execute($query_values);  | 
                                                        |
| 1017 | -                } catch(PDOException $e) { | 
                                                        |
| 1018 | - return "error : ".$e->getMessage();  | 
                                                        |
| 1019 | - }  | 
                                                        |
| 1020 | - }  | 
                                                        |
| 1013 | +				$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); | 
                                                        |
| 1014 | +				 try { | 
                                                        |
| 1015 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 1016 | + $sth->execute($query_values);  | 
                                                        |
| 1017 | +				} catch(PDOException $e) { | 
                                                        |
| 1018 | + return "error : ".$e->getMessage();  | 
                                                        |
| 1019 | + }  | 
                                                        |
| 1020 | + }  | 
                                                        |
| 1021 | 1021 |  	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { | 
                                                        
| 1022 | 1022 | global $globalDBdriver;  | 
                                                        
| 1023 | 1023 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -1025,14 +1025,14 @@ discard block  | 
                                                    ||
| 1025 | 1025 |  		} else { | 
                                                        
| 1026 | 1026 | $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);";  | 
                                                        
| 1027 | 1027 | }  | 
                                                        
| 1028 | -                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); | 
                                                        |
| 1029 | -                 try { | 
                                                        |
| 1030 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 1031 | - $sth->execute($query_values);  | 
                                                        |
| 1032 | -                } catch(PDOException $e) { | 
                                                        |
| 1033 | - return "error : ".$e->getMessage();  | 
                                                        |
| 1034 | - }  | 
                                                        |
| 1035 | - }  | 
                                                        |
| 1028 | +				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); | 
                                                        |
| 1029 | +				 try { | 
                                                        |
| 1030 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 1031 | + $sth->execute($query_values);  | 
                                                        |
| 1032 | +				} catch(PDOException $e) { | 
                                                        |
| 1033 | + return "error : ".$e->getMessage();  | 
                                                        |
| 1034 | + }  | 
                                                        |
| 1035 | + }  | 
                                                        |
| 1036 | 1036 |  	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { | 
                                                        
| 1037 | 1037 | global $globalDBdriver;  | 
                                                        
| 1038 | 1038 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -1040,14 +1040,14 @@ discard block  | 
                                                    ||
| 1040 | 1040 |  		} else { | 
                                                        
| 1041 | 1041 | $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);";  | 
                                                        
| 1042 | 1042 | }  | 
                                                        
| 1043 | -                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 1044 | -                 try { | 
                                                        |
| 1045 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 1046 | - $sth->execute($query_values);  | 
                                                        |
| 1047 | -                } catch(PDOException $e) { | 
                                                        |
| 1048 | - return "error : ".$e->getMessage();  | 
                                                        |
| 1049 | - }  | 
                                                        |
| 1050 | - }  | 
                                                        |
| 1043 | +				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 1044 | +				 try { | 
                                                        |
| 1045 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 1046 | + $sth->execute($query_values);  | 
                                                        |
| 1047 | +				} catch(PDOException $e) { | 
                                                        |
| 1048 | + return "error : ".$e->getMessage();  | 
                                                        |
| 1049 | + }  | 
                                                        |
| 1050 | + }  | 
                                                        |
| 1051 | 1051 |  	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '') { | 
                                                        
| 1052 | 1052 | global $globalDBdriver;  | 
                                                        
| 1053 | 1053 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -1055,14 +1055,14 @@ discard block  | 
                                                    ||
| 1055 | 1055 |  		} else { | 
                                                        
| 1056 | 1056 | $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);";  | 
                                                        
| 1057 | 1057 | }  | 
                                                        
| 1058 | -                $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); | 
                                                        |
| 1059 | -                 try { | 
                                                        |
| 1060 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 1061 | - $sth->execute($query_values);  | 
                                                        |
| 1062 | -                } catch(PDOException $e) { | 
                                                        |
| 1063 | - return "error : ".$e->getMessage();  | 
                                                        |
| 1064 | - }  | 
                                                        |
| 1065 | - }  | 
                                                        |
| 1058 | +				$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); | 
                                                        |
| 1059 | +				 try { | 
                                                        |
| 1060 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 1061 | + $sth->execute($query_values);  | 
                                                        |
| 1062 | +				} catch(PDOException $e) { | 
                                                        |
| 1063 | + return "error : ".$e->getMessage();  | 
                                                        |
| 1064 | + }  | 
                                                        |
| 1065 | + }  | 
                                                        |
| 1066 | 1066 |  	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { | 
                                                        
| 1067 | 1067 | global $globalDBdriver;  | 
                                                        
| 1068 | 1068 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -1070,14 +1070,14 @@ discard block  | 
                                                    ||
| 1070 | 1070 |  		} else { | 
                                                        
| 1071 | 1071 | $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);";  | 
                                                        
| 1072 | 1072 | }  | 
                                                        
| 1073 | -                $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); | 
                                                        |
| 1074 | -                 try { | 
                                                        |
| 1075 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 1076 | - $sth->execute($query_values);  | 
                                                        |
| 1077 | -                } catch(PDOException $e) { | 
                                                        |
| 1078 | - return "error : ".$e->getMessage();  | 
                                                        |
| 1079 | - }  | 
                                                        |
| 1080 | - }  | 
                                                        |
| 1073 | +				$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); | 
                                                        |
| 1074 | +				 try { | 
                                                        |
| 1075 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 1076 | + $sth->execute($query_values);  | 
                                                        |
| 1077 | +				} catch(PDOException $e) { | 
                                                        |
| 1078 | + return "error : ".$e->getMessage();  | 
                                                        |
| 1079 | + }  | 
                                                        |
| 1080 | + }  | 
                                                        |
| 1081 | 1081 |  	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { | 
                                                        
| 1082 | 1082 | global $globalDBdriver;  | 
                                                        
| 1083 | 1083 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -1085,14 +1085,14 @@ discard block  | 
                                                    ||
| 1085 | 1085 |  		} else { | 
                                                        
| 1086 | 1086 | $query = "UPDATE stats_airport SET departure = 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);";  | 
                                                        
| 1087 | 1087 | }  | 
                                                        
| 1088 | -                $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); | 
                                                        |
| 1089 | -                 try { | 
                                                        |
| 1090 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 1091 | - $sth->execute($query_values);  | 
                                                        |
| 1092 | -                } catch(PDOException $e) { | 
                                                        |
| 1093 | - return "error : ".$e->getMessage();  | 
                                                        |
| 1094 | - }  | 
                                                        |
| 1095 | - }  | 
                                                        |
| 1088 | +				$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); | 
                                                        |
| 1089 | +				 try { | 
                                                        |
| 1090 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 1091 | + $sth->execute($query_values);  | 
                                                        |
| 1092 | +				} catch(PDOException $e) { | 
                                                        |
| 1093 | + return "error : ".$e->getMessage();  | 
                                                        |
| 1094 | + }  | 
                                                        |
| 1095 | + }  | 
                                                        |
| 1096 | 1096 |  	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { | 
                                                        
| 1097 | 1097 | global $globalDBdriver;  | 
                                                        
| 1098 | 1098 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -1100,14 +1100,14 @@ discard block  | 
                                                    ||
| 1100 | 1100 |  		} else { | 
                                                        
| 1101 | 1101 | $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);";  | 
                                                        
| 1102 | 1102 | }  | 
                                                        
| 1103 | -                $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); | 
                                                        |
| 1104 | -                 try { | 
                                                        |
| 1105 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 1106 | - $sth->execute($query_values);  | 
                                                        |
| 1107 | -                } catch(PDOException $e) { | 
                                                        |
| 1108 | - return "error : ".$e->getMessage();  | 
                                                        |
| 1109 | - }  | 
                                                        |
| 1110 | - }  | 
                                                        |
| 1103 | +				$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); | 
                                                        |
| 1104 | +				 try { | 
                                                        |
| 1105 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 1106 | + $sth->execute($query_values);  | 
                                                        |
| 1107 | +				} catch(PDOException $e) { | 
                                                        |
| 1108 | + return "error : ".$e->getMessage();  | 
                                                        |
| 1109 | + }  | 
                                                        |
| 1110 | + }  | 
                                                        |
| 1111 | 1111 |  	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { | 
                                                        
| 1112 | 1112 | global $globalDBdriver;  | 
                                                        
| 1113 | 1113 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -1115,52 +1115,52 @@ discard block  | 
                                                    ||
| 1115 | 1115 |  		} else { | 
                                                        
| 1116 | 1116 | $query = "UPDATE stats_airport SET arrival = 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);";  | 
                                                        
| 1117 | 1117 | }  | 
                                                        
| 1118 | -                $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); | 
                                                        |
| 1119 | -                 try { | 
                                                        |
| 1120 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 1121 | - $sth->execute($query_values);  | 
                                                        |
| 1122 | -                } catch(PDOException $e) { | 
                                                        |
| 1123 | - return "error : ".$e->getMessage();  | 
                                                        |
| 1124 | - }  | 
                                                        |
| 1125 | - }  | 
                                                        |
| 1118 | +				$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); | 
                                                        |
| 1119 | +				 try { | 
                                                        |
| 1120 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 1121 | + $sth->execute($query_values);  | 
                                                        |
| 1122 | +				} catch(PDOException $e) { | 
                                                        |
| 1123 | + return "error : ".$e->getMessage();  | 
                                                        |
| 1124 | + }  | 
                                                        |
| 1125 | + }  | 
                                                        |
| 1126 | 1126 | |
| 1127 | 1127 |  	public function deleteStat($id) { | 
                                                        
| 1128 | - $query = "DELETE FROM stats WHERE stats_id = :id";  | 
                                                        |
| 1129 | -                $query_values = array(':id' => $id); | 
                                                        |
| 1130 | -                 try { | 
                                                        |
| 1131 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 1132 | - $sth->execute($query_values);  | 
                                                        |
| 1133 | -                } catch(PDOException $e) { | 
                                                        |
| 1134 | - return "error : ".$e->getMessage();  | 
                                                        |
| 1135 | - }  | 
                                                        |
| 1136 | - }  | 
                                                        |
| 1128 | + $query = "DELETE FROM stats WHERE stats_id = :id";  | 
                                                        |
| 1129 | +				$query_values = array(':id' => $id); | 
                                                        |
| 1130 | +				 try { | 
                                                        |
| 1131 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 1132 | + $sth->execute($query_values);  | 
                                                        |
| 1133 | +				} catch(PDOException $e) { | 
                                                        |
| 1134 | + return "error : ".$e->getMessage();  | 
                                                        |
| 1135 | + }  | 
                                                        |
| 1136 | + }  | 
                                                        |
| 1137 | 1137 |  	public function deleteStatFlight($type) { | 
                                                        
| 1138 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type";  | 
                                                        |
| 1139 | -                $query_values = array(':type' => $type); | 
                                                        |
| 1140 | -                 try { | 
                                                        |
| 1141 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 1142 | - $sth->execute($query_values);  | 
                                                        |
| 1143 | -                } catch(PDOException $e) { | 
                                                        |
| 1144 | - return "error : ".$e->getMessage();  | 
                                                        |
| 1145 | - }  | 
                                                        |
| 1146 | - }  | 
                                                        |
| 1138 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type";  | 
                                                        |
| 1139 | +				$query_values = array(':type' => $type); | 
                                                        |
| 1140 | +				 try { | 
                                                        |
| 1141 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 1142 | + $sth->execute($query_values);  | 
                                                        |
| 1143 | +				} catch(PDOException $e) { | 
                                                        |
| 1144 | + return "error : ".$e->getMessage();  | 
                                                        |
| 1145 | + }  | 
                                                        |
| 1146 | + }  | 
                                                        |
| 1147 | 1147 |  	public function deleteStatAirport($type) { | 
                                                        
| 1148 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type";  | 
                                                        |
| 1149 | -                $query_values = array(':type' => $type); | 
                                                        |
| 1150 | -                 try { | 
                                                        |
| 1151 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 1152 | - $sth->execute($query_values);  | 
                                                        |
| 1153 | -                } catch(PDOException $e) { | 
                                                        |
| 1154 | - return "error : ".$e->getMessage();  | 
                                                        |
| 1155 | - }  | 
                                                        |
| 1156 | - }  | 
                                                        |
| 1148 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type";  | 
                                                        |
| 1149 | +				$query_values = array(':type' => $type); | 
                                                        |
| 1150 | +				 try { | 
                                                        |
| 1151 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 1152 | + $sth->execute($query_values);  | 
                                                        |
| 1153 | +				} catch(PDOException $e) { | 
                                                        |
| 1154 | + return "error : ".$e->getMessage();  | 
                                                        |
| 1155 | + }  | 
                                                        |
| 1156 | + }  | 
                                                        |
| 1157 | 1157 | |
| 1158 | -        public function addOldStats() { | 
                                                        |
| 1159 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters;  | 
                                                        |
| 1160 | - $Common = new Common();  | 
                                                        |
| 1161 | - $Connection = new Connection();  | 
                                                        |
| 1162 | -    		date_default_timezone_set('UTC'); | 
                                                        |
| 1163 | -    		$last_update = $this->getLastStatsUpdate('last_update_stats'); | 
                                                        |
| 1158 | +		public function addOldStats() { | 
                                                        |
| 1159 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters;  | 
                                                        |
| 1160 | + $Common = new Common();  | 
                                                        |
| 1161 | + $Connection = new Connection();  | 
                                                        |
| 1162 | +			date_default_timezone_set('UTC'); | 
                                                        |
| 1163 | +			$last_update = $this->getLastStatsUpdate('last_update_stats'); | 
                                                        |
| 1164 | 1164 | //print_r($last_update);  | 
                                                        
| 1165 | 1165 | /*  | 
                                                        
| 1166 | 1166 |  		$flightsbymonth = $this->getStats('flights_by_month'); | 
                                                        
@@ -1422,24 +1422,24 @@ discard block  | 
                                                    ||
| 1422 | 1422 | if ($globalDebug) echo 'Count all departure airports...'."\n";  | 
                                                        
| 1423 | 1423 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);  | 
                                                        
| 1424 | 1424 | if ($globalDebug) echo 'Count all detected departure airports...'."\n";  | 
                                                        
| 1425 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);  | 
                                                        |
| 1425 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);  | 
                                                        |
| 1426 | 1426 | if ($globalDebug) echo 'Order departure airports...'."\n";  | 
                                                        
| 1427 | - $alldata = array();  | 
                                                        |
| 1427 | + $alldata = array();  | 
                                                        |
| 1428 | 1428 | |
| 1429 | -    			foreach ($pall as $value) { | 
                                                        |
| 1430 | - $icao = $value['airport_departure_icao'];  | 
                                                        |
| 1431 | - $alldata[$icao] = $value;  | 
                                                        |
| 1432 | - }  | 
                                                        |
| 1433 | -	        	foreach ($dall as $value) { | 
                                                        |
| 1434 | - $icao = $value['airport_departure_icao'];  | 
                                                        |
| 1435 | -        			if (isset($alldata[$icao])) { | 
                                                        |
| 1436 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];  | 
                                                        |
| 1437 | - } else $alldata[$icao] = $value;  | 
                                                        |
| 1438 | - }  | 
                                                        |
| 1439 | - $count = array();  | 
                                                        |
| 1440 | -    			foreach ($alldata as $key => $row) { | 
                                                        |
| 1441 | - $count[$key] = $row['airport_departure_icao_count'];  | 
                                                        |
| 1442 | - }  | 
                                                        |
| 1429 | +				foreach ($pall as $value) { | 
                                                        |
| 1430 | + $icao = $value['airport_departure_icao'];  | 
                                                        |
| 1431 | + $alldata[$icao] = $value;  | 
                                                        |
| 1432 | + }  | 
                                                        |
| 1433 | +				foreach ($dall as $value) { | 
                                                        |
| 1434 | + $icao = $value['airport_departure_icao'];  | 
                                                        |
| 1435 | +					if (isset($alldata[$icao])) { | 
                                                        |
| 1436 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];  | 
                                                        |
| 1437 | + } else $alldata[$icao] = $value;  | 
                                                        |
| 1438 | + }  | 
                                                        |
| 1439 | + $count = array();  | 
                                                        |
| 1440 | +				foreach ($alldata as $key => $row) { | 
                                                        |
| 1441 | + $count[$key] = $row['airport_departure_icao_count'];  | 
                                                        |
| 1442 | + }  | 
                                                        |
| 1443 | 1443 | array_multisort($count,SORT_DESC,$alldata);  | 
                                                        
| 1444 | 1444 |  			foreach ($alldata as $number) { | 
                                                        
| 1445 | 1445 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);  | 
                                                        
@@ -1447,25 +1447,25 @@ discard block  | 
                                                    ||
| 1447 | 1447 | if ($globalDebug) echo 'Count all arrival airports...'."\n";  | 
                                                        
| 1448 | 1448 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);  | 
                                                        
| 1449 | 1449 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n";  | 
                                                        
| 1450 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);  | 
                                                        |
| 1450 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);  | 
                                                        |
| 1451 | 1451 | if ($globalDebug) echo 'Order arrival airports...'."\n";  | 
                                                        
| 1452 | - $alldata = array();  | 
                                                        |
| 1453 | -    			foreach ($pall as $value) { | 
                                                        |
| 1454 | - $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 1455 | - $alldata[$icao] = $value;  | 
                                                        |
| 1456 | - }  | 
                                                        |
| 1457 | -	        	foreach ($dall as $value) { | 
                                                        |
| 1458 | - $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 1459 | -        			if (isset($alldata[$icao])) { | 
                                                        |
| 1460 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];  | 
                                                        |
| 1461 | - } else $alldata[$icao] = $value;  | 
                                                        |
| 1462 | - }  | 
                                                        |
| 1463 | - $count = array();  | 
                                                        |
| 1464 | -        		foreach ($alldata as $key => $row) { | 
                                                        |
| 1465 | - $count[$key] = $row['airport_arrival_icao_count'];  | 
                                                        |
| 1466 | - }  | 
                                                        |
| 1467 | - array_multisort($count,SORT_DESC,$alldata);  | 
                                                        |
| 1468 | -                        foreach ($alldata as $number) { | 
                                                        |
| 1452 | + $alldata = array();  | 
                                                        |
| 1453 | +				foreach ($pall as $value) { | 
                                                        |
| 1454 | + $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 1455 | + $alldata[$icao] = $value;  | 
                                                        |
| 1456 | + }  | 
                                                        |
| 1457 | +				foreach ($dall as $value) { | 
                                                        |
| 1458 | + $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 1459 | +					if (isset($alldata[$icao])) { | 
                                                        |
| 1460 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];  | 
                                                        |
| 1461 | + } else $alldata[$icao] = $value;  | 
                                                        |
| 1462 | + }  | 
                                                        |
| 1463 | + $count = array();  | 
                                                        |
| 1464 | +				foreach ($alldata as $key => $row) { | 
                                                        |
| 1465 | + $count[$key] = $row['airport_arrival_icao_count'];  | 
                                                        |
| 1466 | + }  | 
                                                        |
| 1467 | + array_multisort($count,SORT_DESC,$alldata);  | 
                                                        |
| 1468 | +						foreach ($alldata as $number) { | 
                                                        |
| 1469 | 1469 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);  | 
                                                        
| 1470 | 1470 | }  | 
                                                        
| 1471 | 1471 |  			if ($Connection->tableExists('countries')) { | 
                                                        
@@ -1525,8 +1525,8 @@ discard block  | 
                                                    ||
| 1525 | 1525 | // $pall = $Spotter->getLast7DaysAirportsDeparture();  | 
                                                        
| 1526 | 1526 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture();  | 
                                                        
| 1527 | 1527 | $pall = $Spotter->getLast7DaysAirportsDeparture();  | 
                                                        
| 1528 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture();  | 
                                                        |
| 1529 | - /*  | 
                                                        |
| 1528 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture();  | 
                                                        |
| 1529 | + /*  | 
                                                        |
| 1530 | 1530 | $alldata = array();  | 
                                                        
| 1531 | 1531 |      			foreach ($pall as $value) { | 
                                                        
| 1532 | 1532 | $icao = $value['departure_airport_icao'];  | 
                                                        
@@ -1545,29 +1545,29 @@ discard block  | 
                                                    ||
| 1545 | 1545 | }  | 
                                                        
| 1546 | 1546 | array_multisort($count,SORT_DESC,$alldata);  | 
                                                        
| 1547 | 1547 | */  | 
                                                        
| 1548 | -    			foreach ($dall as $value) { | 
                                                        |
| 1549 | - $icao = $value['departure_airport_icao'];  | 
                                                        |
| 1550 | - $ddate = $value['date'];  | 
                                                        |
| 1551 | - $find = false;  | 
                                                        |
| 1552 | -    				foreach ($pall as $pvalue) { | 
                                                        |
| 1553 | -    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { | 
                                                        |
| 1554 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];  | 
                                                        |
| 1555 | - $find = true;  | 
                                                        |
| 1556 | - break;  | 
                                                        |
| 1557 | - }  | 
                                                        |
| 1558 | - }  | 
                                                        |
| 1559 | -    				if ($find === false) { | 
                                                        |
| 1560 | - $pall[] = $value;  | 
                                                        |
| 1561 | - }  | 
                                                        |
| 1562 | - }  | 
                                                        |
| 1563 | - $alldata = $pall;  | 
                                                        |
| 1548 | +				foreach ($dall as $value) { | 
                                                        |
| 1549 | + $icao = $value['departure_airport_icao'];  | 
                                                        |
| 1550 | + $ddate = $value['date'];  | 
                                                        |
| 1551 | + $find = false;  | 
                                                        |
| 1552 | +					foreach ($pall as $pvalue) { | 
                                                        |
| 1553 | +						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { | 
                                                        |
| 1554 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];  | 
                                                        |
| 1555 | + $find = true;  | 
                                                        |
| 1556 | + break;  | 
                                                        |
| 1557 | + }  | 
                                                        |
| 1558 | + }  | 
                                                        |
| 1559 | +					if ($find === false) { | 
                                                        |
| 1560 | + $pall[] = $value;  | 
                                                        |
| 1561 | + }  | 
                                                        |
| 1562 | + }  | 
                                                        |
| 1563 | + $alldata = $pall;  | 
                                                        |
| 1564 | 1564 |  			foreach ($alldata as $number) { | 
                                                        
| 1565 | 1565 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);  | 
                                                        
| 1566 | 1566 | }  | 
                                                        
| 1567 | 1567 | echo '...Arrival'."\n";  | 
                                                        
| 1568 | 1568 | $pall = $Spotter->getLast7DaysAirportsArrival();  | 
                                                        
| 1569 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival();  | 
                                                        |
| 1570 | - /*  | 
                                                        |
| 1569 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival();  | 
                                                        |
| 1570 | + /*  | 
                                                        |
| 1571 | 1571 | $alldata = array();  | 
                                                        
| 1572 | 1572 |      			foreach ($pall as $value) { | 
                                                        
| 1573 | 1573 | $icao = $value['arrival_airport_icao'];  | 
                                                        
@@ -1587,22 +1587,22 @@ discard block  | 
                                                    ||
| 1587 | 1587 | */  | 
                                                        
| 1588 | 1588 | |
| 1589 | 1589 | |
| 1590 | -    			foreach ($dall as $value) { | 
                                                        |
| 1591 | - $icao = $value['arrival_airport_icao'];  | 
                                                        |
| 1592 | - $ddate = $value['date'];  | 
                                                        |
| 1593 | - $find = false;  | 
                                                        |
| 1594 | -    				foreach ($pall as $pvalue) { | 
                                                        |
| 1595 | -    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { | 
                                                        |
| 1596 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];  | 
                                                        |
| 1597 | - $find = true;  | 
                                                        |
| 1598 | - break;  | 
                                                        |
| 1599 | - }  | 
                                                        |
| 1600 | - }  | 
                                                        |
| 1601 | -    				if ($find === false) { | 
                                                        |
| 1602 | - $pall[] = $value;  | 
                                                        |
| 1603 | - }  | 
                                                        |
| 1604 | - }  | 
                                                        |
| 1605 | - $alldata = $pall;  | 
                                                        |
| 1590 | +				foreach ($dall as $value) { | 
                                                        |
| 1591 | + $icao = $value['arrival_airport_icao'];  | 
                                                        |
| 1592 | + $ddate = $value['date'];  | 
                                                        |
| 1593 | + $find = false;  | 
                                                        |
| 1594 | +					foreach ($pall as $pvalue) { | 
                                                        |
| 1595 | +						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { | 
                                                        |
| 1596 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];  | 
                                                        |
| 1597 | + $find = true;  | 
                                                        |
| 1598 | + break;  | 
                                                        |
| 1599 | + }  | 
                                                        |
| 1600 | + }  | 
                                                        |
| 1601 | +					if ($find === false) { | 
                                                        |
| 1602 | + $pall[] = $value;  | 
                                                        |
| 1603 | + }  | 
                                                        |
| 1604 | + }  | 
                                                        |
| 1605 | + $alldata = $pall;  | 
                                                        |
| 1606 | 1606 |  			foreach ($alldata as $number) { | 
                                                        
| 1607 | 1607 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);  | 
                                                        
| 1608 | 1608 | }  | 
                                                        
@@ -1669,51 +1669,51 @@ discard block  | 
                                                    ||
| 1669 | 1669 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";  | 
                                                        
| 1670 | 1670 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);  | 
                                                        
| 1671 | 1671 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";  | 
                                                        
| 1672 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1672 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1673 | 1673 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";  | 
                                                        
| 1674 | - //$alldata = array();  | 
                                                        |
| 1675 | -    			foreach ($dall as $value) { | 
                                                        |
| 1676 | - $icao = $value['airport_departure_icao'];  | 
                                                        |
| 1677 | - $dicao = $value['airline_icao'];  | 
                                                        |
| 1678 | - $find = false;  | 
                                                        |
| 1679 | -    				foreach ($pall as $pvalue) { | 
                                                        |
| 1680 | -    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { | 
                                                        |
| 1681 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];  | 
                                                        |
| 1682 | - $find = true;  | 
                                                        |
| 1683 | - break;  | 
                                                        |
| 1684 | - }  | 
                                                        |
| 1685 | - }  | 
                                                        |
| 1686 | -    				if ($find === false) { | 
                                                        |
| 1687 | - $pall[] = $value;  | 
                                                        |
| 1688 | - }  | 
                                                        |
| 1689 | - }  | 
                                                        |
| 1690 | - $alldata = $pall;  | 
                                                        |
| 1674 | + //$alldata = array();  | 
                                                        |
| 1675 | +				foreach ($dall as $value) { | 
                                                        |
| 1676 | + $icao = $value['airport_departure_icao'];  | 
                                                        |
| 1677 | + $dicao = $value['airline_icao'];  | 
                                                        |
| 1678 | + $find = false;  | 
                                                        |
| 1679 | +					foreach ($pall as $pvalue) { | 
                                                        |
| 1680 | +						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { | 
                                                        |
| 1681 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];  | 
                                                        |
| 1682 | + $find = true;  | 
                                                        |
| 1683 | + break;  | 
                                                        |
| 1684 | + }  | 
                                                        |
| 1685 | + }  | 
                                                        |
| 1686 | +					if ($find === false) { | 
                                                        |
| 1687 | + $pall[] = $value;  | 
                                                        |
| 1688 | + }  | 
                                                        |
| 1689 | + }  | 
                                                        |
| 1690 | + $alldata = $pall;  | 
                                                        |
| 1691 | 1691 |  			foreach ($alldata as $number) { | 
                                                        
| 1692 | 1692 | 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']);  | 
                                                        
| 1693 | 1693 | }  | 
                                                        
| 1694 | 1694 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";  | 
                                                        
| 1695 | 1695 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);  | 
                                                        
| 1696 | 1696 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";  | 
                                                        
| 1697 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1697 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1698 | 1698 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";  | 
                                                        
| 1699 | - //$alldata = array();  | 
                                                        |
| 1700 | -    			foreach ($dall as $value) { | 
                                                        |
| 1701 | - $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 1702 | - $dicao = $value['airline_icao'];  | 
                                                        |
| 1703 | - $find = false;  | 
                                                        |
| 1704 | -    				foreach ($pall as $pvalue) { | 
                                                        |
| 1705 | -    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { | 
                                                        |
| 1706 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];  | 
                                                        |
| 1707 | - $find = true;  | 
                                                        |
| 1708 | - break;  | 
                                                        |
| 1709 | - }  | 
                                                        |
| 1710 | - }  | 
                                                        |
| 1711 | -    				if ($find === false) { | 
                                                        |
| 1712 | - $pall[] = $value;  | 
                                                        |
| 1713 | - }  | 
                                                        |
| 1714 | - }  | 
                                                        |
| 1715 | - $alldata = $pall;  | 
                                                        |
| 1716 | -                        foreach ($alldata as $number) { | 
                                                        |
| 1699 | + //$alldata = array();  | 
                                                        |
| 1700 | +				foreach ($dall as $value) { | 
                                                        |
| 1701 | + $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 1702 | + $dicao = $value['airline_icao'];  | 
                                                        |
| 1703 | + $find = false;  | 
                                                        |
| 1704 | +					foreach ($pall as $pvalue) { | 
                                                        |
| 1705 | +						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { | 
                                                        |
| 1706 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];  | 
                                                        |
| 1707 | + $find = true;  | 
                                                        |
| 1708 | + break;  | 
                                                        |
| 1709 | + }  | 
                                                        |
| 1710 | + }  | 
                                                        |
| 1711 | +					if ($find === false) { | 
                                                        |
| 1712 | + $pall[] = $value;  | 
                                                        |
| 1713 | + }  | 
                                                        |
| 1714 | + }  | 
                                                        |
| 1715 | + $alldata = $pall;  | 
                                                        |
| 1716 | +						foreach ($alldata as $number) { | 
                                                        |
| 1717 | 1717 | 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']);  | 
                                                        
| 1718 | 1718 | }  | 
                                                        
| 1719 | 1719 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";  | 
                                                        
@@ -1746,47 +1746,47 @@ discard block  | 
                                                    ||
| 1746 | 1746 | }  | 
                                                        
| 1747 | 1747 | if ($globalDebug) echo '...Departure'."\n";  | 
                                                        
| 1748 | 1748 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();  | 
                                                        
| 1749 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();  | 
                                                        |
| 1750 | -    			foreach ($dall as $value) { | 
                                                        |
| 1751 | - $icao = $value['departure_airport_icao'];  | 
                                                        |
| 1752 | - $airline = $value['airline_icao'];  | 
                                                        |
| 1753 | - $ddate = $value['date'];  | 
                                                        |
| 1754 | - $find = false;  | 
                                                        |
| 1755 | -    				foreach ($pall as $pvalue) { | 
                                                        |
| 1756 | -    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { | 
                                                        |
| 1757 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];  | 
                                                        |
| 1758 | - $find = true;  | 
                                                        |
| 1759 | - break;  | 
                                                        |
| 1760 | - }  | 
                                                        |
| 1761 | - }  | 
                                                        |
| 1762 | -    				if ($find === false) { | 
                                                        |
| 1763 | - $pall[] = $value;  | 
                                                        |
| 1764 | - }  | 
                                                        |
| 1765 | - }  | 
                                                        |
| 1766 | - $alldata = $pall;  | 
                                                        |
| 1749 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();  | 
                                                        |
| 1750 | +				foreach ($dall as $value) { | 
                                                        |
| 1751 | + $icao = $value['departure_airport_icao'];  | 
                                                        |
| 1752 | + $airline = $value['airline_icao'];  | 
                                                        |
| 1753 | + $ddate = $value['date'];  | 
                                                        |
| 1754 | + $find = false;  | 
                                                        |
| 1755 | +					foreach ($pall as $pvalue) { | 
                                                        |
| 1756 | +						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { | 
                                                        |
| 1757 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];  | 
                                                        |
| 1758 | + $find = true;  | 
                                                        |
| 1759 | + break;  | 
                                                        |
| 1760 | + }  | 
                                                        |
| 1761 | + }  | 
                                                        |
| 1762 | +					if ($find === false) { | 
                                                        |
| 1763 | + $pall[] = $value;  | 
                                                        |
| 1764 | + }  | 
                                                        |
| 1765 | + }  | 
                                                        |
| 1766 | + $alldata = $pall;  | 
                                                        |
| 1767 | 1767 |  			foreach ($alldata as $number) { | 
                                                        
| 1768 | 1768 | $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']);  | 
                                                        
| 1769 | 1769 | }  | 
                                                        
| 1770 | 1770 | if ($globalDebug) echo '...Arrival'."\n";  | 
                                                        
| 1771 | 1771 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();  | 
                                                        
| 1772 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();  | 
                                                        |
| 1773 | -    			foreach ($dall as $value) { | 
                                                        |
| 1774 | - $icao = $value['arrival_airport_icao'];  | 
                                                        |
| 1775 | - $airline = $value['airline_icao'];  | 
                                                        |
| 1776 | - $ddate = $value['date'];  | 
                                                        |
| 1777 | - $find = false;  | 
                                                        |
| 1778 | -    				foreach ($pall as $pvalue) { | 
                                                        |
| 1779 | -    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { | 
                                                        |
| 1780 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];  | 
                                                        |
| 1781 | - $find = true;  | 
                                                        |
| 1782 | - break;  | 
                                                        |
| 1783 | - }  | 
                                                        |
| 1784 | - }  | 
                                                        |
| 1785 | -    				if ($find === false) { | 
                                                        |
| 1786 | - $pall[] = $value;  | 
                                                        |
| 1787 | - }  | 
                                                        |
| 1788 | - }  | 
                                                        |
| 1789 | - $alldata = $pall;  | 
                                                        |
| 1772 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();  | 
                                                        |
| 1773 | +				foreach ($dall as $value) { | 
                                                        |
| 1774 | + $icao = $value['arrival_airport_icao'];  | 
                                                        |
| 1775 | + $airline = $value['airline_icao'];  | 
                                                        |
| 1776 | + $ddate = $value['date'];  | 
                                                        |
| 1777 | + $find = false;  | 
                                                        |
| 1778 | +					foreach ($pall as $pvalue) { | 
                                                        |
| 1779 | +						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { | 
                                                        |
| 1780 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];  | 
                                                        |
| 1781 | + $find = true;  | 
                                                        |
| 1782 | + break;  | 
                                                        |
| 1783 | + }  | 
                                                        |
| 1784 | + }  | 
                                                        |
| 1785 | +					if ($find === false) { | 
                                                        |
| 1786 | + $pall[] = $value;  | 
                                                        |
| 1787 | + }  | 
                                                        |
| 1788 | + }  | 
                                                        |
| 1789 | + $alldata = $pall;  | 
                                                        |
| 1790 | 1790 |  			foreach ($alldata as $number) { | 
                                                        
| 1791 | 1791 | $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']);  | 
                                                        
| 1792 | 1792 | }  | 
                                                        
@@ -1856,44 +1856,44 @@ discard block  | 
                                                    ||
| 1856 | 1856 | }  | 
                                                        
| 1857 | 1857 | |
| 1858 | 1858 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);  | 
                                                        
| 1859 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);  | 
                                                        |
| 1860 | - $alldata = array();  | 
                                                        |
| 1861 | -	    			foreach ($pall as $value) { | 
                                                        |
| 1862 | - $icao = $value['airport_departure_icao'];  | 
                                                        |
| 1863 | - $alldata[$icao] = $value;  | 
                                                        |
| 1864 | - }  | 
                                                        |
| 1865 | -		        	foreach ($dall as $value) { | 
                                                        |
| 1866 | - $icao = $value['airport_departure_icao'];  | 
                                                        |
| 1867 | -        				if (isset($alldata[$icao])) { | 
                                                        |
| 1868 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];  | 
                                                        |
| 1869 | - } else $alldata[$icao] = $value;  | 
                                                        |
| 1870 | - }  | 
                                                        |
| 1871 | - $count = array();  | 
                                                        |
| 1872 | -    				foreach ($alldata as $key => $row) { | 
                                                        |
| 1873 | - $count[$key] = $row['airport_departure_icao_count'];  | 
                                                        |
| 1874 | - }  | 
                                                        |
| 1859 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);  | 
                                                        |
| 1860 | + $alldata = array();  | 
                                                        |
| 1861 | +					foreach ($pall as $value) { | 
                                                        |
| 1862 | + $icao = $value['airport_departure_icao'];  | 
                                                        |
| 1863 | + $alldata[$icao] = $value;  | 
                                                        |
| 1864 | + }  | 
                                                        |
| 1865 | +					foreach ($dall as $value) { | 
                                                        |
| 1866 | + $icao = $value['airport_departure_icao'];  | 
                                                        |
| 1867 | +						if (isset($alldata[$icao])) { | 
                                                        |
| 1868 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];  | 
                                                        |
| 1869 | + } else $alldata[$icao] = $value;  | 
                                                        |
| 1870 | + }  | 
                                                        |
| 1871 | + $count = array();  | 
                                                        |
| 1872 | +					foreach ($alldata as $key => $row) { | 
                                                        |
| 1873 | + $count[$key] = $row['airport_departure_icao_count'];  | 
                                                        |
| 1874 | + }  | 
                                                        |
| 1875 | 1875 | array_multisort($count,SORT_DESC,$alldata);  | 
                                                        
| 1876 | 1876 |  				foreach ($alldata as $number) { | 
                                                        
| 1877 | - 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);  | 
                                                        |
| 1877 | + 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);  | 
                                                        |
| 1878 | 1878 | }  | 
                                                        
| 1879 | 1879 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter);  | 
                                                        
| 1880 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);  | 
                                                        |
| 1880 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);  | 
                                                        |
| 1881 | 1881 | $alldata = array();  | 
                                                        
| 1882 | -    				foreach ($pall as $value) { | 
                                                        |
| 1883 | - $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 1884 | - $alldata[$icao] = $value;  | 
                                                        |
| 1885 | - }  | 
                                                        |
| 1886 | -		        	foreach ($dall as $value) { | 
                                                        |
| 1887 | - $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 1888 | -        				if (isset($alldata[$icao])) { | 
                                                        |
| 1889 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];  | 
                                                        |
| 1890 | - } else $alldata[$icao] = $value;  | 
                                                        |
| 1891 | - }  | 
                                                        |
| 1892 | - $count = array();  | 
                                                        |
| 1893 | -        			foreach ($alldata as $key => $row) { | 
                                                        |
| 1894 | - $count[$key] = $row['airport_arrival_icao_count'];  | 
                                                        |
| 1895 | - }  | 
                                                        |
| 1896 | - array_multisort($count,SORT_DESC,$alldata);  | 
                                                        |
| 1882 | +					foreach ($pall as $value) { | 
                                                        |
| 1883 | + $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 1884 | + $alldata[$icao] = $value;  | 
                                                        |
| 1885 | + }  | 
                                                        |
| 1886 | +					foreach ($dall as $value) { | 
                                                        |
| 1887 | + $icao = $value['airport_arrival_icao'];  | 
                                                        |
| 1888 | +						if (isset($alldata[$icao])) { | 
                                                        |
| 1889 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];  | 
                                                        |
| 1890 | + } else $alldata[$icao] = $value;  | 
                                                        |
| 1891 | + }  | 
                                                        |
| 1892 | + $count = array();  | 
                                                        |
| 1893 | +					foreach ($alldata as $key => $row) { | 
                                                        |
| 1894 | + $count[$key] = $row['airport_arrival_icao_count'];  | 
                                                        |
| 1895 | + }  | 
                                                        |
| 1896 | + array_multisort($count,SORT_DESC,$alldata);  | 
                                                        |
| 1897 | 1897 |  				foreach ($alldata as $number) { | 
                                                        
| 1898 | 1898 | 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);  | 
                                                        
| 1899 | 1899 | }  | 
                                                        
@@ -1922,45 +1922,45 @@ discard block  | 
                                                    ||
| 1922 | 1922 | }  | 
                                                        
| 1923 | 1923 | echo '...Departure'."\n";  | 
                                                        
| 1924 | 1924 |  				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); | 
                                                        
| 1925 | -        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); | 
                                                        |
| 1925 | +					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); | 
                                                        |
| 1926 | 1926 |  				foreach ($dall as $value) { | 
                                                        
| 1927 | - $icao = $value['departure_airport_icao'];  | 
                                                        |
| 1928 | - $ddate = $value['date'];  | 
                                                        |
| 1929 | - $find = false;  | 
                                                        |
| 1930 | -    					foreach ($pall as $pvalue) { | 
                                                        |
| 1931 | -    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { | 
                                                        |
| 1932 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];  | 
                                                        |
| 1933 | - $find = true;  | 
                                                        |
| 1934 | - break;  | 
                                                        |
| 1935 | - }  | 
                                                        |
| 1936 | - }  | 
                                                        |
| 1937 | -    					if ($find === false) { | 
                                                        |
| 1938 | - $pall[] = $value;  | 
                                                        |
| 1939 | - }  | 
                                                        |
| 1940 | - }  | 
                                                        |
| 1941 | - $alldata = $pall;  | 
                                                        |
| 1927 | + $icao = $value['departure_airport_icao'];  | 
                                                        |
| 1928 | + $ddate = $value['date'];  | 
                                                        |
| 1929 | + $find = false;  | 
                                                        |
| 1930 | +						foreach ($pall as $pvalue) { | 
                                                        |
| 1931 | +							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { | 
                                                        |
| 1932 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];  | 
                                                        |
| 1933 | + $find = true;  | 
                                                        |
| 1934 | + break;  | 
                                                        |
| 1935 | + }  | 
                                                        |
| 1936 | + }  | 
                                                        |
| 1937 | +						if ($find === false) { | 
                                                        |
| 1938 | + $pall[] = $value;  | 
                                                        |
| 1939 | + }  | 
                                                        |
| 1940 | + }  | 
                                                        |
| 1941 | + $alldata = $pall;  | 
                                                        |
| 1942 | 1942 |  				foreach ($alldata as $number) { | 
                                                        
| 1943 | 1943 | $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);  | 
                                                        
| 1944 | 1944 | }  | 
                                                        
| 1945 | 1945 | echo '...Arrival'."\n";  | 
                                                        
| 1946 | 1946 |  				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter); | 
                                                        
| 1947 | -    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); | 
                                                        |
| 1947 | +					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); | 
                                                        |
| 1948 | 1948 |  				foreach ($dall as $value) { | 
                                                        
| 1949 | 1949 | $icao = $value['arrival_airport_icao'];  | 
                                                        
| 1950 | 1950 | $ddate = $value['date'];  | 
                                                        
| 1951 | - $find = false;  | 
                                                        |
| 1951 | + $find = false;  | 
                                                        |
| 1952 | 1952 |  					foreach ($pall as $pvalue) { | 
                                                        
| 1953 | -    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { | 
                                                        |
| 1954 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];  | 
                                                        |
| 1955 | - $find = true;  | 
                                                        |
| 1956 | - break;  | 
                                                        |
| 1957 | - }  | 
                                                        |
| 1958 | - }  | 
                                                        |
| 1959 | -    					if ($find === false) { | 
                                                        |
| 1960 | - $pall[] = $value;  | 
                                                        |
| 1961 | - }  | 
                                                        |
| 1962 | - }  | 
                                                        |
| 1963 | - $alldata = $pall;  | 
                                                        |
| 1953 | +							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { | 
                                                        |
| 1954 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];  | 
                                                        |
| 1955 | + $find = true;  | 
                                                        |
| 1956 | + break;  | 
                                                        |
| 1957 | + }  | 
                                                        |
| 1958 | + }  | 
                                                        |
| 1959 | +						if ($find === false) { | 
                                                        |
| 1960 | + $pall[] = $value;  | 
                                                        |
| 1961 | + }  | 
                                                        |
| 1962 | + }  | 
                                                        |
| 1963 | + $alldata = $pall;  | 
                                                        |
| 1964 | 1964 |  				foreach ($alldata as $number) { | 
                                                        
| 1965 | 1965 | $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);  | 
                                                        
| 1966 | 1966 | }  | 
                                                        
@@ -17,14 +17,14 @@ discard block  | 
                                                    ||
| 17 | 17 | $this->db = $Connection->db();  | 
                                                        
| 18 | 18 | }  | 
                                                        
| 19 | 19 | |
| 20 | -	public function addLastStatsUpdate($type,$stats_date) { | 
                                                        |
| 20 | +	public function addLastStatsUpdate($type, $stats_date) { | 
                                                        |
| 21 | 21 | $query = "DELETE FROM config WHERE name = :type;  | 
                                                        
| 22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);";  | 
                                                        
| 23 | -                $query_values = array('type' => $type,':stats_date' => $stats_date); | 
                                                        |
| 23 | +                $query_values = array('type' => $type, ':stats_date' => $stats_date); | 
                                                        |
| 24 | 24 |                   try { | 
                                                        
| 25 | 25 | $sth = $this->db->prepare($query);  | 
                                                        
| 26 | 26 | $sth->execute($query_values);  | 
                                                        
| 27 | -                } catch(PDOException $e) { | 
                                                        |
| 27 | +                } catch (PDOException $e) { | 
                                                        |
| 28 | 28 | return "error : ".$e->getMessage();  | 
                                                        
| 29 | 29 | }  | 
                                                        
| 30 | 30 | }  | 
                                                        
@@ -34,7 +34,7 @@ discard block  | 
                                                    ||
| 34 | 34 |                   try { | 
                                                        
| 35 | 35 | $sth = $this->db->prepare($query);  | 
                                                        
| 36 | 36 |                          $sth->execute(array(':type' => $type)); | 
                                                        
| 37 | -                } catch(PDOException $e) { | 
                                                        |
| 37 | +                } catch (PDOException $e) { | 
                                                        |
| 38 | 38 | echo "error : ".$e->getMessage();  | 
                                                        
| 39 | 39 | }  | 
                                                        
| 40 | 40 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
@@ -54,7 +54,7 @@ discard block  | 
                                                    ||
| 54 | 54 |                   try { | 
                                                        
| 55 | 55 | $sth = $this->db->prepare($query);  | 
                                                        
| 56 | 56 |                          $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        
| 57 | -                } catch(PDOException $e) { | 
                                                        |
| 57 | +                } catch (PDOException $e) { | 
                                                        |
| 58 | 58 | return "error : ".$e->getMessage();  | 
                                                        
| 59 | 59 | }  | 
                                                        
| 60 | 60 | }  | 
                                                        
@@ -64,43 +64,43 @@ discard block  | 
                                                    ||
| 64 | 64 |                   try { | 
                                                        
| 65 | 65 | $sth = $this->db->prepare($query);  | 
                                                        
| 66 | 66 |                          $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        
| 67 | -                } catch(PDOException $e) { | 
                                                        |
| 67 | +                } catch (PDOException $e) { | 
                                                        |
| 68 | 68 | echo "error : ".$e->getMessage();  | 
                                                        
| 69 | 69 | }  | 
                                                        
| 70 | 70 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 71 | 71 | return $all;  | 
                                                        
| 72 | 72 | }  | 
                                                        
| 73 | -	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { | 
                                                        |
| 73 | +	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { | 
                                                        |
| 74 | 74 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 75 | 75 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";  | 
                                                        
| 76 | 76 |                   try { | 
                                                        
| 77 | 77 | $sth = $this->db->prepare($query);  | 
                                                        
| 78 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 79 | -                } catch(PDOException $e) { | 
                                                        |
| 78 | +                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 79 | +                } catch (PDOException $e) { | 
                                                        |
| 80 | 80 | echo "error : ".$e->getMessage();  | 
                                                        
| 81 | 81 | }  | 
                                                        
| 82 | 82 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 83 | 83 | return $all;  | 
                                                        
| 84 | 84 | }  | 
                                                        
| 85 | -	public function getAllManufacturers($stats_airline = '',$filter_name = '') { | 
                                                        |
| 85 | +	public function getAllManufacturers($stats_airline = '', $filter_name = '') { | 
                                                        |
| 86 | 86 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 87 | 87 | $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";  | 
                                                        
| 88 | 88 |                   try { | 
                                                        
| 89 | 89 | $sth = $this->db->prepare($query);  | 
                                                        
| 90 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 91 | -                } catch(PDOException $e) { | 
                                                        |
| 90 | +                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 91 | +                } catch (PDOException $e) { | 
                                                        |
| 92 | 92 | echo "error : ".$e->getMessage();  | 
                                                        
| 93 | 93 | }  | 
                                                        
| 94 | 94 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 95 | 95 | return $all;  | 
                                                        
| 96 | 96 | }  | 
                                                        
| 97 | -	public function getAllAirportNames($stats_airline = '',$filter_name = '') { | 
                                                        |
| 97 | +	public function getAllAirportNames($stats_airline = '', $filter_name = '') { | 
                                                        |
| 98 | 98 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 99 | 99 | $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";  | 
                                                        
| 100 | 100 |                   try { | 
                                                        
| 101 | 101 | $sth = $this->db->prepare($query);  | 
                                                        
| 102 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 103 | -                } catch(PDOException $e) { | 
                                                        |
| 102 | +                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 103 | +                } catch (PDOException $e) { | 
                                                        |
| 104 | 104 | echo "error : ".$e->getMessage();  | 
                                                        
| 105 | 105 | }  | 
                                                        
| 106 | 106 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
@@ -115,22 +115,22 @@ discard block  | 
                                                    ||
| 115 | 115 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";  | 
                                                        
| 116 | 116 |                   try { | 
                                                        
| 117 | 117 | $sth = $this->db->prepare($query);  | 
                                                        
| 118 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 119 | -                } catch(PDOException $e) { | 
                                                        |
| 118 | +                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 119 | +                } catch (PDOException $e) { | 
                                                        |
| 120 | 120 | echo "error : ".$e->getMessage();  | 
                                                        
| 121 | 121 | }  | 
                                                        
| 122 | 122 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 123 | 123 |                  if (empty($all)) { | 
                                                        
| 124 | 124 |              	    $filters = array('airlines' => array($stats_airline)); | 
                                                        
| 125 | 125 |              	    if ($filter_name != '') { | 
                                                        
| 126 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 126 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 127 | 127 | }  | 
                                                        
| 128 | 128 | $Spotter = new Spotter($this->db);  | 
                                                        
| 129 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);  | 
                                                        |
| 129 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);  | 
                                                        |
| 130 | 130 | }  | 
                                                        
| 131 | 131 | return $all;  | 
                                                        
| 132 | 132 | }  | 
                                                        
| 133 | -	public function countAllAirlineCountries($limit = true,$filter_name = '') { | 
                                                        |
| 133 | +	public function countAllAirlineCountries($limit = true, $filter_name = '') { | 
                                                        |
| 134 | 134 | global $globalStatsFilters;  | 
                                                        
| 135 | 135 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 136 | 136 | if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";  | 
                                                        
@@ -138,7 +138,7 @@ discard block  | 
                                                    ||
| 138 | 138 |                   try { | 
                                                        
| 139 | 139 | $sth = $this->db->prepare($query);  | 
                                                        
| 140 | 140 |                          $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        
| 141 | -                } catch(PDOException $e) { | 
                                                        |
| 141 | +                } catch (PDOException $e) { | 
                                                        |
| 142 | 142 | echo "error : ".$e->getMessage();  | 
                                                        
| 143 | 143 | }  | 
                                                        
| 144 | 144 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
@@ -146,28 +146,28 @@ discard block  | 
                                                    ||
| 146 | 146 | $Spotter = new Spotter($this->db);  | 
                                                        
| 147 | 147 | $filters = array();  | 
                                                        
| 148 | 148 |              		if ($filter_name != '') { | 
                                                        
| 149 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 149 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 150 | 150 | }  | 
                                                        
| 151 | - $all = $Spotter->countAllAirlineCountries($limit,$filters);  | 
                                                        |
| 151 | + $all = $Spotter->countAllAirlineCountries($limit, $filters);  | 
                                                        |
| 152 | 152 | }  | 
                                                        
| 153 | 153 | return $all;  | 
                                                        
| 154 | 154 | }  | 
                                                        
| 155 | -	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { | 
                                                        |
| 155 | +	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 156 | 156 | global $globalStatsFilters;  | 
                                                        
| 157 | 157 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 158 | 158 | if ($limit) $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 LIMIT 10 OFFSET 0";  | 
                                                        
| 159 | 159 | 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";  | 
                                                        
| 160 | 160 |                   try { | 
                                                        
| 161 | 161 | $sth = $this->db->prepare($query);  | 
                                                        
| 162 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 163 | -                } catch(PDOException $e) { | 
                                                        |
| 162 | +                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 163 | +                } catch (PDOException $e) { | 
                                                        |
| 164 | 164 | echo "error : ".$e->getMessage();  | 
                                                        
| 165 | 165 | }  | 
                                                        
| 166 | 166 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 167 | 167 |                  if (empty($all)) { | 
                                                        
| 168 | 168 |              		$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 169 | 169 |              		if ($filter_name != '') { | 
                                                        
| 170 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 170 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 171 | 171 | }  | 
                                                        
| 172 | 172 | $Spotter = new Spotter($this->db);  | 
                                                        
| 173 | 173 | $all = $Spotter->countAllAircraftManufacturers($filters);  | 
                                                        
@@ -182,18 +182,18 @@ discard block  | 
                                                    ||
| 182 | 182 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";  | 
                                                        
| 183 | 183 |                   try { | 
                                                        
| 184 | 184 | $sth = $this->db->prepare($query);  | 
                                                        
| 185 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 186 | -                } catch(PDOException $e) { | 
                                                        |
| 185 | +                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 186 | +                } catch (PDOException $e) { | 
                                                        |
| 187 | 187 | echo "error : ".$e->getMessage();  | 
                                                        
| 188 | 188 | }  | 
                                                        
| 189 | 189 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 190 | 190 |                  if (empty($all)) { | 
                                                        
| 191 | 191 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 192 | 192 |  			if ($filter_name != '') { | 
                                                        
| 193 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 193 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 194 | 194 | }  | 
                                                        
| 195 | 195 | $Spotter = new Spotter($this->db);  | 
                                                        
| 196 | - $all = $Spotter->countAllArrivalCountries($limit,$filters);  | 
                                                        |
| 196 | + $all = $Spotter->countAllArrivalCountries($limit, $filters);  | 
                                                        |
| 197 | 197 | }  | 
                                                        
| 198 | 198 | return $all;  | 
                                                        
| 199 | 199 | }  | 
                                                        
@@ -204,15 +204,15 @@ discard block  | 
                                                    ||
| 204 | 204 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";  | 
                                                        
| 205 | 205 |                   try { | 
                                                        
| 206 | 206 | $sth = $this->db->prepare($query);  | 
                                                        
| 207 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 208 | -                } catch(PDOException $e) { | 
                                                        |
| 207 | +                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 208 | +                } catch (PDOException $e) { | 
                                                        |
| 209 | 209 | echo "error : ".$e->getMessage();  | 
                                                        
| 210 | 210 | }  | 
                                                        
| 211 | 211 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 212 | 212 |                  if (empty($all)) { | 
                                                        
| 213 | 213 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 214 | 214 |  			if ($filter_name != '') { | 
                                                        
| 215 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 215 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 216 | 216 | }  | 
                                                        
| 217 | 217 | $Spotter = new Spotter($this->db);  | 
                                                        
| 218 | 218 | $all = $Spotter->countAllDepartureCountries($filters);  | 
                                                        
@@ -220,7 +220,7 @@ discard block  | 
                                                    ||
| 220 | 220 | return $all;  | 
                                                        
| 221 | 221 | }  | 
                                                        
| 222 | 222 | |
| 223 | -	public function countAllAirlines($limit = true,$filter_name = '') { | 
                                                        |
| 223 | +	public function countAllAirlines($limit = true, $filter_name = '') { | 
                                                        |
| 224 | 224 | global $globalStatsFilters;  | 
                                                        
| 225 | 225 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 226 | 226 | 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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0";  | 
                                                        
@@ -228,7 +228,7 @@ discard block  | 
                                                    ||
| 228 | 228 |                   try { | 
                                                        
| 229 | 229 | $sth = $this->db->prepare($query);  | 
                                                        
| 230 | 230 |                          $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        
| 231 | -                } catch(PDOException $e) { | 
                                                        |
| 231 | +                } catch (PDOException $e) { | 
                                                        |
| 232 | 232 | echo "error : ".$e->getMessage();  | 
                                                        
| 233 | 233 | }  | 
                                                        
| 234 | 234 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
@@ -236,58 +236,58 @@ discard block  | 
                                                    ||
| 236 | 236 | $Spotter = new Spotter($this->db);  | 
                                                        
| 237 | 237 | $filters = array();  | 
                                                        
| 238 | 238 |              		if ($filter_name != '') { | 
                                                        
| 239 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 239 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 240 | 240 | }  | 
                                                        
| 241 | 241 | |
| 242 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters);  | 
                                                        |
| 242 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters);  | 
                                                        |
| 243 | 243 | }  | 
                                                        
| 244 | 244 | return $all;  | 
                                                        
| 245 | 245 | }  | 
                                                        
| 246 | -	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        |
| 246 | +	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 247 | 247 | global $globalStatsFilters;  | 
                                                        
| 248 | 248 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 249 | 249 | 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 = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";  | 
                                                        
| 250 | 250 | 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";  | 
                                                        
| 251 | 251 |                   try { | 
                                                        
| 252 | 252 | $sth = $this->db->prepare($query);  | 
                                                        
| 253 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 254 | -                } catch(PDOException $e) { | 
                                                        |
| 253 | +                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 254 | +                } catch (PDOException $e) { | 
                                                        |
| 255 | 255 | echo "error : ".$e->getMessage();  | 
                                                        
| 256 | 256 | }  | 
                                                        
| 257 | 257 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 258 | 258 |                  if (empty($all)) { | 
                                                        
| 259 | 259 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 260 | 260 |  			if ($filter_name != '') { | 
                                                        
| 261 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 261 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 262 | 262 | }  | 
                                                        
| 263 | 263 | $Spotter = new Spotter($this->db);  | 
                                                        
| 264 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);  | 
                                                        |
| 264 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);  | 
                                                        |
| 265 | 265 | }  | 
                                                        
| 266 | 266 | return $all;  | 
                                                        
| 267 | 267 | }  | 
                                                        
| 268 | -	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        |
| 268 | +	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 269 | 269 | global $globalStatsFilters;  | 
                                                        
| 270 | 270 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 271 | 271 | 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 = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";  | 
                                                        
| 272 | 272 | 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";  | 
                                                        
| 273 | 273 |  		 try { | 
                                                        
| 274 | 274 | $sth = $this->db->prepare($query);  | 
                                                        
| 275 | -			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 276 | -		} catch(PDOException $e) { | 
                                                        |
| 275 | +			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 276 | +		} catch (PDOException $e) { | 
                                                        |
| 277 | 277 | echo "error : ".$e->getMessage();  | 
                                                        
| 278 | 278 | }  | 
                                                        
| 279 | 279 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 280 | 280 |  		if (empty($all)) { | 
                                                        
| 281 | 281 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 282 | 282 |  			if ($filter_name != '') { | 
                                                        
| 283 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 283 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 284 | 284 | }  | 
                                                        
| 285 | 285 | $Spotter = new Spotter($this->db);  | 
                                                        
| 286 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters);  | 
                                                        |
| 286 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters);  | 
                                                        |
| 287 | 287 | }  | 
                                                        
| 288 | 288 | return $all;  | 
                                                        
| 289 | 289 | }  | 
                                                        
| 290 | -	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { | 
                                                        |
| 290 | +	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 291 | 291 | $Connection = new Connection();  | 
                                                        
| 292 | 292 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 293 | 293 |  		if ($Connection->tableExists('countries')) { | 
                                                        
@@ -295,8 +295,8 @@ discard block  | 
                                                    ||
| 295 | 295 | 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";  | 
                                                        
| 296 | 296 |  			 try { | 
                                                        
| 297 | 297 | $sth = $this->db->prepare($query);  | 
                                                        
| 298 | -				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 299 | -			} catch(PDOException $e) { | 
                                                        |
| 298 | +				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 299 | +			} catch (PDOException $e) { | 
                                                        |
| 300 | 300 | echo "error : ".$e->getMessage();  | 
                                                        
| 301 | 301 | }  | 
                                                        
| 302 | 302 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
@@ -311,70 +311,70 @@ discard block  | 
                                                    ||
| 311 | 311 | return array();  | 
                                                        
| 312 | 312 | }  | 
                                                        
| 313 | 313 | }  | 
                                                        
| 314 | -	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        |
| 314 | +	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 315 | 315 | global $globalStatsFilters;  | 
                                                        
| 316 | 316 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 317 | 317 | if ($limit) $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 LIMIT 10 OFFSET 0";  | 
                                                        
| 318 | 318 | 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";  | 
                                                        
| 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 |                  if (empty($all)) { | 
                                                        
| 327 | 327 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 328 | 328 |  			if ($filter_name != '') { | 
                                                        
| 329 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 329 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 330 | 330 | }  | 
                                                        
| 331 | 331 | $Spotter = new Spotter($this->db);  | 
                                                        
| 332 | - $all = $Spotter->countAllPilots($limit,0,'',$filters);  | 
                                                        |
| 332 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters);  | 
                                                        |
| 333 | 333 | }  | 
                                                        
| 334 | 334 | return $all;  | 
                                                        
| 335 | 335 | }  | 
                                                        
| 336 | -	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { | 
                                                        |
| 336 | +	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 337 | 337 | global $globalStatsFilters;  | 
                                                        
| 338 | 338 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 339 | 339 | if ($limit) $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 LIMIT 10 OFFSET 0";  | 
                                                        
| 340 | 340 | 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";  | 
                                                        
| 341 | 341 |                   try { | 
                                                        
| 342 | 342 | $sth = $this->db->prepare($query);  | 
                                                        
| 343 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 344 | -                } catch(PDOException $e) { | 
                                                        |
| 343 | +                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 344 | +                } catch (PDOException $e) { | 
                                                        |
| 345 | 345 | echo "error : ".$e->getMessage();  | 
                                                        
| 346 | 346 | }  | 
                                                        
| 347 | 347 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 348 | 348 |                  if (empty($all)) { | 
                                                        
| 349 | 349 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 350 | 350 |  			if ($filter_name != '') { | 
                                                        
| 351 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 351 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 352 | 352 | }  | 
                                                        
| 353 | 353 | $Spotter = new Spotter($this->db);  | 
                                                        
| 354 | - $all = $Spotter->countAllOwners($limit,0,'',$filters);  | 
                                                        |
| 354 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters);  | 
                                                        |
| 355 | 355 | }  | 
                                                        
| 356 | 356 | return $all;  | 
                                                        
| 357 | 357 | }  | 
                                                        
| 358 | -	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        |
| 358 | +	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 359 | 359 | global $globalStatsFilters;  | 
                                                        
| 360 | 360 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 361 | 361 | 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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";  | 
                                                        
| 362 | 362 | 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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";  | 
                                                        
| 363 | 363 |                   try { | 
                                                        
| 364 | 364 | $sth = $this->db->prepare($query);  | 
                                                        
| 365 | -                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 366 | -                } catch(PDOException $e) { | 
                                                        |
| 365 | +                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 366 | +                } catch (PDOException $e) { | 
                                                        |
| 367 | 367 | echo "error : ".$e->getMessage();  | 
                                                        
| 368 | 368 | }  | 
                                                        
| 369 | 369 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 370 | 370 |                  if (empty($all)) { | 
                                                        
| 371 | 371 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 372 | 372 |              		if ($filter_name != '') { | 
                                                        
| 373 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 373 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 374 | 374 | }  | 
                                                        
| 375 | 375 | $Spotter = new Spotter($this->db);  | 
                                                        
| 376 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);  | 
                                                        |
| 377 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);  | 
                                                        |
| 376 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);  | 
                                                        |
| 377 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);  | 
                                                        |
| 378 | 378 | $all = array();  | 
                                                        
| 379 | 379 |          		foreach ($pall as $value) { | 
                                                        
| 380 | 380 | $icao = $value['airport_departure_icao'];  | 
                                                        
@@ -391,30 +391,30 @@ discard block  | 
                                                    ||
| 391 | 391 |          		foreach ($all as $key => $row) { | 
                                                        
| 392 | 392 | $count[$key] = $row['airport_departure_icao_count'];  | 
                                                        
| 393 | 393 | }  | 
                                                        
| 394 | - array_multisort($count,SORT_DESC,$all);  | 
                                                        |
| 394 | + array_multisort($count, SORT_DESC, $all);  | 
                                                        |
| 395 | 395 | }  | 
                                                        
| 396 | 396 | return $all;  | 
                                                        
| 397 | 397 | }  | 
                                                        
| 398 | -	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        |
| 398 | +	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 399 | 399 | global $globalStatsFilters;  | 
                                                        
| 400 | 400 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 401 | 401 | 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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";  | 
                                                        
| 402 | 402 | 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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";  | 
                                                        
| 403 | 403 |  		try { | 
                                                        
| 404 | 404 | $sth = $this->db->prepare($query);  | 
                                                        
| 405 | -			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        |
| 406 | -		} catch(PDOException $e) { | 
                                                        |
| 405 | +			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        |
| 406 | +		} catch (PDOException $e) { | 
                                                        |
| 407 | 407 | echo "error : ".$e->getMessage();  | 
                                                        
| 408 | 408 | }  | 
                                                        
| 409 | 409 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 410 | 410 |  		if (empty($all)) { | 
                                                        
| 411 | 411 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 412 | 412 |  			if ($filter_name != '') { | 
                                                        
| 413 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 413 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 414 | 414 | }  | 
                                                        
| 415 | 415 | $Spotter = new Spotter($this->db);  | 
                                                        
| 416 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);  | 
                                                        |
| 417 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);  | 
                                                        |
| 416 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);  | 
                                                        |
| 417 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);  | 
                                                        |
| 418 | 418 | $all = array();  | 
                                                        
| 419 | 419 |          		foreach ($pall as $value) { | 
                                                        
| 420 | 420 | $icao = $value['airport_arrival_icao'];  | 
                                                        
@@ -431,12 +431,12 @@ discard block  | 
                                                    ||
| 431 | 431 |          		foreach ($all as $key => $row) { | 
                                                        
| 432 | 432 | $count[$key] = $row['airport_arrival_icao_count'];  | 
                                                        
| 433 | 433 | }  | 
                                                        
| 434 | - array_multisort($count,SORT_DESC,$all);  | 
                                                        |
| 434 | + array_multisort($count, SORT_DESC, $all);  | 
                                                        |
| 435 | 435 | }  | 
                                                        
| 436 | 436 | |
| 437 | 437 | return $all;  | 
                                                        
| 438 | 438 | }  | 
                                                        
| 439 | -	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        |
| 439 | +	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 440 | 440 | global $globalDBdriver, $globalStatsFilters;  | 
                                                        
| 441 | 441 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 442 | 442 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -446,18 +446,18 @@ discard block  | 
                                                    ||
| 446 | 446 | 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";  | 
                                                        
| 447 | 447 | 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";  | 
                                                        
| 448 | 448 | }  | 
                                                        
| 449 | -		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 449 | +		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 450 | 450 |                   try { | 
                                                        
| 451 | 451 | $sth = $this->db->prepare($query);  | 
                                                        
| 452 | 452 | $sth->execute($query_data);  | 
                                                        
| 453 | -                } catch(PDOException $e) { | 
                                                        |
| 453 | +                } catch (PDOException $e) { | 
                                                        |
| 454 | 454 | echo "error : ".$e->getMessage();  | 
                                                        
| 455 | 455 | }  | 
                                                        
| 456 | 456 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 457 | 457 |                  if (empty($all)) { | 
                                                        
| 458 | 458 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 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->countAllMonthsLastYear($filters);  | 
                                                        
@@ -466,29 +466,29 @@ discard block  | 
                                                    ||
| 466 | 466 | return $all;  | 
                                                        
| 467 | 467 | }  | 
                                                        
| 468 | 468 | |
| 469 | -	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { | 
                                                        |
| 469 | +	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { | 
                                                        |
| 470 | 470 | global $globalStatsFilters;  | 
                                                        
| 471 | 471 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 472 | 472 | $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";  | 
                                                        
| 473 | -		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 473 | +		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 474 | 474 |                   try { | 
                                                        
| 475 | 475 | $sth = $this->db->prepare($query);  | 
                                                        
| 476 | 476 | $sth->execute($query_data);  | 
                                                        
| 477 | -                } catch(PDOException $e) { | 
                                                        |
| 477 | +                } catch (PDOException $e) { | 
                                                        |
| 478 | 478 | echo "error : ".$e->getMessage();  | 
                                                        
| 479 | 479 | }  | 
                                                        
| 480 | 480 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 481 | 481 |                  if (empty($all)) { | 
                                                        
| 482 | 482 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 483 | 483 |  			if ($filter_name != '') { | 
                                                        
| 484 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 484 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 485 | 485 | }  | 
                                                        
| 486 | 486 | $Spotter = new Spotter($this->db);  | 
                                                        
| 487 | 487 | $all = $Spotter->countAllDatesLastMonth($filters);  | 
                                                        
| 488 | 488 | }  | 
                                                        
| 489 | 489 | return $all;  | 
                                                        
| 490 | 490 | }  | 
                                                        
| 491 | -	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { | 
                                                        |
| 491 | +	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { | 
                                                        |
| 492 | 492 | global $globalDBdriver, $globalStatsFilters;  | 
                                                        
| 493 | 493 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 494 | 494 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -496,40 +496,40 @@ discard block  | 
                                                    ||
| 496 | 496 |  		} else { | 
                                                        
| 497 | 497 | $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";  | 
                                                        
| 498 | 498 | }  | 
                                                        
| 499 | -		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 499 | +		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 500 | 500 |                   try { | 
                                                        
| 501 | 501 | $sth = $this->db->prepare($query);  | 
                                                        
| 502 | 502 | $sth->execute($query_data);  | 
                                                        
| 503 | -                } catch(PDOException $e) { | 
                                                        |
| 503 | +                } catch (PDOException $e) { | 
                                                        |
| 504 | 504 | echo "error : ".$e->getMessage();  | 
                                                        
| 505 | 505 | }  | 
                                                        
| 506 | 506 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 507 | 507 |                  if (empty($all)) { | 
                                                        
| 508 | 508 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 509 | 509 |  			if ($filter_name != '') { | 
                                                        
| 510 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 510 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 511 | 511 | }  | 
                                                        
| 512 | 512 | $Spotter = new Spotter($this->db);  | 
                                                        
| 513 | 513 | $all = $Spotter->countAllDatesLast7Days($filters);  | 
                                                        
| 514 | 514 | }  | 
                                                        
| 515 | 515 | return $all;  | 
                                                        
| 516 | 516 | }  | 
                                                        
| 517 | -	public function countAllDates($stats_airline = '',$filter_name = '') { | 
                                                        |
| 517 | +	public function countAllDates($stats_airline = '', $filter_name = '') { | 
                                                        |
| 518 | 518 | global $globalStatsFilters;  | 
                                                        
| 519 | 519 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 520 | 520 | $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";  | 
                                                        
| 521 | -		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 521 | +		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 522 | 522 |                   try { | 
                                                        
| 523 | 523 | $sth = $this->db->prepare($query);  | 
                                                        
| 524 | 524 | $sth->execute($query_data);  | 
                                                        
| 525 | -                } catch(PDOException $e) { | 
                                                        |
| 525 | +                } catch (PDOException $e) { | 
                                                        |
| 526 | 526 | echo "error : ".$e->getMessage();  | 
                                                        
| 527 | 527 | }  | 
                                                        
| 528 | 528 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 529 | 529 |                  if (empty($all)) { | 
                                                        
| 530 | 530 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 531 | 531 |  			if ($filter_name != '') { | 
                                                        
| 532 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 532 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 533 | 533 | }  | 
                                                        
| 534 | 534 | $Spotter = new Spotter($this->db);  | 
                                                        
| 535 | 535 | $all = $Spotter->countAllDates($filters);  | 
                                                        
@@ -544,35 +544,35 @@ discard block  | 
                                                    ||
| 544 | 544 |                   try { | 
                                                        
| 545 | 545 | $sth = $this->db->prepare($query);  | 
                                                        
| 546 | 546 | $sth->execute($query_data);  | 
                                                        
| 547 | -                } catch(PDOException $e) { | 
                                                        |
| 547 | +                } catch (PDOException $e) { | 
                                                        |
| 548 | 548 | echo "error : ".$e->getMessage();  | 
                                                        
| 549 | 549 | }  | 
                                                        
| 550 | 550 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 551 | 551 |                  if (empty($all)) { | 
                                                        
| 552 | 552 | $filters = array();  | 
                                                        
| 553 | 553 |              		if ($filter_name != '') { | 
                                                        
| 554 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 554 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 555 | 555 | }  | 
                                                        
| 556 | 556 | $Spotter = new Spotter($this->db);  | 
                                                        
| 557 | 557 | $all = $Spotter->countAllDatesByAirlines($filters);  | 
                                                        
| 558 | 558 | }  | 
                                                        
| 559 | 559 | return $all;  | 
                                                        
| 560 | 560 | }  | 
                                                        
| 561 | -	public function countAllMonths($stats_airline = '',$filter_name = '') { | 
                                                        |
| 561 | +	public function countAllMonths($stats_airline = '', $filter_name = '') { | 
                                                        |
| 562 | 562 | global $globalStatsFilters;  | 
                                                        
| 563 | 563 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 564 | 564 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        
| 565 | 565 |                   try { | 
                                                        
| 566 | 566 | $sth = $this->db->prepare($query);  | 
                                                        
| 567 | 567 |                          $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        
| 568 | -                } catch(PDOException $e) { | 
                                                        |
| 568 | +                } catch (PDOException $e) { | 
                                                        |
| 569 | 569 | echo "error : ".$e->getMessage();  | 
                                                        
| 570 | 570 | }  | 
                                                        
| 571 | 571 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 572 | 572 |                  if (empty($all)) { | 
                                                        
| 573 | 573 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 574 | 574 |  			if ($filter_name != '') { | 
                                                        
| 575 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 575 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 576 | 576 | }  | 
                                                        
| 577 | 577 | $Spotter = new Spotter($this->db);  | 
                                                        
| 578 | 578 | $all = $Spotter->countAllMonths($filters);  | 
                                                        
@@ -586,21 +586,21 @@ discard block  | 
                                                    ||
| 586 | 586 |                   try { | 
                                                        
| 587 | 587 | $sth = $this->db->prepare($query);  | 
                                                        
| 588 | 588 |                          $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        
| 589 | -                } catch(PDOException $e) { | 
                                                        |
| 589 | +                } catch (PDOException $e) { | 
                                                        |
| 590 | 590 | echo "error : ".$e->getMessage();  | 
                                                        
| 591 | 591 | }  | 
                                                        
| 592 | 592 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 593 | 593 |                  if (empty($all)) { | 
                                                        
| 594 | 594 | $filters = array();  | 
                                                        
| 595 | 595 |              		if ($filter_name != '') { | 
                                                        
| 596 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 596 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 597 | 597 | }  | 
                                                        
| 598 | 598 | $Spotter = new Spotter($this->db);  | 
                                                        
| 599 | 599 | $all = $Spotter->countAllMilitaryMonths($filters);  | 
                                                        
| 600 | 600 | }  | 
                                                        
| 601 | 601 | return $all;  | 
                                                        
| 602 | 602 | }  | 
                                                        
| 603 | -	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        |
| 603 | +	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 604 | 604 | global $globalTimezone, $globalDBdriver, $globalStatsFilters;  | 
                                                        
| 605 | 605 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 606 | 606 | 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";  | 
                                                        
@@ -617,17 +617,17 @@ discard block  | 
                                                    ||
| 617 | 617 |                   try { | 
                                                        
| 618 | 618 | $sth = $this->db->prepare($query);  | 
                                                        
| 619 | 619 |                          $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        
| 620 | -                } catch(PDOException $e) { | 
                                                        |
| 620 | +                } catch (PDOException $e) { | 
                                                        |
| 621 | 621 | echo "error : ".$e->getMessage();  | 
                                                        
| 622 | 622 | }  | 
                                                        
| 623 | 623 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 624 | 624 |                  if (empty($all)) { | 
                                                        
| 625 | 625 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 626 | 626 |  			if ($filter_name != '') { | 
                                                        
| 627 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 627 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 628 | 628 | }  | 
                                                        
| 629 | 629 | $Spotter = new Spotter($this->db);  | 
                                                        
| 630 | - $all = $Spotter->countAllHours($orderby,$filters);  | 
                                                        |
| 630 | + $all = $Spotter->countAllHours($orderby, $filters);  | 
                                                        |
| 631 | 631 | }  | 
                                                        
| 632 | 632 | return $all;  | 
                                                        
| 633 | 633 | }  | 
                                                        
@@ -635,11 +635,11 @@ discard block  | 
                                                    ||
| 635 | 635 |  	public function countOverallFlights($stats_airline = '', $filter_name = '') { | 
                                                        
| 636 | 636 | global $globalStatsFilters;  | 
                                                        
| 637 | 637 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 638 | -		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); | 
                                                        |
| 638 | +		$all = $this->getSumStats('flights_bymonth', date('Y'), $stats_airline, $filter_name); | 
                                                        |
| 639 | 639 |  		if (empty($all)) { | 
                                                        
| 640 | 640 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 641 | 641 |  			if ($filter_name != '') { | 
                                                        
| 642 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 642 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 643 | 643 | }  | 
                                                        
| 644 | 644 | $Spotter = new Spotter($this->db);  | 
                                                        
| 645 | 645 | $all = $Spotter->countOverallFlights($filters);  | 
                                                        
@@ -649,39 +649,39 @@ discard block  | 
                                                    ||
| 649 | 649 |  	public function countOverallMilitaryFlights($filter_name = '') { | 
                                                        
| 650 | 650 | global $globalStatsFilters;  | 
                                                        
| 651 | 651 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 652 | -		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); | 
                                                        |
| 652 | +		$all = $this->getSumStats('military_flights_bymonth', date('Y'), '', $filter_name); | 
                                                        |
| 653 | 653 |  		if (empty($all)) { | 
                                                        
| 654 | 654 | $filters = array();  | 
                                                        
| 655 | 655 |              		if ($filter_name != '') { | 
                                                        
| 656 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 656 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 657 | 657 | }  | 
                                                        
| 658 | 658 | $Spotter = new Spotter($this->db);  | 
                                                        
| 659 | 659 | $all = $Spotter->countOverallMilitaryFlights($filters);  | 
                                                        
| 660 | 660 | }  | 
                                                        
| 661 | 661 | return $all;  | 
                                                        
| 662 | 662 | }  | 
                                                        
| 663 | -	public function countOverallArrival($stats_airline = '',$filter_name = '') { | 
                                                        |
| 663 | +	public function countOverallArrival($stats_airline = '', $filter_name = '') { | 
                                                        |
| 664 | 664 | global $globalStatsFilters;  | 
                                                        
| 665 | 665 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 666 | -		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); | 
                                                        |
| 666 | +		$all = $this->getSumStats('realarrivals_bymonth', date('Y'), $stats_airline, $filter_name); | 
                                                        |
| 667 | 667 |  		if (empty($all)) { | 
                                                        
| 668 | 668 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 669 | 669 |  			if ($filter_name != '') { | 
                                                        
| 670 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 670 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 671 | 671 | }  | 
                                                        
| 672 | 672 | $Spotter = new Spotter($this->db);  | 
                                                        
| 673 | 673 | $all = $Spotter->countOverallArrival($filters);  | 
                                                        
| 674 | 674 | }  | 
                                                        
| 675 | 675 | return $all;  | 
                                                        
| 676 | 676 | }  | 
                                                        
| 677 | -	public function countOverallAircrafts($stats_airline = '',$filter_name = '') { | 
                                                        |
| 677 | +	public function countOverallAircrafts($stats_airline = '', $filter_name = '') { | 
                                                        |
| 678 | 678 | global $globalStatsFilters;  | 
                                                        
| 679 | 679 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 680 | -		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); | 
                                                        |
| 680 | +		$all = $this->getSumStats('aircrafts_bymonth', date('Y'), $stats_airline, $filter_name); | 
                                                        |
| 681 | 681 |  		if (empty($all)) { | 
                                                        
| 682 | 682 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 683 | 683 |  			if ($filter_name != '') { | 
                                                        
| 684 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 684 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 685 | 685 | }  | 
                                                        
| 686 | 686 | $Spotter = new Spotter($this->db);  | 
                                                        
| 687 | 687 | $all = $Spotter->countOverallAircrafts($filters);  | 
                                                        
@@ -695,7 +695,7 @@ discard block  | 
                                                    ||
| 695 | 695 |                   try { | 
                                                        
| 696 | 696 | $sth = $this->db->prepare($query);  | 
                                                        
| 697 | 697 |                          $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        
| 698 | -                } catch(PDOException $e) { | 
                                                        |
| 698 | +                } catch (PDOException $e) { | 
                                                        |
| 699 | 699 | echo "error : ".$e->getMessage();  | 
                                                        
| 700 | 700 | }  | 
                                                        
| 701 | 701 | $result = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
@@ -704,14 +704,14 @@ discard block  | 
                                                    ||
| 704 | 704 |  		if (empty($all)) { | 
                                                        
| 705 | 705 | $filters = array();  | 
                                                        
| 706 | 706 |              		if ($filter_name != '') { | 
                                                        
| 707 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 707 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 708 | 708 | }  | 
                                                        
| 709 | 709 | $Spotter = new Spotter($this->db);  | 
                                                        
| 710 | 710 | $all = $Spotter->countOverallAirlines($filters);  | 
                                                        
| 711 | 711 | }  | 
                                                        
| 712 | 712 | return $all;  | 
                                                        
| 713 | 713 | }  | 
                                                        
| 714 | -	public function countOverallOwners($stats_airline = '',$filter_name = '') { | 
                                                        |
| 714 | +	public function countOverallOwners($stats_airline = '', $filter_name = '') { | 
                                                        |
| 715 | 715 | global $globalStatsFilters;  | 
                                                        
| 716 | 716 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 717 | 717 | /*  | 
                                                        
@@ -725,25 +725,25 @@ discard block  | 
                                                    ||
| 725 | 725 | $result = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 726 | 726 | $all = $result[0]['nb_owner'];  | 
                                                        
| 727 | 727 | */  | 
                                                        
| 728 | -		$all = $this->getSumStats('owners_bymonth',date('Y'),$stats_airline,$filter_name); | 
                                                        |
| 728 | +		$all = $this->getSumStats('owners_bymonth', date('Y'), $stats_airline, $filter_name); | 
                                                        |
| 729 | 729 |  		if (empty($all)) { | 
                                                        
| 730 | 730 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 731 | 731 |  			if ($filter_name != '') { | 
                                                        
| 732 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 732 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 733 | 733 | }  | 
                                                        
| 734 | 734 | $Spotter = new Spotter($this->db);  | 
                                                        
| 735 | 735 | $all = $Spotter->countOverallOwners($filters);  | 
                                                        
| 736 | 736 | }  | 
                                                        
| 737 | 737 | return $all;  | 
                                                        
| 738 | 738 | }  | 
                                                        
| 739 | -	public function countOverallPilots($stats_airline = '',$filter_name = '') { | 
                                                        |
| 739 | +	public function countOverallPilots($stats_airline = '', $filter_name = '') { | 
                                                        |
| 740 | 740 | global $globalStatsFilters;  | 
                                                        
| 741 | 741 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 742 | -		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); | 
                                                        |
| 742 | +		$all = $this->getSumStats('pilots_bymonth', date('Y'), $stats_airline, $filter_name); | 
                                                        |
| 743 | 743 |  		if (empty($all)) { | 
                                                        
| 744 | 744 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
| 745 | 745 |  			if ($filter_name != '') { | 
                                                        
| 746 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]);  | 
                                                        |
| 746 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]);  | 
                                                        |
| 747 | 747 | }  | 
                                                        
| 748 | 748 | $Spotter = new Spotter($this->db);  | 
                                                        
| 749 | 749 | $all = $Spotter->countOverallPilots($filters);  | 
                                                        
@@ -751,33 +751,33 @@ discard block  | 
                                                    ||
| 751 | 751 | return $all;  | 
                                                        
| 752 | 752 | }  | 
                                                        
| 753 | 753 | |
| 754 | -	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { | 
                                                        |
| 754 | +	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { | 
                                                        |
| 755 | 755 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 756 | 756 | $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";  | 
                                                        
| 757 | -		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 757 | +		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 758 | 758 |                   try { | 
                                                        
| 759 | 759 | $sth = $this->db->prepare($query);  | 
                                                        
| 760 | 760 | $sth->execute($query_values);  | 
                                                        
| 761 | -                } catch(PDOException $e) { | 
                                                        |
| 761 | +                } catch (PDOException $e) { | 
                                                        |
| 762 | 762 | echo "error : ".$e->getMessage();  | 
                                                        
| 763 | 763 | }  | 
                                                        
| 764 | 764 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 765 | 765 | return $all;  | 
                                                        
| 766 | 766 | }  | 
                                                        
| 767 | -	public function getStats($type,$stats_airline = '', $filter_name = '') { | 
                                                        |
| 767 | +	public function getStats($type, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 768 | 768 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 769 | 769 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";  | 
                                                        
| 770 | -                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 770 | +                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 771 | 771 |                   try { | 
                                                        
| 772 | 772 | $sth = $this->db->prepare($query);  | 
                                                        
| 773 | 773 | $sth->execute($query_values);  | 
                                                        
| 774 | -                } catch(PDOException $e) { | 
                                                        |
| 774 | +                } catch (PDOException $e) { | 
                                                        |
| 775 | 775 | echo "error : ".$e->getMessage();  | 
                                                        
| 776 | 776 | }  | 
                                                        
| 777 | 777 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 778 | 778 | return $all;  | 
                                                        
| 779 | 779 | }  | 
                                                        
| 780 | -	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { | 
                                                        |
| 780 | +	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 781 | 781 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 782 | 782 | global $globalArchiveMonths, $globalDBdriver;  | 
                                                        
| 783 | 783 |      		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -785,11 +785,11 @@ discard block  | 
                                                    ||
| 785 | 785 |  	        } else { | 
                                                        
| 786 | 786 | $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";  | 
                                                        
| 787 | 787 | }  | 
                                                        
| 788 | -                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 788 | +                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 789 | 789 |                   try { | 
                                                        
| 790 | 790 | $sth = $this->db->prepare($query);  | 
                                                        
| 791 | 791 | $sth->execute($query_values);  | 
                                                        
| 792 | -                } catch(PDOException $e) { | 
                                                        |
| 792 | +                } catch (PDOException $e) { | 
                                                        |
| 793 | 793 | echo "error : ".$e->getMessage();  | 
                                                        
| 794 | 794 | }  | 
                                                        
| 795 | 795 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
@@ -807,7 +807,7 @@ discard block  | 
                                                    ||
| 807 | 807 |                   try { | 
                                                        
| 808 | 808 | $sth = $this->db->prepare($query);  | 
                                                        
| 809 | 809 | $sth->execute($query_values);  | 
                                                        
| 810 | -                } catch(PDOException $e) { | 
                                                        |
| 810 | +                } catch (PDOException $e) { | 
                                                        |
| 811 | 811 | echo "error : ".$e->getMessage();  | 
                                                        
| 812 | 812 | }  | 
                                                        
| 813 | 813 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
@@ -824,7 +824,7 @@ discard block  | 
                                                    ||
| 824 | 824 |                   try { | 
                                                        
| 825 | 825 | $sth = $this->db->prepare($query);  | 
                                                        
| 826 | 826 |                          $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        
| 827 | -                } catch(PDOException $e) { | 
                                                        |
| 827 | +                } catch (PDOException $e) { | 
                                                        |
| 828 | 828 | echo "error : ".$e->getMessage();  | 
                                                        
| 829 | 829 | }  | 
                                                        
| 830 | 830 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
@@ -841,7 +841,7 @@ discard block  | 
                                                    ||
| 841 | 841 |                   try { | 
                                                        
| 842 | 842 | $sth = $this->db->prepare($query);  | 
                                                        
| 843 | 843 |                          $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        
| 844 | -                } catch(PDOException $e) { | 
                                                        |
| 844 | +                } catch (PDOException $e) { | 
                                                        |
| 845 | 845 | echo "error : ".$e->getMessage();  | 
                                                        
| 846 | 846 | }  | 
                                                        
| 847 | 847 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
@@ -858,7 +858,7 @@ discard block  | 
                                                    ||
| 858 | 858 |                   try { | 
                                                        
| 859 | 859 | $sth = $this->db->prepare($query);  | 
                                                        
| 860 | 860 |                          $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        
| 861 | -                } catch(PDOException $e) { | 
                                                        |
| 861 | +                } catch (PDOException $e) { | 
                                                        |
| 862 | 862 | echo "error : ".$e->getMessage();  | 
                                                        
| 863 | 863 | }  | 
                                                        
| 864 | 864 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
@@ -875,14 +875,14 @@ discard block  | 
                                                    ||
| 875 | 875 |                   try { | 
                                                        
| 876 | 876 | $sth = $this->db->prepare($query);  | 
                                                        
| 877 | 877 |                          $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        
| 878 | -                } catch(PDOException $e) { | 
                                                        |
| 878 | +                } catch (PDOException $e) { | 
                                                        |
| 879 | 879 | echo "error : ".$e->getMessage();  | 
                                                        
| 880 | 880 | }  | 
                                                        
| 881 | 881 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 882 | 882 | return $all[0]['total'];  | 
                                                        
| 883 | 883 | }  | 
                                                        
| 884 | 884 | |
| 885 | -	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { | 
                                                        |
| 885 | +	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 886 | 886 | global $globalDBdriver;  | 
                                                        
| 887 | 887 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 888 | 888 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -890,15 +890,15 @@ discard block  | 
                                                    ||
| 890 | 890 |                  } else { | 
                                                        
| 891 | 891 | $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);";  | 
                                                        
| 892 | 892 | }  | 
                                                        
| 893 | -                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 893 | +                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 894 | 894 |                   try { | 
                                                        
| 895 | 895 | $sth = $this->db->prepare($query);  | 
                                                        
| 896 | 896 | $sth->execute($query_values);  | 
                                                        
| 897 | -                } catch(PDOException $e) { | 
                                                        |
| 897 | +                } catch (PDOException $e) { | 
                                                        |
| 898 | 898 | return "error : ".$e->getMessage();  | 
                                                        
| 899 | 899 | }  | 
                                                        
| 900 | 900 | }  | 
                                                        
| 901 | -	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { | 
                                                        |
| 901 | +	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 902 | 902 | global $globalDBdriver;  | 
                                                        
| 903 | 903 | if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        
| 904 | 904 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -907,219 +907,219 @@ discard block  | 
                                                    ||
| 907 | 907 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";  | 
                                                        
| 908 | 908 | $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);";  | 
                                                        
| 909 | 909 | }  | 
                                                        
| 910 | -                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 910 | +                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 911 | 911 |                   try { | 
                                                        
| 912 | 912 | $sth = $this->db->prepare($query);  | 
                                                        
| 913 | 913 | $sth->execute($query_values);  | 
                                                        
| 914 | -                } catch(PDOException $e) { | 
                                                        |
| 914 | +                } catch (PDOException $e) { | 
                                                        |
| 915 | 915 | return "error : ".$e->getMessage();  | 
                                                        
| 916 | 916 | }  | 
                                                        
| 917 | 917 | }  | 
                                                        
| 918 | -	public function getStatsSource($date,$stats_type = '') { | 
                                                        |
| 918 | +	public function getStatsSource($date, $stats_type = '') { | 
                                                        |
| 919 | 919 |  		if ($stats_type == '') { | 
                                                        
| 920 | 920 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";  | 
                                                        
| 921 | 921 |  			$query_values = array(':date' => $date); | 
                                                        
| 922 | 922 |  		} else { | 
                                                        
| 923 | 923 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";  | 
                                                        
| 924 | -			$query_values = array(':date' => $date,':stats_type' => $stats_type); | 
                                                        |
| 924 | +			$query_values = array(':date' => $date, ':stats_type' => $stats_type); | 
                                                        |
| 925 | 925 | }  | 
                                                        
| 926 | 926 |                   try { | 
                                                        
| 927 | 927 | $sth = $this->db->prepare($query);  | 
                                                        
| 928 | 928 | $sth->execute($query_values);  | 
                                                        
| 929 | -                } catch(PDOException $e) { | 
                                                        |
| 929 | +                } catch (PDOException $e) { | 
                                                        |
| 930 | 930 | echo "error : ".$e->getMessage();  | 
                                                        
| 931 | 931 | }  | 
                                                        
| 932 | 932 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 933 | 933 | return $all;  | 
                                                        
| 934 | 934 | }  | 
                                                        
| 935 | 935 | |
| 936 | -	public function addStatSource($data,$source_name,$stats_type,$date) { | 
                                                        |
| 936 | +	public function addStatSource($data, $source_name, $stats_type, $date) { | 
                                                        |
| 937 | 937 | global $globalDBdriver;  | 
                                                        
| 938 | 938 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 939 | 939 | $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";  | 
                                                        
| 940 | 940 |  		} else { | 
                                                        
| 941 | 941 | $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);";  | 
                                                        
| 942 | 942 | }  | 
                                                        
| 943 | -                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); | 
                                                        |
| 943 | +                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); | 
                                                        |
| 944 | 944 |                   try { | 
                                                        
| 945 | 945 | $sth = $this->db->prepare($query);  | 
                                                        
| 946 | 946 | $sth->execute($query_values);  | 
                                                        
| 947 | -                } catch(PDOException $e) { | 
                                                        |
| 947 | +                } catch (PDOException $e) { | 
                                                        |
| 948 | 948 | return "error : ".$e->getMessage();  | 
                                                        
| 949 | 949 | }  | 
                                                        
| 950 | 950 | }  | 
                                                        
| 951 | -	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { | 
                                                        |
| 951 | +	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 952 | 952 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";  | 
                                                        
| 953 | -                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 953 | +                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 954 | 954 |                   try { | 
                                                        
| 955 | 955 | $sth = $this->db->prepare($query);  | 
                                                        
| 956 | 956 | $sth->execute($query_values);  | 
                                                        
| 957 | -                } catch(PDOException $e) { | 
                                                        |
| 957 | +                } catch (PDOException $e) { | 
                                                        |
| 958 | 958 | return "error : ".$e->getMessage();  | 
                                                        
| 959 | 959 | }  | 
                                                        
| 960 | 960 | }  | 
                                                        
| 961 | -	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { | 
                                                        |
| 961 | +	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '') { | 
                                                        |
| 962 | 962 | global $globalDBdriver;  | 
                                                        
| 963 | 963 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 964 | 964 | $query = "INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) VALUES (:aircraft_icao,:registration,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";  | 
                                                        
| 965 | 965 |  		} else { | 
                                                        
| 966 | 966 | $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);";  | 
                                                        
| 967 | 967 | }  | 
                                                        
| 968 | -                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); | 
                                                        |
| 968 | +                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); | 
                                                        |
| 969 | 969 |                   try { | 
                                                        
| 970 | 970 | $sth = $this->db->prepare($query);  | 
                                                        
| 971 | 971 | $sth->execute($query_values);  | 
                                                        
| 972 | -                } catch(PDOException $e) { | 
                                                        |
| 972 | +                } catch (PDOException $e) { | 
                                                        |
| 973 | 973 | return "error : ".$e->getMessage();  | 
                                                        
| 974 | 974 | }  | 
                                                        
| 975 | 975 | }  | 
                                                        
| 976 | -	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { | 
                                                        |
| 976 | +	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '') { | 
                                                        |
| 977 | 977 | global $globalDBdriver;  | 
                                                        
| 978 | 978 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 979 | 979 | $query = "INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) VALUES (:callsign_icao,:airline_icao,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";  | 
                                                        
| 980 | 980 |  		} else { | 
                                                        
| 981 | 981 | $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);";  | 
                                                        
| 982 | 982 | }  | 
                                                        
| 983 | -                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); | 
                                                        |
| 983 | +                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); | 
                                                        |
| 984 | 984 |                   try { | 
                                                        
| 985 | 985 | $sth = $this->db->prepare($query);  | 
                                                        
| 986 | 986 | $sth->execute($query_values);  | 
                                                        
| 987 | -                } catch(PDOException $e) { | 
                                                        |
| 987 | +                } catch (PDOException $e) { | 
                                                        |
| 988 | 988 | return "error : ".$e->getMessage();  | 
                                                        
| 989 | 989 | }  | 
                                                        
| 990 | 990 | }  | 
                                                        
| 991 | -	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { | 
                                                        |
| 991 | +	public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '') { | 
                                                        |
| 992 | 992 | global $globalDBdriver;  | 
                                                        
| 993 | 993 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 994 | 994 | $query = "INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) VALUES (:iso2,:iso3,:name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";  | 
                                                        
| 995 | 995 |  		} else { | 
                                                        
| 996 | 996 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);";  | 
                                                        
| 997 | 997 | }  | 
                                                        
| 998 | -                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); | 
                                                        |
| 998 | +                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name); | 
                                                        |
| 999 | 999 |                   try { | 
                                                        
| 1000 | 1000 | $sth = $this->db->prepare($query);  | 
                                                        
| 1001 | 1001 | $sth->execute($query_values);  | 
                                                        
| 1002 | -                } catch(PDOException $e) { | 
                                                        |
| 1002 | +                } catch (PDOException $e) { | 
                                                        |
| 1003 | 1003 | return "error : ".$e->getMessage();  | 
                                                        
| 1004 | 1004 | }  | 
                                                        
| 1005 | 1005 | }  | 
                                                        
| 1006 | -	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { | 
                                                        |
| 1006 | +	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { | 
                                                        |
| 1007 | 1007 | global $globalDBdriver;  | 
                                                        
| 1008 | 1008 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1009 | 1009 | $query = "INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline, filter_name) VALUES (:aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, stats_airline = :stats_airline";  | 
                                                        
| 1010 | 1010 |  		} else { | 
                                                        
| 1011 | 1011 | $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);";  | 
                                                        
| 1012 | 1012 | }  | 
                                                        
| 1013 | -                $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); | 
                                                        |
| 1013 | +                $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); | 
                                                        |
| 1014 | 1014 |                   try { | 
                                                        
| 1015 | 1015 | $sth = $this->db->prepare($query);  | 
                                                        
| 1016 | 1016 | $sth->execute($query_values);  | 
                                                        
| 1017 | -                } catch(PDOException $e) { | 
                                                        |
| 1017 | +                } catch (PDOException $e) { | 
                                                        |
| 1018 | 1018 | return "error : ".$e->getMessage();  | 
                                                        
| 1019 | 1019 | }  | 
                                                        
| 1020 | 1020 | }  | 
                                                        
| 1021 | -	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { | 
                                                        |
| 1021 | +	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '') { | 
                                                        |
| 1022 | 1022 | global $globalDBdriver;  | 
                                                        
| 1023 | 1023 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1024 | 1024 | $query = "INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) VALUES (:airline_icao,:airline_name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt,airline_name = :airline_name";  | 
                                                        
| 1025 | 1025 |  		} else { | 
                                                        
| 1026 | 1026 | $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);";  | 
                                                        
| 1027 | 1027 | }  | 
                                                        
| 1028 | -                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); | 
                                                        |
| 1028 | +                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); | 
                                                        |
| 1029 | 1029 |                   try { | 
                                                        
| 1030 | 1030 | $sth = $this->db->prepare($query);  | 
                                                        
| 1031 | 1031 | $sth->execute($query_values);  | 
                                                        
| 1032 | -                } catch(PDOException $e) { | 
                                                        |
| 1032 | +                } catch (PDOException $e) { | 
                                                        |
| 1033 | 1033 | return "error : ".$e->getMessage();  | 
                                                        
| 1034 | 1034 | }  | 
                                                        
| 1035 | 1035 | }  | 
                                                        
| 1036 | -	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { | 
                                                        |
| 1036 | +	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '') { | 
                                                        |
| 1037 | 1037 | global $globalDBdriver;  | 
                                                        
| 1038 | 1038 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1039 | 1039 | $query = "INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) VALUES (:owner_name,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";  | 
                                                        
| 1040 | 1040 |  		} else { | 
                                                        
| 1041 | 1041 | $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);";  | 
                                                        
| 1042 | 1042 | }  | 
                                                        
| 1043 | -                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        |
| 1043 | +                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        |
| 1044 | 1044 |                   try { | 
                                                        
| 1045 | 1045 | $sth = $this->db->prepare($query);  | 
                                                        
| 1046 | 1046 | $sth->execute($query_values);  | 
                                                        
| 1047 | -                } catch(PDOException $e) { | 
                                                        |
| 1047 | +                } catch (PDOException $e) { | 
                                                        |
| 1048 | 1048 | return "error : ".$e->getMessage();  | 
                                                        
| 1049 | 1049 | }  | 
                                                        
| 1050 | 1050 | }  | 
                                                        
| 1051 | -	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '') { | 
                                                        |
| 1051 | +	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '') { | 
                                                        |
| 1052 | 1052 | global $globalDBdriver;  | 
                                                        
| 1053 | 1053 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1054 | 1054 | $query = "INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) VALUES (:pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, pilot_name = :pilot_name";  | 
                                                        
| 1055 | 1055 |  		} else { | 
                                                        
| 1056 | 1056 | $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);";  | 
                                                        
| 1057 | 1057 | }  | 
                                                        
| 1058 | -                $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); | 
                                                        |
| 1058 | +                $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); | 
                                                        |
| 1059 | 1059 |                   try { | 
                                                        
| 1060 | 1060 | $sth = $this->db->prepare($query);  | 
                                                        
| 1061 | 1061 | $sth->execute($query_values);  | 
                                                        
| 1062 | -                } catch(PDOException $e) { | 
                                                        |
| 1062 | +                } catch (PDOException $e) { | 
                                                        |
| 1063 | 1063 | return "error : ".$e->getMessage();  | 
                                                        
| 1064 | 1064 | }  | 
                                                        
| 1065 | 1065 | }  | 
                                                        
| 1066 | -	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { | 
                                                        |
| 1066 | +	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { | 
                                                        |
| 1067 | 1067 | global $globalDBdriver;  | 
                                                        
| 1068 | 1068 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1069 | 1069 | $query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE departure = departure+:departure";  | 
                                                        
| 1070 | 1070 |  		} else { | 
                                                        
| 1071 | 1071 | $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);";  | 
                                                        
| 1072 | 1072 | }  | 
                                                        
| 1073 | -                $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); | 
                                                        |
| 1073 | +                $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); | 
                                                        |
| 1074 | 1074 |                   try { | 
                                                        
| 1075 | 1075 | $sth = $this->db->prepare($query);  | 
                                                        
| 1076 | 1076 | $sth->execute($query_values);  | 
                                                        
| 1077 | -                } catch(PDOException $e) { | 
                                                        |
| 1077 | +                } catch (PDOException $e) { | 
                                                        |
| 1078 | 1078 | return "error : ".$e->getMessage();  | 
                                                        
| 1079 | 1079 | }  | 
                                                        
| 1080 | 1080 | }  | 
                                                        
| 1081 | -	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { | 
                                                        |
| 1081 | +	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { | 
                                                        |
| 1082 | 1082 | global $globalDBdriver;  | 
                                                        
| 1083 | 1083 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1084 | 1084 | $query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE departure = :departure";  | 
                                                        
| 1085 | 1085 |  		} else { | 
                                                        
| 1086 | 1086 | $query = "UPDATE stats_airport SET departure = 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);";  | 
                                                        
| 1087 | 1087 | }  | 
                                                        
| 1088 | -                $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); | 
                                                        |
| 1088 | +                $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); | 
                                                        |
| 1089 | 1089 |                   try { | 
                                                        
| 1090 | 1090 | $sth = $this->db->prepare($query);  | 
                                                        
| 1091 | 1091 | $sth->execute($query_values);  | 
                                                        
| 1092 | -                } catch(PDOException $e) { | 
                                                        |
| 1092 | +                } catch (PDOException $e) { | 
                                                        |
| 1093 | 1093 | return "error : ".$e->getMessage();  | 
                                                        
| 1094 | 1094 | }  | 
                                                        
| 1095 | 1095 | }  | 
                                                        
| 1096 | -	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { | 
                                                        |
| 1096 | +	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { | 
                                                        |
| 1097 | 1097 | global $globalDBdriver;  | 
                                                        
| 1098 | 1098 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1099 | 1099 | $query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE arrival = arrival+:arrival";  | 
                                                        
| 1100 | 1100 |  		} else { | 
                                                        
| 1101 | 1101 | $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);";  | 
                                                        
| 1102 | 1102 | }  | 
                                                        
| 1103 | -                $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); | 
                                                        |
| 1103 | +                $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); | 
                                                        |
| 1104 | 1104 |                   try { | 
                                                        
| 1105 | 1105 | $sth = $this->db->prepare($query);  | 
                                                        
| 1106 | 1106 | $sth->execute($query_values);  | 
                                                        
| 1107 | -                } catch(PDOException $e) { | 
                                                        |
| 1107 | +                } catch (PDOException $e) { | 
                                                        |
| 1108 | 1108 | return "error : ".$e->getMessage();  | 
                                                        
| 1109 | 1109 | }  | 
                                                        
| 1110 | 1110 | }  | 
                                                        
| 1111 | -	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { | 
                                                        |
| 1111 | +	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { | 
                                                        |
| 1112 | 1112 | global $globalDBdriver;  | 
                                                        
| 1113 | 1113 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1114 | 1114 | $query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE arrival = :arrival";  | 
                                                        
| 1115 | 1115 |  		} else { | 
                                                        
| 1116 | 1116 | $query = "UPDATE stats_airport SET arrival = 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);";  | 
                                                        
| 1117 | 1117 | }  | 
                                                        
| 1118 | -                $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); | 
                                                        |
| 1118 | +                $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); | 
                                                        |
| 1119 | 1119 |                   try { | 
                                                        
| 1120 | 1120 | $sth = $this->db->prepare($query);  | 
                                                        
| 1121 | 1121 | $sth->execute($query_values);  | 
                                                        
| 1122 | -                } catch(PDOException $e) { | 
                                                        |
| 1122 | +                } catch (PDOException $e) { | 
                                                        |
| 1123 | 1123 | return "error : ".$e->getMessage();  | 
                                                        
| 1124 | 1124 | }  | 
                                                        
| 1125 | 1125 | }  | 
                                                        
@@ -1130,7 +1130,7 @@ discard block  | 
                                                    ||
| 1130 | 1130 |                   try { | 
                                                        
| 1131 | 1131 | $sth = $this->db->prepare($query);  | 
                                                        
| 1132 | 1132 | $sth->execute($query_values);  | 
                                                        
| 1133 | -                } catch(PDOException $e) { | 
                                                        |
| 1133 | +                } catch (PDOException $e) { | 
                                                        |
| 1134 | 1134 | return "error : ".$e->getMessage();  | 
                                                        
| 1135 | 1135 | }  | 
                                                        
| 1136 | 1136 | }  | 
                                                        
@@ -1140,7 +1140,7 @@ discard block  | 
                                                    ||
| 1140 | 1140 |                   try { | 
                                                        
| 1141 | 1141 | $sth = $this->db->prepare($query);  | 
                                                        
| 1142 | 1142 | $sth->execute($query_values);  | 
                                                        
| 1143 | -                } catch(PDOException $e) { | 
                                                        |
| 1143 | +                } catch (PDOException $e) { | 
                                                        |
| 1144 | 1144 | return "error : ".$e->getMessage();  | 
                                                        
| 1145 | 1145 | }  | 
                                                        
| 1146 | 1146 | }  | 
                                                        
@@ -1150,7 +1150,7 @@ discard block  | 
                                                    ||
| 1150 | 1150 |                   try { | 
                                                        
| 1151 | 1151 | $sth = $this->db->prepare($query);  | 
                                                        
| 1152 | 1152 | $sth->execute($query_values);  | 
                                                        
| 1153 | -                } catch(PDOException $e) { | 
                                                        |
| 1153 | +                } catch (PDOException $e) { | 
                                                        |
| 1154 | 1154 | return "error : ".$e->getMessage();  | 
                                                        
| 1155 | 1155 | }  | 
                                                        
| 1156 | 1156 | }  | 
                                                        
@@ -1389,40 +1389,40 @@ discard block  | 
                                                    ||
| 1389 | 1389 | $last_update_day = $last_update[0]['value'];  | 
                                                        
| 1390 | 1390 | } else $last_update_day = '2012-12-12 12:12:12';  | 
                                                        
| 1391 | 1391 | $Spotter = new Spotter($this->db);  | 
                                                        
| 1392 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);  | 
                                                        |
| 1392 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);  | 
                                                        |
| 1393 | 1393 |  			foreach ($alldata as $number) { | 
                                                        
| 1394 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']);  | 
                                                        |
| 1394 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer']);  | 
                                                        |
| 1395 | 1395 | }  | 
                                                        
| 1396 | 1396 | if ($globalDebug) echo 'Count all airlines...'."\n";  | 
                                                        
| 1397 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day);  | 
                                                        |
| 1397 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);  | 
                                                        |
| 1398 | 1398 |  			foreach ($alldata as $number) { | 
                                                        
| 1399 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);  | 
                                                        |
| 1399 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);  | 
                                                        |
| 1400 | 1400 | }  | 
                                                        
| 1401 | 1401 | if ($globalDebug) echo 'Count all registrations...'."\n";  | 
                                                        
| 1402 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);  | 
                                                        |
| 1402 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);  | 
                                                        |
| 1403 | 1403 |  			foreach ($alldata as $number) { | 
                                                        
| 1404 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);  | 
                                                        |
| 1404 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']);  | 
                                                        |
| 1405 | 1405 | }  | 
                                                        
| 1406 | 1406 | if ($globalDebug) echo 'Count all callsigns...'."\n";  | 
                                                        
| 1407 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);  | 
                                                        |
| 1407 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);  | 
                                                        |
| 1408 | 1408 |  			foreach ($alldata as $number) { | 
                                                        
| 1409 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);  | 
                                                        |
| 1409 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);  | 
                                                        |
| 1410 | 1410 | }  | 
                                                        
| 1411 | 1411 | if ($globalDebug) echo 'Count all owners...'."\n";  | 
                                                        
| 1412 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day);  | 
                                                        |
| 1412 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day);  | 
                                                        |
| 1413 | 1413 |  			foreach ($alldata as $number) { | 
                                                        
| 1414 | - $this->addStatOwner($number['owner_name'],$number['owner_count']);  | 
                                                        |
| 1414 | + $this->addStatOwner($number['owner_name'], $number['owner_count']);  | 
                                                        |
| 1415 | 1415 | }  | 
                                                        
| 1416 | 1416 | if ($globalDebug) echo 'Count all pilots...'."\n";  | 
                                                        
| 1417 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day);  | 
                                                        |
| 1417 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day);  | 
                                                        |
| 1418 | 1418 |  			foreach ($alldata as $number) { | 
                                                        
| 1419 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source']);  | 
                                                        |
| 1419 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source']);  | 
                                                        |
| 1420 | 1420 | }  | 
                                                        
| 1421 | 1421 | |
| 1422 | 1422 | if ($globalDebug) echo 'Count all departure airports...'."\n";  | 
                                                        
| 1423 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);  | 
                                                        |
| 1423 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);  | 
                                                        |
| 1424 | 1424 | if ($globalDebug) echo 'Count all detected departure airports...'."\n";  | 
                                                        
| 1425 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);  | 
                                                        |
| 1425 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);  | 
                                                        |
| 1426 | 1426 | if ($globalDebug) echo 'Order departure airports...'."\n";  | 
                                                        
| 1427 | 1427 | $alldata = array();  | 
                                                        
| 1428 | 1428 | |
@@ -1440,14 +1440,14 @@ discard block  | 
                                                    ||
| 1440 | 1440 |      			foreach ($alldata as $key => $row) { | 
                                                        
| 1441 | 1441 | $count[$key] = $row['airport_departure_icao_count'];  | 
                                                        
| 1442 | 1442 | }  | 
                                                        
| 1443 | - array_multisort($count,SORT_DESC,$alldata);  | 
                                                        |
| 1443 | + array_multisort($count, SORT_DESC, $alldata);  | 
                                                        |
| 1444 | 1444 |  			foreach ($alldata as $number) { | 
                                                        
| 1445 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);  | 
                                                        |
| 1445 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']);  | 
                                                        |
| 1446 | 1446 | }  | 
                                                        
| 1447 | 1447 | if ($globalDebug) echo 'Count all arrival airports...'."\n";  | 
                                                        
| 1448 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);  | 
                                                        |
| 1448 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);  | 
                                                        |
| 1449 | 1449 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n";  | 
                                                        
| 1450 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);  | 
                                                        |
| 1450 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);  | 
                                                        |
| 1451 | 1451 | if ($globalDebug) echo 'Order arrival airports...'."\n";  | 
                                                        
| 1452 | 1452 | $alldata = array();  | 
                                                        
| 1453 | 1453 |      			foreach ($pall as $value) { | 
                                                        
@@ -1464,16 +1464,16 @@ discard block  | 
                                                    ||
| 1464 | 1464 |          		foreach ($alldata as $key => $row) { | 
                                                        
| 1465 | 1465 | $count[$key] = $row['airport_arrival_icao_count'];  | 
                                                        
| 1466 | 1466 | }  | 
                                                        
| 1467 | - array_multisort($count,SORT_DESC,$alldata);  | 
                                                        |
| 1467 | + array_multisort($count, SORT_DESC, $alldata);  | 
                                                        |
| 1468 | 1468 |                          foreach ($alldata as $number) { | 
                                                        
| 1469 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);  | 
                                                        |
| 1469 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']);  | 
                                                        |
| 1470 | 1470 | }  | 
                                                        
| 1471 | 1471 |  			if ($Connection->tableExists('countries')) { | 
                                                        
| 1472 | 1472 | if ($globalDebug) echo 'Count all flights by countries...'."\n";  | 
                                                        
| 1473 | 1473 | $SpotterArchive = new SpotterArchive();  | 
                                                        
| 1474 | - $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);  | 
                                                        |
| 1474 | + $alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);  | 
                                                        |
| 1475 | 1475 |  				foreach ($alldata as $number) { | 
                                                        
| 1476 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);  | 
                                                        |
| 1476 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);  | 
                                                        |
| 1477 | 1477 | }  | 
                                                        
| 1478 | 1478 | }  | 
                                                        
| 1479 | 1479 | |
@@ -1487,37 +1487,37 @@ discard block  | 
                                                    ||
| 1487 | 1487 | $lastyear = false;  | 
                                                        
| 1488 | 1488 |  			foreach ($alldata as $number) { | 
                                                        
| 1489 | 1489 |  				if ($number['year_name'] != date('Y')) $lastyear = true; | 
                                                        
| 1490 | -				$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']))); | 
                                                        |
| 1490 | +				$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']))); | 
                                                        |
| 1491 | 1491 | }  | 
                                                        
| 1492 | 1492 | if ($globalDebug) echo 'Count all military flights by months...'."\n";  | 
                                                        
| 1493 | 1493 | $alldata = $Spotter->countAllMilitaryMonths();  | 
                                                        
| 1494 | 1494 |  			foreach ($alldata as $number) { | 
                                                        
| 1495 | -				$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']))); | 
                                                        |
| 1495 | +				$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']))); | 
                                                        |
| 1496 | 1496 | }  | 
                                                        
| 1497 | 1497 | if ($globalDebug) echo 'Count all owners by months...'."\n";  | 
                                                        
| 1498 | 1498 | $alldata = $Spotter->countAllMonthsOwners();  | 
                                                        
| 1499 | 1499 |  			foreach ($alldata as $number) { | 
                                                        
| 1500 | -				$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']))); | 
                                                        |
| 1500 | +				$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']))); | 
                                                        |
| 1501 | 1501 | }  | 
                                                        
| 1502 | 1502 | if ($globalDebug) echo 'Count all pilots by months...'."\n";  | 
                                                        
| 1503 | 1503 | $alldata = $Spotter->countAllMonthsPilots();  | 
                                                        
| 1504 | 1504 |  			foreach ($alldata as $number) { | 
                                                        
| 1505 | -				$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']))); | 
                                                        |
| 1505 | +				$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']))); | 
                                                        |
| 1506 | 1506 | }  | 
                                                        
| 1507 | 1507 | if ($globalDebug) echo 'Count all airlines by months...'."\n";  | 
                                                        
| 1508 | 1508 | $alldata = $Spotter->countAllMonthsAirlines();  | 
                                                        
| 1509 | 1509 |  			foreach ($alldata as $number) { | 
                                                        
| 1510 | -				$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']))); | 
                                                        |
| 1510 | +				$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']))); | 
                                                        |
| 1511 | 1511 | }  | 
                                                        
| 1512 | 1512 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n";  | 
                                                        
| 1513 | 1513 | $alldata = $Spotter->countAllMonthsAircrafts();  | 
                                                        
| 1514 | 1514 |  			foreach ($alldata as $number) { | 
                                                        
| 1515 | -				$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']))); | 
                                                        |
| 1515 | +				$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']))); | 
                                                        |
| 1516 | 1516 | }  | 
                                                        
| 1517 | 1517 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n";  | 
                                                        
| 1518 | 1518 | $alldata = $Spotter->countAllMonthsRealArrivals();  | 
                                                        
| 1519 | 1519 |  			foreach ($alldata as $number) { | 
                                                        
| 1520 | -				$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']))); | 
                                                        |
| 1520 | +				$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']))); | 
                                                        |
| 1521 | 1521 | }  | 
                                                        
| 1522 | 1522 | if ($globalDebug) echo 'Airports data...'."\n";  | 
                                                        
| 1523 | 1523 | if ($globalDebug) echo '...Departure'."\n";  | 
                                                        
@@ -1562,7 +1562,7 @@ discard block  | 
                                                    ||
| 1562 | 1562 | }  | 
                                                        
| 1563 | 1563 | $alldata = $pall;  | 
                                                        
| 1564 | 1564 |  			foreach ($alldata as $number) { | 
                                                        
| 1565 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);  | 
                                                        |
| 1565 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);  | 
                                                        |
| 1566 | 1566 | }  | 
                                                        
| 1567 | 1567 | echo '...Arrival'."\n";  | 
                                                        
| 1568 | 1568 | $pall = $Spotter->getLast7DaysAirportsArrival();  | 
                                                        
@@ -1604,7 +1604,7 @@ discard block  | 
                                                    ||
| 1604 | 1604 | }  | 
                                                        
| 1605 | 1605 | $alldata = $pall;  | 
                                                        
| 1606 | 1606 |  			foreach ($alldata as $number) { | 
                                                        
| 1607 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);  | 
                                                        |
| 1607 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);  | 
                                                        |
| 1608 | 1608 | }  | 
                                                        
| 1609 | 1609 | |
| 1610 | 1610 | echo 'Flights data...'."\n";  | 
                                                        
@@ -1612,28 +1612,28 @@ discard block  | 
                                                    ||
| 1612 | 1612 | echo '-> countAllDatesLastMonth...'."\n";  | 
                                                        
| 1613 | 1613 | $alldata = $Spotter->countAllDatesLastMonth();  | 
                                                        
| 1614 | 1614 |  			foreach ($alldata as $number) { | 
                                                        
| 1615 | -				$this->addStatFlight('month',$number['date_name'],$number['date_count']); | 
                                                        |
| 1615 | +				$this->addStatFlight('month', $number['date_name'], $number['date_count']); | 
                                                        |
| 1616 | 1616 | }  | 
                                                        
| 1617 | 1617 | echo '-> countAllDates...'."\n";  | 
                                                        
| 1618 | 1618 | $previousdata = $this->countAllDates();  | 
                                                        
| 1619 | 1619 | $previousdatabyairlines = $this->countAllDatesByAirlines();  | 
                                                        
| 1620 | 1620 |  			$this->deleteStatFlight('date'); | 
                                                        
| 1621 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());  | 
                                                        |
| 1621 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());  | 
                                                        |
| 1622 | 1622 | $values = array();  | 
                                                        
| 1623 | 1623 |  			foreach ($alldata as $cnt) { | 
                                                        
| 1624 | 1624 | $values[] = $cnt['date_count'];  | 
                                                        
| 1625 | 1625 | }  | 
                                                        
| 1626 | - array_multisort($values,SORT_DESC,$alldata);  | 
                                                        |
| 1627 | - array_splice($alldata,11);  | 
                                                        |
| 1626 | + array_multisort($values, SORT_DESC, $alldata);  | 
                                                        |
| 1627 | + array_splice($alldata, 11);  | 
                                                        |
| 1628 | 1628 |  			foreach ($alldata as $number) { | 
                                                        
| 1629 | -				$this->addStatFlight('date',$number['date_name'],$number['date_count']); | 
                                                        |
| 1629 | +				$this->addStatFlight('date', $number['date_name'], $number['date_count']); | 
                                                        |
| 1630 | 1630 | }  | 
                                                        
| 1631 | 1631 | |
| 1632 | 1632 |  			$this->deleteStatFlight('hour'); | 
                                                        
| 1633 | 1633 | echo '-> countAllHours...'."\n";  | 
                                                        
| 1634 | 1634 |  			$alldata = $Spotter->countAllHours('hour'); | 
                                                        
| 1635 | 1635 |  			foreach ($alldata as $number) { | 
                                                        
| 1636 | -				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); | 
                                                        |
| 1636 | +				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); | 
                                                        |
| 1637 | 1637 | }  | 
                                                        
| 1638 | 1638 | |
| 1639 | 1639 | |
@@ -1642,34 +1642,34 @@ discard block  | 
                                                    ||
| 1642 | 1642 | echo '--- Stats by airlines ---'."\n";  | 
                                                        
| 1643 | 1643 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";  | 
                                                        
| 1644 | 1644 | $Spotter = new Spotter($this->db);  | 
                                                        
| 1645 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1645 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);  | 
                                                        |
| 1646 | 1646 |  			foreach ($alldata as $number) { | 
                                                        
| 1647 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']);  | 
                                                        |
| 1647 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao']);  | 
                                                        |
| 1648 | 1648 | }  | 
                                                        
| 1649 | 1649 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";  | 
                                                        
| 1650 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1650 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);  | 
                                                        |
| 1651 | 1651 |  			foreach ($alldata as $number) { | 
                                                        
| 1652 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']);  | 
                                                        |
| 1652 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao']);  | 
                                                        |
| 1653 | 1653 | }  | 
                                                        
| 1654 | 1654 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";  | 
                                                        
| 1655 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1655 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);  | 
                                                        |
| 1656 | 1656 |  			foreach ($alldata as $number) { | 
                                                        
| 1657 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);  | 
                                                        |
| 1657 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);  | 
                                                        |
| 1658 | 1658 | }  | 
                                                        
| 1659 | 1659 | if ($globalDebug) echo 'Count all owners by airlines...'."\n";  | 
                                                        
| 1660 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1660 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);  | 
                                                        |
| 1661 | 1661 |  			foreach ($alldata as $number) { | 
                                                        
| 1662 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']);  | 
                                                        |
| 1662 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao']);  | 
                                                        |
| 1663 | 1663 | }  | 
                                                        
| 1664 | 1664 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n";  | 
                                                        
| 1665 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1665 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);  | 
                                                        |
| 1666 | 1666 |  			foreach ($alldata as $number) { | 
                                                        
| 1667 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source']);  | 
                                                        |
| 1667 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source']);  | 
                                                        |
| 1668 | 1668 | }  | 
                                                        
| 1669 | 1669 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";  | 
                                                        
| 1670 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1670 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);  | 
                                                        |
| 1671 | 1671 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";  | 
                                                        
| 1672 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1672 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);  | 
                                                        |
| 1673 | 1673 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";  | 
                                                        
| 1674 | 1674 | //$alldata = array();  | 
                                                        
| 1675 | 1675 |      			foreach ($dall as $value) { | 
                                                        
@@ -1689,12 +1689,12 @@ discard block  | 
                                                    ||
| 1689 | 1689 | }  | 
                                                        
| 1690 | 1690 | $alldata = $pall;  | 
                                                        
| 1691 | 1691 |  			foreach ($alldata as $number) { | 
                                                        
| 1692 | - 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']);  | 
                                                        |
| 1692 | + 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']);  | 
                                                        |
| 1693 | 1693 | }  | 
                                                        
| 1694 | 1694 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";  | 
                                                        
| 1695 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1695 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);  | 
                                                        |
| 1696 | 1696 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";  | 
                                                        
| 1697 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);  | 
                                                        |
| 1697 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);  | 
                                                        |
| 1698 | 1698 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";  | 
                                                        
| 1699 | 1699 | //$alldata = array();  | 
                                                        
| 1700 | 1700 |      			foreach ($dall as $value) { | 
                                                        
@@ -1714,7 +1714,7 @@ discard block  | 
                                                    ||
| 1714 | 1714 | }  | 
                                                        
| 1715 | 1715 | $alldata = $pall;  | 
                                                        
| 1716 | 1716 |                          foreach ($alldata as $number) { | 
                                                        
| 1717 | - 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']);  | 
                                                        |
| 1717 | + 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']);  | 
                                                        |
| 1718 | 1718 | }  | 
                                                        
| 1719 | 1719 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";  | 
                                                        
| 1720 | 1720 | $Spotter = new Spotter($this->db);  | 
                                                        
@@ -1722,27 +1722,27 @@ discard block  | 
                                                    ||
| 1722 | 1722 | $lastyear = false;  | 
                                                        
| 1723 | 1723 |  			foreach ($alldata as $number) { | 
                                                        
| 1724 | 1724 |  				if ($number['year_name'] != date('Y')) $lastyear = true; | 
                                                        
| 1725 | -				$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']); | 
                                                        |
| 1725 | +				$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']); | 
                                                        |
| 1726 | 1726 | }  | 
                                                        
| 1727 | 1727 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";  | 
                                                        
| 1728 | 1728 | $alldata = $Spotter->countAllMonthsOwnersByAirlines();  | 
                                                        
| 1729 | 1729 |  			foreach ($alldata as $number) { | 
                                                        
| 1730 | -				$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']); | 
                                                        |
| 1730 | +				$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']); | 
                                                        |
| 1731 | 1731 | }  | 
                                                        
| 1732 | 1732 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";  | 
                                                        
| 1733 | 1733 | $alldata = $Spotter->countAllMonthsPilotsByAirlines();  | 
                                                        
| 1734 | 1734 |  			foreach ($alldata as $number) { | 
                                                        
| 1735 | -				$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']); | 
                                                        |
| 1735 | +				$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']); | 
                                                        |
| 1736 | 1736 | }  | 
                                                        
| 1737 | 1737 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";  | 
                                                        
| 1738 | 1738 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines();  | 
                                                        
| 1739 | 1739 |  			foreach ($alldata as $number) { | 
                                                        
| 1740 | -				$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']); | 
                                                        |
| 1740 | +				$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']); | 
                                                        |
| 1741 | 1741 | }  | 
                                                        
| 1742 | 1742 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";  | 
                                                        
| 1743 | 1743 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();  | 
                                                        
| 1744 | 1744 |  			foreach ($alldata as $number) { | 
                                                        
| 1745 | -				$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']); | 
                                                        |
| 1745 | +				$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']); | 
                                                        |
| 1746 | 1746 | }  | 
                                                        
| 1747 | 1747 | if ($globalDebug) echo '...Departure'."\n";  | 
                                                        
| 1748 | 1748 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();  | 
                                                        
@@ -1765,7 +1765,7 @@ discard block  | 
                                                    ||
| 1765 | 1765 | }  | 
                                                        
| 1766 | 1766 | $alldata = $pall;  | 
                                                        
| 1767 | 1767 |  			foreach ($alldata as $number) { | 
                                                        
| 1768 | - $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']);  | 
                                                        |
| 1768 | + $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']);  | 
                                                        |
| 1769 | 1769 | }  | 
                                                        
| 1770 | 1770 | if ($globalDebug) echo '...Arrival'."\n";  | 
                                                        
| 1771 | 1771 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();  | 
                                                        
@@ -1788,32 +1788,32 @@ discard block  | 
                                                    ||
| 1788 | 1788 | }  | 
                                                        
| 1789 | 1789 | $alldata = $pall;  | 
                                                        
| 1790 | 1790 |  			foreach ($alldata as $number) { | 
                                                        
| 1791 | - $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']);  | 
                                                        |
| 1791 | + $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']);  | 
                                                        |
| 1792 | 1792 | }  | 
                                                        
| 1793 | 1793 | |
| 1794 | 1794 | if ($globalDebug) echo 'Flights data...'."\n";  | 
                                                        
| 1795 | 1795 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";  | 
                                                        
| 1796 | 1796 | $alldata = $Spotter->countAllDatesLastMonthByAirlines();  | 
                                                        
| 1797 | 1797 |  			foreach ($alldata as $number) { | 
                                                        
| 1798 | -				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); | 
                                                        |
| 1798 | +				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); | 
                                                        |
| 1799 | 1799 | }  | 
                                                        
| 1800 | 1800 | if ($globalDebug) echo '-> countAllDates...'."\n";  | 
                                                        
| 1801 | 1801 | //$previousdata = $this->countAllDatesByAirlines();  | 
                                                        
| 1802 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());  | 
                                                        |
| 1802 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());  | 
                                                        |
| 1803 | 1803 | $values = array();  | 
                                                        
| 1804 | 1804 |  			foreach ($alldata as $cnt) { | 
                                                        
| 1805 | 1805 | $values[] = $cnt['date_count'];  | 
                                                        
| 1806 | 1806 | }  | 
                                                        
| 1807 | - array_multisort($values,SORT_DESC,$alldata);  | 
                                                        |
| 1808 | - array_splice($alldata,11);  | 
                                                        |
| 1807 | + array_multisort($values, SORT_DESC, $alldata);  | 
                                                        |
| 1808 | + array_splice($alldata, 11);  | 
                                                        |
| 1809 | 1809 |  			foreach ($alldata as $number) { | 
                                                        
| 1810 | -				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); | 
                                                        |
| 1810 | +				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); | 
                                                        |
| 1811 | 1811 | }  | 
                                                        
| 1812 | 1812 | |
| 1813 | 1813 | if ($globalDebug) echo '-> countAllHours...'."\n";  | 
                                                        
| 1814 | 1814 |  			$alldata = $Spotter->countAllHoursByAirlines('hour'); | 
                                                        
| 1815 | 1815 |  			foreach ($alldata as $number) { | 
                                                        
| 1816 | -				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); | 
                                                        |
| 1816 | +				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); | 
                                                        |
| 1817 | 1817 | }  | 
                                                        
| 1818 | 1818 | |
| 1819 | 1819 | |
@@ -1830,33 +1830,33 @@ discard block  | 
                                                    ||
| 1830 | 1830 | // Count by filter  | 
                                                        
| 1831 | 1831 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";  | 
                                                        
| 1832 | 1832 | $Spotter = new Spotter($this->db);  | 
                                                        
| 1833 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);  | 
                                                        |
| 1833 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);  | 
                                                        |
| 1834 | 1834 |  				foreach ($alldata as $number) { | 
                                                        
| 1835 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name);  | 
                                                        |
| 1835 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name);  | 
                                                        |
| 1836 | 1836 | }  | 
                                                        
| 1837 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);  | 
                                                        |
| 1837 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);  | 
                                                        |
| 1838 | 1838 |  				foreach ($alldata as $number) { | 
                                                        
| 1839 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name);  | 
                                                        |
| 1839 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name);  | 
                                                        |
| 1840 | 1840 | }  | 
                                                        
| 1841 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);  | 
                                                        |
| 1841 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);  | 
                                                        |
| 1842 | 1842 |  				foreach ($alldata as $number) { | 
                                                        
| 1843 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name);  | 
                                                        |
| 1843 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name);  | 
                                                        |
| 1844 | 1844 | }  | 
                                                        
| 1845 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);  | 
                                                        |
| 1845 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);  | 
                                                        |
| 1846 | 1846 |  				foreach ($alldata as $number) { | 
                                                        
| 1847 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name);  | 
                                                        |
| 1847 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name);  | 
                                                        |
| 1848 | 1848 | }  | 
                                                        
| 1849 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);  | 
                                                        |
| 1849 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);  | 
                                                        |
| 1850 | 1850 |  				foreach ($alldata as $number) { | 
                                                        
| 1851 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name);  | 
                                                        |
| 1851 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name);  | 
                                                        |
| 1852 | 1852 | }  | 
                                                        
| 1853 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);  | 
                                                        |
| 1853 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);  | 
                                                        |
| 1854 | 1854 |  				foreach ($alldata as $number) { | 
                                                        
| 1855 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source']);  | 
                                                        |
| 1855 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source']);  | 
                                                        |
| 1856 | 1856 | }  | 
                                                        
| 1857 | 1857 | |
| 1858 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);  | 
                                                        |
| 1859 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);  | 
                                                        |
| 1858 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);  | 
                                                        |
| 1859 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);  | 
                                                        |
| 1860 | 1860 | $alldata = array();  | 
                                                        
| 1861 | 1861 |  	    			foreach ($pall as $value) { | 
                                                        
| 1862 | 1862 | $icao = $value['airport_departure_icao'];  | 
                                                        
@@ -1872,12 +1872,12 @@ discard block  | 
                                                    ||
| 1872 | 1872 |      				foreach ($alldata as $key => $row) { | 
                                                        
| 1873 | 1873 | $count[$key] = $row['airport_departure_icao_count'];  | 
                                                        
| 1874 | 1874 | }  | 
                                                        
| 1875 | - array_multisort($count,SORT_DESC,$alldata);  | 
                                                        |
| 1875 | + array_multisort($count, SORT_DESC, $alldata);  | 
                                                        |
| 1876 | 1876 |  				foreach ($alldata as $number) { | 
                                                        
| 1877 | - 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);  | 
                                                        |
| 1877 | + 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);  | 
                                                        |
| 1878 | 1878 | }  | 
                                                        
| 1879 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter);  | 
                                                        |
| 1880 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);  | 
                                                        |
| 1879 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, $filter);  | 
                                                        |
| 1880 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, $filter);  | 
                                                        |
| 1881 | 1881 | $alldata = array();  | 
                                                        
| 1882 | 1882 |      				foreach ($pall as $value) { | 
                                                        
| 1883 | 1883 | $icao = $value['airport_arrival_icao'];  | 
                                                        
@@ -1893,36 +1893,36 @@ discard block  | 
                                                    ||
| 1893 | 1893 |          			foreach ($alldata as $key => $row) { | 
                                                        
| 1894 | 1894 | $count[$key] = $row['airport_arrival_icao_count'];  | 
                                                        
| 1895 | 1895 | }  | 
                                                        
| 1896 | - array_multisort($count,SORT_DESC,$alldata);  | 
                                                        |
| 1896 | + array_multisort($count, SORT_DESC, $alldata);  | 
                                                        |
| 1897 | 1897 |  				foreach ($alldata as $number) { | 
                                                        
| 1898 | - 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);  | 
                                                        |
| 1898 | + 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);  | 
                                                        |
| 1899 | 1899 | }  | 
                                                        
| 1900 | 1900 | $Spotter = new Spotter($this->db);  | 
                                                        
| 1901 | 1901 | $alldata = $Spotter->countAllMonths($filter);  | 
                                                        
| 1902 | 1902 | $lastyear = false;  | 
                                                        
| 1903 | 1903 |  				foreach ($alldata as $number) { | 
                                                        
| 1904 | 1904 |  					if ($number['year_name'] != date('Y')) $lastyear = true; | 
                                                        
| 1905 | -					$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); | 
                                                        |
| 1905 | +					$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); | 
                                                        |
| 1906 | 1906 | }  | 
                                                        
| 1907 | 1907 | $alldata = $Spotter->countAllMonthsOwners($filter);  | 
                                                        
| 1908 | 1908 |  				foreach ($alldata as $number) { | 
                                                        
| 1909 | -					$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); | 
                                                        |
| 1909 | +					$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); | 
                                                        |
| 1910 | 1910 | }  | 
                                                        
| 1911 | 1911 | $alldata = $Spotter->countAllMonthsPilots($filter);  | 
                                                        
| 1912 | 1912 |  				foreach ($alldata as $number) { | 
                                                        
| 1913 | -					$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); | 
                                                        |
| 1913 | +					$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); | 
                                                        |
| 1914 | 1914 | }  | 
                                                        
| 1915 | 1915 | $alldata = $Spotter->countAllMonthsAircrafts($filter);  | 
                                                        
| 1916 | 1916 |  				foreach ($alldata as $number) { | 
                                                        
| 1917 | -					$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); | 
                                                        |
| 1917 | +					$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); | 
                                                        |
| 1918 | 1918 | }  | 
                                                        
| 1919 | 1919 | $alldata = $Spotter->countAllMonthsRealArrivals($filter);  | 
                                                        
| 1920 | 1920 |  				foreach ($alldata as $number) { | 
                                                        
| 1921 | -					$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); | 
                                                        |
| 1921 | +					$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); | 
                                                        |
| 1922 | 1922 | }  | 
                                                        
| 1923 | 1923 | echo '...Departure'."\n";  | 
                                                        
| 1924 | -				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); | 
                                                        |
| 1925 | -        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); | 
                                                        |
| 1924 | +				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); | 
                                                        |
| 1925 | +        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); | 
                                                        |
| 1926 | 1926 |  				foreach ($dall as $value) { | 
                                                        
| 1927 | 1927 | $icao = $value['departure_airport_icao'];  | 
                                                        
| 1928 | 1928 | $ddate = $value['date'];  | 
                                                        
@@ -1940,11 +1940,11 @@ discard block  | 
                                                    ||
| 1940 | 1940 | }  | 
                                                        
| 1941 | 1941 | $alldata = $pall;  | 
                                                        
| 1942 | 1942 |  				foreach ($alldata as $number) { | 
                                                        
| 1943 | - $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);  | 
                                                        |
| 1943 | + $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);  | 
                                                        |
| 1944 | 1944 | }  | 
                                                        
| 1945 | 1945 | echo '...Arrival'."\n";  | 
                                                        
| 1946 | -				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter); | 
                                                        |
| 1947 | -    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); | 
                                                        |
| 1946 | +				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter); | 
                                                        |
| 1947 | +    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); | 
                                                        |
| 1948 | 1948 |  				foreach ($dall as $value) { | 
                                                        
| 1949 | 1949 | $icao = $value['arrival_airport_icao'];  | 
                                                        
| 1950 | 1950 | $ddate = $value['date'];  | 
                                                        
@@ -1962,36 +1962,36 @@ discard block  | 
                                                    ||
| 1962 | 1962 | }  | 
                                                        
| 1963 | 1963 | $alldata = $pall;  | 
                                                        
| 1964 | 1964 |  				foreach ($alldata as $number) { | 
                                                        
| 1965 | - $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);  | 
                                                        |
| 1965 | + $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);  | 
                                                        |
| 1966 | 1966 | }  | 
                                                        
| 1967 | 1967 | |
| 1968 | 1968 | echo 'Flights data...'."\n";  | 
                                                        
| 1969 | 1969 | echo '-> countAllDatesLastMonth...'."\n";  | 
                                                        
| 1970 | 1970 | $alldata = $Spotter->countAllDatesLastMonth($filter);  | 
                                                        
| 1971 | 1971 |  				foreach ($alldata as $number) { | 
                                                        
| 1972 | -					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); | 
                                                        |
| 1972 | +					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); | 
                                                        |
| 1973 | 1973 | }  | 
                                                        
| 1974 | 1974 | echo '-> countAllDates...'."\n";  | 
                                                        
| 1975 | -				$previousdata = $this->countAllDates('',$filter_name); | 
                                                        |
| 1976 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));  | 
                                                        |
| 1975 | +				$previousdata = $this->countAllDates('', $filter_name); | 
                                                        |
| 1976 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));  | 
                                                        |
| 1977 | 1977 | $values = array();  | 
                                                        
| 1978 | 1978 |  				foreach ($alldata as $cnt) { | 
                                                        
| 1979 | 1979 | $values[] = $cnt['date_count'];  | 
                                                        
| 1980 | 1980 | }  | 
                                                        
| 1981 | - array_multisort($values,SORT_DESC,$alldata);  | 
                                                        |
| 1982 | - array_splice($alldata,11);  | 
                                                        |
| 1981 | + array_multisort($values, SORT_DESC, $alldata);  | 
                                                        |
| 1982 | + array_splice($alldata, 11);  | 
                                                        |
| 1983 | 1983 |  				foreach ($alldata as $number) { | 
                                                        
| 1984 | -					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); | 
                                                        |
| 1984 | +					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); | 
                                                        |
| 1985 | 1985 | }  | 
                                                        
| 1986 | 1986 | |
| 1987 | 1987 | echo '-> countAllHours...'."\n";  | 
                                                        
| 1988 | -				$alldata = $Spotter->countAllHours('hour',$filter); | 
                                                        |
| 1988 | +				$alldata = $Spotter->countAllHours('hour', $filter); | 
                                                        |
| 1989 | 1989 |  				foreach ($alldata as $number) { | 
                                                        
| 1990 | -					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); | 
                                                        |
| 1990 | +					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); | 
                                                        |
| 1991 | 1991 | }  | 
                                                        
| 1992 | 1992 | echo 'Insert last stats update date...'."\n";  | 
                                                        
| 1993 | 1993 |  				date_default_timezone_set('UTC'); | 
                                                        
| 1994 | -				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s')); | 
                                                        |
| 1994 | +				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s')); | 
                                                        |
| 1995 | 1995 | }  | 
                                                        
| 1996 | 1996 | |
| 1997 | 1997 | |
@@ -2001,16 +2001,16 @@ discard block  | 
                                                    ||
| 2001 | 2001 | // SUM all previous month to put as year  | 
                                                        
| 2002 | 2002 |  				$previous_year = date('Y'); | 
                                                        
| 2003 | 2003 | $previous_year--;  | 
                                                        
| 2004 | -				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); | 
                                                        |
| 2005 | -				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); | 
                                                        |
| 2006 | -				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); | 
                                                        |
| 2007 | -				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); | 
                                                        |
| 2004 | +				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); | 
                                                        |
| 2005 | +				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); | 
                                                        |
| 2006 | +				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); | 
                                                        |
| 2007 | +				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); | 
                                                        |
| 2008 | 2008 | $allairlines = $this->getAllAirlineNames();  | 
                                                        
| 2009 | 2009 |  				foreach ($allairlines as $data) { | 
                                                        
| 2010 | -					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); | 
                                                        |
| 2011 | -					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); | 
                                                        |
| 2012 | -					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); | 
                                                        |
| 2013 | -					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); | 
                                                        |
| 2010 | +					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); | 
                                                        |
| 2011 | +					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); | 
                                                        |
| 2012 | +					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); | 
                                                        |
| 2013 | +					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); | 
                                                        |
| 2014 | 2014 | }  | 
                                                        
| 2015 | 2015 | |
| 2016 | 2016 |  				if (isset($globalArchiveYear) && $globalArchiveYear) { | 
                                                        
@@ -2019,7 +2019,7 @@ discard block  | 
                                                    ||
| 2019 | 2019 |  						try { | 
                                                        
| 2020 | 2020 | $sth = $this->db->prepare($query);  | 
                                                        
| 2021 | 2021 | $sth->execute();  | 
                                                        
| 2022 | -						} catch(PDOException $e) { | 
                                                        |
| 2022 | +						} catch (PDOException $e) { | 
                                                        |
| 2023 | 2023 | return "error : ".$e->getMessage().' - query : '.$query."\n";  | 
                                                        
| 2024 | 2024 | }  | 
                                                        
| 2025 | 2025 | }  | 
                                                        
@@ -2028,7 +2028,7 @@ discard block  | 
                                                    ||
| 2028 | 2028 |  					try { | 
                                                        
| 2029 | 2029 | $sth = $this->db->prepare($query);  | 
                                                        
| 2030 | 2030 | $sth->execute();  | 
                                                        
| 2031 | -					} catch(PDOException $e) { | 
                                                        |
| 2031 | +					} catch (PDOException $e) { | 
                                                        |
| 2032 | 2032 | return "error : ".$e->getMessage().' - query : '.$query."\n";  | 
                                                        
| 2033 | 2033 | }  | 
                                                        
| 2034 | 2034 | }  | 
                                                        
@@ -2050,7 +2050,7 @@ discard block  | 
                                                    ||
| 2050 | 2050 |  					try { | 
                                                        
| 2051 | 2051 | $sth = $this->db->prepare($query);  | 
                                                        
| 2052 | 2052 | $sth->execute();  | 
                                                        
| 2053 | -					} catch(PDOException $e) { | 
                                                        |
| 2053 | +					} catch (PDOException $e) { | 
                                                        |
| 2054 | 2054 | return "error : ".$e->getMessage();  | 
                                                        
| 2055 | 2055 | }  | 
                                                        
| 2056 | 2056 | }  | 
                                                        
@@ -2064,13 +2064,13 @@ discard block  | 
                                                    ||
| 2064 | 2064 |  				try { | 
                                                        
| 2065 | 2065 | $sth = $this->db->prepare($query);  | 
                                                        
| 2066 | 2066 | $sth->execute();  | 
                                                        
| 2067 | -				} catch(PDOException $e) { | 
                                                        |
| 2067 | +				} catch (PDOException $e) { | 
                                                        |
| 2068 | 2068 | return "error : ".$e->getMessage();  | 
                                                        
| 2069 | 2069 | }  | 
                                                        
| 2070 | 2070 | }  | 
                                                        
| 2071 | 2071 | echo 'Insert last stats update date...'."\n";  | 
                                                        
| 2072 | 2072 |  			date_default_timezone_set('UTC'); | 
                                                        
| 2073 | -			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); | 
                                                        |
| 2073 | +			$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); | 
                                                        |
| 2074 | 2074 | //}  | 
                                                        
| 2075 | 2075 | }  | 
                                                        
| 2076 | 2076 | }  | 
                                                        
@@ -12,7 +12,9 @@ discard block  | 
                                                    ||
| 12 | 12 | |
| 13 | 13 |  	public function __construct($dbc = null) { | 
                                                        
| 14 | 14 | global $globalFilterName;  | 
                                                        
| 15 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName;  | 
                                                        |
| 15 | +		if (isset($globalFilterName)) { | 
                                                        |
| 16 | + $this->filter_name = $globalFilterName;  | 
                                                        |
| 17 | + }  | 
                                                        |
| 16 | 18 | $Connection = new Connection($dbc);  | 
                                                        
| 17 | 19 | $this->db = $Connection->db();  | 
                                                        
| 18 | 20 | }  | 
                                                        
@@ -59,7 +61,9 @@ discard block  | 
                                                    ||
| 59 | 61 | }  | 
                                                        
| 60 | 62 | }  | 
                                                        
| 61 | 63 |  	public function getAllAirlineNames($filter_name = '') { | 
                                                        
| 62 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 64 | +		if ($filter_name == '') { | 
                                                        |
| 65 | + $filter_name = $this->filter_name;  | 
                                                        |
| 66 | + }  | 
                                                        |
| 63 | 67 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";  | 
                                                        
| 64 | 68 |                   try { | 
                                                        
| 65 | 69 | $sth = $this->db->prepare($query);  | 
                                                        
@@ -71,7 +75,9 @@ discard block  | 
                                                    ||
| 71 | 75 | return $all;  | 
                                                        
| 72 | 76 | }  | 
                                                        
| 73 | 77 |  	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { | 
                                                        
| 74 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 78 | +		if ($filter_name == '') { | 
                                                        |
| 79 | + $filter_name = $this->filter_name;  | 
                                                        |
| 80 | + }  | 
                                                        |
| 75 | 81 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";  | 
                                                        
| 76 | 82 |                   try { | 
                                                        
| 77 | 83 | $sth = $this->db->prepare($query);  | 
                                                        
@@ -83,7 +89,9 @@ discard block  | 
                                                    ||
| 83 | 89 | return $all;  | 
                                                        
| 84 | 90 | }  | 
                                                        
| 85 | 91 |  	public function getAllManufacturers($stats_airline = '',$filter_name = '') { | 
                                                        
| 86 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 92 | +		if ($filter_name == '') { | 
                                                        |
| 93 | + $filter_name = $this->filter_name;  | 
                                                        |
| 94 | + }  | 
                                                        |
| 87 | 95 | $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";  | 
                                                        
| 88 | 96 |                   try { | 
                                                        
| 89 | 97 | $sth = $this->db->prepare($query);  | 
                                                        
@@ -95,7 +103,9 @@ discard block  | 
                                                    ||
| 95 | 103 | return $all;  | 
                                                        
| 96 | 104 | }  | 
                                                        
| 97 | 105 |  	public function getAllAirportNames($stats_airline = '',$filter_name = '') { | 
                                                        
| 98 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 106 | +		if ($filter_name == '') { | 
                                                        |
| 107 | + $filter_name = $this->filter_name;  | 
                                                        |
| 108 | + }  | 
                                                        |
| 99 | 109 | $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";  | 
                                                        
| 100 | 110 |                   try { | 
                                                        
| 101 | 111 | $sth = $this->db->prepare($query);  | 
                                                        
@@ -110,9 +120,14 @@ discard block  | 
                                                    ||
| 110 | 120 | |
| 111 | 121 |  	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        
| 112 | 122 | global $globalStatsFilters;  | 
                                                        
| 113 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 114 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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 LIMIT 10 OFFSET 0";  | 
                                                        |
| 115 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";  | 
                                                        |
| 123 | +		if ($filter_name == '') { | 
                                                        |
| 124 | + $filter_name = $this->filter_name;  | 
                                                        |
| 125 | + }  | 
                                                        |
| 126 | +		if ($limit) { | 
                                                        |
| 127 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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 LIMIT 10 OFFSET 0";  | 
                                                        |
| 128 | +		} else { | 
                                                        |
| 129 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";  | 
                                                        |
| 130 | + }  | 
                                                        |
| 116 | 131 |                   try { | 
                                                        
| 117 | 132 | $sth = $this->db->prepare($query);  | 
                                                        
| 118 | 133 |                          $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        
@@ -132,9 +147,14 @@ discard block  | 
                                                    ||
| 132 | 147 | }  | 
                                                        
| 133 | 148 |  	public function countAllAirlineCountries($limit = true,$filter_name = '') { | 
                                                        
| 134 | 149 | global $globalStatsFilters;  | 
                                                        
| 135 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 136 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 137 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";  | 
                                                        |
| 150 | +		if ($filter_name == '') { | 
                                                        |
| 151 | + $filter_name = $this->filter_name;  | 
                                                        |
| 152 | + }  | 
                                                        |
| 153 | +		if ($limit) { | 
                                                        |
| 154 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 155 | +		} else { | 
                                                        |
| 156 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";  | 
                                                        |
| 157 | + }  | 
                                                        |
| 138 | 158 |                   try { | 
                                                        
| 139 | 159 | $sth = $this->db->prepare($query);  | 
                                                        
| 140 | 160 |                          $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        
@@ -154,9 +174,14 @@ discard block  | 
                                                    ||
| 154 | 174 | }  | 
                                                        
| 155 | 175 |  	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { | 
                                                        
| 156 | 176 | global $globalStatsFilters;  | 
                                                        
| 157 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 158 | - if ($limit) $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 LIMIT 10 OFFSET 0";  | 
                                                        |
| 159 | - 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";  | 
                                                        |
| 177 | +		if ($filter_name == '') { | 
                                                        |
| 178 | + $filter_name = $this->filter_name;  | 
                                                        |
| 179 | + }  | 
                                                        |
| 180 | +		if ($limit) { | 
                                                        |
| 181 | + $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 LIMIT 10 OFFSET 0";  | 
                                                        |
| 182 | +		} else { | 
                                                        |
| 183 | + $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";  | 
                                                        |
| 184 | + }  | 
                                                        |
| 160 | 185 |                   try { | 
                                                        
| 161 | 186 | $sth = $this->db->prepare($query);  | 
                                                        
| 162 | 187 |                          $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        
@@ -177,9 +202,14 @@ discard block  | 
                                                    ||
| 177 | 202 | |
| 178 | 203 |  	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        
| 179 | 204 | global $globalStatsFilters;  | 
                                                        
| 180 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 181 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 182 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";  | 
                                                        |
| 205 | +		if ($filter_name == '') { | 
                                                        |
| 206 | + $filter_name = $this->filter_name;  | 
                                                        |
| 207 | + }  | 
                                                        |
| 208 | +		if ($limit) { | 
                                                        |
| 209 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 210 | +		} else { | 
                                                        |
| 211 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";  | 
                                                        |
| 212 | + }  | 
                                                        |
| 183 | 213 |                   try { | 
                                                        
| 184 | 214 | $sth = $this->db->prepare($query);  | 
                                                        
| 185 | 215 |                          $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        
@@ -199,9 +229,14 @@ discard block  | 
                                                    ||
| 199 | 229 | }  | 
                                                        
| 200 | 230 |  	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { | 
                                                        
| 201 | 231 | global $globalStatsFilters;  | 
                                                        
| 202 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 203 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 204 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";  | 
                                                        |
| 232 | +		if ($filter_name == '') { | 
                                                        |
| 233 | + $filter_name = $this->filter_name;  | 
                                                        |
| 234 | + }  | 
                                                        |
| 235 | +		if ($limit) { | 
                                                        |
| 236 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 237 | +		} else { | 
                                                        |
| 238 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";  | 
                                                        |
| 239 | + }  | 
                                                        |
| 205 | 240 |                   try { | 
                                                        
| 206 | 241 | $sth = $this->db->prepare($query);  | 
                                                        
| 207 | 242 |                          $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        
@@ -222,9 +257,14 @@ discard block  | 
                                                    ||
| 222 | 257 | |
| 223 | 258 |  	public function countAllAirlines($limit = true,$filter_name = '') { | 
                                                        
| 224 | 259 | global $globalStatsFilters;  | 
                                                        
| 225 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 226 | - 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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 227 | - 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 ORDER BY airline_count DESC";  | 
                                                        |
| 260 | +		if ($filter_name == '') { | 
                                                        |
| 261 | + $filter_name = $this->filter_name;  | 
                                                        |
| 262 | + }  | 
                                                        |
| 263 | +		if ($limit) { | 
                                                        |
| 264 | + $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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 265 | +		} else { | 
                                                        |
| 266 | + $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 ORDER BY airline_count DESC";  | 
                                                        |
| 267 | + }  | 
                                                        |
| 228 | 268 |                   try { | 
                                                        
| 229 | 269 | $sth = $this->db->prepare($query);  | 
                                                        
| 230 | 270 |                          $sth->execute(array(':filter_name' => $filter_name)); | 
                                                        
@@ -245,9 +285,14 @@ discard block  | 
                                                    ||
| 245 | 285 | }  | 
                                                        
| 246 | 286 |  	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 247 | 287 | global $globalStatsFilters;  | 
                                                        
| 248 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 249 | - 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 = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 250 | - 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";  | 
                                                        |
| 288 | +		if ($filter_name == '') { | 
                                                        |
| 289 | + $filter_name = $this->filter_name;  | 
                                                        |
| 290 | + }  | 
                                                        |
| 291 | +		if ($limit) { | 
                                                        |
| 292 | + $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 = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 293 | +		} else { | 
                                                        |
| 294 | + $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";  | 
                                                        |
| 295 | + }  | 
                                                        |
| 251 | 296 |                   try { | 
                                                        
| 252 | 297 | $sth = $this->db->prepare($query);  | 
                                                        
| 253 | 298 |                          $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        
@@ -267,9 +312,14 @@ discard block  | 
                                                    ||
| 267 | 312 | }  | 
                                                        
| 268 | 313 |  	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 269 | 314 | global $globalStatsFilters;  | 
                                                        
| 270 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 271 | - 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 = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 272 | - 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";  | 
                                                        |
| 315 | +		if ($filter_name == '') { | 
                                                        |
| 316 | + $filter_name = $this->filter_name;  | 
                                                        |
| 317 | + }  | 
                                                        |
| 318 | +		if ($limit) { | 
                                                        |
| 319 | + $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 LIMIT 10 OFFSET 0";  | 
                                                        |
| 320 | +		} else { | 
                                                        |
| 321 | + $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";  | 
                                                        |
| 322 | + }  | 
                                                        |
| 273 | 323 |  		 try { | 
                                                        
| 274 | 324 | $sth = $this->db->prepare($query);  | 
                                                        
| 275 | 325 |  			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        
@@ -289,10 +339,15 @@ discard block  | 
                                                    ||
| 289 | 339 | }  | 
                                                        
| 290 | 340 |  	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { | 
                                                        
| 291 | 341 | $Connection = new Connection();  | 
                                                        
| 292 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 342 | +		if ($filter_name == '') { | 
                                                        |
| 343 | + $filter_name = $this->filter_name;  | 
                                                        |
| 344 | + }  | 
                                                        |
| 293 | 345 |  		if ($Connection->tableExists('countries')) { | 
                                                        
| 294 | - 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 = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";  | 
                                                        |
| 295 | - 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";  | 
                                                        |
| 346 | +			if ($limit) { | 
                                                        |
| 347 | + $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 LIMIT 20 OFFSET 0";  | 
                                                        |
| 348 | +			} else { | 
                                                        |
| 349 | + $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";  | 
                                                        |
| 350 | + }  | 
                                                        |
| 296 | 351 |  			 try { | 
                                                        
| 297 | 352 | $sth = $this->db->prepare($query);  | 
                                                        
| 298 | 353 |  				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        
@@ -313,9 +368,14 @@ discard block  | 
                                                    ||
| 313 | 368 | }  | 
                                                        
| 314 | 369 |  	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 315 | 370 | global $globalStatsFilters;  | 
                                                        
| 316 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 317 | - if ($limit) $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 LIMIT 10 OFFSET 0";  | 
                                                        |
| 318 | - 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";  | 
                                                        |
| 371 | +		if ($filter_name == '') { | 
                                                        |
| 372 | + $filter_name = $this->filter_name;  | 
                                                        |
| 373 | + }  | 
                                                        |
| 374 | +		if ($limit) { | 
                                                        |
| 375 | + $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 LIMIT 10 OFFSET 0";  | 
                                                        |
| 376 | +		} else { | 
                                                        |
| 377 | + $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";  | 
                                                        |
| 378 | + }  | 
                                                        |
| 319 | 379 |                   try { | 
                                                        
| 320 | 380 | $sth = $this->db->prepare($query);  | 
                                                        
| 321 | 381 |                          $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        
@@ -335,9 +395,14 @@ discard block  | 
                                                    ||
| 335 | 395 | }  | 
                                                        
| 336 | 396 |  	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { | 
                                                        
| 337 | 397 | global $globalStatsFilters;  | 
                                                        
| 338 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 339 | - if ($limit) $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 LIMIT 10 OFFSET 0";  | 
                                                        |
| 340 | - 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";  | 
                                                        |
| 398 | +		if ($filter_name == '') { | 
                                                        |
| 399 | + $filter_name = $this->filter_name;  | 
                                                        |
| 400 | + }  | 
                                                        |
| 401 | +		if ($limit) { | 
                                                        |
| 402 | + $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 LIMIT 10 OFFSET 0";  | 
                                                        |
| 403 | +		} else { | 
                                                        |
| 404 | + $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";  | 
                                                        |
| 405 | + }  | 
                                                        |
| 341 | 406 |                   try { | 
                                                        
| 342 | 407 | $sth = $this->db->prepare($query);  | 
                                                        
| 343 | 408 |                          $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        
@@ -357,9 +422,14 @@ discard block  | 
                                                    ||
| 357 | 422 | }  | 
                                                        
| 358 | 423 |  	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 359 | 424 | global $globalStatsFilters;  | 
                                                        
| 360 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 361 | - 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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 362 | - 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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";  | 
                                                        |
| 425 | +		if ($filter_name == '') { | 
                                                        |
| 426 | + $filter_name = $this->filter_name;  | 
                                                        |
| 427 | + }  | 
                                                        |
| 428 | +		if ($limit) { | 
                                                        |
| 429 | + $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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 430 | +		} else { | 
                                                        |
| 431 | + $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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";  | 
                                                        |
| 432 | + }  | 
                                                        |
| 363 | 433 |                   try { | 
                                                        
| 364 | 434 | $sth = $this->db->prepare($query);  | 
                                                        
| 365 | 435 |                          $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        
@@ -385,7 +455,9 @@ discard block  | 
                                                    ||
| 385 | 455 | $icao = $value['airport_departure_icao'];  | 
                                                        
| 386 | 456 |          			if (isset($all[$icao])) { | 
                                                        
| 387 | 457 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];  | 
                                                        
| 388 | - } else $all[$icao] = $value;  | 
                                                        |
| 458 | +        			} else { | 
                                                        |
| 459 | + $all[$icao] = $value;  | 
                                                        |
| 460 | + }  | 
                                                        |
| 389 | 461 | }  | 
                                                        
| 390 | 462 | $count = array();  | 
                                                        
| 391 | 463 |          		foreach ($all as $key => $row) { | 
                                                        
@@ -397,9 +469,14 @@ discard block  | 
                                                    ||
| 397 | 469 | }  | 
                                                        
| 398 | 470 |  	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 399 | 471 | global $globalStatsFilters;  | 
                                                        
| 400 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 401 | - 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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 402 | - 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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";  | 
                                                        |
| 472 | +		if ($filter_name == '') { | 
                                                        |
| 473 | + $filter_name = $this->filter_name;  | 
                                                        |
| 474 | + }  | 
                                                        |
| 475 | +		if ($limit) { | 
                                                        |
| 476 | + $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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";  | 
                                                        |
| 477 | +		} else { | 
                                                        |
| 478 | + $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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";  | 
                                                        |
| 479 | + }  | 
                                                        |
| 403 | 480 |  		try { | 
                                                        
| 404 | 481 | $sth = $this->db->prepare($query);  | 
                                                        
| 405 | 482 |  			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); | 
                                                        
@@ -425,7 +502,9 @@ discard block  | 
                                                    ||
| 425 | 502 | $icao = $value['airport_arrival_icao'];  | 
                                                        
| 426 | 503 |          			if (isset($all[$icao])) { | 
                                                        
| 427 | 504 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];  | 
                                                        
| 428 | - } else $all[$icao] = $value;  | 
                                                        |
| 505 | +        			} else { | 
                                                        |
| 506 | + $all[$icao] = $value;  | 
                                                        |
| 507 | + }  | 
                                                        |
| 429 | 508 | }  | 
                                                        
| 430 | 509 | $count = array();  | 
                                                        
| 431 | 510 |          		foreach ($all as $key => $row) { | 
                                                        
@@ -438,13 +517,21 @@ discard block  | 
                                                    ||
| 438 | 517 | }  | 
                                                        
| 439 | 518 |  	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 440 | 519 | global $globalDBdriver, $globalStatsFilters;  | 
                                                        
| 441 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 520 | +		if ($filter_name == '') { | 
                                                        |
| 521 | + $filter_name = $this->filter_name;  | 
                                                        |
| 522 | + }  | 
                                                        |
| 442 | 523 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 443 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        |
| 444 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(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";  | 
                                                        |
| 524 | +			if ($limit) { | 
                                                        |
| 525 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        |
| 526 | +			} else { | 
                                                        |
| 527 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(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";  | 
                                                        |
| 528 | + }  | 
                                                        |
| 445 | 529 |  		} else { | 
                                                        
| 446 | - 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";  | 
                                                        |
| 447 | - 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";  | 
                                                        |
| 530 | +			if ($limit) { | 
                                                        |
| 531 | + $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";  | 
                                                        |
| 532 | +			} else { | 
                                                        |
| 533 | + $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";  | 
                                                        |
| 534 | + }  | 
                                                        |
| 448 | 535 | }  | 
                                                        
| 449 | 536 |  		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        
| 450 | 537 |                   try { | 
                                                        
@@ -468,7 +555,9 @@ discard block  | 
                                                    ||
| 468 | 555 | |
| 469 | 556 |  	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { | 
                                                        
| 470 | 557 | global $globalStatsFilters;  | 
                                                        
| 471 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 558 | +		if ($filter_name == '') { | 
                                                        |
| 559 | + $filter_name = $this->filter_name;  | 
                                                        |
| 560 | + }  | 
                                                        |
| 472 | 561 | $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";  | 
                                                        
| 473 | 562 |  		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        
| 474 | 563 |                   try { | 
                                                        
@@ -490,7 +579,9 @@ discard block  | 
                                                    ||
| 490 | 579 | }  | 
                                                        
| 491 | 580 |  	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { | 
                                                        
| 492 | 581 | global $globalDBdriver, $globalStatsFilters;  | 
                                                        
| 493 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 582 | +		if ($filter_name == '') { | 
                                                        |
| 583 | + $filter_name = $this->filter_name;  | 
                                                        |
| 584 | + }  | 
                                                        |
| 494 | 585 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 495 | 586 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        
| 496 | 587 |  		} else { | 
                                                        
@@ -516,7 +607,9 @@ discard block  | 
                                                    ||
| 516 | 607 | }  | 
                                                        
| 517 | 608 |  	public function countAllDates($stats_airline = '',$filter_name = '') { | 
                                                        
| 518 | 609 | global $globalStatsFilters;  | 
                                                        
| 519 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 610 | +		if ($filter_name == '') { | 
                                                        |
| 611 | + $filter_name = $this->filter_name;  | 
                                                        |
| 612 | + }  | 
                                                        |
| 520 | 613 | $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";  | 
                                                        
| 521 | 614 |  		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        
| 522 | 615 |                   try { | 
                                                        
@@ -538,7 +631,9 @@ discard block  | 
                                                    ||
| 538 | 631 | }  | 
                                                        
| 539 | 632 |  	public function countAllDatesByAirlines($filter_name = '') { | 
                                                        
| 540 | 633 | global $globalStatsFilters;  | 
                                                        
| 541 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 634 | +		if ($filter_name == '') { | 
                                                        |
| 635 | + $filter_name = $this->filter_name;  | 
                                                        |
| 636 | + }  | 
                                                        |
| 542 | 637 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";  | 
                                                        
| 543 | 638 |  		$query_data = array('filter_name' => $filter_name); | 
                                                        
| 544 | 639 |                   try { | 
                                                        
@@ -560,7 +655,9 @@ discard block  | 
                                                    ||
| 560 | 655 | }  | 
                                                        
| 561 | 656 |  	public function countAllMonths($stats_airline = '',$filter_name = '') { | 
                                                        
| 562 | 657 | global $globalStatsFilters;  | 
                                                        
| 563 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 658 | +		if ($filter_name == '') { | 
                                                        |
| 659 | + $filter_name = $this->filter_name;  | 
                                                        |
| 660 | + }  | 
                                                        |
| 564 | 661 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        
| 565 | 662 |                   try { | 
                                                        
| 566 | 663 | $sth = $this->db->prepare($query);  | 
                                                        
@@ -581,7 +678,9 @@ discard block  | 
                                                    ||
| 581 | 678 | }  | 
                                                        
| 582 | 679 |  	public function countAllMilitaryMonths($filter_name = '') { | 
                                                        
| 583 | 680 | global $globalStatsFilters;  | 
                                                        
| 584 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 681 | +		if ($filter_name == '') { | 
                                                        |
| 682 | + $filter_name = $this->filter_name;  | 
                                                        |
| 683 | + }  | 
                                                        |
| 585 | 684 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";  | 
                                                        
| 586 | 685 |                   try { | 
                                                        
| 587 | 686 | $sth = $this->db->prepare($query);  | 
                                                        
@@ -602,9 +701,14 @@ discard block  | 
                                                    ||
| 602 | 701 | }  | 
                                                        
| 603 | 702 |  	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { | 
                                                        
| 604 | 703 | global $globalTimezone, $globalDBdriver, $globalStatsFilters;  | 
                                                        
| 605 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 606 | - 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";  | 
                                                        |
| 607 | - else $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";  | 
                                                        |
| 704 | +		if ($filter_name == '') { | 
                                                        |
| 705 | + $filter_name = $this->filter_name;  | 
                                                        |
| 706 | + }  | 
                                                        |
| 707 | +		if ($limit) { | 
                                                        |
| 708 | + $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";  | 
                                                        |
| 709 | +		} else { | 
                                                        |
| 710 | + $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";  | 
                                                        |
| 711 | + }  | 
                                                        |
| 608 | 712 |  		if ($orderby == 'hour') { | 
                                                        
| 609 | 713 | /*  | 
                                                        
| 610 | 714 |  			if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -613,7 +717,9 @@ discard block  | 
                                                    ||
| 613 | 717 | */  | 
                                                        
| 614 | 718 | $query .= " ORDER BY CAST(flight_date AS integer) ASC";  | 
                                                        
| 615 | 719 | }  | 
                                                        
| 616 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";  | 
                                                        |
| 720 | +		if ($orderby == 'count') { | 
                                                        |
| 721 | + $query .= " ORDER BY hour_count DESC";  | 
                                                        |
| 722 | + }  | 
                                                        |
| 617 | 723 |                   try { | 
                                                        
| 618 | 724 | $sth = $this->db->prepare($query);  | 
                                                        
| 619 | 725 |                          $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); | 
                                                        
@@ -634,7 +740,9 @@ discard block  | 
                                                    ||
| 634 | 740 | |
| 635 | 741 |  	public function countOverallFlights($stats_airline = '', $filter_name = '') { | 
                                                        
| 636 | 742 | global $globalStatsFilters;  | 
                                                        
| 637 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 743 | +		if ($filter_name == '') { | 
                                                        |
| 744 | + $filter_name = $this->filter_name;  | 
                                                        |
| 745 | + }  | 
                                                        |
| 638 | 746 |  		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); | 
                                                        
| 639 | 747 |  		if (empty($all)) { | 
                                                        
| 640 | 748 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
@@ -648,7 +756,9 @@ discard block  | 
                                                    ||
| 648 | 756 | }  | 
                                                        
| 649 | 757 |  	public function countOverallMilitaryFlights($filter_name = '') { | 
                                                        
| 650 | 758 | global $globalStatsFilters;  | 
                                                        
| 651 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 759 | +		if ($filter_name == '') { | 
                                                        |
| 760 | + $filter_name = $this->filter_name;  | 
                                                        |
| 761 | + }  | 
                                                        |
| 652 | 762 |  		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); | 
                                                        
| 653 | 763 |  		if (empty($all)) { | 
                                                        
| 654 | 764 | $filters = array();  | 
                                                        
@@ -662,7 +772,9 @@ discard block  | 
                                                    ||
| 662 | 772 | }  | 
                                                        
| 663 | 773 |  	public function countOverallArrival($stats_airline = '',$filter_name = '') { | 
                                                        
| 664 | 774 | global $globalStatsFilters;  | 
                                                        
| 665 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 775 | +		if ($filter_name == '') { | 
                                                        |
| 776 | + $filter_name = $this->filter_name;  | 
                                                        |
| 777 | + }  | 
                                                        |
| 666 | 778 |  		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); | 
                                                        
| 667 | 779 |  		if (empty($all)) { | 
                                                        
| 668 | 780 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
@@ -676,7 +788,9 @@ discard block  | 
                                                    ||
| 676 | 788 | }  | 
                                                        
| 677 | 789 |  	public function countOverallAircrafts($stats_airline = '',$filter_name = '') { | 
                                                        
| 678 | 790 | global $globalStatsFilters;  | 
                                                        
| 679 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 791 | +		if ($filter_name == '') { | 
                                                        |
| 792 | + $filter_name = $this->filter_name;  | 
                                                        |
| 793 | + }  | 
                                                        |
| 680 | 794 |  		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); | 
                                                        
| 681 | 795 |  		if (empty($all)) { | 
                                                        
| 682 | 796 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
@@ -690,7 +804,9 @@ discard block  | 
                                                    ||
| 690 | 804 | }  | 
                                                        
| 691 | 805 |  	public function countOverallAirlines($filter_name = '') { | 
                                                        
| 692 | 806 | global $globalStatsFilters;  | 
                                                        
| 693 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 807 | +		if ($filter_name == '') { | 
                                                        |
| 808 | + $filter_name = $this->filter_name;  | 
                                                        |
| 809 | + }  | 
                                                        |
| 694 | 810 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";  | 
                                                        
| 695 | 811 |                   try { | 
                                                        
| 696 | 812 | $sth = $this->db->prepare($query);  | 
                                                        
@@ -713,7 +829,9 @@ discard block  | 
                                                    ||
| 713 | 829 | }  | 
                                                        
| 714 | 830 |  	public function countOverallOwners($stats_airline = '',$filter_name = '') { | 
                                                        
| 715 | 831 | global $globalStatsFilters;  | 
                                                        
| 716 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 832 | +		if ($filter_name == '') { | 
                                                        |
| 833 | + $filter_name = $this->filter_name;  | 
                                                        |
| 834 | + }  | 
                                                        |
| 717 | 835 | /*  | 
                                                        
| 718 | 836 | $query = "SELECT COUNT(*) AS nb_owner FROM stats_owner";  | 
                                                        
| 719 | 837 |                   try { | 
                                                        
@@ -738,7 +856,9 @@ discard block  | 
                                                    ||
| 738 | 856 | }  | 
                                                        
| 739 | 857 |  	public function countOverallPilots($stats_airline = '',$filter_name = '') { | 
                                                        
| 740 | 858 | global $globalStatsFilters;  | 
                                                        
| 741 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 859 | +		if ($filter_name == '') { | 
                                                        |
| 860 | + $filter_name = $this->filter_name;  | 
                                                        |
| 861 | + }  | 
                                                        |
| 742 | 862 |  		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); | 
                                                        
| 743 | 863 |  		if (empty($all)) { | 
                                                        
| 744 | 864 |  			$filters = array('airlines' => array($stats_airline)); | 
                                                        
@@ -752,7 +872,9 @@ discard block  | 
                                                    ||
| 752 | 872 | }  | 
                                                        
| 753 | 873 | |
| 754 | 874 |  	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { | 
                                                        
| 755 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 875 | +		if ($filter_name == '') { | 
                                                        |
| 876 | + $filter_name = $this->filter_name;  | 
                                                        |
| 877 | + }  | 
                                                        |
| 756 | 878 | $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";  | 
                                                        
| 757 | 879 |  		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); | 
                                                        
| 758 | 880 |                   try { | 
                                                        
@@ -765,7 +887,9 @@ discard block  | 
                                                    ||
| 765 | 887 | return $all;  | 
                                                        
| 766 | 888 | }  | 
                                                        
| 767 | 889 |  	public function getStats($type,$stats_airline = '', $filter_name = '') { | 
                                                        
| 768 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 890 | +		if ($filter_name == '') { | 
                                                        |
| 891 | + $filter_name = $this->filter_name;  | 
                                                        |
| 892 | + }  | 
                                                        |
| 769 | 893 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";  | 
                                                        
| 770 | 894 |                  $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); | 
                                                        
| 771 | 895 |                   try { | 
                                                        
@@ -778,7 +902,9 @@ discard block  | 
                                                    ||
| 778 | 902 | return $all;  | 
                                                        
| 779 | 903 | }  | 
                                                        
| 780 | 904 |  	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { | 
                                                        
| 781 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 905 | +		if ($filter_name == '') { | 
                                                        |
| 906 | + $filter_name = $this->filter_name;  | 
                                                        |
| 907 | + }  | 
                                                        |
| 782 | 908 | global $globalArchiveMonths, $globalDBdriver;  | 
                                                        
| 783 | 909 |      		if ($globalDBdriver == 'mysql') { | 
                                                        
| 784 | 910 | $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";  | 
                                                        
@@ -797,7 +923,9 @@ discard block  | 
                                                    ||
| 797 | 923 | }  | 
                                                        
| 798 | 924 |  	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { | 
                                                        
| 799 | 925 | global $globalArchiveMonths, $globalDBdriver;  | 
                                                        
| 800 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 926 | +		if ($filter_name == '') { | 
                                                        |
| 927 | + $filter_name = $this->filter_name;  | 
                                                        |
| 928 | + }  | 
                                                        |
| 801 | 929 |      		if ($globalDBdriver == 'mysql') { | 
                                                        
| 802 | 930 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        
| 803 | 931 |  		} else { | 
                                                        
@@ -815,7 +943,9 @@ discard block  | 
                                                    ||
| 815 | 943 | }  | 
                                                        
| 816 | 944 |  	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { | 
                                                        
| 817 | 945 | global $globalArchiveMonths, $globalDBdriver;  | 
                                                        
| 818 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 946 | +		if ($filter_name == '') { | 
                                                        |
| 947 | + $filter_name = $this->filter_name;  | 
                                                        |
| 948 | + }  | 
                                                        |
| 819 | 949 |      		if ($globalDBdriver == 'mysql') { | 
                                                        
| 820 | 950 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";  | 
                                                        
| 821 | 951 |                  } else { | 
                                                        
@@ -832,7 +962,9 @@ discard block  | 
                                                    ||
| 832 | 962 | }  | 
                                                        
| 833 | 963 |  	public function getStatsAirlineTotal($filter_name = '') { | 
                                                        
| 834 | 964 | global $globalArchiveMonths, $globalDBdriver;  | 
                                                        
| 835 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 965 | +		if ($filter_name == '') { | 
                                                        |
| 966 | + $filter_name = $this->filter_name;  | 
                                                        |
| 967 | + }  | 
                                                        |
| 836 | 968 |      		if ($globalDBdriver == 'mysql') { | 
                                                        
| 837 | 969 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";  | 
                                                        
| 838 | 970 |                  } else { | 
                                                        
@@ -849,7 +981,9 @@ discard block  | 
                                                    ||
| 849 | 981 | }  | 
                                                        
| 850 | 982 |  	public function getStatsOwnerTotal($filter_name = '') { | 
                                                        
| 851 | 983 | global $globalArchiveMonths, $globalDBdriver;  | 
                                                        
| 852 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 984 | +		if ($filter_name == '') { | 
                                                        |
| 985 | + $filter_name = $this->filter_name;  | 
                                                        |
| 986 | + }  | 
                                                        |
| 853 | 987 |      		if ($globalDBdriver == 'mysql') { | 
                                                        
| 854 | 988 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";  | 
                                                        
| 855 | 989 |  		} else { | 
                                                        
@@ -866,7 +1000,9 @@ discard block  | 
                                                    ||
| 866 | 1000 | }  | 
                                                        
| 867 | 1001 |  	public function getStatsPilotTotal($filter_name = '') { | 
                                                        
| 868 | 1002 | global $globalArchiveMonths, $globalDBdriver;  | 
                                                        
| 869 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 1003 | +		if ($filter_name == '') { | 
                                                        |
| 1004 | + $filter_name = $this->filter_name;  | 
                                                        |
| 1005 | + }  | 
                                                        |
| 870 | 1006 |      		if ($globalDBdriver == 'mysql') { | 
                                                        
| 871 | 1007 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";  | 
                                                        
| 872 | 1008 |              	} else { | 
                                                        
@@ -884,7 +1020,9 @@ discard block  | 
                                                    ||
| 884 | 1020 | |
| 885 | 1021 |  	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { | 
                                                        
| 886 | 1022 | global $globalDBdriver;  | 
                                                        
| 887 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 1023 | +		if ($filter_name == '') { | 
                                                        |
| 1024 | + $filter_name = $this->filter_name;  | 
                                                        |
| 1025 | + }  | 
                                                        |
| 888 | 1026 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 889 | 1027 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";  | 
                                                        
| 890 | 1028 |                  } else { | 
                                                        
@@ -900,7 +1038,9 @@ discard block  | 
                                                    ||
| 900 | 1038 | }  | 
                                                        
| 901 | 1039 |  	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { | 
                                                        
| 902 | 1040 | global $globalDBdriver;  | 
                                                        
| 903 | - if ($filter_name == '') $filter_name = $this->filter_name;  | 
                                                        |
| 1041 | +		if ($filter_name == '') { | 
                                                        |
| 1042 | + $filter_name = $this->filter_name;  | 
                                                        |
| 1043 | + }  | 
                                                        |
| 904 | 1044 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 905 | 1045 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";  | 
                                                        
| 906 | 1046 |  		} else { | 
                                                        
@@ -1383,47 +1523,69 @@ discard block  | 
                                                    ||
| 1383 | 1523 |  			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); | 
                                                        
| 1384 | 1524 |  		} else { | 
                                                        
| 1385 | 1525 | */  | 
                                                        
| 1386 | - if ($globalDebug) echo 'Update stats !'."\n";  | 
                                                        |
| 1387 | - if ($globalDebug) echo 'Count all aircraft types...'."\n";  | 
                                                        |
| 1526 | +			if ($globalDebug) { | 
                                                        |
| 1527 | + echo 'Update stats !'."\n";  | 
                                                        |
| 1528 | + }  | 
                                                        |
| 1529 | +			if ($globalDebug) { | 
                                                        |
| 1530 | + echo 'Count all aircraft types...'."\n";  | 
                                                        |
| 1531 | + }  | 
                                                        |
| 1388 | 1532 |  			if (isset($last_update[0]['value'])) { | 
                                                        
| 1389 | 1533 | $last_update_day = $last_update[0]['value'];  | 
                                                        
| 1390 | - } else $last_update_day = '2012-12-12 12:12:12';  | 
                                                        |
| 1534 | +			} else { | 
                                                        |
| 1535 | + $last_update_day = '2012-12-12 12:12:12';  | 
                                                        |
| 1536 | + }  | 
                                                        |
| 1391 | 1537 | $Spotter = new Spotter($this->db);  | 
                                                        
| 1392 | 1538 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);  | 
                                                        
| 1393 | 1539 |  			foreach ($alldata as $number) { | 
                                                        
| 1394 | 1540 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']);  | 
                                                        
| 1395 | 1541 | }  | 
                                                        
| 1396 | - if ($globalDebug) echo 'Count all airlines...'."\n";  | 
                                                        |
| 1542 | +			if ($globalDebug) { | 
                                                        |
| 1543 | + echo 'Count all airlines...'."\n";  | 
                                                        |
| 1544 | + }  | 
                                                        |
| 1397 | 1545 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day);  | 
                                                        
| 1398 | 1546 |  			foreach ($alldata as $number) { | 
                                                        
| 1399 | 1547 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);  | 
                                                        
| 1400 | 1548 | }  | 
                                                        
| 1401 | - if ($globalDebug) echo 'Count all registrations...'."\n";  | 
                                                        |
| 1549 | +			if ($globalDebug) { | 
                                                        |
| 1550 | + echo 'Count all registrations...'."\n";  | 
                                                        |
| 1551 | + }  | 
                                                        |
| 1402 | 1552 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);  | 
                                                        
| 1403 | 1553 |  			foreach ($alldata as $number) { | 
                                                        
| 1404 | 1554 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);  | 
                                                        
| 1405 | 1555 | }  | 
                                                        
| 1406 | - if ($globalDebug) echo 'Count all callsigns...'."\n";  | 
                                                        |
| 1556 | +			if ($globalDebug) { | 
                                                        |
| 1557 | + echo 'Count all callsigns...'."\n";  | 
                                                        |
| 1558 | + }  | 
                                                        |
| 1407 | 1559 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);  | 
                                                        
| 1408 | 1560 |  			foreach ($alldata as $number) { | 
                                                        
| 1409 | 1561 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);  | 
                                                        
| 1410 | 1562 | }  | 
                                                        
| 1411 | - if ($globalDebug) echo 'Count all owners...'."\n";  | 
                                                        |
| 1563 | +			if ($globalDebug) { | 
                                                        |
| 1564 | + echo 'Count all owners...'."\n";  | 
                                                        |
| 1565 | + }  | 
                                                        |
| 1412 | 1566 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day);  | 
                                                        
| 1413 | 1567 |  			foreach ($alldata as $number) { | 
                                                        
| 1414 | 1568 | $this->addStatOwner($number['owner_name'],$number['owner_count']);  | 
                                                        
| 1415 | 1569 | }  | 
                                                        
| 1416 | - if ($globalDebug) echo 'Count all pilots...'."\n";  | 
                                                        |
| 1570 | +			if ($globalDebug) { | 
                                                        |
| 1571 | + echo 'Count all pilots...'."\n";  | 
                                                        |
| 1572 | + }  | 
                                                        |
| 1417 | 1573 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day);  | 
                                                        
| 1418 | 1574 |  			foreach ($alldata as $number) { | 
                                                        
| 1419 | 1575 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source']);  | 
                                                        
| 1420 | 1576 | }  | 
                                                        
| 1421 | 1577 | |
| 1422 | - if ($globalDebug) echo 'Count all departure airports...'."\n";  | 
                                                        |
| 1578 | +			if ($globalDebug) { | 
                                                        |
| 1579 | + echo 'Count all departure airports...'."\n";  | 
                                                        |
| 1580 | + }  | 
                                                        |
| 1423 | 1581 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);  | 
                                                        
| 1424 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n";  | 
                                                        |
| 1582 | +			if ($globalDebug) { | 
                                                        |
| 1583 | + echo 'Count all detected departure airports...'."\n";  | 
                                                        |
| 1584 | + }  | 
                                                        |
| 1425 | 1585 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);  | 
                                                        
| 1426 | - if ($globalDebug) echo 'Order departure airports...'."\n";  | 
                                                        |
| 1586 | +			if ($globalDebug) { | 
                                                        |
| 1587 | + echo 'Order departure airports...'."\n";  | 
                                                        |
| 1588 | + }  | 
                                                        |
| 1427 | 1589 | $alldata = array();  | 
                                                        
| 1428 | 1590 | |
| 1429 | 1591 |      			foreach ($pall as $value) { | 
                                                        
@@ -1434,7 +1596,9 @@ discard block  | 
                                                    ||
| 1434 | 1596 | $icao = $value['airport_departure_icao'];  | 
                                                        
| 1435 | 1597 |          			if (isset($alldata[$icao])) { | 
                                                        
| 1436 | 1598 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];  | 
                                                        
| 1437 | - } else $alldata[$icao] = $value;  | 
                                                        |
| 1599 | +        			} else { | 
                                                        |
| 1600 | + $alldata[$icao] = $value;  | 
                                                        |
| 1601 | + }  | 
                                                        |
| 1438 | 1602 | }  | 
                                                        
| 1439 | 1603 | $count = array();  | 
                                                        
| 1440 | 1604 |      			foreach ($alldata as $key => $row) { | 
                                                        
@@ -1444,11 +1608,17 @@ discard block  | 
                                                    ||
| 1444 | 1608 |  			foreach ($alldata as $number) { | 
                                                        
| 1445 | 1609 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);  | 
                                                        
| 1446 | 1610 | }  | 
                                                        
| 1447 | - if ($globalDebug) echo 'Count all arrival airports...'."\n";  | 
                                                        |
| 1611 | +			if ($globalDebug) { | 
                                                        |
| 1612 | + echo 'Count all arrival airports...'."\n";  | 
                                                        |
| 1613 | + }  | 
                                                        |
| 1448 | 1614 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);  | 
                                                        
| 1449 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n";  | 
                                                        |
| 1615 | +			if ($globalDebug) { | 
                                                        |
| 1616 | + echo 'Count all detected arrival airports...'."\n";  | 
                                                        |
| 1617 | + }  | 
                                                        |
| 1450 | 1618 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);  | 
                                                        
| 1451 | - if ($globalDebug) echo 'Order arrival airports...'."\n";  | 
                                                        |
| 1619 | +			if ($globalDebug) { | 
                                                        |
| 1620 | + echo 'Order arrival airports...'."\n";  | 
                                                        |
| 1621 | + }  | 
                                                        |
| 1452 | 1622 | $alldata = array();  | 
                                                        
| 1453 | 1623 |      			foreach ($pall as $value) { | 
                                                        
| 1454 | 1624 | $icao = $value['airport_arrival_icao'];  | 
                                                        
@@ -1458,7 +1628,9 @@ discard block  | 
                                                    ||
| 1458 | 1628 | $icao = $value['airport_arrival_icao'];  | 
                                                        
| 1459 | 1629 |          			if (isset($alldata[$icao])) { | 
                                                        
| 1460 | 1630 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];  | 
                                                        
| 1461 | - } else $alldata[$icao] = $value;  | 
                                                        |
| 1631 | +	        		} else { | 
                                                        |
| 1632 | + $alldata[$icao] = $value;  | 
                                                        |
| 1633 | + }  | 
                                                        |
| 1462 | 1634 | }  | 
                                                        
| 1463 | 1635 | $count = array();  | 
                                                        
| 1464 | 1636 |          		foreach ($alldata as $key => $row) { | 
                                                        
@@ -1469,7 +1641,9 @@ discard block  | 
                                                    ||
| 1469 | 1641 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);  | 
                                                        
| 1470 | 1642 | }  | 
                                                        
| 1471 | 1643 |  			if ($Connection->tableExists('countries')) { | 
                                                        
| 1472 | - if ($globalDebug) echo 'Count all flights by countries...'."\n";  | 
                                                        |
| 1644 | +				if ($globalDebug) { | 
                                                        |
| 1645 | + echo 'Count all flights by countries...'."\n";  | 
                                                        |
| 1646 | + }  | 
                                                        |
| 1473 | 1647 | $SpotterArchive = new SpotterArchive();  | 
                                                        
| 1474 | 1648 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);  | 
                                                        
| 1475 | 1649 |  				foreach ($alldata as $number) { | 
                                                        
@@ -1481,46 +1655,66 @@ discard block  | 
                                                    ||
| 1481 | 1655 | // Add by month using getstat if month finish...  | 
                                                        
| 1482 | 1656 | |
| 1483 | 1657 |  			//if (date('m',strtotime($last_update_day)) != date('m')) { | 
                                                        
| 1484 | - if ($globalDebug) echo 'Count all flights by months...'."\n";  | 
                                                        |
| 1658 | +			if ($globalDebug) { | 
                                                        |
| 1659 | + echo 'Count all flights by months...'."\n";  | 
                                                        |
| 1660 | + }  | 
                                                        |
| 1485 | 1661 | $Spotter = new Spotter($this->db);  | 
                                                        
| 1486 | 1662 | $alldata = $Spotter->countAllMonths();  | 
                                                        
| 1487 | 1663 | $lastyear = false;  | 
                                                        
| 1488 | 1664 |  			foreach ($alldata as $number) { | 
                                                        
| 1489 | -				if ($number['year_name'] != date('Y')) $lastyear = true; | 
                                                        |
| 1665 | +				if ($number['year_name'] != date('Y')) { | 
                                                        |
| 1666 | + $lastyear = true;  | 
                                                        |
| 1667 | + }  | 
                                                        |
| 1490 | 1668 |  				$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']))); | 
                                                        
| 1491 | 1669 | }  | 
                                                        
| 1492 | - if ($globalDebug) echo 'Count all military flights by months...'."\n";  | 
                                                        |
| 1670 | +			if ($globalDebug) { | 
                                                        |
| 1671 | + echo 'Count all military flights by months...'."\n";  | 
                                                        |
| 1672 | + }  | 
                                                        |
| 1493 | 1673 | $alldata = $Spotter->countAllMilitaryMonths();  | 
                                                        
| 1494 | 1674 |  			foreach ($alldata as $number) { | 
                                                        
| 1495 | 1675 |  				$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']))); | 
                                                        
| 1496 | 1676 | }  | 
                                                        
| 1497 | - if ($globalDebug) echo 'Count all owners by months...'."\n";  | 
                                                        |
| 1677 | +			if ($globalDebug) { | 
                                                        |
| 1678 | + echo 'Count all owners by months...'."\n";  | 
                                                        |
| 1679 | + }  | 
                                                        |
| 1498 | 1680 | $alldata = $Spotter->countAllMonthsOwners();  | 
                                                        
| 1499 | 1681 |  			foreach ($alldata as $number) { | 
                                                        
| 1500 | 1682 |  				$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']))); | 
                                                        
| 1501 | 1683 | }  | 
                                                        
| 1502 | - if ($globalDebug) echo 'Count all pilots by months...'."\n";  | 
                                                        |
| 1684 | +			if ($globalDebug) { | 
                                                        |
| 1685 | + echo 'Count all pilots by months...'."\n";  | 
                                                        |
| 1686 | + }  | 
                                                        |
| 1503 | 1687 | $alldata = $Spotter->countAllMonthsPilots();  | 
                                                        
| 1504 | 1688 |  			foreach ($alldata as $number) { | 
                                                        
| 1505 | 1689 |  				$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']))); | 
                                                        
| 1506 | 1690 | }  | 
                                                        
| 1507 | - if ($globalDebug) echo 'Count all airlines by months...'."\n";  | 
                                                        |
| 1691 | +			if ($globalDebug) { | 
                                                        |
| 1692 | + echo 'Count all airlines by months...'."\n";  | 
                                                        |
| 1693 | + }  | 
                                                        |
| 1508 | 1694 | $alldata = $Spotter->countAllMonthsAirlines();  | 
                                                        
| 1509 | 1695 |  			foreach ($alldata as $number) { | 
                                                        
| 1510 | 1696 |  				$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']))); | 
                                                        
| 1511 | 1697 | }  | 
                                                        
| 1512 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n";  | 
                                                        |
| 1698 | +			if ($globalDebug) { | 
                                                        |
| 1699 | + echo 'Count all aircrafts by months...'."\n";  | 
                                                        |
| 1700 | + }  | 
                                                        |
| 1513 | 1701 | $alldata = $Spotter->countAllMonthsAircrafts();  | 
                                                        
| 1514 | 1702 |  			foreach ($alldata as $number) { | 
                                                        
| 1515 | 1703 |  				$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']))); | 
                                                        
| 1516 | 1704 | }  | 
                                                        
| 1517 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n";  | 
                                                        |
| 1705 | +			if ($globalDebug) { | 
                                                        |
| 1706 | + echo 'Count all real arrivals by months...'."\n";  | 
                                                        |
| 1707 | + }  | 
                                                        |
| 1518 | 1708 | $alldata = $Spotter->countAllMonthsRealArrivals();  | 
                                                        
| 1519 | 1709 |  			foreach ($alldata as $number) { | 
                                                        
| 1520 | 1710 |  				$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']))); | 
                                                        
| 1521 | 1711 | }  | 
                                                        
| 1522 | - if ($globalDebug) echo 'Airports data...'."\n";  | 
                                                        |
| 1523 | - if ($globalDebug) echo '...Departure'."\n";  | 
                                                        |
| 1712 | +			if ($globalDebug) { | 
                                                        |
| 1713 | + echo 'Airports data...'."\n";  | 
                                                        |
| 1714 | + }  | 
                                                        |
| 1715 | +			if ($globalDebug) { | 
                                                        |
| 1716 | + echo '...Departure'."\n";  | 
                                                        |
| 1717 | + }  | 
                                                        |
| 1524 | 1718 |  			$this->deleteStatAirport('daily'); | 
                                                        
| 1525 | 1719 | // $pall = $Spotter->getLast7DaysAirportsDeparture();  | 
                                                        
| 1526 | 1720 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture();  | 
                                                        
@@ -1640,37 +1834,53 @@ discard block  | 
                                                    ||
| 1640 | 1834 | |
| 1641 | 1835 | // Count by airlines  | 
                                                        
| 1642 | 1836 | echo '--- Stats by airlines ---'."\n";  | 
                                                        
| 1643 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";  | 
                                                        |
| 1837 | +			if ($globalDebug) { | 
                                                        |
| 1838 | + echo 'Count all aircraft types by airlines...'."\n";  | 
                                                        |
| 1839 | + }  | 
                                                        |
| 1644 | 1840 | $Spotter = new Spotter($this->db);  | 
                                                        
| 1645 | 1841 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);  | 
                                                        
| 1646 | 1842 |  			foreach ($alldata as $number) { | 
                                                        
| 1647 | 1843 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']);  | 
                                                        
| 1648 | 1844 | }  | 
                                                        
| 1649 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";  | 
                                                        |
| 1845 | +			if ($globalDebug) { | 
                                                        |
| 1846 | + echo 'Count all aircraft registrations by airlines...'."\n";  | 
                                                        |
| 1847 | + }  | 
                                                        |
| 1650 | 1848 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);  | 
                                                        
| 1651 | 1849 |  			foreach ($alldata as $number) { | 
                                                        
| 1652 | 1850 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']);  | 
                                                        
| 1653 | 1851 | }  | 
                                                        
| 1654 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";  | 
                                                        |
| 1852 | +			if ($globalDebug) { | 
                                                        |
| 1853 | + echo 'Count all callsigns by airlines...'."\n";  | 
                                                        |
| 1854 | + }  | 
                                                        |
| 1655 | 1855 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);  | 
                                                        
| 1656 | 1856 |  			foreach ($alldata as $number) { | 
                                                        
| 1657 | 1857 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);  | 
                                                        
| 1658 | 1858 | }  | 
                                                        
| 1659 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n";  | 
                                                        |
| 1859 | +			if ($globalDebug) { | 
                                                        |
| 1860 | + echo 'Count all owners by airlines...'."\n";  | 
                                                        |
| 1861 | + }  | 
                                                        |
| 1660 | 1862 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);  | 
                                                        
| 1661 | 1863 |  			foreach ($alldata as $number) { | 
                                                        
| 1662 | 1864 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']);  | 
                                                        
| 1663 | 1865 | }  | 
                                                        
| 1664 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n";  | 
                                                        |
| 1866 | +			if ($globalDebug) { | 
                                                        |
| 1867 | + echo 'Count all pilots by airlines...'."\n";  | 
                                                        |
| 1868 | + }  | 
                                                        |
| 1665 | 1869 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);  | 
                                                        
| 1666 | 1870 |  			foreach ($alldata as $number) { | 
                                                        
| 1667 | 1871 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source']);  | 
                                                        
| 1668 | 1872 | }  | 
                                                        
| 1669 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";  | 
                                                        |
| 1873 | +			if ($globalDebug) { | 
                                                        |
| 1874 | + echo 'Count all departure airports by airlines...'."\n";  | 
                                                        |
| 1875 | + }  | 
                                                        |
| 1670 | 1876 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);  | 
                                                        
| 1671 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";  | 
                                                        |
| 1877 | +			if ($globalDebug) { | 
                                                        |
| 1878 | + echo 'Count all detected departure airports by airlines...'."\n";  | 
                                                        |
| 1879 | + }  | 
                                                        |
| 1672 | 1880 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);  | 
                                                        
| 1673 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";  | 
                                                        |
| 1881 | +			if ($globalDebug) { | 
                                                        |
| 1882 | + echo 'Order detected departure airports by airlines...'."\n";  | 
                                                        |
| 1883 | + }  | 
                                                        |
| 1674 | 1884 | //$alldata = array();  | 
                                                        
| 1675 | 1885 |      			foreach ($dall as $value) { | 
                                                        
| 1676 | 1886 | $icao = $value['airport_departure_icao'];  | 
                                                        
@@ -1691,11 +1901,17 @@ discard block  | 
                                                    ||
| 1691 | 1901 |  			foreach ($alldata as $number) { | 
                                                        
| 1692 | 1902 | 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']);  | 
                                                        
| 1693 | 1903 | }  | 
                                                        
| 1694 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";  | 
                                                        |
| 1904 | +			if ($globalDebug) { | 
                                                        |
| 1905 | + echo 'Count all arrival airports by airlines...'."\n";  | 
                                                        |
| 1906 | + }  | 
                                                        |
| 1695 | 1907 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);  | 
                                                        
| 1696 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";  | 
                                                        |
| 1908 | +			if ($globalDebug) { | 
                                                        |
| 1909 | + echo 'Count all detected arrival airports by airlines...'."\n";  | 
                                                        |
| 1910 | + }  | 
                                                        |
| 1697 | 1911 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);  | 
                                                        
| 1698 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";  | 
                                                        |
| 1912 | +			if ($globalDebug) { | 
                                                        |
| 1913 | + echo 'Order arrival airports by airlines...'."\n";  | 
                                                        |
| 1914 | + }  | 
                                                        |
| 1699 | 1915 | //$alldata = array();  | 
                                                        
| 1700 | 1916 |      			foreach ($dall as $value) { | 
                                                        
| 1701 | 1917 | $icao = $value['airport_arrival_icao'];  | 
                                                        
@@ -1716,35 +1932,49 @@ discard block  | 
                                                    ||
| 1716 | 1932 |                          foreach ($alldata as $number) { | 
                                                        
| 1717 | 1933 | 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']);  | 
                                                        
| 1718 | 1934 | }  | 
                                                        
| 1719 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";  | 
                                                        |
| 1935 | +			if ($globalDebug) { | 
                                                        |
| 1936 | + echo 'Count all flights by months by airlines...'."\n";  | 
                                                        |
| 1937 | + }  | 
                                                        |
| 1720 | 1938 | $Spotter = new Spotter($this->db);  | 
                                                        
| 1721 | 1939 | $alldata = $Spotter->countAllMonthsByAirlines();  | 
                                                        
| 1722 | 1940 | $lastyear = false;  | 
                                                        
| 1723 | 1941 |  			foreach ($alldata as $number) { | 
                                                        
| 1724 | -				if ($number['year_name'] != date('Y')) $lastyear = true; | 
                                                        |
| 1942 | +				if ($number['year_name'] != date('Y')) { | 
                                                        |
| 1943 | + $lastyear = true;  | 
                                                        |
| 1944 | + }  | 
                                                        |
| 1725 | 1945 |  				$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']); | 
                                                        
| 1726 | 1946 | }  | 
                                                        
| 1727 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";  | 
                                                        |
| 1947 | +			if ($globalDebug) { | 
                                                        |
| 1948 | + echo 'Count all owners by months by airlines...'."\n";  | 
                                                        |
| 1949 | + }  | 
                                                        |
| 1728 | 1950 | $alldata = $Spotter->countAllMonthsOwnersByAirlines();  | 
                                                        
| 1729 | 1951 |  			foreach ($alldata as $number) { | 
                                                        
| 1730 | 1952 |  				$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']); | 
                                                        
| 1731 | 1953 | }  | 
                                                        
| 1732 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";  | 
                                                        |
| 1954 | +			if ($globalDebug) { | 
                                                        |
| 1955 | + echo 'Count all pilots by months by airlines...'."\n";  | 
                                                        |
| 1956 | + }  | 
                                                        |
| 1733 | 1957 | $alldata = $Spotter->countAllMonthsPilotsByAirlines();  | 
                                                        
| 1734 | 1958 |  			foreach ($alldata as $number) { | 
                                                        
| 1735 | 1959 |  				$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']); | 
                                                        
| 1736 | 1960 | }  | 
                                                        
| 1737 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";  | 
                                                        |
| 1961 | +			if ($globalDebug) { | 
                                                        |
| 1962 | + echo 'Count all aircrafts by months by airlines...'."\n";  | 
                                                        |
| 1963 | + }  | 
                                                        |
| 1738 | 1964 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines();  | 
                                                        
| 1739 | 1965 |  			foreach ($alldata as $number) { | 
                                                        
| 1740 | 1966 |  				$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']); | 
                                                        
| 1741 | 1967 | }  | 
                                                        
| 1742 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";  | 
                                                        |
| 1968 | +			if ($globalDebug) { | 
                                                        |
| 1969 | + echo 'Count all real arrivals by months by airlines...'."\n";  | 
                                                        |
| 1970 | + }  | 
                                                        |
| 1743 | 1971 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();  | 
                                                        
| 1744 | 1972 |  			foreach ($alldata as $number) { | 
                                                        
| 1745 | 1973 |  				$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']); | 
                                                        
| 1746 | 1974 | }  | 
                                                        
| 1747 | - if ($globalDebug) echo '...Departure'."\n";  | 
                                                        |
| 1975 | +			if ($globalDebug) { | 
                                                        |
| 1976 | + echo '...Departure'."\n";  | 
                                                        |
| 1977 | + }  | 
                                                        |
| 1748 | 1978 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();  | 
                                                        
| 1749 | 1979 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();  | 
                                                        
| 1750 | 1980 |      			foreach ($dall as $value) { | 
                                                        
@@ -1767,7 +1997,9 @@ discard block  | 
                                                    ||
| 1767 | 1997 |  			foreach ($alldata as $number) { | 
                                                        
| 1768 | 1998 | $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']);  | 
                                                        
| 1769 | 1999 | }  | 
                                                        
| 1770 | - if ($globalDebug) echo '...Arrival'."\n";  | 
                                                        |
| 2000 | +			if ($globalDebug) { | 
                                                        |
| 2001 | + echo '...Arrival'."\n";  | 
                                                        |
| 2002 | + }  | 
                                                        |
| 1771 | 2003 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();  | 
                                                        
| 1772 | 2004 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();  | 
                                                        
| 1773 | 2005 |      			foreach ($dall as $value) { | 
                                                        
@@ -1791,13 +2023,19 @@ discard block  | 
                                                    ||
| 1791 | 2023 | $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']);  | 
                                                        
| 1792 | 2024 | }  | 
                                                        
| 1793 | 2025 | |
| 1794 | - if ($globalDebug) echo 'Flights data...'."\n";  | 
                                                        |
| 1795 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";  | 
                                                        |
| 2026 | +			if ($globalDebug) { | 
                                                        |
| 2027 | + echo 'Flights data...'."\n";  | 
                                                        |
| 2028 | + }  | 
                                                        |
| 2029 | +			if ($globalDebug) { | 
                                                        |
| 2030 | + echo '-> countAllDatesLastMonth...'."\n";  | 
                                                        |
| 2031 | + }  | 
                                                        |
| 1796 | 2032 | $alldata = $Spotter->countAllDatesLastMonthByAirlines();  | 
                                                        
| 1797 | 2033 |  			foreach ($alldata as $number) { | 
                                                        
| 1798 | 2034 |  				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); | 
                                                        
| 1799 | 2035 | }  | 
                                                        
| 1800 | - if ($globalDebug) echo '-> countAllDates...'."\n";  | 
                                                        |
| 2036 | +			if ($globalDebug) { | 
                                                        |
| 2037 | + echo '-> countAllDates...'."\n";  | 
                                                        |
| 2038 | + }  | 
                                                        |
| 1801 | 2039 | //$previousdata = $this->countAllDatesByAirlines();  | 
                                                        
| 1802 | 2040 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());  | 
                                                        
| 1803 | 2041 | $values = array();  | 
                                                        
@@ -1810,14 +2048,18 @@ discard block  | 
                                                    ||
| 1810 | 2048 |  				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); | 
                                                        
| 1811 | 2049 | }  | 
                                                        
| 1812 | 2050 | |
| 1813 | - if ($globalDebug) echo '-> countAllHours...'."\n";  | 
                                                        |
| 2051 | +			if ($globalDebug) { | 
                                                        |
| 2052 | + echo '-> countAllHours...'."\n";  | 
                                                        |
| 2053 | + }  | 
                                                        |
| 1814 | 2054 |  			$alldata = $Spotter->countAllHoursByAirlines('hour'); | 
                                                        
| 1815 | 2055 |  			foreach ($alldata as $number) { | 
                                                        
| 1816 | 2056 |  				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); | 
                                                        
| 1817 | 2057 | }  | 
                                                        
| 1818 | 2058 | |
| 1819 | 2059 | |
| 1820 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();  | 
                                                        |
| 2060 | +			if (!isset($globalStatsFilters) || $globalStatsFilters == '') { | 
                                                        |
| 2061 | + $globalStatsFilters = array();  | 
                                                        |
| 2062 | + }  | 
                                                        |
| 1821 | 2063 |  			foreach ($globalStatsFilters as $name => $filter) { | 
                                                        
| 1822 | 2064 | //$filter_name = $filter['name'];  | 
                                                        
| 1823 | 2065 | $filter_name = $name;  | 
                                                        
@@ -1825,10 +2067,14 @@ discard block  | 
                                                    ||
| 1825 | 2067 |  				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); | 
                                                        
| 1826 | 2068 |  				if (isset($last_update[0]['value'])) { | 
                                                        
| 1827 | 2069 | $last_update_day = $last_update[0]['value'];  | 
                                                        
| 1828 | - } else $last_update_day = '2012-12-12 12:12:12';  | 
                                                        |
| 2070 | +				} else { | 
                                                        |
| 2071 | + $last_update_day = '2012-12-12 12:12:12';  | 
                                                        |
| 2072 | + }  | 
                                                        |
| 1829 | 2073 | |
| 1830 | 2074 | // Count by filter  | 
                                                        
| 1831 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";  | 
                                                        |
| 2075 | +				if ($globalDebug) { | 
                                                        |
| 2076 | + echo '--- Stats for filter '.$filter_name.' ---'."\n";  | 
                                                        |
| 2077 | + }  | 
                                                        |
| 1832 | 2078 | $Spotter = new Spotter($this->db);  | 
                                                        
| 1833 | 2079 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);  | 
                                                        
| 1834 | 2080 |  				foreach ($alldata as $number) { | 
                                                        
@@ -1866,7 +2112,9 @@ discard block  | 
                                                    ||
| 1866 | 2112 | $icao = $value['airport_departure_icao'];  | 
                                                        
| 1867 | 2113 |          				if (isset($alldata[$icao])) { | 
                                                        
| 1868 | 2114 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];  | 
                                                        
| 1869 | - } else $alldata[$icao] = $value;  | 
                                                        |
| 2115 | +        				} else { | 
                                                        |
| 2116 | + $alldata[$icao] = $value;  | 
                                                        |
| 2117 | + }  | 
                                                        |
| 1870 | 2118 | }  | 
                                                        
| 1871 | 2119 | $count = array();  | 
                                                        
| 1872 | 2120 |      				foreach ($alldata as $key => $row) { | 
                                                        
@@ -1887,7 +2135,9 @@ discard block  | 
                                                    ||
| 1887 | 2135 | $icao = $value['airport_arrival_icao'];  | 
                                                        
| 1888 | 2136 |          				if (isset($alldata[$icao])) { | 
                                                        
| 1889 | 2137 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];  | 
                                                        
| 1890 | - } else $alldata[$icao] = $value;  | 
                                                        |
| 2138 | +		        		} else { | 
                                                        |
| 2139 | + $alldata[$icao] = $value;  | 
                                                        |
| 2140 | + }  | 
                                                        |
| 1891 | 2141 | }  | 
                                                        
| 1892 | 2142 | $count = array();  | 
                                                        
| 1893 | 2143 |          			foreach ($alldata as $key => $row) { | 
                                                        
@@ -1901,7 +2151,9 @@ discard block  | 
                                                    ||
| 1901 | 2151 | $alldata = $Spotter->countAllMonths($filter);  | 
                                                        
| 1902 | 2152 | $lastyear = false;  | 
                                                        
| 1903 | 2153 |  				foreach ($alldata as $number) { | 
                                                        
| 1904 | -					if ($number['year_name'] != date('Y')) $lastyear = true; | 
                                                        |
| 2154 | +					if ($number['year_name'] != date('Y')) { | 
                                                        |
| 2155 | + $lastyear = true;  | 
                                                        |
| 2156 | + }  | 
                                                        |
| 1905 | 2157 |  					$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); | 
                                                        
| 1906 | 2158 | }  | 
                                                        
| 1907 | 2159 | $alldata = $Spotter->countAllMonthsOwners($filter);  |