Completed
Push — master ( faaa5e...84cf6c )
by Yannick
06:16
created
statistics-date.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,17 +6,17 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Busiest Day");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == 'all') {
11 11
     unset($_COOKIE['stats_airline_icao']);
12
-    setcookie('stats_airline_icao', '', time()-3600);
12
+    setcookie('stats_airline_icao', '', time() - 3600);
13 13
     $airline_icao = '';
14 14
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 15
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 16
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17 17
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18 18
 }
19
-setcookie('stats_airline_icao',$airline_icao);
19
+setcookie('stats_airline_icao', $airline_icao);
20 20
 
21 21
 require_once('header.php');
22 22
 include('statistics-sub-menu.php'); 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	  </div>
28 28
       <p>'._("Below is a chart that plots the busiest day during the <strong>last 7 days</strong>.").'</p>';
29 29
 
30
-$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
30
+$date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
31 31
 if (count($date_array) == 0) {
32 32
 	print _("No data available");
33 33
 } else {
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             	["'._("Date").'", "'._("# of Flights").'"], ';
41 41
 
42 42
 $date_data = '';
43
-foreach($date_array as $date_item)
43
+foreach ($date_array as $date_item)
44 44
 {
45 45
 	$date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
46 46
 }
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
       </script>';
67 67
 }
68 68
 if (isset($globalDBArchiveMonths) && $globalDBArchiveMonths > 0) {
69
-	print '<p>'.sprintf(_("Below are the <strong>Top 10</strong> most busiest dates of last %d month(s)."),$globalDBArchiveMonths).'</p>';
69
+	print '<p>'.sprintf(_("Below are the <strong>Top 10</strong> most busiest dates of last %d month(s)."), $globalDBArchiveMonths).'</p>';
70 70
 } else {
71 71
 	print '<p>'._("Below are the <strong>Top 10</strong> most busiest dates.").'</p>';
72 72
 }
73
-$date_array = $Stats->countAllDates($airline_icao,$filter_name);
73
+$date_array = $Stats->countAllDates($airline_icao, $filter_name);
74 74
 if (!empty($date_array))
75 75
 {
76 76
 	print '<div class="table-responsive">';
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	print '</thead>';
83 83
 	print '<tbody>';
84 84
 	$i = 1;
85
-	foreach($date_array as $date_item)
85
+	foreach ($date_array as $date_item)
86 86
 	{
87 87
 		print '<tr>';
88 88
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Indentation   +757 added lines, -757 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@  discard block
 block discarded – undo
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,106 +50,106 @@  discard block
 block discarded – undo
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
-        }
61
-        public function deleteOldStats($filter_name = '') {
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
+		public function deleteOldStats($filter_name = '') {
62 62
         	
63
-        	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
-                 try {
65
-                        $sth = $this->db->prepare($query);
66
-                        $sth->execute();
67
-                } catch(PDOException $e) {
68
-                        return "error : ".$e->getMessage();
69
-                }
63
+			$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
+				 try {
65
+						$sth = $this->db->prepare($query);
66
+						$sth->execute();
67
+				} catch(PDOException $e) {
68
+						return "error : ".$e->getMessage();
69
+				}
70 70
                 
71
-        	$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
72
-                 try {
73
-                        $sth = $this->db->prepare($query);
74
-                        $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
76
-                        return "error : ".$e->getMessage();
77
-                }
78
-        }
71
+			$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
72
+				 try {
73
+						$sth = $this->db->prepare($query);
74
+						$sth->execute(array(':filter_name' => $filter_name));
75
+				} catch(PDOException $e) {
76
+						return "error : ".$e->getMessage();
77
+				}
78
+		}
79 79
 	public function getAllAirlineNames($filter_name = '') {
80 80
 		if ($filter_name == '') $filter_name = $this->filter_name;
81
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
-                 try {
83
-                        $sth = $this->db->prepare($query);
84
-                        $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
86
-                        echo "error : ".$e->getMessage();
87
-                }
88
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
-                return $all;
90
-        }
81
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
+				 try {
83
+						$sth = $this->db->prepare($query);
84
+						$sth->execute(array(':filter_name' => $filter_name));
85
+				} catch(PDOException $e) {
86
+						echo "error : ".$e->getMessage();
87
+				}
88
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
+				return $all;
90
+		}
91 91
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
-                 try {
95
-                        $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
98
-                        echo "error : ".$e->getMessage();
99
-                }
100
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
-                return $all;
102
-        }
93
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
+				 try {
95
+						$sth = $this->db->prepare($query);
96
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
+				} catch(PDOException $e) {
98
+						echo "error : ".$e->getMessage();
99
+				}
100
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
+				return $all;
102
+		}
103 103
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105
-                $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";
106
-                 try {
107
-                        $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
110
-                        echo "error : ".$e->getMessage();
111
-                }
112
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
-                return $all;
114
-        }
105
+				$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";
106
+				 try {
107
+						$sth = $this->db->prepare($query);
108
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
+				} catch(PDOException $e) {
110
+						echo "error : ".$e->getMessage();
111
+				}
112
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
+				return $all;
114
+		}
115 115
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117
-                $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";
118
-                 try {
119
-                        $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
122
-                        echo "error : ".$e->getMessage();
123
-                }
124
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
-                return $all;
126
-        }
117
+				$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";
118
+				 try {
119
+						$sth = $this->db->prepare($query);
120
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
+				} catch(PDOException $e) {
122
+						echo "error : ".$e->getMessage();
123
+				}
124
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
+				return $all;
126
+		}
127 127
 
128 128
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129 129
 		if ($filter_name == '') $filter_name = $this->filter_name;
130
-                $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131
-                 try {
132
-                        $sth = $this->db->prepare($query);
133
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
-                } catch(PDOException $e) {
135
-                        echo "error : ".$e->getMessage();
136
-                }
137
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
138
-                return $all;
139
-        }
130
+				$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131
+				 try {
132
+						$sth = $this->db->prepare($query);
133
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
+				} catch(PDOException $e) {
135
+						echo "error : ".$e->getMessage();
136
+				}
137
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
138
+				return $all;
139
+		}
140 140
 
141 141
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143
-                $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144
-                 try {
145
-                        $sth = $this->db->prepare($query);
146
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-                } catch(PDOException $e) {
148
-                        echo "error : ".$e->getMessage();
149
-                }
150
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
151
-                return $all;
152
-        }
143
+				$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144
+				 try {
145
+						$sth = $this->db->prepare($query);
146
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
+				} catch(PDOException $e) {
148
+						echo "error : ".$e->getMessage();
149
+				}
150
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
151
+				return $all;
152
+		}
153 153
 
154 154
 
155 155
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 			}
167 167
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168 168
 		} else $all = array();
169
-                if (empty($all)) {
170
-            	    $filters = array('airlines' => array($stats_airline));
171
-            	    if ($filter_name != '') {
172
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
-            	    }
174
-            	    $Spotter = new Spotter($this->db);
175
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
176
-                }
177
-                return $all;
169
+				if (empty($all)) {
170
+					$filters = array('airlines' => array($stats_airline));
171
+					if ($filter_name != '') {
172
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
+					}
174
+					$Spotter = new Spotter($this->db);
175
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
176
+				}
177
+				return $all;
178 178
 	}
179 179
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 180
 		global $globalStatsFilters;
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
 			}
191 191
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192 192
 		} else $all = array();
193
-                if (empty($all)) {
194
-            		$Spotter = new Spotter($this->db);
195
-            		$filters = array();
196
-            		if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
193
+				if (empty($all)) {
194
+					$Spotter = new Spotter($this->db);
195
+					$filters = array();
196
+					if ($filter_name != '') {
197
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
198 198
 			}
199
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
200
-                }
201
-                return $all;
199
+					$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
200
+				}
201
+				return $all;
202 202
 	}
203 203
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 204
 		global $globalStatsFilters;
@@ -239,37 +239,37 @@  discard block
 block discarded – undo
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241 241
 		} else $all = array();
242
-                if (empty($all)) {
242
+				if (empty($all)) {
243 243
 			$filters = array('airlines' => array($stats_airline));
244 244
 			if ($filter_name != '') {
245
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
245
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
246 246
 			}
247 247
 			$Spotter = new Spotter($this->db);
248 248
 			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
249
-                }
250
-                return $all;
249
+				}
250
+				return $all;
251 251
 	}
252 252
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 253
 		global $globalStatsFilters;
254 254
 		if ($filter_name == '') $filter_name = $this->filter_name;
255 255
 		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";
256 256
 		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";
257
-                 try {
258
-                        $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
-                } catch(PDOException $e) {
261
-                        echo "error : ".$e->getMessage();
262
-                }
263
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
-                if (empty($all)) {
257
+				 try {
258
+						$sth = $this->db->prepare($query);
259
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
+				} catch(PDOException $e) {
261
+						echo "error : ".$e->getMessage();
262
+				}
263
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
+				if (empty($all)) {
265 265
 			$filters = array('airlines' => array($stats_airline));
266 266
 			if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 			$Spotter = new Spotter($this->db);
270 270
 			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
271
-                }
272
-                return $all;
271
+				}
272
+				return $all;
273 273
 	}
274 274
 
275 275
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
 			}
287 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
288 288
 		} else $all = array();
289
-                if (empty($all)) {
290
-	                $Spotter = new Spotter($this->db);
291
-            		$filters = array();
292
-            		if ($filter_name != '') {
293
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
289
+				if (empty($all)) {
290
+					$Spotter = new Spotter($this->db);
291
+					$filters = array();
292
+					if ($filter_name != '') {
293
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
294 294
 			}
295 295
 
296
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
297
-                }
298
-                return $all;
296
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
297
+				}
298
+				return $all;
299 299
 	}
300 300
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
301 301
 		global $globalStatsFilters;
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
 			}
312 312
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
313 313
 		} else $all = array();
314
-                if (empty($all)) {
314
+				if (empty($all)) {
315 315
 			$filters = array('airlines' => array($stats_airline));
316 316
 			if ($filter_name != '') {
317 317
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
318 318
 			}
319
-	                $Spotter = new Spotter($this->db);
320
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
321
-                }
322
-                return $all;
319
+					$Spotter = new Spotter($this->db);
320
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
321
+				}
322
+				return $all;
323 323
 	}
324 324
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
325 325
 		global $globalStatsFilters;
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 					echo "error : ".$e->getMessage();
360 360
 				}
361 361
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
362
-                /*
362
+				/*
363 363
                 if (empty($all)) {
364 364
 	                $Spotter = new Spotter($this->db);
365 365
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -410,15 +410,15 @@  discard block
 block discarded – undo
410 410
 			}
411 411
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
412 412
 		} else $all = array();
413
-                if (empty($all)) {
413
+				if (empty($all)) {
414 414
 			$filters = array('airlines' => array($stats_airline));
415 415
 			if ($filter_name != '') {
416 416
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
417 417
 			}
418
-            		$Spotter = new Spotter($this->db);
419
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
420
-                }
421
-                return $all;
418
+					$Spotter = new Spotter($this->db);
419
+					$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
420
+				}
421
+				return $all;
422 422
 	}
423 423
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
424 424
 		global $globalStatsFilters;
@@ -434,33 +434,33 @@  discard block
 block discarded – undo
434 434
 			}
435 435
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
436 436
 		} else $all = array();
437
-                if (empty($all)) {
437
+				if (empty($all)) {
438 438
 			$filters = array('airlines' => array($stats_airline));
439
-            		if ($filter_name != '') {
440
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
441
-			}
442
-            		$Spotter = new Spotter($this->db);
443
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
445
-        		$all = array();
446
-        		foreach ($pall as $value) {
447
-        			$icao = $value['airport_departure_icao'];
448
-        			$all[$icao] = $value;
449
-        		}
439
+					if ($filter_name != '') {
440
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
441
+			}
442
+					$Spotter = new Spotter($this->db);
443
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
445
+				$all = array();
446
+				foreach ($pall as $value) {
447
+					$icao = $value['airport_departure_icao'];
448
+					$all[$icao] = $value;
449
+				}
450 450
         		
451
-        		foreach ($dall as $value) {
452
-        			$icao = $value['airport_departure_icao'];
453
-        			if (isset($all[$icao])) {
454
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
-        			} else $all[$icao] = $value;
456
-        		}
457
-        		$count = array();
458
-        		foreach ($all as $key => $row) {
459
-        			$count[$key] = $row['airport_departure_icao_count'];
460
-        		}
461
-        		array_multisort($count,SORT_DESC,$all);
462
-                }
463
-                return $all;
451
+				foreach ($dall as $value) {
452
+					$icao = $value['airport_departure_icao'];
453
+					if (isset($all[$icao])) {
454
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
+					} else $all[$icao] = $value;
456
+				}
457
+				$count = array();
458
+				foreach ($all as $key => $row) {
459
+					$count[$key] = $row['airport_departure_icao_count'];
460
+				}
461
+				array_multisort($count,SORT_DESC,$all);
462
+				}
463
+				return $all;
464 464
 	}
465 465
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
466 466
 		global $globalStatsFilters;
@@ -484,26 +484,26 @@  discard block
 block discarded – undo
484 484
 			$Spotter = new Spotter($this->db);
485 485
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
486 486
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
487
-        		$all = array();
488
-        		foreach ($pall as $value) {
489
-        			$icao = $value['airport_arrival_icao'];
490
-        			$all[$icao] = $value;
491
-        		}
487
+				$all = array();
488
+				foreach ($pall as $value) {
489
+					$icao = $value['airport_arrival_icao'];
490
+					$all[$icao] = $value;
491
+				}
492 492
         		
493
-        		foreach ($dall as $value) {
494
-        			$icao = $value['airport_arrival_icao'];
495
-        			if (isset($all[$icao])) {
496
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
-        			} else $all[$icao] = $value;
498
-        		}
499
-        		$count = array();
500
-        		foreach ($all as $key => $row) {
501
-        			$count[$key] = $row['airport_arrival_icao_count'];
502
-        		}
503
-        		array_multisort($count,SORT_DESC,$all);
504
-                }
493
+				foreach ($dall as $value) {
494
+					$icao = $value['airport_arrival_icao'];
495
+					if (isset($all[$icao])) {
496
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
+					} else $all[$icao] = $value;
498
+				}
499
+				$count = array();
500
+				foreach ($all as $key => $row) {
501
+					$count[$key] = $row['airport_arrival_icao_count'];
502
+				}
503
+				array_multisort($count,SORT_DESC,$all);
504
+				}
505 505
  
506
-                return $all;
506
+				return $all;
507 507
 	}
508 508
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
509 509
 		global $globalDBdriver, $globalStatsFilters;
@@ -516,23 +516,23 @@  discard block
 block discarded – undo
516 516
 			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";
517 517
 		}
518 518
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
519
-                 try {
520
-                        $sth = $this->db->prepare($query);
521
-                        $sth->execute($query_data);
522
-                } catch(PDOException $e) {
523
-                        echo "error : ".$e->getMessage();
524
-                }
525
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
526
-                if (empty($all)) {
519
+				 try {
520
+						$sth = $this->db->prepare($query);
521
+						$sth->execute($query_data);
522
+				} catch(PDOException $e) {
523
+						echo "error : ".$e->getMessage();
524
+				}
525
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
526
+				if (empty($all)) {
527 527
 			$filters = array('airlines' => array($stats_airline));
528 528
 			if ($filter_name != '') {
529 529
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
530 530
 			}
531
-            		$Spotter = new Spotter($this->db);
532
-            		$all = $Spotter->countAllMonthsLastYear($filters);
533
-                }
531
+					$Spotter = new Spotter($this->db);
532
+					$all = $Spotter->countAllMonthsLastYear($filters);
533
+				}
534 534
                 
535
-                return $all;
535
+				return $all;
536 536
 	}
537 537
 	
538 538
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -540,22 +540,22 @@  discard block
 block discarded – undo
540 540
 		if ($filter_name == '') $filter_name = $this->filter_name;
541 541
 		$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";
542 542
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
543
-                 try {
544
-                        $sth = $this->db->prepare($query);
545
-                        $sth->execute($query_data);
546
-                } catch(PDOException $e) {
547
-                        echo "error : ".$e->getMessage();
548
-                }
549
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
550
-                if (empty($all)) {
543
+				 try {
544
+						$sth = $this->db->prepare($query);
545
+						$sth->execute($query_data);
546
+				} catch(PDOException $e) {
547
+						echo "error : ".$e->getMessage();
548
+				}
549
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
550
+				if (empty($all)) {
551 551
 			$filters = array('airlines' => array($stats_airline));
552 552
 			if ($filter_name != '') {
553 553
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
554 554
 			}
555
-            		$Spotter = new Spotter($this->db);
556
-            		$all = $Spotter->countAllDatesLastMonth($filters);
557
-                }
558
-                return $all;
555
+					$Spotter = new Spotter($this->db);
556
+					$all = $Spotter->countAllDatesLastMonth($filters);
557
+				}
558
+				return $all;
559 559
 	}
560 560
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
561 561
 		global $globalDBdriver, $globalStatsFilters;
@@ -566,110 +566,110 @@  discard block
 block discarded – undo
566 566
 			$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";
567 567
 		}
568 568
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
569
-                 try {
570
-                        $sth = $this->db->prepare($query);
571
-                        $sth->execute($query_data);
572
-                } catch(PDOException $e) {
573
-                        echo "error : ".$e->getMessage();
574
-                }
575
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
576
-                if (empty($all)) {
569
+				 try {
570
+						$sth = $this->db->prepare($query);
571
+						$sth->execute($query_data);
572
+				} catch(PDOException $e) {
573
+						echo "error : ".$e->getMessage();
574
+				}
575
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
576
+				if (empty($all)) {
577 577
 			$filters = array('airlines' => array($stats_airline));
578 578
 			if ($filter_name != '') {
579 579
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
580 580
 			}
581
-            		$Spotter = new Spotter($this->db);
582
-            		$all = $Spotter->countAllDatesLast7Days($filters);
583
-                }
584
-                return $all;
581
+					$Spotter = new Spotter($this->db);
582
+					$all = $Spotter->countAllDatesLast7Days($filters);
583
+				}
584
+				return $all;
585 585
 	}
586 586
 	public function countAllDates($stats_airline = '',$filter_name = '') {
587 587
 		global $globalStatsFilters;
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		$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";
590 590
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
591
-                 try {
592
-                        $sth = $this->db->prepare($query);
593
-                        $sth->execute($query_data);
594
-                } catch(PDOException $e) {
595
-                        echo "error : ".$e->getMessage();
596
-                }
597
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
598
-                if (empty($all)) {
591
+				 try {
592
+						$sth = $this->db->prepare($query);
593
+						$sth->execute($query_data);
594
+				} catch(PDOException $e) {
595
+						echo "error : ".$e->getMessage();
596
+				}
597
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
598
+				if (empty($all)) {
599 599
 			$filters = array('airlines' => array($stats_airline));
600 600
 			if ($filter_name != '') {
601
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
601
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
602 602
 			}
603
-            		$Spotter = new Spotter($this->db);
604
-            		$all = $Spotter->countAllDates($filters);
605
-                }
606
-                return $all;
603
+					$Spotter = new Spotter($this->db);
604
+					$all = $Spotter->countAllDates($filters);
605
+				}
606
+				return $all;
607 607
 	}
608 608
 	public function countAllDatesByAirlines($filter_name = '') {
609 609
 		global $globalStatsFilters;
610 610
 		if ($filter_name == '') $filter_name = $this->filter_name;
611 611
 		$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";
612 612
 		$query_data = array('filter_name' => $filter_name);
613
-                 try {
614
-                        $sth = $this->db->prepare($query);
615
-                        $sth->execute($query_data);
616
-                } catch(PDOException $e) {
617
-                        echo "error : ".$e->getMessage();
618
-                }
619
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
-                if (empty($all)) {
621
-            		$filters = array();
622
-            		if ($filter_name != '') {
623
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
613
+				 try {
614
+						$sth = $this->db->prepare($query);
615
+						$sth->execute($query_data);
616
+				} catch(PDOException $e) {
617
+						echo "error : ".$e->getMessage();
618
+				}
619
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
+				if (empty($all)) {
621
+					$filters = array();
622
+					if ($filter_name != '') {
623
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
624 624
 			}
625
-            		$Spotter = new Spotter($this->db);
626
-            		$all = $Spotter->countAllDatesByAirlines($filters);
627
-                }
628
-                return $all;
625
+					$Spotter = new Spotter($this->db);
626
+					$all = $Spotter->countAllDatesByAirlines($filters);
627
+				}
628
+				return $all;
629 629
 	}
630 630
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
631 631
 		global $globalStatsFilters;
632 632
 		if ($filter_name == '') $filter_name = $this->filter_name;
633
-	    	$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";
634
-                 try {
635
-                        $sth = $this->db->prepare($query);
636
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
-                } catch(PDOException $e) {
638
-                        echo "error : ".$e->getMessage();
639
-                }
640
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
633
+			$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";
634
+				 try {
635
+						$sth = $this->db->prepare($query);
636
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
+				} catch(PDOException $e) {
638
+						echo "error : ".$e->getMessage();
639
+				}
640
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
641 641
                 
642
-                if (empty($all)) {
642
+				if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645 645
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
646 646
 			}
647
-            		$Spotter = new Spotter($this->db);
648
-            		$all = $Spotter->countAllMonths($filters);
649
-                }
647
+					$Spotter = new Spotter($this->db);
648
+					$all = $Spotter->countAllMonths($filters);
649
+				}
650 650
                 
651
-                return $all;
651
+				return $all;
652 652
 	}
653 653
 	public function countAllMilitaryMonths($filter_name = '') {
654 654
 		global $globalStatsFilters;
655 655
 		if ($filter_name == '') $filter_name = $this->filter_name;
656
-	    	$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";
657
-                 try {
658
-                        $sth = $this->db->prepare($query);
659
-                        $sth->execute(array(':filter_name' => $filter_name));
660
-                } catch(PDOException $e) {
661
-                        echo "error : ".$e->getMessage();
662
-                }
663
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
664
-                if (empty($all)) {
665
-            		$filters = array();
666
-            		if ($filter_name != '') {
667
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
656
+			$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";
657
+				 try {
658
+						$sth = $this->db->prepare($query);
659
+						$sth->execute(array(':filter_name' => $filter_name));
660
+				} catch(PDOException $e) {
661
+						echo "error : ".$e->getMessage();
662
+				}
663
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
664
+				if (empty($all)) {
665
+					$filters = array();
666
+					if ($filter_name != '') {
667
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
668 668
 			}
669
-            		$Spotter = new Spotter($this->db);
670
-            		$all = $Spotter->countAllMilitaryMonths($filters);
671
-                }
672
-                return $all;
669
+					$Spotter = new Spotter($this->db);
670
+					$all = $Spotter->countAllMilitaryMonths($filters);
671
+				}
672
+				return $all;
673 673
 	}
674 674
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
675 675
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -685,22 +685,22 @@  discard block
 block discarded – undo
685 685
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
686 686
 		}
687 687
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
688
-                 try {
689
-                        $sth = $this->db->prepare($query);
690
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
-                } catch(PDOException $e) {
692
-                        echo "error : ".$e->getMessage();
693
-                }
694
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
-                if (empty($all)) {
688
+				 try {
689
+						$sth = $this->db->prepare($query);
690
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
+				} catch(PDOException $e) {
692
+						echo "error : ".$e->getMessage();
693
+				}
694
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
+				if (empty($all)) {
696 696
 			$filters = array('airlines' => array($stats_airline));
697 697
 			if ($filter_name != '') {
698
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
698
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
699 699
 			}
700
-            		$Spotter = new Spotter($this->db);
701
-            		$all = $Spotter->countAllHours($orderby,$filters);
702
-                }
703
-                return $all;
700
+					$Spotter = new Spotter($this->db);
701
+					$all = $Spotter->countAllHours($orderby,$filters);
702
+				}
703
+				return $all;
704 704
 	}
705 705
 	
706 706
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
@@ -724,9 +724,9 @@  discard block
 block discarded – undo
724 724
 		if ($year == '') $year = date('Y');
725 725
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
726 726
 		if (empty($all)) {
727
-		        $filters = array();
728
-            		if ($filter_name != '') {
729
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
727
+				$filters = array();
728
+					if ($filter_name != '') {
729
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
730 730
 			}
731 731
 			$Spotter = new Spotter($this->db);
732 732
 			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -778,9 +778,9 @@  discard block
 block discarded – undo
778 778
 			$all = $result[0]['nb_airline'];
779 779
 		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
780 780
 		if (empty($all)) {
781
-            		$filters = array();
782
-            		if ($filter_name != '') {
783
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
781
+					$filters = array();
782
+					if ($filter_name != '') {
783
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
784 784
 			}
785 785
 			$Spotter = new Spotter($this->db);
786 786
 			$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -833,33 +833,33 @@  discard block
 block discarded – undo
833 833
 		if ($filter_name == '') $filter_name = $this->filter_name;
834 834
 		$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";
835 835
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
836
-                 try {
837
-                        $sth = $this->db->prepare($query);
838
-                        $sth->execute($query_values);
839
-                } catch(PDOException $e) {
840
-                        echo "error : ".$e->getMessage();
841
-                }
842
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
843
-                return $all;
836
+				 try {
837
+						$sth = $this->db->prepare($query);
838
+						$sth->execute($query_values);
839
+				} catch(PDOException $e) {
840
+						echo "error : ".$e->getMessage();
841
+				}
842
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
843
+				return $all;
844 844
 	}
845 845
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
846 846
 		if ($filter_name == '') $filter_name = $this->filter_name;
847
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
848
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
849
-                 try {
850
-                        $sth = $this->db->prepare($query);
851
-                        $sth->execute($query_values);
852
-                } catch(PDOException $e) {
853
-                        echo "error : ".$e->getMessage();
854
-                }
855
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
856
-                return $all;
857
-        }
847
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
848
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
849
+				 try {
850
+						$sth = $this->db->prepare($query);
851
+						$sth->execute($query_values);
852
+				} catch(PDOException $e) {
853
+						echo "error : ".$e->getMessage();
854
+				}
855
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
856
+				return $all;
857
+		}
858 858
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
859 859
 		if ($filter_name == '') $filter_name = $this->filter_name;
860
-    		global $globalArchiveMonths, $globalDBdriver;
861
-    		if ($globalDBdriver == 'mysql') {
862
-    			if ($month == '') {
860
+			global $globalArchiveMonths, $globalDBdriver;
861
+			if ($globalDBdriver == 'mysql') {
862
+				if ($month == '') {
863 863
 				$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";
864 864
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
865 865
 			} else {
@@ -874,137 +874,137 @@  discard block
 block discarded – undo
874 874
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
875 875
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
876 876
 			}
877
-                }
878
-                 try {
879
-                        $sth = $this->db->prepare($query);
880
-                        $sth->execute($query_values);
881
-                } catch(PDOException $e) {
882
-                        echo "error : ".$e->getMessage();
883
-                }
884
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
885
-                return $all[0]['total'];
886
-        }
877
+				}
878
+				 try {
879
+						$sth = $this->db->prepare($query);
880
+						$sth->execute($query_values);
881
+				} catch(PDOException $e) {
882
+						echo "error : ".$e->getMessage();
883
+				}
884
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
885
+				return $all[0]['total'];
886
+		}
887 887
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
888
-    		global $globalArchiveMonths, $globalDBdriver;
888
+			global $globalArchiveMonths, $globalDBdriver;
889 889
 		if ($filter_name == '') $filter_name = $this->filter_name;
890
-    		if ($globalDBdriver == 'mysql') {
890
+			if ($globalDBdriver == 'mysql') {
891 891
 			$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";
892 892
 		} else {
893 893
 			$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";
894
-                }
895
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
896
-                 try {
897
-                        $sth = $this->db->prepare($query);
898
-                        $sth->execute($query_values);
899
-                } catch(PDOException $e) {
900
-                        echo "error : ".$e->getMessage();
901
-                }
902
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
903
-                return $all[0]['total'];
904
-        }
894
+				}
895
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
896
+				 try {
897
+						$sth = $this->db->prepare($query);
898
+						$sth->execute($query_values);
899
+				} catch(PDOException $e) {
900
+						echo "error : ".$e->getMessage();
901
+				}
902
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
903
+				return $all[0]['total'];
904
+		}
905 905
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
906
-    		global $globalArchiveMonths, $globalDBdriver;
906
+			global $globalArchiveMonths, $globalDBdriver;
907 907
 		if ($filter_name == '') $filter_name = $this->filter_name;
908
-    		if ($globalDBdriver == 'mysql') {
908
+			if ($globalDBdriver == 'mysql') {
909 909
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
910
-                } else {
910
+				} else {
911 911
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
912
-                }
913
-                 try {
914
-                        $sth = $this->db->prepare($query);
915
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
916
-                } catch(PDOException $e) {
917
-                        echo "error : ".$e->getMessage();
918
-                }
919
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
920
-                return $all[0]['total'];
921
-        }
912
+				}
913
+				 try {
914
+						$sth = $this->db->prepare($query);
915
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
916
+				} catch(PDOException $e) {
917
+						echo "error : ".$e->getMessage();
918
+				}
919
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
920
+				return $all[0]['total'];
921
+		}
922 922
 	public function getStatsAirlineTotal($filter_name = '') {
923
-    		global $globalArchiveMonths, $globalDBdriver;
923
+			global $globalArchiveMonths, $globalDBdriver;
924 924
 		if ($filter_name == '') $filter_name = $this->filter_name;
925
-    		if ($globalDBdriver == 'mysql') {
925
+			if ($globalDBdriver == 'mysql') {
926 926
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
927
-                } else {
927
+				} else {
928 928
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
929
-                }
930
-                 try {
931
-                        $sth = $this->db->prepare($query);
932
-                        $sth->execute(array(':filter_name' => $filter_name));
933
-                } catch(PDOException $e) {
934
-                        echo "error : ".$e->getMessage();
935
-                }
936
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
937
-                return $all[0]['total'];
938
-        }
929
+				}
930
+				 try {
931
+						$sth = $this->db->prepare($query);
932
+						$sth->execute(array(':filter_name' => $filter_name));
933
+				} catch(PDOException $e) {
934
+						echo "error : ".$e->getMessage();
935
+				}
936
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
937
+				return $all[0]['total'];
938
+		}
939 939
 	public function getStatsOwnerTotal($filter_name = '') {
940
-    		global $globalArchiveMonths, $globalDBdriver;
940
+			global $globalArchiveMonths, $globalDBdriver;
941 941
 		if ($filter_name == '') $filter_name = $this->filter_name;
942
-    		if ($globalDBdriver == 'mysql') {
942
+			if ($globalDBdriver == 'mysql') {
943 943
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
944 944
 		} else {
945 945
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
946
-                }
947
-                 try {
948
-                        $sth = $this->db->prepare($query);
949
-                        $sth->execute(array(':filter_name' => $filter_name));
950
-                } catch(PDOException $e) {
951
-                        echo "error : ".$e->getMessage();
952
-                }
953
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
954
-                return $all[0]['total'];
955
-        }
946
+				}
947
+				 try {
948
+						$sth = $this->db->prepare($query);
949
+						$sth->execute(array(':filter_name' => $filter_name));
950
+				} catch(PDOException $e) {
951
+						echo "error : ".$e->getMessage();
952
+				}
953
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
954
+				return $all[0]['total'];
955
+		}
956 956
 	public function getStatsPilotTotal($filter_name = '') {
957
-    		global $globalArchiveMonths, $globalDBdriver;
957
+			global $globalArchiveMonths, $globalDBdriver;
958 958
 		if ($filter_name == '') $filter_name = $this->filter_name;
959
-    		if ($globalDBdriver == 'mysql') {
960
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
961
-            	} else {
962
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
963
-            	}
964
-                 try {
965
-                        $sth = $this->db->prepare($query);
966
-                        $sth->execute(array(':filter_name' => $filter_name));
967
-                } catch(PDOException $e) {
968
-                        echo "error : ".$e->getMessage();
969
-                }
970
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
971
-                return $all[0]['total'];
972
-        }
959
+			if ($globalDBdriver == 'mysql') {
960
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
961
+				} else {
962
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
963
+				}
964
+				 try {
965
+						$sth = $this->db->prepare($query);
966
+						$sth->execute(array(':filter_name' => $filter_name));
967
+				} catch(PDOException $e) {
968
+						echo "error : ".$e->getMessage();
969
+				}
970
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
971
+				return $all[0]['total'];
972
+		}
973 973
 
974 974
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
975 975
 		global $globalDBdriver;
976 976
 		if ($filter_name == '') $filter_name = $this->filter_name;
977 977
 		if ($globalDBdriver == 'mysql') {
978 978
 			$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";
979
-                } else {
979
+				} else {
980 980
 			$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);"; 
981 981
 		}
982
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
983
-                 try {
984
-                        $sth = $this->db->prepare($query);
985
-                        $sth->execute($query_values);
986
-                } catch(PDOException $e) {
987
-                        return "error : ".$e->getMessage();
988
-                }
989
-        }
982
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
983
+				 try {
984
+						$sth = $this->db->prepare($query);
985
+						$sth->execute($query_values);
986
+				} catch(PDOException $e) {
987
+						return "error : ".$e->getMessage();
988
+				}
989
+		}
990 990
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
991 991
 		global $globalDBdriver;
992 992
 		if ($filter_name == '') $filter_name = $this->filter_name;
993 993
 		if ($globalDBdriver == 'mysql') {
994 994
 			$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";
995 995
 		} else {
996
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
996
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
997 997
 			$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);"; 
998
-                }
999
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1000
-                 try {
1001
-                        $sth = $this->db->prepare($query);
1002
-                        $sth->execute($query_values);
1003
-                } catch(PDOException $e) {
1004
-                        return "error : ".$e->getMessage();
1005
-                }
1006
-        }
1007
-        /*
998
+				}
999
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1000
+				 try {
1001
+						$sth = $this->db->prepare($query);
1002
+						$sth->execute($query_values);
1003
+				} catch(PDOException $e) {
1004
+						return "error : ".$e->getMessage();
1005
+				}
1006
+		}
1007
+		/*
1008 1008
 	public function getStatsSource($date,$stats_type = '') {
1009 1009
 		if ($stats_type == '') {
1010 1010
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -1073,25 +1073,25 @@  discard block
 block discarded – undo
1073 1073
 			$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";
1074 1074
 		} else {
1075 1075
 			$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);"; 
1076
-                }
1077
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1078
-                 try {
1079
-                        $sth = $this->db->prepare($query);
1080
-                        $sth->execute($query_values);
1081
-                } catch(PDOException $e) {
1082
-                        return "error : ".$e->getMessage();
1083
-                }
1084
-        }
1085
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1086
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1087
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1088
-                 try {
1089
-                        $sth = $this->db->prepare($query);
1090
-                        $sth->execute($query_values);
1091
-                } catch(PDOException $e) {
1092
-                        return "error : ".$e->getMessage();
1093
-                }
1094
-        }
1076
+				}
1077
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1078
+				 try {
1079
+						$sth = $this->db->prepare($query);
1080
+						$sth->execute($query_values);
1081
+				} catch(PDOException $e) {
1082
+						return "error : ".$e->getMessage();
1083
+				}
1084
+		}
1085
+	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1086
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1087
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1088
+				 try {
1089
+						$sth = $this->db->prepare($query);
1090
+						$sth->execute($query_values);
1091
+				} catch(PDOException $e) {
1092
+						return "error : ".$e->getMessage();
1093
+				}
1094
+		}
1095 1095
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1096 1096
 		global $globalDBdriver;
1097 1097
 		if ($globalDBdriver == 'mysql') {
@@ -1107,14 +1107,14 @@  discard block
 block discarded – undo
1107 1107
 				$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);"; 
1108 1108
 			}
1109 1109
 		}
1110
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1111
-                 try {
1112
-                        $sth = $this->db->prepare($query);
1113
-                        $sth->execute($query_values);
1114
-                } catch(PDOException $e) {
1115
-                        return "error : ".$e->getMessage();
1116
-                }
1117
-        }
1110
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1111
+				 try {
1112
+						$sth = $this->db->prepare($query);
1113
+						$sth->execute($query_values);
1114
+				} catch(PDOException $e) {
1115
+						return "error : ".$e->getMessage();
1116
+				}
1117
+		}
1118 1118
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1119 1119
 		global $globalDBdriver;
1120 1120
 		if ($globalDBdriver == 'mysql') {
@@ -1130,14 +1130,14 @@  discard block
 block discarded – undo
1130 1130
 				$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);"; 
1131 1131
 			}
1132 1132
 		}
1133
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1134
-                 try {
1135
-                        $sth = $this->db->prepare($query);
1136
-                        $sth->execute($query_values);
1137
-                } catch(PDOException $e) {
1138
-                        return "error : ".$e->getMessage();
1139
-                }
1140
-        }
1133
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1134
+				 try {
1135
+						$sth = $this->db->prepare($query);
1136
+						$sth->execute($query_values);
1137
+				} catch(PDOException $e) {
1138
+						return "error : ".$e->getMessage();
1139
+				}
1140
+		}
1141 1141
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
1142 1142
 		global $globalDBdriver;
1143 1143
 		if ($globalDBdriver == 'mysql') {
@@ -1153,14 +1153,14 @@  discard block
 block discarded – undo
1153 1153
 				$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);"; 
1154 1154
 			}
1155 1155
 		}
1156
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1157
-                 try {
1158
-                        $sth = $this->db->prepare($query);
1159
-                        $sth->execute($query_values);
1160
-                } catch(PDOException $e) {
1161
-                        return "error : ".$e->getMessage();
1162
-                }
1163
-        }
1156
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1157
+				 try {
1158
+						$sth = $this->db->prepare($query);
1159
+						$sth->execute($query_values);
1160
+				} catch(PDOException $e) {
1161
+						return "error : ".$e->getMessage();
1162
+				}
1163
+		}
1164 1164
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1165 1165
 		global $globalDBdriver;
1166 1166
 		if ($globalDBdriver == 'mysql') {
@@ -1176,14 +1176,14 @@  discard block
 block discarded – undo
1176 1176
 				$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);"; 
1177 1177
 			}
1178 1178
 		}
1179
-                $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);
1180
-                 try {
1181
-                        $sth = $this->db->prepare($query);
1182
-                        $sth->execute($query_values);
1183
-                } catch(PDOException $e) {
1184
-                        return "error : ".$e->getMessage();
1185
-                }
1186
-        }
1179
+				$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);
1180
+				 try {
1181
+						$sth = $this->db->prepare($query);
1182
+						$sth->execute($query_values);
1183
+				} catch(PDOException $e) {
1184
+						return "error : ".$e->getMessage();
1185
+				}
1186
+		}
1187 1187
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1188 1188
 		global $globalDBdriver;
1189 1189
 		if ($globalDBdriver == 'mysql') {
@@ -1199,14 +1199,14 @@  discard block
 block discarded – undo
1199 1199
 				$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);"; 
1200 1200
 			}
1201 1201
 		}
1202
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1203
-                 try {
1204
-                        $sth = $this->db->prepare($query);
1205
-                        $sth->execute($query_values);
1206
-                } catch(PDOException $e) {
1207
-                        return "error : ".$e->getMessage();
1208
-                }
1209
-        }
1202
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1203
+				 try {
1204
+						$sth = $this->db->prepare($query);
1205
+						$sth->execute($query_values);
1206
+				} catch(PDOException $e) {
1207
+						return "error : ".$e->getMessage();
1208
+				}
1209
+		}
1210 1210
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1211 1211
 		global $globalDBdriver;
1212 1212
 		if ($globalDBdriver == 'mysql') {
@@ -1222,14 +1222,14 @@  discard block
 block discarded – undo
1222 1222
 				$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);"; 
1223 1223
 			}
1224 1224
 		}
1225
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1226
-                 try {
1227
-                        $sth = $this->db->prepare($query);
1228
-                        $sth->execute($query_values);
1229
-                } catch(PDOException $e) {
1230
-                        return "error : ".$e->getMessage();
1231
-                }
1232
-        }
1225
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1226
+				 try {
1227
+						$sth = $this->db->prepare($query);
1228
+						$sth->execute($query_values);
1229
+				} catch(PDOException $e) {
1230
+						return "error : ".$e->getMessage();
1231
+				}
1232
+		}
1233 1233
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1234 1234
 		global $globalDBdriver;
1235 1235
 		if ($globalDBdriver == 'mysql') {
@@ -1245,14 +1245,14 @@  discard block
 block discarded – undo
1245 1245
 				$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);"; 
1246 1246
 			}
1247 1247
 		}
1248
-                $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);
1249
-                 try {
1250
-                        $sth = $this->db->prepare($query);
1251
-                        $sth->execute($query_values);
1252
-                } catch(PDOException $e) {
1253
-                        return "error : ".$e->getMessage();
1254
-                }
1255
-        }
1248
+				$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);
1249
+				 try {
1250
+						$sth = $this->db->prepare($query);
1251
+						$sth->execute($query_values);
1252
+				} catch(PDOException $e) {
1253
+						return "error : ".$e->getMessage();
1254
+				}
1255
+		}
1256 1256
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1257 1257
 		global $globalDBdriver;
1258 1258
 		if ($airport_icao != '') {
@@ -1276,8 +1276,8 @@  discard block
 block discarded – undo
1276 1276
 			} catch(PDOException $e) {
1277 1277
 				return "error : ".$e->getMessage();
1278 1278
 			}
1279
-                }
1280
-        }
1279
+				}
1280
+		}
1281 1281
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1282 1282
 		global $globalDBdriver;
1283 1283
 		if ($airport_icao != '') {
@@ -1293,8 +1293,8 @@  discard block
 block discarded – undo
1293 1293
 			} catch(PDOException $e) {
1294 1294
 				return "error : ".$e->getMessage();
1295 1295
 			}
1296
-                }
1297
-        }
1296
+				}
1297
+		}
1298 1298
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1299 1299
 		global $globalDBdriver;
1300 1300
 		if ($airport_icao != '') {
@@ -1311,15 +1311,15 @@  discard block
 block discarded – undo
1311 1311
 					$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);"; 
1312 1312
 				}
1313 1313
 			}
1314
-	                $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);
1314
+					$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);
1315 1315
 			 try {
1316
-                    		$sth = $this->db->prepare($query);
1317
-	                        $sth->execute($query_values);
1318
-    		        } catch(PDOException $e) {
1319
-            		        return "error : ".$e->getMessage();
1320
-	                }
1321
-	        }
1322
-        }
1316
+							$sth = $this->db->prepare($query);
1317
+							$sth->execute($query_values);
1318
+					} catch(PDOException $e) {
1319
+							return "error : ".$e->getMessage();
1320
+					}
1321
+			}
1322
+		}
1323 1323
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1324 1324
 		global $globalDBdriver;
1325 1325
 		if ($airport_icao != '') {
@@ -1335,46 +1335,46 @@  discard block
 block discarded – undo
1335 1335
 			} catch(PDOException $e) {
1336 1336
 				return "error : ".$e->getMessage();
1337 1337
 			}
1338
-                }
1339
-        }
1338
+				}
1339
+		}
1340 1340
 
1341 1341
 	public function deleteStat($id) {
1342
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1343
-                $query_values = array(':id' => $id);
1344
-                 try {
1345
-                        $sth = $this->db->prepare($query);
1346
-                        $sth->execute($query_values);
1347
-                } catch(PDOException $e) {
1348
-                        return "error : ".$e->getMessage();
1349
-                }
1350
-        }
1342
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1343
+				$query_values = array(':id' => $id);
1344
+				 try {
1345
+						$sth = $this->db->prepare($query);
1346
+						$sth->execute($query_values);
1347
+				} catch(PDOException $e) {
1348
+						return "error : ".$e->getMessage();
1349
+				}
1350
+		}
1351 1351
 	public function deleteStatFlight($type) {
1352
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1353
-                $query_values = array(':type' => $type);
1354
-                 try {
1355
-                        $sth = $this->db->prepare($query);
1356
-                        $sth->execute($query_values);
1357
-                } catch(PDOException $e) {
1358
-                        return "error : ".$e->getMessage();
1359
-                }
1360
-        }
1352
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1353
+				$query_values = array(':type' => $type);
1354
+				 try {
1355
+						$sth = $this->db->prepare($query);
1356
+						$sth->execute($query_values);
1357
+				} catch(PDOException $e) {
1358
+						return "error : ".$e->getMessage();
1359
+				}
1360
+		}
1361 1361
 	public function deleteStatAirport($type) {
1362
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1363
-                $query_values = array(':type' => $type);
1364
-                 try {
1365
-                        $sth = $this->db->prepare($query);
1366
-                        $sth->execute($query_values);
1367
-                } catch(PDOException $e) {
1368
-                        return "error : ".$e->getMessage();
1369
-                }
1370
-        }
1362
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1363
+				$query_values = array(':type' => $type);
1364
+				 try {
1365
+						$sth = $this->db->prepare($query);
1366
+						$sth->execute($query_values);
1367
+				} catch(PDOException $e) {
1368
+						return "error : ".$e->getMessage();
1369
+				}
1370
+		}
1371 1371
         
1372
-        public function addOldStats() {
1373
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1374
-    		$Common = new Common();
1375
-    		$Connection = new Connection();
1376
-    		date_default_timezone_set('UTC');
1377
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1372
+		public function addOldStats() {
1373
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1374
+			$Common = new Common();
1375
+			$Connection = new Connection();
1376
+			date_default_timezone_set('UTC');
1377
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1378 1378
 			if ($globalDebug) echo 'Update stats !'."\n";
1379 1379
 			if (isset($last_update[0]['value'])) {
1380 1380
 				$last_update_day = $last_update[0]['value'];
@@ -1420,24 +1420,24 @@  discard block
 block discarded – undo
1420 1420
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1421 1421
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1422 1422
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1423
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1423
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1424 1424
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1425
-	        	$alldata = array();
1425
+				$alldata = array();
1426 1426
 	        	
1427
-    			foreach ($pall as $value) {
1428
-	        		$icao = $value['airport_departure_icao'];
1429
-    				$alldata[$icao] = $value;
1430
-	        	}
1431
-	        	foreach ($dall as $value) {
1432
-    				$icao = $value['airport_departure_icao'];
1433
-        			if (isset($alldata[$icao])) {
1434
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1435
-        			} else $alldata[$icao] = $value;
1436
-			}
1437
-    			$count = array();
1438
-    			foreach ($alldata as $key => $row) {
1439
-    				$count[$key] = $row['airport_departure_icao_count'];
1440
-        		}
1427
+				foreach ($pall as $value) {
1428
+					$icao = $value['airport_departure_icao'];
1429
+					$alldata[$icao] = $value;
1430
+				}
1431
+				foreach ($dall as $value) {
1432
+					$icao = $value['airport_departure_icao'];
1433
+					if (isset($alldata[$icao])) {
1434
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1435
+					} else $alldata[$icao] = $value;
1436
+			}
1437
+				$count = array();
1438
+				foreach ($alldata as $key => $row) {
1439
+					$count[$key] = $row['airport_departure_icao_count'];
1440
+				}
1441 1441
 			array_multisort($count,SORT_DESC,$alldata);
1442 1442
 			foreach ($alldata as $number) {
1443 1443
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
@@ -1445,25 +1445,25 @@  discard block
 block discarded – undo
1445 1445
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1446 1446
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1447 1447
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1448
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1448
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1449 1449
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1450
-	        	$alldata = array();
1451
-    			foreach ($pall as $value) {
1452
-	        		$icao = $value['airport_arrival_icao'];
1453
-    				$alldata[$icao] = $value;
1454
-	        	}
1455
-	        	foreach ($dall as $value) {
1456
-    				$icao = $value['airport_arrival_icao'];
1457
-        			if (isset($alldata[$icao])) {
1458
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1459
-	        		} else $alldata[$icao] = $value;
1460
-    			}
1461
-        		$count = array();
1462
-        		foreach ($alldata as $key => $row) {
1463
-        			$count[$key] = $row['airport_arrival_icao_count'];
1464
-	        	}
1465
-    			array_multisort($count,SORT_DESC,$alldata);
1466
-                        foreach ($alldata as $number) {
1450
+				$alldata = array();
1451
+				foreach ($pall as $value) {
1452
+					$icao = $value['airport_arrival_icao'];
1453
+					$alldata[$icao] = $value;
1454
+				}
1455
+				foreach ($dall as $value) {
1456
+					$icao = $value['airport_arrival_icao'];
1457
+					if (isset($alldata[$icao])) {
1458
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1459
+					} else $alldata[$icao] = $value;
1460
+				}
1461
+				$count = array();
1462
+				foreach ($alldata as $key => $row) {
1463
+					$count[$key] = $row['airport_arrival_icao_count'];
1464
+				}
1465
+				array_multisort($count,SORT_DESC,$alldata);
1466
+						foreach ($alldata as $number) {
1467 1467
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1468 1468
 			}
1469 1469
 			if ($Connection->tableExists('countries')) {
@@ -1523,8 +1523,8 @@  discard block
 block discarded – undo
1523 1523
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1524 1524
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1525 1525
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1526
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1527
-        		/*
1526
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1527
+				/*
1528 1528
 	        	$alldata = array();
1529 1529
     			foreach ($pall as $value) {
1530 1530
 	        		$icao = $value['departure_airport_icao'];
@@ -1543,29 +1543,29 @@  discard block
 block discarded – undo
1543 1543
 	        	}
1544 1544
     			array_multisort($count,SORT_DESC,$alldata);
1545 1545
     			*/
1546
-    			foreach ($dall as $value) {
1547
-    				$icao = $value['departure_airport_icao'];
1548
-    				$ddate = $value['date'];
1549
-    				$find = false;
1550
-    				foreach ($pall as $pvalue) {
1551
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1552
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1553
-    						$find = true;
1554
-    						break;
1555
-    					}
1556
-    				}
1557
-    				if ($find === false) {
1558
-    					$pall[] = $value;
1559
-    				}
1560
-    			}
1561
-    			$alldata = $pall;
1546
+				foreach ($dall as $value) {
1547
+					$icao = $value['departure_airport_icao'];
1548
+					$ddate = $value['date'];
1549
+					$find = false;
1550
+					foreach ($pall as $pvalue) {
1551
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1552
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1553
+							$find = true;
1554
+							break;
1555
+						}
1556
+					}
1557
+					if ($find === false) {
1558
+						$pall[] = $value;
1559
+					}
1560
+				}
1561
+				$alldata = $pall;
1562 1562
 			foreach ($alldata as $number) {
1563 1563
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1564 1564
 			}
1565 1565
 			echo '...Arrival'."\n";
1566 1566
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1567
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1568
-        		/*
1567
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1568
+				/*
1569 1569
 	        	$alldata = array();
1570 1570
     			foreach ($pall as $value) {
1571 1571
 	        		$icao = $value['arrival_airport_icao'];
@@ -1585,22 +1585,22 @@  discard block
 block discarded – undo
1585 1585
     			*/
1586 1586
 
1587 1587
 
1588
-    			foreach ($dall as $value) {
1589
-    				$icao = $value['arrival_airport_icao'];
1590
-    				$ddate = $value['date'];
1591
-    				$find = false;
1592
-    				foreach ($pall as $pvalue) {
1593
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1594
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1595
-    						$find = true;
1596
-    						break;
1597
-    					}
1598
-    				}
1599
-    				if ($find === false) {
1600
-    					$pall[] = $value;
1601
-    				}
1602
-    			}
1603
-    			$alldata = $pall;
1588
+				foreach ($dall as $value) {
1589
+					$icao = $value['arrival_airport_icao'];
1590
+					$ddate = $value['date'];
1591
+					$find = false;
1592
+					foreach ($pall as $pvalue) {
1593
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1594
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1595
+							$find = true;
1596
+							break;
1597
+						}
1598
+					}
1599
+					if ($find === false) {
1600
+						$pall[] = $value;
1601
+					}
1602
+				}
1603
+				$alldata = $pall;
1604 1604
 			foreach ($alldata as $number) {
1605 1605
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1606 1606
 			}
@@ -1667,51 +1667,51 @@  discard block
 block discarded – undo
1667 1667
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1668 1668
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1669 1669
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1670
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1670
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1671 1671
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1672
-	        	//$alldata = array();
1673
-    			foreach ($dall as $value) {
1674
-    				$icao = $value['airport_departure_icao'];
1675
-    				$dicao = $value['airline_icao'];
1676
-    				$find = false;
1677
-    				foreach ($pall as $pvalue) {
1678
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1679
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1680
-    						$find = true;
1681
-    						break;
1682
-    					}
1683
-    				}
1684
-    				if ($find === false) {
1685
-    					$pall[] = $value;
1686
-    				}
1687
-    			}
1688
-    			$alldata = $pall;
1672
+				//$alldata = array();
1673
+				foreach ($dall as $value) {
1674
+					$icao = $value['airport_departure_icao'];
1675
+					$dicao = $value['airline_icao'];
1676
+					$find = false;
1677
+					foreach ($pall as $pvalue) {
1678
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1679
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1680
+							$find = true;
1681
+							break;
1682
+						}
1683
+					}
1684
+					if ($find === false) {
1685
+						$pall[] = $value;
1686
+					}
1687
+				}
1688
+				$alldata = $pall;
1689 1689
 			foreach ($alldata as $number) {
1690 1690
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
1691 1691
 			}
1692 1692
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1693 1693
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1694 1694
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1695
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1695
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1696 1696
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1697
-	        	//$alldata = array();
1698
-    			foreach ($dall as $value) {
1699
-    				$icao = $value['airport_arrival_icao'];
1700
-    				$dicao = $value['airline_icao'];
1701
-    				$find = false;
1702
-    				foreach ($pall as $pvalue) {
1703
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1704
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1705
-    						$find = true;
1706
-    						break;
1707
-    					}
1708
-    				}
1709
-    				if ($find === false) {
1710
-    					$pall[] = $value;
1711
-    				}
1712
-    			}
1713
-    			$alldata = $pall;
1714
-                        foreach ($alldata as $number) {
1697
+				//$alldata = array();
1698
+				foreach ($dall as $value) {
1699
+					$icao = $value['airport_arrival_icao'];
1700
+					$dicao = $value['airline_icao'];
1701
+					$find = false;
1702
+					foreach ($pall as $pvalue) {
1703
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1704
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1705
+							$find = true;
1706
+							break;
1707
+						}
1708
+					}
1709
+					if ($find === false) {
1710
+						$pall[] = $value;
1711
+					}
1712
+				}
1713
+				$alldata = $pall;
1714
+						foreach ($alldata as $number) {
1715 1715
 				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
1716 1716
 			}
1717 1717
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1744,47 +1744,47 @@  discard block
 block discarded – undo
1744 1744
 			}
1745 1745
 			if ($globalDebug) echo '...Departure'."\n";
1746 1746
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1747
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1748
-    			foreach ($dall as $value) {
1749
-    				$icao = $value['departure_airport_icao'];
1750
-    				$airline = $value['airline_icao'];
1751
-    				$ddate = $value['date'];
1752
-    				$find = false;
1753
-    				foreach ($pall as $pvalue) {
1754
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1755
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1756
-    						$find = true;
1757
-    						break;
1758
-    					}
1759
-    				}
1760
-    				if ($find === false) {
1761
-    					$pall[] = $value;
1762
-    				}
1763
-    			}
1764
-    			$alldata = $pall;
1747
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1748
+				foreach ($dall as $value) {
1749
+					$icao = $value['departure_airport_icao'];
1750
+					$airline = $value['airline_icao'];
1751
+					$ddate = $value['date'];
1752
+					$find = false;
1753
+					foreach ($pall as $pvalue) {
1754
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1755
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1756
+							$find = true;
1757
+							break;
1758
+						}
1759
+					}
1760
+					if ($find === false) {
1761
+						$pall[] = $value;
1762
+					}
1763
+				}
1764
+				$alldata = $pall;
1765 1765
 			foreach ($alldata as $number) {
1766 1766
 				$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']);
1767 1767
 			}
1768 1768
 			if ($globalDebug) echo '...Arrival'."\n";
1769 1769
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1770
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1771
-    			foreach ($dall as $value) {
1772
-    				$icao = $value['arrival_airport_icao'];
1773
-    				$airline = $value['airline_icao'];
1774
-    				$ddate = $value['date'];
1775
-    				$find = false;
1776
-    				foreach ($pall as $pvalue) {
1777
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1778
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1779
-    						$find = true;
1780
-    						break;
1781
-    					}
1782
-    				}
1783
-    				if ($find === false) {
1784
-    					$pall[] = $value;
1785
-    				}
1786
-    			}
1787
-    			$alldata = $pall;
1770
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1771
+				foreach ($dall as $value) {
1772
+					$icao = $value['arrival_airport_icao'];
1773
+					$airline = $value['airline_icao'];
1774
+					$ddate = $value['date'];
1775
+					$find = false;
1776
+					foreach ($pall as $pvalue) {
1777
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1778
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1779
+							$find = true;
1780
+							break;
1781
+						}
1782
+					}
1783
+					if ($find === false) {
1784
+						$pall[] = $value;
1785
+					}
1786
+				}
1787
+				$alldata = $pall;
1788 1788
 			foreach ($alldata as $number) {
1789 1789
 				$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']);
1790 1790
 			}
@@ -1855,44 +1855,44 @@  discard block
 block discarded – undo
1855 1855
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1856 1856
 				}
1857 1857
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1858
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1859
-		        	$alldata = array();
1860
-	    			foreach ($pall as $value) {
1861
-		        		$icao = $value['airport_departure_icao'];
1862
-    					$alldata[$icao] = $value;
1863
-	    			}
1864
-		        	foreach ($dall as $value) {
1865
-	    				$icao = $value['airport_departure_icao'];
1866
-        				if (isset($alldata[$icao])) {
1867
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1868
-        				} else $alldata[$icao] = $value;
1869
-				}
1870
-	    			$count = array();
1871
-    				foreach ($alldata as $key => $row) {
1872
-    					$count[$key] = $row['airport_departure_icao_count'];
1873
-    				}
1858
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1859
+					$alldata = array();
1860
+					foreach ($pall as $value) {
1861
+						$icao = $value['airport_departure_icao'];
1862
+						$alldata[$icao] = $value;
1863
+					}
1864
+					foreach ($dall as $value) {
1865
+						$icao = $value['airport_departure_icao'];
1866
+						if (isset($alldata[$icao])) {
1867
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1868
+						} else $alldata[$icao] = $value;
1869
+				}
1870
+					$count = array();
1871
+					foreach ($alldata as $key => $row) {
1872
+						$count[$key] = $row['airport_departure_icao_count'];
1873
+					}
1874 1874
 				array_multisort($count,SORT_DESC,$alldata);
1875 1875
 				foreach ($alldata as $number) {
1876
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1876
+						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1877 1877
 				}
1878 1878
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1879
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1879
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1880 1880
 				$alldata = array();
1881
-    				foreach ($pall as $value) {
1882
-		        		$icao = $value['airport_arrival_icao'];
1883
-    					$alldata[$icao] = $value;
1884
-	    			}
1885
-		        	foreach ($dall as $value) {
1886
-	    				$icao = $value['airport_arrival_icao'];
1887
-        				if (isset($alldata[$icao])) {
1888
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1889
-		        		} else $alldata[$icao] = $value;
1890
-	    			}
1891
-        			$count = array();
1892
-        			foreach ($alldata as $key => $row) {
1893
-    					$count[$key] = $row['airport_arrival_icao_count'];
1894
-		        	}
1895
-        			array_multisort($count,SORT_DESC,$alldata);
1881
+					foreach ($pall as $value) {
1882
+						$icao = $value['airport_arrival_icao'];
1883
+						$alldata[$icao] = $value;
1884
+					}
1885
+					foreach ($dall as $value) {
1886
+						$icao = $value['airport_arrival_icao'];
1887
+						if (isset($alldata[$icao])) {
1888
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1889
+						} else $alldata[$icao] = $value;
1890
+					}
1891
+					$count = array();
1892
+					foreach ($alldata as $key => $row) {
1893
+						$count[$key] = $row['airport_arrival_icao_count'];
1894
+					}
1895
+					array_multisort($count,SORT_DESC,$alldata);
1896 1896
 				foreach ($alldata as $number) {
1897 1897
 					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
1898 1898
 				}
@@ -1925,45 +1925,45 @@  discard block
 block discarded – undo
1925 1925
 				}
1926 1926
 				echo '...Departure'."\n";
1927 1927
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1928
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1928
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1929 1929
 				foreach ($dall as $value) {
1930
-    					$icao = $value['departure_airport_icao'];
1931
-    					$ddate = $value['date'];
1932
-    					$find = false;
1933
-    					foreach ($pall as $pvalue) {
1934
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1935
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1936
-	    						$find = true;
1937
-    							break;
1938
-    						}
1939
-    					}
1940
-    					if ($find === false) {
1941
-    						$pall[] = $value;
1942
-	    				}
1943
-    				}
1944
-	    			$alldata = $pall;
1930
+						$icao = $value['departure_airport_icao'];
1931
+						$ddate = $value['date'];
1932
+						$find = false;
1933
+						foreach ($pall as $pvalue) {
1934
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1935
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1936
+								$find = true;
1937
+								break;
1938
+							}
1939
+						}
1940
+						if ($find === false) {
1941
+							$pall[] = $value;
1942
+						}
1943
+					}
1944
+					$alldata = $pall;
1945 1945
 				foreach ($alldata as $number) {
1946 1946
 					$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);
1947 1947
 				}
1948 1948
 				echo '...Arrival'."\n";
1949 1949
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1950
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1950
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1951 1951
 				foreach ($dall as $value) {
1952 1952
 					$icao = $value['arrival_airport_icao'];
1953 1953
 					$ddate = $value['date'];
1954
-    					$find = false;
1954
+						$find = false;
1955 1955
 					foreach ($pall as $pvalue) {
1956
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1957
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1958
-    							$find = true;
1959
-    							break;
1960
-	    					}
1961
-    					}
1962
-    					if ($find === false) {
1963
-    						$pall[] = $value;
1964
-	    				}
1965
-    				}
1966
-    				$alldata = $pall;
1956
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1957
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1958
+								$find = true;
1959
+								break;
1960
+							}
1961
+						}
1962
+						if ($find === false) {
1963
+							$pall[] = $value;
1964
+						}
1965
+					}
1966
+					$alldata = $pall;
1967 1967
 				foreach ($alldata as $number) {
1968 1968
 					$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);
1969 1969
 				}
Please login to merge, or discard this patch.
statistics-time.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,17 +6,17 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Busiest Time of the Day");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == 'all') {
11 11
     unset($_COOKIE['stats_airline_icao']);
12
-    setcookie('stats_airline_icao', '', time()-3600);
12
+    setcookie('stats_airline_icao', '', time() - 3600);
13 13
     $airline_icao = '';
14 14
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 15
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 16
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17 17
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18 18
 }
19
-setcookie('stats_airline_icao',$airline_icao);
19
+setcookie('stats_airline_icao', $airline_icao);
20 20
 
21 21
 require_once('header.php');
22 22
 include('statistics-sub-menu.php');
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	</div>
28 28
 	<p>'._("Below is a list of the most common <strong>time of day</strong>.").'</p>';
29 29
 
30
-$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
30
+$hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
31 31
 print '<div id="chartHour" class="chart" width="100%"></div>
32 32
       	<script> 
33 33
       		google.load("visualization", "1", {packages:["corechart"]});
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	date_default_timezone_set('UTC');
44 44
 }
45 45
 //print_r($hour_array);
46
-foreach($hour_array as $hour_item)
46
+foreach ($hour_array as $hour_item)
47 47
 {
48 48
 	$hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
49 49
 }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     			});
69 69
       </script>';
70 70
 
71
-$hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name);
71
+$hour_array = $Stats->countAllHours('count', true, $airline_icao, $filter_name);
72 72
 if (!empty($hour_array))
73 73
 {
74 74
 	print '<div class="table-responsive">';
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	print '</thead>';
81 81
 	print '<tbody>';
82 82
 	$i = 1;
83
-	foreach($hour_array as $hour_item)
83
+	foreach ($hour_array as $hour_item)
84 84
 	{
85 85
 		print '<tr>';
86 86
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.