Completed
Push — master ( f32ba6...d43b85 )
by Yannick
30:30
created
install/class.update_schema.php 3 patches
Indentation   +447 added lines, -447 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
 class update_schema {
9 9
 
10 10
 	public static function update_schedule() {
11
-	    $Connection = new Connection();
12
-	    $Schedule = new Schedule();
13
-	    $query = "SELECT * FROM schedule";
14
-            try {
15
-            	$sth = $Connection->db->prepare($query);
11
+		$Connection = new Connection();
12
+		$Schedule = new Schedule();
13
+		$query = "SELECT * FROM schedule";
14
+			try {
15
+				$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+			} catch(PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19
-    	    }
20
-    	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
-    	    }
19
+			}
20
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
+			$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
+			}
23 23
 	
24 24
 	}
25 25
 /*
@@ -43,198 +43,198 @@  discard block
 block discarded – undo
43 43
     	}
44 44
 */	
45 45
 	private static function update_from_1() {
46
-    		$Connection = new Connection();
47
-    		// Add new column to routes table
48
-    		//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
46
+			$Connection = new Connection();
47
+			// Add new column to routes table
48
+			//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
49 49
 		$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL";
50
-        	try {
51
-            	    $sth = $Connection->db->prepare($query);
52
-		    $sth->execute();
53
-    		} catch(PDOException $e) {
54
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
-    		}
56
-    		// Copy schedules data to routes table
57
-    		self::update_schedule();
58
-    		// Delete schedule table
50
+			try {
51
+					$sth = $Connection->db->prepare($query);
52
+			$sth->execute();
53
+			} catch(PDOException $e) {
54
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
+			}
56
+			// Copy schedules data to routes table
57
+			self::update_schedule();
58
+			// Delete schedule table
59 59
 		$query = "DROP TABLE `schedule`";
60
-        	try {
61
-            	    $sth = $Connection->db->prepare($query);
62
-		    $sth->execute();
63
-    		} catch(PDOException $e) {
64
-		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65
-    		}
66
-    		// Add source column
67
-    		$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
-    		try {
69
-            	    $sth = $Connection->db->prepare($query);
70
-		    $sth->execute();
71
-    		} catch(PDOException $e) {
72
-		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
-    		}
60
+			try {
61
+					$sth = $Connection->db->prepare($query);
62
+			$sth->execute();
63
+			} catch(PDOException $e) {
64
+			return "error (delete schedule table) : ".$e->getMessage()."\n";
65
+			}
66
+			// Add source column
67
+			$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
+			try {
69
+					$sth = $Connection->db->prepare($query);
70
+			$sth->execute();
71
+			} catch(PDOException $e) {
72
+			return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
+			}
74 74
 		// Delete unused column
75 75
 		$query = "ALTER TABLE `aircraft_modes`  DROP `SerialNo`,  DROP `OperatorFlagCode`,  DROP `Manufacturer`,  DROP `Type`,  DROP `FirstRegDate`,  DROP `CurrentRegDate`,  DROP `Country`,  DROP `PreviousID`,  DROP `DeRegDate`,  DROP `Status`,  DROP `PopularName`,  DROP `GenericName`,  DROP `AircraftClass`,  DROP `Engines`,  DROP `OwnershipStatus`,  DROP `RegisteredOwners`,  DROP `MTOW`,  DROP `TotalHours`,  DROP `YearBuilt`,  DROP `CofACategory`,  DROP `CofAExpiry`,  DROP `UserNotes`,  DROP `Interested`,  DROP `UserTag`,  DROP `InfoUrl`,  DROP `PictureUrl1`,  DROP `PictureUrl2`,  DROP `PictureUrl3`,  DROP `UserBool1`,  DROP `UserBool2`,  DROP `UserBool3`,  DROP `UserBool4`,  DROP `UserBool5`,  DROP `UserString1`,  DROP `UserString2`,  DROP `UserString3`,  DROP `UserString4`,  DROP `UserString5`,  DROP `UserInt1`,  DROP `UserInt2`,  DROP `UserInt3`,  DROP `UserInt4`,  DROP `UserInt5`";
76
-    		try {
77
-            	    $sth = $Connection->db->prepare($query);
78
-		    $sth->execute();
79
-    		} catch(PDOException $e) {
80
-		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
-    		}
76
+			try {
77
+					$sth = $Connection->db->prepare($query);
78
+			$sth->execute();
79
+			} catch(PDOException $e) {
80
+			return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
+			}
82 82
 		// Add ModeS column
83 83
 		$query = "ALTER TABLE `spotter_output`  ADD `ModeS` VARCHAR(255) NULL";
84
-    		try {
85
-            	    $sth = $Connection->db->prepare($query);
86
-		    $sth->execute();
87
-    		} catch(PDOException $e) {
88
-		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
-    		}
84
+			try {
85
+					$sth = $Connection->db->prepare($query);
86
+			$sth->execute();
87
+			} catch(PDOException $e) {
88
+			return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
+			}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91
-    		try {
92
-            	    $sth = $Connection->db->prepare($query);
93
-		    $sth->execute();
94
-    		} catch(PDOException $e) {
95
-		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
-    		}
97
-    		// Add auto_increment for aircraft_modes
98
-    		$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
-    		try {
100
-            	    $sth = $Connection->db->prepare($query);
101
-		    $sth->execute();
102
-    		} catch(PDOException $e) {
103
-		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
-    		}
105
-    		$error = '';
91
+			try {
92
+					$sth = $Connection->db->prepare($query);
93
+			$sth->execute();
94
+			} catch(PDOException $e) {
95
+			return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
+			}
97
+			// Add auto_increment for aircraft_modes
98
+			$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
+			try {
100
+					$sth = $Connection->db->prepare($query);
101
+			$sth->execute();
102
+			} catch(PDOException $e) {
103
+			return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
+			}
105
+			$error = '';
106 106
 		$error .= create_db::import_file('../db/acars_live.sql');
107 107
 		$error .= create_db::import_file('../db/config.sql');
108 108
 		// Update schema_version to 2
109 109
 		$query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'";
110
-        	try {
111
-            	    $sth = $Connection->db->prepare($query);
112
-		    $sth->execute();
113
-    		} catch(PDOException $e) {
114
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
115
-    		}
110
+			try {
111
+					$sth = $Connection->db->prepare($query);
112
+			$sth->execute();
113
+			} catch(PDOException $e) {
114
+			return "error (update schema_version) : ".$e->getMessage()."\n";
115
+			}
116 116
 		return $error;
117
-        }
117
+		}
118 118
 
119 119
 	private static function update_from_2() {
120
-    		$Connection = new Connection();
121
-    		// Add new column decode to acars_live table
120
+			$Connection = new Connection();
121
+			// Add new column decode to acars_live table
122 122
 		$query = "ALTER TABLE `acars_live` ADD `decode` TEXT";
123
-        	try {
124
-            	    $sth = $Connection->db->prepare($query);
125
-		    $sth->execute();
126
-    		} catch(PDOException $e) {
127
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
-    		}
129
-    		$error = '';
130
-    		// Create table acars_archive
123
+			try {
124
+					$sth = $Connection->db->prepare($query);
125
+			$sth->execute();
126
+			} catch(PDOException $e) {
127
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
+			}
129
+			$error = '';
130
+			// Create table acars_archive
131 131
 		$error .= create_db::import_file('../db/acars_archive.sql');
132 132
 		// Update schema_version to 3
133 133
 		$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'";
134
-        	try {
135
-            	    $sth = $Connection->db->prepare($query);
136
-		    $sth->execute();
137
-    		} catch(PDOException $e) {
138
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
139
-    		}
134
+			try {
135
+					$sth = $Connection->db->prepare($query);
136
+			$sth->execute();
137
+			} catch(PDOException $e) {
138
+			return "error (update schema_version) : ".$e->getMessage()."\n";
139
+			}
140 140
 		return $error;
141 141
 	}
142 142
 
143 143
 	private static function update_from_3() {
144
-    		$Connection = new Connection();
145
-    		// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
144
+			$Connection = new Connection();
145
+			// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
146 146
 		$query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP";
147
-        	try {
148
-            	    $sth = $Connection->db->prepare($query);
149
-		    $sth->execute();
150
-    		} catch(PDOException $e) {
151
-		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
-    		}
153
-    		// Add image_source_website column to spotter_image
147
+			try {
148
+					$sth = $Connection->db->prepare($query);
149
+			$sth->execute();
150
+			} catch(PDOException $e) {
151
+			return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
+			}
153
+			// Add image_source_website column to spotter_image
154 154
 		$query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL";
155
-        	try {
156
-            	    $sth = $Connection->db->prepare($query);
157
-		    $sth->execute();
158
-    		} catch(PDOException $e) {
159
-		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
-    		}
161
-    		$error = '';
155
+			try {
156
+					$sth = $Connection->db->prepare($query);
157
+			$sth->execute();
158
+			} catch(PDOException $e) {
159
+			return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
+			}
161
+			$error = '';
162 162
 		// Update schema_version to 4
163 163
 		$query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'";
164
-        	try {
165
-            	    $sth = $Connection->db->prepare($query);
166
-		    $sth->execute();
167
-    		} catch(PDOException $e) {
168
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
169
-    		}
164
+			try {
165
+					$sth = $Connection->db->prepare($query);
166
+			$sth->execute();
167
+			} catch(PDOException $e) {
168
+			return "error (update schema_version) : ".$e->getMessage()."\n";
169
+			}
170 170
 		return $error;
171 171
 	}
172 172
 	
173 173
 	private static function update_from_4() {
174
-    		$Connection = new Connection();
174
+			$Connection = new Connection();
175 175
 	
176
-    		$error = '';
177
-    		// Create table acars_label
176
+			$error = '';
177
+			// Create table acars_label
178 178
 		$error .= create_db::import_file('../db/acars_label.sql');
179 179
 		if ($error == '') {
180
-		    // Update schema_version to 5
181
-		    $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
-        	    try {
183
-            		$sth = $Connection->db->prepare($query);
180
+			// Update schema_version to 5
181
+			$query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
+				try {
183
+					$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+				} catch(PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187
-    		    }
188
-    		}
187
+				}
188
+			}
189 189
 		return $error;
190 190
 	}
191 191
 
192 192
 	private static function update_from_5() {
193
-    		$Connection = new Connection();
194
-    		// Add columns to translation
193
+			$Connection = new Connection();
194
+			// Add columns to translation
195 195
 		$query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;";
196
-        	try {
197
-            	    $sth = $Connection->db->prepare($query);
198
-		    $sth->execute();
199
-    		} catch(PDOException $e) {
200
-		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
-    		}
202
-    		// Add aircraft_shadow column to aircraft
203
-    		$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
-        	try {
205
-            	    $sth = $Connection->db->prepare($query);
206
-		    $sth->execute();
207
-    		} catch(PDOException $e) {
208
-		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
-    		}
210
-    		// Add aircraft_shadow column to spotter_live
211
-    		$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
-        	try {
213
-            	    $sth = $Connection->db->prepare($query);
214
-		    $sth->execute();
215
-    		} catch(PDOException $e) {
216
-		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
-    		}
218
-    		$error = '';
219
-    		// Update table aircraft
196
+			try {
197
+					$sth = $Connection->db->prepare($query);
198
+			$sth->execute();
199
+			} catch(PDOException $e) {
200
+			return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
+			}
202
+			// Add aircraft_shadow column to aircraft
203
+			$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
+			try {
205
+					$sth = $Connection->db->prepare($query);
206
+			$sth->execute();
207
+			} catch(PDOException $e) {
208
+			return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
+			}
210
+			// Add aircraft_shadow column to spotter_live
211
+			$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
+			try {
213
+					$sth = $Connection->db->prepare($query);
214
+			$sth->execute();
215
+			} catch(PDOException $e) {
216
+			return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
+			}
218
+			$error = '';
219
+			// Update table aircraft
220 220
 		$error .= create_db::import_file('../db/aircraft.sql');
221 221
 		$error .= create_db::import_file('../db/spotter_archive.sql');
222 222
 
223 223
 		// Update schema_version to 6
224 224
 		$query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'";
225
-        	try {
226
-            	    $sth = $Connection->db->prepare($query);
227
-		    $sth->execute();
228
-    		} catch(PDOException $e) {
229
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
230
-    		}
225
+			try {
226
+					$sth = $Connection->db->prepare($query);
227
+			$sth->execute();
228
+			} catch(PDOException $e) {
229
+			return "error (update schema_version) : ".$e->getMessage()."\n";
230
+			}
231 231
 		return $error;
232 232
 	}
233 233
 
234 234
 	private static function update_from_6() {
235
-    		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
-    		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
235
+			$Connection = new Connection();
236
+			if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
+				$query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
240 240
 			ALTER TABLE spotter_live ADD INDEX(flightaware_id);
@@ -247,147 +247,147 @@  discard block
 block discarded – undo
247 247
 			ALTER TABLE aircraft ADD INDEX(icao);
248 248
 			ALTER TABLE airport ADD INDEX(icao);
249 249
 			ALTER TABLE translation ADD INDEX(Operator);";
250
-        	    try {
251
-            		$sth = $Connection->db->prepare($query);
250
+				try {
251
+					$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+				} catch(PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255
-    		    }
256
-    		}
257
-    		$error = '';
258
-    		// Update table countries
259
-    		if ($Connection->tableExists('airspace')) {
260
-    		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
255
+				}
256
+			}
257
+			$error = '';
258
+			// Update table countries
259
+			if ($Connection->tableExists('airspace')) {
260
+				$error .= update_db::update_countries();
261
+			if ($error != '') return $error;
262 262
 		}
263 263
 		// Update schema_version to 7
264 264
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
265
-        	try {
266
-            	    $sth = $Connection->db->prepare($query);
267
-		    $sth->execute();
268
-    		} catch(PDOException $e) {
269
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
270
-    		}
265
+			try {
266
+					$sth = $Connection->db->prepare($query);
267
+			$sth->execute();
268
+			} catch(PDOException $e) {
269
+			return "error (update schema_version) : ".$e->getMessage()."\n";
270
+			}
271 271
 		return $error;
272
-    	}
272
+		}
273 273
 
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276
-    		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
276
+			$Connection = new Connection();
277
+			$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279
-        	try {
280
-            	    $sth = $Connection->db->prepare($query);
281
-		    $sth->execute();
282
-    		} catch(PDOException $e) {
283
-		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
-    		}
285
-    		if ($globalDBdriver == 'mysql') {
286
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
-		    try {
288
-            		$sth = $Connection->db->prepare($query);
289
-			$sth->execute();
290
-    		    } catch(PDOException $e) {
279
+			try {
280
+					$sth = $Connection->db->prepare($query);
281
+			$sth->execute();
282
+			} catch(PDOException $e) {
283
+			return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
+			}
285
+			if ($globalDBdriver == 'mysql') {
286
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
+			try {
288
+					$sth = $Connection->db->prepare($query);
289
+			$sth->execute();
290
+				} catch(PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292
-    		    }
293
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
294
-    		    if ($row['engine'] == 'ARCHIVE') {
292
+				}
293
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
294
+				if ($row['engine'] == 'ARCHIVE') {
295 295
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
296 296
 				ALTER TABLE copy ENGINE=ARCHIVE;
297 297
 				ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
298 298
 				INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`;
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301
-            	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
-            	    }
304
-                } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
-                }
307
-        	try {
308
-            	    $sth = $Connection->db->prepare($query);
309
-		    $sth->execute();
310
-    		} catch(PDOException $e) {
311
-		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
-    		}
301
+					} else {
302
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
+					}
304
+				} else {
305
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
+				}
307
+			try {
308
+					$sth = $Connection->db->prepare($query);
309
+			$sth->execute();
310
+			} catch(PDOException $e) {
311
+			return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
+			}
313 313
 
314
-    		$error = '';
315
-    		// Update table aircraft
314
+			$error = '';
315
+			// Update table aircraft
316 316
 		$error .= create_db::import_file('../db/source_location.sql');
317 317
 		if ($error != '') return $error;
318 318
 		// Update schema_version to 6
319 319
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320
-        	try {
321
-            	    $sth = $Connection->db->prepare($query);
322
-		    $sth->execute();
323
-    		} catch(PDOException $e) {
324
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
325
-    		}
320
+			try {
321
+					$sth = $Connection->db->prepare($query);
322
+			$sth->execute();
323
+			} catch(PDOException $e) {
324
+			return "error (update schema_version) : ".$e->getMessage()."\n";
325
+			}
326 326
 		return $error;
327 327
 	}
328 328
 
329 329
 	private static function update_from_8() {
330
-    		$Connection = new Connection();
331
-    		$error = '';
332
-    		// Update table aircraft
330
+			$Connection = new Connection();
331
+			$error = '';
332
+			// Update table aircraft
333 333
 		$error .= create_db::import_file('../db/notam.sql');
334 334
 		if ($error != '') return $error;
335 335
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 336
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 337
                         DELETE FROM config WHERE name = 'last_update_notam_db';
338 338
                         INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
339
-        	try {
340
-            	    $sth = $Connection->db->prepare($query);
341
-		    $sth->execute();
342
-    		} catch(PDOException $e) {
343
-		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344
-    		}
339
+			try {
340
+					$sth = $Connection->db->prepare($query);
341
+			$sth->execute();
342
+			} catch(PDOException $e) {
343
+			return "error (insert last_update values) : ".$e->getMessage()."\n";
344
+			}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346
-        	try {
347
-            	    $sth = $Connection->db->prepare($query);
348
-		    $sth->execute();
349
-    		} catch(PDOException $e) {
350
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
351
-    		}
346
+			try {
347
+					$sth = $Connection->db->prepare($query);
348
+			$sth->execute();
349
+			} catch(PDOException $e) {
350
+			return "error (update schema_version) : ".$e->getMessage()."\n";
351
+			}
352 352
 		return $error;
353 353
 	}
354 354
 
355 355
 	private static function update_from_9() {
356
-    		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
356
+			$Connection = new Connection();
357
+			$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359
-        	try {
360
-            	    $sth = $Connection->db->prepare($query);
361
-		    $sth->execute();
362
-    		} catch(PDOException $e) {
363
-		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
-    		}
359
+			try {
360
+					$sth = $Connection->db->prepare($query);
361
+			$sth->execute();
362
+			} catch(PDOException $e) {
363
+			return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
+			}
365 365
 		$error = '';
366
-    		// Update table atc
366
+			// Update table atc
367 367
 		$error .= create_db::import_file('../db/atc.sql');
368 368
 		if ($error != '') return $error;
369 369
 		
370 370
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371
-        	try {
372
-            	    $sth = $Connection->db->prepare($query);
373
-		    $sth->execute();
374
-    		} catch(PDOException $e) {
375
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
376
-    		}
371
+			try {
372
+					$sth = $Connection->db->prepare($query);
373
+			$sth->execute();
374
+			} catch(PDOException $e) {
375
+			return "error (update schema_version) : ".$e->getMessage()."\n";
376
+			}
377 377
 		return $error;
378 378
 	}
379 379
 
380 380
 	private static function update_from_10() {
381
-    		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
-        	try {
384
-            	    $sth = $Connection->db->prepare($query);
385
-		    $sth->execute();
386
-    		} catch(PDOException $e) {
387
-		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
-    		}
381
+			$Connection = new Connection();
382
+			$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
+			try {
384
+					$sth = $Connection->db->prepare($query);
385
+			$sth->execute();
386
+			} catch(PDOException $e) {
387
+			return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
+			}
389 389
 		$error = '';
390
-    		// Add tables
390
+			// Add tables
391 391
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392 392
 		if ($error != '') return $error;
393 393
 		$error .= create_db::import_file('../db/metar.sql');
@@ -398,76 +398,76 @@  discard block
 block discarded – undo
398 398
 		if ($error != '') return $error;
399 399
 		
400 400
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401
-        	try {
402
-            	    $sth = $Connection->db->prepare($query);
403
-		    $sth->execute();
404
-    		} catch(PDOException $e) {
405
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
406
-    		}
401
+			try {
402
+					$sth = $Connection->db->prepare($query);
403
+			$sth->execute();
404
+			} catch(PDOException $e) {
405
+			return "error (update schema_version) : ".$e->getMessage()."\n";
406
+			}
407 407
 		return $error;
408 408
 	}
409 409
 
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412
-    		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
-        	try {
415
-            	    $sth = $Connection->db->prepare($query);
416
-		    $sth->execute();
417
-    		} catch(PDOException $e) {
418
-		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
-    		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
-        	try {
422
-            	    $sth = $Connection->db->prepare($query);
423
-		    $sth->execute();
424
-    		} catch(PDOException $e) {
425
-		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
-    		}
427
-    		if ($globalDBdriver == 'mysql') {
428
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
-		    try {
430
-            		$sth = $Connection->db->prepare($query);
431
-			$sth->execute();
432
-    		    } catch(PDOException $e) {
412
+			$Connection = new Connection();
413
+			$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
+			try {
415
+					$sth = $Connection->db->prepare($query);
416
+			$sth->execute();
417
+			} catch(PDOException $e) {
418
+			return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
+			}
420
+			$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
+			try {
422
+					$sth = $Connection->db->prepare($query);
423
+			$sth->execute();
424
+			} catch(PDOException $e) {
425
+			return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
+			}
427
+			if ($globalDBdriver == 'mysql') {
428
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
+			try {
430
+					$sth = $Connection->db->prepare($query);
431
+			$sth->execute();
432
+				} catch(PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434
-    		    }
435
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
436
-    		    if ($row['engine'] == 'ARCHIVE') {
434
+				}
435
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
436
+				if ($row['engine'] == 'ARCHIVE') {
437 437
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
438 438
 				ALTER TABLE copy ENGINE=ARCHIVE;
439 439
 				ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE;
440 440
 				INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`;
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443
-            	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
-            	    }
446
-                } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
-                }
449
-        	try {
450
-            	    $sth = $Connection->db->prepare($query);
451
-		    $sth->execute();
452
-    		} catch(PDOException $e) {
453
-		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
-    		}
443
+					} else {
444
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
+					}
446
+				} else {
447
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
+				}
449
+			try {
450
+					$sth = $Connection->db->prepare($query);
451
+			$sth->execute();
452
+			} catch(PDOException $e) {
453
+			return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
+			}
455 455
 
456 456
 		$error = '';
457 457
 		
458 458
 		$query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'";
459
-        	try {
460
-            	    $sth = $Connection->db->prepare($query);
461
-		    $sth->execute();
462
-    		} catch(PDOException $e) {
463
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
464
-    		}
459
+			try {
460
+					$sth = $Connection->db->prepare($query);
461
+			$sth->execute();
462
+			} catch(PDOException $e) {
463
+			return "error (update schema_version) : ".$e->getMessage()."\n";
464
+			}
465 465
 		return $error;
466 466
 	}
467 467
 	private static function update_from_12() {
468
-    		$Connection = new Connection();
468
+			$Connection = new Connection();
469 469
 		$error = '';
470
-    		// Add tables
470
+			// Add tables
471 471
 		$error .= create_db::import_file('../db/stats.sql');
472 472
 		if ($error != '') return $error;
473 473
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
@@ -484,166 +484,166 @@  discard block
 block discarded – undo
484 484
 		if ($error != '') return $error;
485 485
 		
486 486
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487
-        	try {
488
-            	    $sth = $Connection->db->prepare($query);
489
-		    $sth->execute();
490
-    		} catch(PDOException $e) {
491
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
492
-    		}
487
+			try {
488
+					$sth = $Connection->db->prepare($query);
489
+			$sth->execute();
490
+			} catch(PDOException $e) {
491
+			return "error (update schema_version) : ".$e->getMessage()."\n";
492
+			}
493 493
 		return $error;
494 494
 	}
495 495
 
496 496
 	private static function update_from_13() {
497
-    		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
497
+			$Connection = new Connection();
498
+			if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
+				$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+				} catch(PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505
-    			}
505
+				}
506 506
 		}
507
-    		$error = '';
507
+			$error = '';
508 508
 		$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'";
509
-        	try {
510
-            	    $sth = $Connection->db->prepare($query);
511
-		    $sth->execute();
512
-    		} catch(PDOException $e) {
513
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
514
-    		}
509
+			try {
510
+					$sth = $Connection->db->prepare($query);
511
+			$sth->execute();
512
+			} catch(PDOException $e) {
513
+			return "error (update schema_version) : ".$e->getMessage()."\n";
514
+			}
515 515
 		return $error;
516 516
 	}
517 517
 
518 518
 	private static function update_from_14() {
519
-    		$Connection = new Connection();
519
+			$Connection = new Connection();
520 520
 		$error = '';
521
-    		// Add tables
522
-    		if (!$Connection->tableExists('stats_flight')) {
521
+			// Add tables
522
+			if (!$Connection->tableExists('stats_flight')) {
523 523
 			$error .= create_db::import_file('../db/stats_flight.sql');
524 524
 			if ($error != '') return $error;
525 525
 		}
526 526
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527
-        	try {
528
-            	    $sth = $Connection->db->prepare($query);
529
-		    $sth->execute();
530
-    		} catch(PDOException $e) {
531
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
532
-    		}
527
+			try {
528
+					$sth = $Connection->db->prepare($query);
529
+			$sth->execute();
530
+			} catch(PDOException $e) {
531
+			return "error (update schema_version) : ".$e->getMessage()."\n";
532
+			}
533 533
 		return $error;
534 534
 	}
535 535
 
536 536
 
537 537
 	private static function update_from_15() {
538
-    		$Connection = new Connection();
538
+			$Connection = new Connection();
539 539
 		$error = '';
540
-    		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
-        	try {
543
-            	    $sth = $Connection->db->prepare($query);
544
-		    $sth->execute();
545
-    		} catch(PDOException $e) {
546
-		    return "error (update stats) : ".$e->getMessage()."\n";
547
-    		}
540
+			// Add tables
541
+			$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
+			try {
543
+					$sth = $Connection->db->prepare($query);
544
+			$sth->execute();
545
+			} catch(PDOException $e) {
546
+			return "error (update stats) : ".$e->getMessage()."\n";
547
+			}
548 548
 		if ($error != '') return $error;
549 549
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550
-        	try {
551
-            	    $sth = $Connection->db->prepare($query);
552
-		    $sth->execute();
553
-    		} catch(PDOException $e) {
554
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
555
-    		}
550
+			try {
551
+					$sth = $Connection->db->prepare($query);
552
+			$sth->execute();
553
+			} catch(PDOException $e) {
554
+			return "error (update schema_version) : ".$e->getMessage()."\n";
555
+			}
556 556
 		return $error;
557 557
 	}
558 558
 
559 559
 	private static function update_from_16() {
560
-    		$Connection = new Connection();
560
+			$Connection = new Connection();
561 561
 		$error = '';
562
-    		// Add tables
563
-    		if (!$Connection->tableExists('stats_registration')) {
562
+			// Add tables
563
+			if (!$Connection->tableExists('stats_registration')) {
564 564
 			$error .= create_db::import_file('../db/stats_registration.sql');
565 565
 		}
566
-    		if (!$Connection->tableExists('stats_callsign')) {
566
+			if (!$Connection->tableExists('stats_callsign')) {
567 567
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 568
 		}
569 569
 		if ($error != '') return $error;
570 570
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571
-        	try {
572
-            	    $sth = $Connection->db->prepare($query);
573
-		    $sth->execute();
574
-    		} catch(PDOException $e) {
575
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
576
-    		}
571
+			try {
572
+					$sth = $Connection->db->prepare($query);
573
+			$sth->execute();
574
+			} catch(PDOException $e) {
575
+			return "error (update schema_version) : ".$e->getMessage()."\n";
576
+			}
577 577
 		return $error;
578 578
 	}
579 579
 
580 580
 	private static function update_from_17() {
581
-    		$Connection = new Connection();
581
+			$Connection = new Connection();
582 582
 		$error = '';
583
-    		// Add tables
584
-    		if (!$Connection->tableExists('stats_country')) {
583
+			// Add tables
584
+			if (!$Connection->tableExists('stats_country')) {
585 585
 			$error .= create_db::import_file('../db/stats_country.sql');
586 586
 		}
587 587
 		if ($error != '') return $error;
588 588
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589
-        	try {
590
-            	    $sth = $Connection->db->prepare($query);
591
-		    $sth->execute();
592
-    		} catch(PDOException $e) {
593
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
594
-    		}
589
+			try {
590
+					$sth = $Connection->db->prepare($query);
591
+			$sth->execute();
592
+			} catch(PDOException $e) {
593
+			return "error (update schema_version) : ".$e->getMessage()."\n";
594
+			}
595 595
 		return $error;
596 596
 	}
597 597
 	private static function update_from_18() {
598
-    		$Connection = new Connection();
598
+			$Connection = new Connection();
599 599
 		$error = '';
600
-    		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
-    			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
-    	        	try {
604
-	            	    $sth = $Connection->db->prepare($query);
605
-			    $sth->execute();
606
-    			} catch(PDOException $e) {
607
-			    return "error (update stats) : ".$e->getMessage()."\n";
608
-    			}
609
-    		}
600
+			// Modify stats_airport table
601
+			if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
+				$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
+					try {
604
+						$sth = $Connection->db->prepare($query);
605
+				$sth->execute();
606
+				} catch(PDOException $e) {
607
+				return "error (update stats) : ".$e->getMessage()."\n";
608
+				}
609
+			}
610 610
 		if ($error != '') return $error;
611 611
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612
-        	try {
613
-            	    $sth = $Connection->db->prepare($query);
614
-		    $sth->execute();
615
-    		} catch(PDOException $e) {
616
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
617
-    		}
612
+			try {
613
+					$sth = $Connection->db->prepare($query);
614
+			$sth->execute();
615
+			} catch(PDOException $e) {
616
+			return "error (update schema_version) : ".$e->getMessage()."\n";
617
+			}
618 618
 		return $error;
619 619
 	}
620 620
 
621 621
 	private static function update_from_19() {
622
-    		$Connection = new Connection();
622
+			$Connection = new Connection();
623 623
 		$error = '';
624
-    		// Update airport table
624
+			// Update airport table
625 625
 		$error .= create_db::import_file('../db/airport.sql');
626 626
 		if ($error != '') return 'Import airport.sql : '.$error;
627 627
 		// Remove primary key on Spotter_Archive
628 628
 		$query = "alter table spotter_archive drop spotter_archive_id";
629
-        	try {
630
-            	    $sth = $Connection->db->prepare($query);
631
-		    $sth->execute();
632
-    		} catch(PDOException $e) {
633
-		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
-    		}
629
+			try {
630
+					$sth = $Connection->db->prepare($query);
631
+			$sth->execute();
632
+			} catch(PDOException $e) {
633
+			return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
+			}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636
-        	try {
637
-            	    $sth = $Connection->db->prepare($query);
638
-		    $sth->execute();
639
-    		} catch(PDOException $e) {
640
-		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
-    		}
636
+			try {
637
+					$sth = $Connection->db->prepare($query);
638
+			$sth->execute();
639
+			} catch(PDOException $e) {
640
+			return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
+			}
642 642
 		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
643 643
 			// Add column over_country
644
-    			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
644
+				$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646
-            			$sth = $Connection->db->prepare($query);
646
+						$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648 648
 			} catch(PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 		if (!$Connection->checkColumnName('spotter_live','over_country')) {
653 653
 			// Add column over_country
654
-    			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
654
+				$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656
-            			$sth = $Connection->db->prepare($query);
656
+						$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658 658
 			} catch(PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -661,74 +661,74 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 		if (!$Connection->checkColumnName('spotter_output','source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664
-    			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
664
+				$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668 668
 			} catch(PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670
-    			}
671
-    		}
670
+				}
671
+			}
672 672
 		if (!$Connection->checkColumnName('spotter_live','source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674
-    			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
674
+				$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678 678
 			} catch(PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680
-    			}
681
-    		}
680
+				}
681
+			}
682 682
 		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684
-    			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
684
+				$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688 688
 			} catch(PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690
-    			}
691
-    		}
690
+				}
691
+			}
692 692
 		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694
-    			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
694
+				$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698 698
 			} catch(PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700
-    			}
701
-    		}
700
+				}
701
+			}
702 702
 		if ($error != '') return $error;
703 703
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704
-        	try {
705
-            	    $sth = $Connection->db->prepare($query);
706
-		    $sth->execute();
707
-    		} catch(PDOException $e) {
708
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
709
-    		}
704
+			try {
705
+					$sth = $Connection->db->prepare($query);
706
+			$sth->execute();
707
+			} catch(PDOException $e) {
708
+			return "error (update schema_version) : ".$e->getMessage()."\n";
709
+			}
710 710
 		return $error;
711 711
 	}
712 712
 
713 713
 	private static function update_from_20() {
714 714
 		global $globalIVAO, $globalVATSIM, $globalphpVMS;
715
-    		$Connection = new Connection();
715
+			$Connection = new Connection();
716 716
 		$error = '';
717
-    		// Update airline table
718
-    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
717
+			// Update airline table
718
+			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722 722
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 723
 			// Add column over_country
724
-    			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
-        		try {
724
+				$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
+				try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728 728
 			} catch(PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730
-    			}
731
-    		}
730
+				}
731
+			}
732 732
 		if ($error != '') return $error;
733 733
 		/*
734 734
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		*/
740 740
 		$query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'";
741
-        	try {
742
-            	    $sth = $Connection->db->prepare($query);
743
-		    $sth->execute();
744
-    		} catch(PDOException $e) {
745
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
746
-    		}
741
+			try {
742
+					$sth = $Connection->db->prepare($query);
743
+			$sth->execute();
744
+			} catch(PDOException $e) {
745
+			return "error (update schema_version) : ".$e->getMessage()."\n";
746
+			}
747 747
 		return $error;
748 748
 	}
749 749
 
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 			if ($error != '') return $error;
763 763
 		}
764 764
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765
-        	try {
766
-            	    $sth = $Connection->db->prepare($query);
767
-		    $sth->execute();
768
-    		} catch(PDOException $e) {
769
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
770
-    		}
765
+			try {
766
+					$sth = $Connection->db->prepare($query);
767
+			$sth->execute();
768
+			} catch(PDOException $e) {
769
+			return "error (update schema_version) : ".$e->getMessage()."\n";
770
+			}
771 771
 		return $error;
772 772
 	}
773 773
 
774 774
 	private static function update_from_22() {
775 775
 		global $globalDBdriver;
776
-    		$Connection = new Connection();
776
+			$Connection = new Connection();
777 777
 		$error = '';
778 778
 		// Add table stats polar
779
-    		if (!$Connection->tableExists('stats_source')) {
779
+			if (!$Connection->tableExists('stats_source')) {
780 780
 			if ($globalDBdriver == 'mysql') {
781
-    				$error .= create_db::import_file('../db/stats_source.sql');
781
+					$error .= create_db::import_file('../db/stats_source.sql');
782 782
 			} else {
783 783
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 784
 			}
785 785
 			if ($error != '') return $error;
786 786
 		}
787 787
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788
-        	try {
789
-            	    $sth = $Connection->db->prepare($query);
790
-		    $sth->execute();
791
-    		} catch(PDOException $e) {
792
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
793
-    		}
788
+			try {
789
+					$sth = $Connection->db->prepare($query);
790
+			$sth->execute();
791
+			} catch(PDOException $e) {
792
+			return "error (update schema_version) : ".$e->getMessage()."\n";
793
+			}
794 794
 		return $error;
795 795
 	}
796 796
 
@@ -820,14 +820,14 @@  discard block
 block discarded – undo
820 820
 		}
821 821
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
822 822
 			// Add aircraft_manufacturer to stats_aircraft
823
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
823
+				$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824 824
 			try {
825 825
 				$sth = $Connection->db->prepare($query);
826 826
 				$sth->execute();
827 827
 			} catch(PDOException $e) {
828 828
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
829
-    			}
830
-    		}
829
+				}
830
+			}
831 831
 		
832 832
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
833 833
 		try {
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 			} catch(PDOException $e) {
1176 1176
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1177 1177
 			}
1178
-                }
1178
+				}
1179 1179
 		if (!$Connection->checkColumnName('aircraft','mfr')) {
1180 1180
 			// Add mfr to aircraft
1181 1181
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 			} catch(PDOException $e) {
1250 1250
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1251 1251
 			}
1252
-                }
1252
+				}
1253 1253
 		if (!$Connection->indexExists('accidents','registration_idx')) {
1254 1254
 			// Add index key
1255 1255
 			$query = "create index registration_idx on accidents (registration)";
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
 			} catch(PDOException $e) {
1260 1260
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1261 1261
 			}
1262
-                }
1262
+				}
1263 1263
 		if (!$Connection->indexExists('accidents','rdts')) {
1264 1264
 			// Add index key
1265 1265
 			$query = "create index rdts on accidents (registration,date,type,source)";
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
 			} catch(PDOException $e) {
1270 1270
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1271 1271
 			}
1272
-                }
1272
+				}
1273 1273
 
1274 1274
 		$query = "UPDATE config SET value = '31' WHERE name = 'schema_version'";
1275 1275
 		try {
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
 			} catch(PDOException $e) {
1562 1562
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1563 1563
 			}
1564
-                }
1564
+				}
1565 1565
 		$query = "UPDATE config SET value = '36' WHERE name = 'schema_version'";
1566 1566
 		try {
1567 1567
 			$sth = $Connection->db->prepare($query);
@@ -1722,7 +1722,7 @@  discard block
 block discarded – undo
1722 1722
 			} catch(PDOException $e) {
1723 1723
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1724 1724
 			}
1725
-                }
1725
+				}
1726 1726
 		$query = "UPDATE config SET value = '38' WHERE name = 'schema_version'";
1727 1727
 		try {
1728 1728
 			$sth = $Connection->db->prepare($query);
Please login to merge, or discard this patch.
Spacing   +248 added lines, -248 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -814,17 +814,17 @@  discard block
 block discarded – undo
814 814
 			try {
815 815
 				$sth = $Connection->db->prepare($query);
816 816
 				$sth->execute();
817
-			} catch(PDOException $e) {
817
+			} catch (PDOException $e) {
818 818
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
819 819
 			}
820 820
 		}
821
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
821
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
822 822
 			// Add aircraft_manufacturer to stats_aircraft
823 823
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824 824
 			try {
825 825
 				$sth = $Connection->db->prepare($query);
826 826
 				$sth->execute();
827
-			} catch(PDOException $e) {
827
+			} catch (PDOException $e) {
828 828
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
829 829
     			}
830 830
     		}
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 		try {
834 834
 			$sth = $Connection->db->prepare($query);
835 835
 			$sth->execute();
836
-		} catch(PDOException $e) {
836
+		} catch (PDOException $e) {
837 837
 			return "error (update schema_version) : ".$e->getMessage()."\n";
838 838
 		}
839 839
 		return $error;
@@ -849,23 +849,23 @@  discard block
 block discarded – undo
849 849
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 850
 		}
851 851
 		if ($error != '') return 'Import airlines.sql : '.$error;
852
-		if (!$Connection->checkColumnName('airlines','forsource')) {
852
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
853 853
 			// Add forsource to airlines
854 854
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
855 855
 			try {
856 856
 				$sth = $Connection->db->prepare($query);
857 857
 				$sth->execute();
858
-			} catch(PDOException $e) {
858
+			} catch (PDOException $e) {
859 859
 				return "error (add forsource column) : ".$e->getMessage()."\n";
860 860
 			}
861 861
 		}
862
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
862
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
863 863
 			// Add forsource to airlines
864 864
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
865 865
 			try {
866 866
 				$sth = $Connection->db->prepare($query);
867 867
 				$sth->execute();
868
-			} catch(PDOException $e) {
868
+			} catch (PDOException $e) {
869 869
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
870 870
 			}
871 871
 			// Add unique key
@@ -877,17 +877,17 @@  discard block
 block discarded – undo
877 877
 			try {
878 878
 				$sth = $Connection->db->prepare($query);
879 879
 				$sth->execute();
880
-			} catch(PDOException $e) {
880
+			} catch (PDOException $e) {
881 881
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
882 882
 			}
883 883
 		}
884
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
884
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
885 885
 			// Add forsource to airlines
886 886
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
887 887
 			try {
888 888
 				$sth = $Connection->db->prepare($query);
889 889
 				$sth->execute();
890
-			} catch(PDOException $e) {
890
+			} catch (PDOException $e) {
891 891
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
892 892
 			}
893 893
 			// Add unique key
@@ -899,17 +899,17 @@  discard block
 block discarded – undo
899 899
 			try {
900 900
 				$sth = $Connection->db->prepare($query);
901 901
 				$sth->execute();
902
-			} catch(PDOException $e) {
902
+			} catch (PDOException $e) {
903 903
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
904 904
 			}
905 905
 		}
906
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
906
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
907 907
 			// Add forsource to airlines
908 908
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
909 909
 			try {
910 910
 				$sth = $Connection->db->prepare($query);
911 911
 				$sth->execute();
912
-			} catch(PDOException $e) {
912
+			} catch (PDOException $e) {
913 913
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
914 914
 			}
915 915
 			// Add unique key
@@ -921,36 +921,36 @@  discard block
 block discarded – undo
921 921
 			try {
922 922
 				$sth = $Connection->db->prepare($query);
923 923
 				$sth->execute();
924
-			} catch(PDOException $e) {
924
+			} catch (PDOException $e) {
925 925
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
926 926
 			}
927 927
 		}
928
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
928
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
929 929
 			// Add forsource to airlines
930 930
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
931 931
 			try {
932 932
 				$sth = $Connection->db->prepare($query);
933 933
 				$sth->execute();
934
-			} catch(PDOException $e) {
934
+			} catch (PDOException $e) {
935 935
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
936 936
 			}
937 937
 		}
938
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
938
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
939 939
 			// Add forsource to airlines
940 940
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
941 941
 			try {
942 942
 				$sth = $Connection->db->prepare($query);
943 943
 				$sth->execute();
944
-			} catch(PDOException $e) {
944
+			} catch (PDOException $e) {
945 945
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
946 946
 			}
947
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
947
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
948 948
 				// Add unique key
949 949
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
950 950
 				try {
951 951
 					$sth = $Connection->db->prepare($query);
952 952
 					$sth->execute();
953
-				} catch(PDOException $e) {
953
+				} catch (PDOException $e) {
954 954
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
955 955
 				}
956 956
 			} else {
@@ -963,18 +963,18 @@  discard block
 block discarded – undo
963 963
 				try {
964 964
 					$sth = $Connection->db->prepare($query);
965 965
 					$sth->execute();
966
-				} catch(PDOException $e) {
966
+				} catch (PDOException $e) {
967 967
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
968 968
 				}
969 969
 			}
970 970
 		}
971
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
971
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
972 972
 			// Add forsource to airlines
973 973
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
974 974
 			try {
975 975
 				$sth = $Connection->db->prepare($query);
976 976
 				$sth->execute();
977
-			} catch(PDOException $e) {
977
+			} catch (PDOException $e) {
978 978
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
979 979
 			}
980 980
 			// Add unique key
@@ -986,17 +986,17 @@  discard block
 block discarded – undo
986 986
 			try {
987 987
 				$sth = $Connection->db->prepare($query);
988 988
 				$sth->execute();
989
-			} catch(PDOException $e) {
989
+			} catch (PDOException $e) {
990 990
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
991 991
 			}
992 992
 		}
993
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
993
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
994 994
 			// Add forsource to airlines
995 995
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
996 996
 			try {
997 997
 				$sth = $Connection->db->prepare($query);
998 998
 				$sth->execute();
999
-			} catch(PDOException $e) {
999
+			} catch (PDOException $e) {
1000 1000
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1001 1001
 			}
1002 1002
 			// Add unique key
@@ -1008,17 +1008,17 @@  discard block
 block discarded – undo
1008 1008
 			try {
1009 1009
 				$sth = $Connection->db->prepare($query);
1010 1010
 				$sth->execute();
1011
-			} catch(PDOException $e) {
1011
+			} catch (PDOException $e) {
1012 1012
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1013 1013
 			}
1014 1014
 		}
1015
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1015
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1016 1016
 			// Add forsource to airlines
1017 1017
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1018 1018
 			try {
1019 1019
 				$sth = $Connection->db->prepare($query);
1020 1020
 				$sth->execute();
1021
-			} catch(PDOException $e) {
1021
+			} catch (PDOException $e) {
1022 1022
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1023 1023
 			}
1024 1024
 			// Add unique key
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 			try {
1031 1031
 				$sth = $Connection->db->prepare($query);
1032 1032
 				$sth->execute();
1033
-			} catch(PDOException $e) {
1033
+			} catch (PDOException $e) {
1034 1034
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1035 1035
 			}
1036 1036
 		}
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 		try {
1040 1040
 			$sth = $Connection->db->prepare($query);
1041 1041
 			$sth->execute();
1042
-		} catch(PDOException $e) {
1042
+		} catch (PDOException $e) {
1043 1043
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1044 1044
 		}
1045 1045
 		return $error;
@@ -1049,13 +1049,13 @@  discard block
 block discarded – undo
1049 1049
 		global $globalDBdriver;
1050 1050
 		$Connection = new Connection();
1051 1051
 		$error = '';
1052
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1052
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1053 1053
 			// Add forsource to airlines
1054 1054
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1055 1055
 			try {
1056 1056
 				$sth = $Connection->db->prepare($query);
1057 1057
 				$sth->execute();
1058
-			} catch(PDOException $e) {
1058
+			} catch (PDOException $e) {
1059 1059
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1060 1060
 			}
1061 1061
 			// Add unique key
@@ -1067,17 +1067,17 @@  discard block
 block discarded – undo
1067 1067
 			try {
1068 1068
 				$sth = $Connection->db->prepare($query);
1069 1069
 				$sth->execute();
1070
-			} catch(PDOException $e) {
1070
+			} catch (PDOException $e) {
1071 1071
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1072 1072
 			}
1073 1073
 		}
1074
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1074
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1075 1075
 			// Add forsource to airlines
1076 1076
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1077 1077
 			try {
1078 1078
 				$sth = $Connection->db->prepare($query);
1079 1079
 				$sth->execute();
1080
-			} catch(PDOException $e) {
1080
+			} catch (PDOException $e) {
1081 1081
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1082 1082
 			}
1083 1083
 			// Add unique key
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 			try {
1090 1090
 				$sth = $Connection->db->prepare($query);
1091 1091
 				$sth->execute();
1092
-			} catch(PDOException $e) {
1092
+			} catch (PDOException $e) {
1093 1093
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1094 1094
 			}
1095 1095
 		}
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 		try {
1098 1098
 			$sth = $Connection->db->prepare($query);
1099 1099
 			$sth->execute();
1100
-		} catch(PDOException $e) {
1100
+		} catch (PDOException $e) {
1101 1101
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1102 1102
 		}
1103 1103
 		return $error;
@@ -1107,12 +1107,12 @@  discard block
 block discarded – undo
1107 1107
 		global $globalDBdriver;
1108 1108
 		$Connection = new Connection();
1109 1109
 		$error = '';
1110
-		if (!$Connection->checkColumnName('atc','format_source')) {
1110
+		if (!$Connection->checkColumnName('atc', 'format_source')) {
1111 1111
 			$query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL";
1112 1112
 			try {
1113 1113
 				$sth = $Connection->db->prepare($query);
1114 1114
 				$sth->execute();
1115
-			} catch(PDOException $e) {
1115
+			} catch (PDOException $e) {
1116 1116
 				return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n";
1117 1117
 			}
1118 1118
 		}
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 		try {
1121 1121
 			$sth = $Connection->db->prepare($query);
1122 1122
 			$sth->execute();
1123
-		} catch(PDOException $e) {
1123
+		} catch (PDOException $e) {
1124 1124
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1125 1125
 		}
1126 1126
 		return $error;
@@ -1130,13 +1130,13 @@  discard block
 block discarded – undo
1130 1130
 		global $globalDBdriver;
1131 1131
 		$Connection = new Connection();
1132 1132
 		$error = '';
1133
-		if (!$Connection->checkColumnName('stats_pilot','format_source')) {
1133
+		if (!$Connection->checkColumnName('stats_pilot', 'format_source')) {
1134 1134
 			// Add forsource to airlines
1135 1135
 			$query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''";
1136 1136
 			try {
1137 1137
 				$sth = $Connection->db->prepare($query);
1138 1138
 				$sth->execute();
1139
-			} catch(PDOException $e) {
1139
+			} catch (PDOException $e) {
1140 1140
 				return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n";
1141 1141
 			}
1142 1142
 			// Add unique key
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
 			try {
1149 1149
 				$sth = $Connection->db->prepare($query);
1150 1150
 				$sth->execute();
1151
-			} catch(PDOException $e) {
1151
+			} catch (PDOException $e) {
1152 1152
 				return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n";
1153 1153
 			}
1154 1154
 		}
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 		try {
1157 1157
 			$sth = $Connection->db->prepare($query);
1158 1158
 			$sth->execute();
1159
-		} catch(PDOException $e) {
1159
+		} catch (PDOException $e) {
1160 1160
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1161 1161
 		}
1162 1162
 		return $error;
@@ -1166,23 +1166,23 @@  discard block
 block discarded – undo
1166 1166
 		global $globalDBdriver;
1167 1167
 		$Connection = new Connection();
1168 1168
 		$error = '';
1169
-		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) {
1169
+		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) {
1170 1170
 			// Add unique key
1171 1171
 			$query = "alter table spotter_live add index(latitude,longitude)";
1172 1172
 			try {
1173 1173
 				$sth = $Connection->db->prepare($query);
1174 1174
 				$sth->execute();
1175
-			} catch(PDOException $e) {
1175
+			} catch (PDOException $e) {
1176 1176
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1177 1177
 			}
1178 1178
                 }
1179
-		if (!$Connection->checkColumnName('aircraft','mfr')) {
1179
+		if (!$Connection->checkColumnName('aircraft', 'mfr')) {
1180 1180
 			// Add mfr to aircraft
1181 1181
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
1182 1182
 			try {
1183 1183
 				$sth = $Connection->db->prepare($query);
1184 1184
 				$sth->execute();
1185
-			} catch(PDOException $e) {
1185
+			} catch (PDOException $e) {
1186 1186
 				return "error (add mfr column in aircraft) : ".$e->getMessage()."\n";
1187 1187
 			}
1188 1188
 		}
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
 		try {
1199 1199
 			$sth = $Connection->db->prepare($query);
1200 1200
 			$sth->execute();
1201
-		} catch(PDOException $e) {
1201
+		} catch (PDOException $e) {
1202 1202
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1203 1203
 		}
1204 1204
 		return $error;
@@ -1208,13 +1208,13 @@  discard block
 block discarded – undo
1208 1208
 		global $globalDBdriver;
1209 1209
 		$Connection = new Connection();
1210 1210
 		$error = '';
1211
-		if ($Connection->checkColumnName('aircraft','mfr')) {
1211
+		if ($Connection->checkColumnName('aircraft', 'mfr')) {
1212 1212
 			// drop mfr to aircraft
1213 1213
 			$query = "ALTER TABLE aircraft DROP COLUMN mfr";
1214 1214
 			try {
1215 1215
 				$sth = $Connection->db->prepare($query);
1216 1216
 				$sth->execute();
1217
-			} catch(PDOException $e) {
1217
+			} catch (PDOException $e) {
1218 1218
 				return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n";
1219 1219
 			}
1220 1220
 		}
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 		try {
1231 1231
 			$sth = $Connection->db->prepare($query);
1232 1232
 			$sth->execute();
1233
-		} catch(PDOException $e) {
1233
+		} catch (PDOException $e) {
1234 1234
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1235 1235
 		}
1236 1236
 		return $error;
@@ -1240,33 +1240,33 @@  discard block
 block discarded – undo
1240 1240
 		global $globalDBdriver;
1241 1241
 		$Connection = new Connection();
1242 1242
 		$error = '';
1243
-		if (!$Connection->indexExists('notam','ref_idx')) {
1243
+		if (!$Connection->indexExists('notam', 'ref_idx')) {
1244 1244
 			// Add index key
1245 1245
 			$query = "create index ref_idx on notam (ref)";
1246 1246
 			try {
1247 1247
 				$sth = $Connection->db->prepare($query);
1248 1248
 				$sth->execute();
1249
-			} catch(PDOException $e) {
1249
+			} catch (PDOException $e) {
1250 1250
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1251 1251
 			}
1252 1252
                 }
1253
-		if (!$Connection->indexExists('accidents','registration_idx')) {
1253
+		if (!$Connection->indexExists('accidents', 'registration_idx')) {
1254 1254
 			// Add index key
1255 1255
 			$query = "create index registration_idx on accidents (registration)";
1256 1256
 			try {
1257 1257
 				$sth = $Connection->db->prepare($query);
1258 1258
 				$sth->execute();
1259
-			} catch(PDOException $e) {
1259
+			} catch (PDOException $e) {
1260 1260
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1261 1261
 			}
1262 1262
                 }
1263
-		if (!$Connection->indexExists('accidents','rdts')) {
1263
+		if (!$Connection->indexExists('accidents', 'rdts')) {
1264 1264
 			// Add index key
1265 1265
 			$query = "create index rdts on accidents (registration,date,type,source)";
1266 1266
 			try {
1267 1267
 				$sth = $Connection->db->prepare($query);
1268 1268
 				$sth->execute();
1269
-			} catch(PDOException $e) {
1269
+			} catch (PDOException $e) {
1270 1270
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1271 1271
 			}
1272 1272
                 }
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
 		try {
1276 1276
 			$sth = $Connection->db->prepare($query);
1277 1277
 			$sth->execute();
1278
-		} catch(PDOException $e) {
1278
+		} catch (PDOException $e) {
1279 1279
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1280 1280
 		}
1281 1281
 		return $error;
@@ -1285,23 +1285,23 @@  discard block
 block discarded – undo
1285 1285
 		global $globalDBdriver;
1286 1286
 		$Connection = new Connection();
1287 1287
 		$error = '';
1288
-		if (!$Connection->checkColumnName('accidents','airline_name')) {
1288
+		if (!$Connection->checkColumnName('accidents', 'airline_name')) {
1289 1289
 			// Add airline_name to accidents
1290 1290
 			$query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL";
1291 1291
 			try {
1292 1292
 				$sth = $Connection->db->prepare($query);
1293 1293
 				$sth->execute();
1294
-			} catch(PDOException $e) {
1294
+			} catch (PDOException $e) {
1295 1295
 				return "error (add airline_name column in accidents) : ".$e->getMessage()."\n";
1296 1296
 			}
1297 1297
 		}
1298
-		if (!$Connection->checkColumnName('accidents','airline_icao')) {
1298
+		if (!$Connection->checkColumnName('accidents', 'airline_icao')) {
1299 1299
 			// Add airline_icao to accidents
1300 1300
 			$query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL";
1301 1301
 			try {
1302 1302
 				$sth = $Connection->db->prepare($query);
1303 1303
 				$sth->execute();
1304
-			} catch(PDOException $e) {
1304
+			} catch (PDOException $e) {
1305 1305
 				return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n";
1306 1306
 			}
1307 1307
 		}
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
 		try {
1310 1310
 			$sth = $Connection->db->prepare($query);
1311 1311
 			$sth->execute();
1312
-		} catch(PDOException $e) {
1312
+		} catch (PDOException $e) {
1313 1313
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1314 1314
 		}
1315 1315
 		return $error;
@@ -1319,13 +1319,13 @@  discard block
 block discarded – undo
1319 1319
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1320 1320
 		$Connection = new Connection();
1321 1321
 		$error = '';
1322
-		if (!$Connection->checkColumnName('airlines','alliance')) {
1322
+		if (!$Connection->checkColumnName('airlines', 'alliance')) {
1323 1323
 			// Add alliance to airlines
1324 1324
 			$query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL";
1325 1325
 			try {
1326 1326
 				$sth = $Connection->db->prepare($query);
1327 1327
 				$sth->execute();
1328
-			} catch(PDOException $e) {
1328
+			} catch (PDOException $e) {
1329 1329
 				return "error (add alliance column in airlines) : ".$e->getMessage()."\n";
1330 1330
 			}
1331 1331
 		}
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
 		try {
1353 1353
 			$sth = $Connection->db->prepare($query);
1354 1354
 			$sth->execute();
1355
-		} catch(PDOException $e) {
1355
+		} catch (PDOException $e) {
1356 1356
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1357 1357
 		}
1358 1358
 		return $error;
@@ -1362,13 +1362,13 @@  discard block
 block discarded – undo
1362 1362
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1363 1363
 		$Connection = new Connection();
1364 1364
 		$error = '';
1365
-		if (!$Connection->checkColumnName('airlines','ban_eu')) {
1365
+		if (!$Connection->checkColumnName('airlines', 'ban_eu')) {
1366 1366
 			// Add ban_eu to airlines
1367 1367
 			$query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'";
1368 1368
 			try {
1369 1369
 				$sth = $Connection->db->prepare($query);
1370 1370
 				$sth->execute();
1371
-			} catch(PDOException $e) {
1371
+			} catch (PDOException $e) {
1372 1372
 				return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n";
1373 1373
 			}
1374 1374
 		}
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 		try {
1377 1377
 			$sth = $Connection->db->prepare($query);
1378 1378
 			$sth->execute();
1379
-		} catch(PDOException $e) {
1379
+		} catch (PDOException $e) {
1380 1380
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1381 1381
 		}
1382 1382
 		return $error;
@@ -1387,19 +1387,19 @@  discard block
 block discarded – undo
1387 1387
 		$Connection = new Connection();
1388 1388
 		$error = '';
1389 1389
 		if ($globalDBdriver == 'mysql') {
1390
-			if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') {
1390
+			if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') {
1391 1391
 				$query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL";
1392 1392
 				try {
1393 1393
 					$sth = $Connection->db->prepare($query);
1394 1394
 					$sth->execute();
1395
-				} catch(PDOException $e) {
1395
+				} catch (PDOException $e) {
1396 1396
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1397 1397
 				}
1398 1398
 				$query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1399 1399
 				try {
1400 1400
 					$sth = $Connection->db->prepare($query);
1401 1401
 					$sth->execute();
1402
-				} catch(PDOException $e) {
1402
+				} catch (PDOException $e) {
1403 1403
 					return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n";
1404 1404
 				}
1405 1405
 				
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 				try {
1408 1408
 					$sth = $Connection->db->prepare($query);
1409 1409
 					$sth->execute();
1410
-				} catch(PDOException $e) {
1410
+				} catch (PDOException $e) {
1411 1411
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1412 1412
 				}
1413 1413
 				/*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150";
@@ -1458,7 +1458,7 @@  discard block
 block discarded – undo
1458 1458
 				try {
1459 1459
 					$sth = $Connection->db->prepare($query);
1460 1460
 					$sth->execute();
1461
-				} catch(PDOException $e) {
1461
+				} catch (PDOException $e) {
1462 1462
 					return "error (fix date) : ".$e->getMessage()."\n";
1463 1463
 				}
1464 1464
 			}
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
 		try {
1544 1544
 			$sth = $Connection->db->prepare($query);
1545 1545
 			$sth->execute();
1546
-		} catch(PDOException $e) {
1546
+		} catch (PDOException $e) {
1547 1547
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1548 1548
 		}
1549 1549
 		return $error;
@@ -1552,13 +1552,13 @@  discard block
 block discarded – undo
1552 1552
 		global $globalDBdriver;
1553 1553
 		$Connection = new Connection();
1554 1554
 		$error = '';
1555
-		if (!$Connection->indexExists('accidents','type')) {
1555
+		if (!$Connection->indexExists('accidents', 'type')) {
1556 1556
 			// Add index key
1557 1557
 			$query = "create index type on accidents (type,date)";
1558 1558
 			try {
1559 1559
 				$sth = $Connection->db->prepare($query);
1560 1560
 				$sth->execute();
1561
-			} catch(PDOException $e) {
1561
+			} catch (PDOException $e) {
1562 1562
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1563 1563
 			}
1564 1564
                 }
@@ -1566,7 +1566,7 @@  discard block
 block discarded – undo
1566 1566
 		try {
1567 1567
 			$sth = $Connection->db->prepare($query);
1568 1568
 			$sth->execute();
1569
-		} catch(PDOException $e) {
1569
+		} catch (PDOException $e) {
1570 1570
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1571 1571
 		}
1572 1572
 		return $error;
@@ -1576,12 +1576,12 @@  discard block
 block discarded – undo
1576 1576
 		global $globalDBdriver;
1577 1577
 		$Connection = new Connection();
1578 1578
 		$error = '';
1579
-		if (!$Connection->checkColumnName('aircraft_modes','source_type')) {
1579
+		if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) {
1580 1580
 			$query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'";
1581 1581
 			try {
1582 1582
 				$sth = $Connection->db->prepare($query);
1583 1583
 				$sth->execute();
1584
-			} catch(PDOException $e) {
1584
+			} catch (PDOException $e) {
1585 1585
 				return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n";
1586 1586
 			}
1587 1587
 		}
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
 		try {
1648 1648
 			$sth = $Connection->db->prepare($query);
1649 1649
 			$sth->execute();
1650
-		} catch(PDOException $e) {
1650
+		} catch (PDOException $e) {
1651 1651
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1652 1652
 		}
1653 1653
 		return $error;
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
 			try {
1700 1700
 				$sth = $Connection->db->prepare($query);
1701 1701
 				$sth->execute();
1702
-			} catch(PDOException $e) {
1702
+			} catch (PDOException $e) {
1703 1703
 				return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
1704 1704
 			}
1705 1705
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1708,18 +1708,18 @@  discard block
 block discarded – undo
1708 1708
 				try {
1709 1709
 					$sth = $Connection->db->prepare($query);
1710 1710
 					$sth->execute();
1711
-				} catch(PDOException $e) {
1711
+				} catch (PDOException $e) {
1712 1712
 					return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n";
1713 1713
 				}
1714 1714
 			}
1715 1715
 		}
1716
-		if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) {
1716
+		if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) {
1717 1717
 			// Add index key
1718 1718
 			$query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)";
1719 1719
 			try {
1720 1720
 				$sth = $Connection->db->prepare($query);
1721 1721
 				$sth->execute();
1722
-			} catch(PDOException $e) {
1722
+			} catch (PDOException $e) {
1723 1723
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1724 1724
 			}
1725 1725
                 }
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
 		try {
1728 1728
 			$sth = $Connection->db->prepare($query);
1729 1729
 			$sth->execute();
1730
-		} catch(PDOException $e) {
1730
+		} catch (PDOException $e) {
1731 1731
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1732 1732
 		}
1733 1733
 		return $error;
@@ -1738,148 +1738,148 @@  discard block
 block discarded – undo
1738 1738
 		$Connection = new Connection();
1739 1739
 		$error = '';
1740 1740
 		if ($globalDBdriver == 'mysql') {
1741
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1741
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1742 1742
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL";
1743 1743
 				try {
1744 1744
 					$sth = $Connection->db->prepare($query);
1745 1745
 					$sth->execute();
1746
-				} catch(PDOException $e) {
1746
+				} catch (PDOException $e) {
1747 1747
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1748 1748
 				}
1749 1749
 			}
1750
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1750
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1751 1751
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL";
1752 1752
 				try {
1753 1753
 					$sth = $Connection->db->prepare($query);
1754 1754
 					$sth->execute();
1755
-				} catch(PDOException $e) {
1755
+				} catch (PDOException $e) {
1756 1756
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1757 1757
 				}
1758 1758
 			}
1759
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1759
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1760 1760
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL";
1761 1761
 				try {
1762 1762
 					$sth = $Connection->db->prepare($query);
1763 1763
 					$sth->execute();
1764
-				} catch(PDOException $e) {
1764
+				} catch (PDOException $e) {
1765 1765
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1766 1766
 				}
1767 1767
 			}
1768
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1768
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1769 1769
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL";
1770 1770
 				try {
1771 1771
 					$sth = $Connection->db->prepare($query);
1772 1772
 					$sth->execute();
1773
-				} catch(PDOException $e) {
1773
+				} catch (PDOException $e) {
1774 1774
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1775 1775
 				}
1776 1776
 			}
1777
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1777
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1778 1778
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL";
1779 1779
 				try {
1780 1780
 					$sth = $Connection->db->prepare($query);
1781 1781
 					$sth->execute();
1782
-				} catch(PDOException $e) {
1782
+				} catch (PDOException $e) {
1783 1783
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1784 1784
 				}
1785 1785
 			}
1786
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1786
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1787 1787
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL";
1788 1788
 				try {
1789 1789
 					$sth = $Connection->db->prepare($query);
1790 1790
 					$sth->execute();
1791
-				} catch(PDOException $e) {
1791
+				} catch (PDOException $e) {
1792 1792
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1793 1793
 				}
1794 1794
 			}
1795
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1795
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1796 1796
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL";
1797 1797
 				try {
1798 1798
 					$sth = $Connection->db->prepare($query);
1799 1799
 					$sth->execute();
1800
-				} catch(PDOException $e) {
1800
+				} catch (PDOException $e) {
1801 1801
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1802 1802
 				}
1803 1803
 			}
1804
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1804
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1805 1805
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL";
1806 1806
 				try {
1807 1807
 					$sth = $Connection->db->prepare($query);
1808 1808
 					$sth->execute();
1809
-				} catch(PDOException $e) {
1809
+				} catch (PDOException $e) {
1810 1810
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1811 1811
 				}
1812 1812
 			}
1813 1813
 		} else {
1814
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1814
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1815 1815
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL";
1816 1816
 				try {
1817 1817
 					$sth = $Connection->db->prepare($query);
1818 1818
 					$sth->execute();
1819
-				} catch(PDOException $e) {
1819
+				} catch (PDOException $e) {
1820 1820
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1821 1821
 				}
1822 1822
 			}
1823
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1823
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1824 1824
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL";
1825 1825
 				try {
1826 1826
 					$sth = $Connection->db->prepare($query);
1827 1827
 					$sth->execute();
1828
-				} catch(PDOException $e) {
1828
+				} catch (PDOException $e) {
1829 1829
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1830 1830
 				}
1831 1831
 			}
1832
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1832
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1833 1833
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL";
1834 1834
 				try {
1835 1835
 					$sth = $Connection->db->prepare($query);
1836 1836
 					$sth->execute();
1837
-				} catch(PDOException $e) {
1837
+				} catch (PDOException $e) {
1838 1838
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1839 1839
 				}
1840 1840
 			}
1841
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1841
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1842 1842
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL";
1843 1843
 				try {
1844 1844
 					$sth = $Connection->db->prepare($query);
1845 1845
 					$sth->execute();
1846
-				} catch(PDOException $e) {
1846
+				} catch (PDOException $e) {
1847 1847
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1848 1848
 				}
1849 1849
 			}
1850
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1850
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1851 1851
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL";
1852 1852
 				try {
1853 1853
 					$sth = $Connection->db->prepare($query);
1854 1854
 					$sth->execute();
1855
-				} catch(PDOException $e) {
1855
+				} catch (PDOException $e) {
1856 1856
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1857 1857
 				}
1858 1858
 			}
1859
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1859
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1860 1860
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL";
1861 1861
 				try {
1862 1862
 					$sth = $Connection->db->prepare($query);
1863 1863
 					$sth->execute();
1864
-				} catch(PDOException $e) {
1864
+				} catch (PDOException $e) {
1865 1865
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1866 1866
 				}
1867 1867
 			}
1868
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1868
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1869 1869
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL";
1870 1870
 				try {
1871 1871
 					$sth = $Connection->db->prepare($query);
1872 1872
 					$sth->execute();
1873
-				} catch(PDOException $e) {
1873
+				} catch (PDOException $e) {
1874 1874
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1875 1875
 				}
1876 1876
 			}
1877
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1877
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1878 1878
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL";
1879 1879
 				try {
1880 1880
 					$sth = $Connection->db->prepare($query);
1881 1881
 					$sth->execute();
1882
-				} catch(PDOException $e) {
1882
+				} catch (PDOException $e) {
1883 1883
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1884 1884
 				}
1885 1885
 			}
@@ -1888,7 +1888,7 @@  discard block
 block discarded – undo
1888 1888
 		try {
1889 1889
 			$sth = $Connection->db->prepare($query);
1890 1890
 			$sth->execute();
1891
-		} catch(PDOException $e) {
1891
+		} catch (PDOException $e) {
1892 1892
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1893 1893
 		}
1894 1894
 		return $error;
@@ -1903,14 +1903,14 @@  discard block
 block discarded – undo
1903 1903
 			try {
1904 1904
 				$sth = $Connection->db->prepare($query);
1905 1905
 				$sth->execute();
1906
-			} catch(PDOException $e) {
1906
+			} catch (PDOException $e) {
1907 1907
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1908 1908
 			}
1909 1909
 			$query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL";
1910 1910
 			try {
1911 1911
 				$sth = $Connection->db->prepare($query);
1912 1912
 				$sth->execute();
1913
-			} catch(PDOException $e) {
1913
+			} catch (PDOException $e) {
1914 1914
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1915 1915
 			}
1916 1916
 		} else {
@@ -1918,14 +1918,14 @@  discard block
 block discarded – undo
1918 1918
 			try {
1919 1919
 				$sth = $Connection->db->prepare($query);
1920 1920
 				$sth->execute();
1921
-			} catch(PDOException $e) {
1921
+			} catch (PDOException $e) {
1922 1922
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1923 1923
 			}
1924 1924
 			$query = "alter table marine_identity alter column mmsi type varchar(255)";
1925 1925
 			try {
1926 1926
 				$sth = $Connection->db->prepare($query);
1927 1927
 				$sth->execute();
1928
-			} catch(PDOException $e) {
1928
+			} catch (PDOException $e) {
1929 1929
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1930 1930
 			}
1931 1931
 		}
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
 		try {
1934 1934
 			$sth = $Connection->db->prepare($query);
1935 1935
 			$sth->execute();
1936
-		} catch(PDOException $e) {
1936
+		} catch (PDOException $e) {
1937 1937
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1938 1938
 		}
1939 1939
 		return $error;
@@ -1943,32 +1943,32 @@  discard block
 block discarded – undo
1943 1943
 		global $globalDBdriver;
1944 1944
 		$Connection = new Connection();
1945 1945
 		$error = '';
1946
-		if (!$Connection->checkColumnName('source_location','last_seen')) {
1946
+		if (!$Connection->checkColumnName('source_location', 'last_seen')) {
1947 1947
 			$query = "ALTER TABLE source_location ADD COLUMN last_seen timestamp NULL DEFAULT NULL";
1948 1948
 			try {
1949 1949
 				$sth = $Connection->db->prepare($query);
1950 1950
 				$sth->execute();
1951
-			} catch(PDOException $e) {
1951
+			} catch (PDOException $e) {
1952 1952
 				return "error (add column last_seen in source_location) : ".$e->getMessage()."\n";
1953 1953
 			}
1954 1954
 		}
1955 1955
 		if ($globalDBdriver == 'mysql') {
1956
-			if (!$Connection->checkColumnName('source_location','location_id')) {
1956
+			if (!$Connection->checkColumnName('source_location', 'location_id')) {
1957 1957
 				$query = "ALTER TABLE source_location ADD COLUMN location_id int(11) DEFAULT NULL";
1958 1958
 				try {
1959 1959
 					$sth = $Connection->db->prepare($query);
1960 1960
 					$sth->execute();
1961
-				} catch(PDOException $e) {
1961
+				} catch (PDOException $e) {
1962 1962
 					return "error (add column location_id in source_location) : ".$e->getMessage()."\n";
1963 1963
 				}
1964 1964
 			}
1965 1965
 		} else {
1966
-			if (!$Connection->checkColumnName('source_location','location_id')) {
1966
+			if (!$Connection->checkColumnName('source_location', 'location_id')) {
1967 1967
 				$query = "ALTER TABLE source_location ADD COLUMN location_id integer DEFAULT NULL";
1968 1968
 				try {
1969 1969
 					$sth = $Connection->db->prepare($query);
1970 1970
 					$sth->execute();
1971
-				} catch(PDOException $e) {
1971
+				} catch (PDOException $e) {
1972 1972
 					return "error (add column location_id in source_location) : ".$e->getMessage()."\n";
1973 1973
 				}
1974 1974
 			}
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
 		try {
1978 1978
 			$sth = $Connection->db->prepare($query);
1979 1979
 			$sth->execute();
1980
-		} catch(PDOException $e) {
1980
+		} catch (PDOException $e) {
1981 1981
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1982 1982
 		}
1983 1983
 		return $error;
@@ -1987,12 +1987,12 @@  discard block
 block discarded – undo
1987 1987
 		global $globalDBdriver;
1988 1988
 		$Connection = new Connection();
1989 1989
 		$error = '';
1990
-		if (!$Connection->checkColumnName('source_location','description')) {
1990
+		if (!$Connection->checkColumnName('source_location', 'description')) {
1991 1991
 			$query = "ALTER TABLE source_location ADD COLUMN description text DEFAULT NULL";
1992 1992
 			try {
1993 1993
 				$sth = $Connection->db->prepare($query);
1994 1994
 				$sth->execute();
1995
-			} catch(PDOException $e) {
1995
+			} catch (PDOException $e) {
1996 1996
 				return "error (add column description in source_location) : ".$e->getMessage()."\n";
1997 1997
 			}
1998 1998
 		}
@@ -2000,7 +2000,7 @@  discard block
 block discarded – undo
2000 2000
 		try {
2001 2001
 			$sth = $Connection->db->prepare($query);
2002 2002
 			$sth->execute();
2003
-		} catch(PDOException $e) {
2003
+		} catch (PDOException $e) {
2004 2004
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2005 2005
 		}
2006 2006
 		return $error;
@@ -2010,39 +2010,39 @@  discard block
 block discarded – undo
2010 2010
 		global $globalDBdriver;
2011 2011
 		$Connection = new Connection();
2012 2012
 		$error = '';
2013
-		if (!$Connection->checkColumnName('spotter_live','real_altitude')) {
2013
+		if (!$Connection->checkColumnName('spotter_live', 'real_altitude')) {
2014 2014
 			$query = "ALTER TABLE spotter_live ADD COLUMN real_altitude float DEFAULT NULL";
2015 2015
 			try {
2016 2016
 				$sth = $Connection->db->prepare($query);
2017 2017
 				$sth->execute();
2018
-			} catch(PDOException $e) {
2018
+			} catch (PDOException $e) {
2019 2019
 				return "error (add column real_altitude in spotter_live) : ".$e->getMessage()."\n";
2020 2020
 			}
2021 2021
 		}
2022
-		if (!$Connection->checkColumnName('spotter_output','real_altitude')) {
2022
+		if (!$Connection->checkColumnName('spotter_output', 'real_altitude')) {
2023 2023
 			$query = "ALTER TABLE spotter_output ADD COLUMN real_altitude float DEFAULT NULL";
2024 2024
 			try {
2025 2025
 				$sth = $Connection->db->prepare($query);
2026 2026
 				$sth->execute();
2027
-			} catch(PDOException $e) {
2027
+			} catch (PDOException $e) {
2028 2028
 				return "error (add column real_altitude in spotter_output) : ".$e->getMessage()."\n";
2029 2029
 			}
2030 2030
 		}
2031
-		if (!$Connection->checkColumnName('spotter_archive_output','real_altitude')) {
2031
+		if (!$Connection->checkColumnName('spotter_archive_output', 'real_altitude')) {
2032 2032
 			$query = "ALTER TABLE spotter_archive_output ADD COLUMN real_altitude float DEFAULT NULL";
2033 2033
 			try {
2034 2034
 				$sth = $Connection->db->prepare($query);
2035 2035
 				$sth->execute();
2036
-			} catch(PDOException $e) {
2036
+			} catch (PDOException $e) {
2037 2037
 				return "error (add column real_altitude in spotter_archive_output) : ".$e->getMessage()."\n";
2038 2038
 			}
2039 2039
 		}
2040
-		if (!$Connection->checkColumnName('spotter_archive','real_altitude')) {
2040
+		if (!$Connection->checkColumnName('spotter_archive', 'real_altitude')) {
2041 2041
 			$query = "ALTER TABLE spotter_archive ADD COLUMN real_altitude float DEFAULT NULL";
2042 2042
 			try {
2043 2043
 				$sth = $Connection->db->prepare($query);
2044 2044
 				$sth->execute();
2045
-			} catch(PDOException $e) {
2045
+			} catch (PDOException $e) {
2046 2046
 				return "error (add column real_altitude in spotter_archive) : ".$e->getMessage()."\n";
2047 2047
 			}
2048 2048
 		}
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
 		try {
2051 2051
 			$sth = $Connection->db->prepare($query);
2052 2052
 			$sth->execute();
2053
-		} catch(PDOException $e) {
2053
+		} catch (PDOException $e) {
2054 2054
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2055 2055
 		}
2056 2056
 		return $error;
@@ -2072,14 +2072,14 @@  discard block
 block discarded – undo
2072 2072
 		try {
2073 2073
 			$sth = $Connection->db->prepare($query);
2074 2074
 			$sth->execute();
2075
-		} catch(PDOException $e) {
2075
+		} catch (PDOException $e) {
2076 2076
 			return "error (modify column altitude in tracker_*) : ".$e->getMessage()."\n";
2077 2077
 		}
2078 2078
 		$query = "UPDATE config SET value = '44' WHERE name = 'schema_version'";
2079 2079
 		try {
2080 2080
 			$sth = $Connection->db->prepare($query);
2081 2081
 			$sth->execute();
2082
-		} catch(PDOException $e) {
2082
+		} catch (PDOException $e) {
2083 2083
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2084 2084
 		}
2085 2085
 		return $error;
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
 		try {
2121 2121
 			$sth = $Connection->db->prepare($query);
2122 2122
 			$sth->execute();
2123
-		} catch(PDOException $e) {
2123
+		} catch (PDOException $e) {
2124 2124
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2125 2125
 		}
2126 2126
 		return $error;
@@ -2143,7 +2143,7 @@  discard block
 block discarded – undo
2143 2143
 		try {
2144 2144
 			$sth = $Connection->db->prepare($query);
2145 2145
 			$sth->execute();
2146
-		} catch(PDOException $e) {
2146
+		} catch (PDOException $e) {
2147 2147
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2148 2148
 		}
2149 2149
 		return $error;
@@ -2193,7 +2193,7 @@  discard block
 block discarded – undo
2193 2193
 		try {
2194 2194
 			$sth = $Connection->db->prepare($query);
2195 2195
 			$sth->execute();
2196
-		} catch(PDOException $e) {
2196
+		} catch (PDOException $e) {
2197 2197
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2198 2198
 		}
2199 2199
 		return $error;
@@ -2216,7 +2216,7 @@  discard block
 block discarded – undo
2216 2216
 		try {
2217 2217
 			$sth = $Connection->db->prepare($query);
2218 2218
 			$sth->execute();
2219
-		} catch(PDOException $e) {
2219
+		} catch (PDOException $e) {
2220 2220
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2221 2221
 		}
2222 2222
 		return $error;
@@ -2239,7 +2239,7 @@  discard block
 block discarded – undo
2239 2239
 		try {
2240 2240
 			$sth = $Connection->db->prepare($query);
2241 2241
 			$sth->execute();
2242
-		} catch(PDOException $e) {
2242
+		} catch (PDOException $e) {
2243 2243
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2244 2244
 		}
2245 2245
 		return $error;
@@ -2260,7 +2260,7 @@  discard block
 block discarded – undo
2260 2260
 		try {
2261 2261
 			$sth = $Connection->db->prepare($query);
2262 2262
 			$sth->execute();
2263
-		} catch(PDOException $e) {
2263
+		} catch (PDOException $e) {
2264 2264
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2265 2265
 		}
2266 2266
 		return $error;
@@ -2285,7 +2285,7 @@  discard block
 block discarded – undo
2285 2285
 		try {
2286 2286
 			$sth = $Connection->db->prepare($query);
2287 2287
 			$sth->execute();
2288
-		} catch(PDOException $e) {
2288
+		} catch (PDOException $e) {
2289 2289
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2290 2290
 		}
2291 2291
 		return $error;
@@ -2295,39 +2295,39 @@  discard block
 block discarded – undo
2295 2295
 		global $globalDBdriver;
2296 2296
 		$Connection = new Connection();
2297 2297
 		$error = '';
2298
-		if (!$Connection->checkColumnName('marine_live','captain_name')) {
2298
+		if (!$Connection->checkColumnName('marine_live', 'captain_name')) {
2299 2299
 			$query = "ALTER TABLE marine_live ADD COLUMN captain_name varchar(255) DEFAULT NULL,ADD COLUMN captain_id varchar(255) DEFAULT NULL,ADD COLUMN race_name varchar(255) DEFAULT NULL,ADD COLUMN race_id varchar(255) DEFAULT NULL";
2300 2300
 			try {
2301 2301
 				$sth = $Connection->db->prepare($query);
2302 2302
 				$sth->execute();
2303
-			} catch(PDOException $e) {
2303
+			} catch (PDOException $e) {
2304 2304
 				return "error (add columns captain and race in marine_live) : ".$e->getMessage()."\n";
2305 2305
 			}
2306 2306
 		}
2307
-		if (!$Connection->checkColumnName('marine_output','captain_name')) {
2307
+		if (!$Connection->checkColumnName('marine_output', 'captain_name')) {
2308 2308
 			$query = "ALTER TABLE marine_output ADD COLUMN captain_name varchar(255) DEFAULT NULL,ADD COLUMN captain_id varchar(255) DEFAULT NULL,ADD COLUMN race_name varchar(255) DEFAULT NULL,ADD COLUMN race_id varchar(255) DEFAULT NULL";
2309 2309
 			try {
2310 2310
 				$sth = $Connection->db->prepare($query);
2311 2311
 				$sth->execute();
2312
-			} catch(PDOException $e) {
2312
+			} catch (PDOException $e) {
2313 2313
 				return "error (add columns captain and race in marine_output) : ".$e->getMessage()."\n";
2314 2314
 			}
2315 2315
 		}
2316
-		if (!$Connection->checkColumnName('marine_archive','captain_name')) {
2316
+		if (!$Connection->checkColumnName('marine_archive', 'captain_name')) {
2317 2317
 			$query = "ALTER TABLE marine_archive ADD COLUMN captain_name varchar(255) DEFAULT NULL,ADD COLUMN captain_id varchar(255) DEFAULT NULL,ADD COLUMN race_name varchar(255) DEFAULT NULL,ADD COLUMN race_id varchar(255) DEFAULT NULL";
2318 2318
 			try {
2319 2319
 				$sth = $Connection->db->prepare($query);
2320 2320
 				$sth->execute();
2321
-			} catch(PDOException $e) {
2321
+			} catch (PDOException $e) {
2322 2322
 				return "error (add columns captain and race in marine_archive) : ".$e->getMessage()."\n";
2323 2323
 			}
2324 2324
 		}
2325
-		if (!$Connection->checkColumnName('marine_archive_output','captain_name')) {
2325
+		if (!$Connection->checkColumnName('marine_archive_output', 'captain_name')) {
2326 2326
 			$query = "ALTER TABLE marine_archive_output ADD COLUMN captain_name varchar(255) DEFAULT NULL,ADD COLUMN captain_id varchar(255) DEFAULT NULL,ADD COLUMN race_name varchar(255) DEFAULT NULL,ADD COLUMN race_id varchar(255) DEFAULT NULL";
2327 2327
 			try {
2328 2328
 				$sth = $Connection->db->prepare($query);
2329 2329
 				$sth->execute();
2330
-			} catch(PDOException $e) {
2330
+			} catch (PDOException $e) {
2331 2331
 				return "error (add columns captain and race in marine_archive_output) : ".$e->getMessage()."\n";
2332 2332
 			}
2333 2333
 		}
@@ -2335,7 +2335,7 @@  discard block
 block discarded – undo
2335 2335
 		try {
2336 2336
 			$sth = $Connection->db->prepare($query);
2337 2337
 			$sth->execute();
2338
-		} catch(PDOException $e) {
2338
+		} catch (PDOException $e) {
2339 2339
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2340 2340
 		}
2341 2341
 		return $error;
@@ -2360,7 +2360,7 @@  discard block
 block discarded – undo
2360 2360
 					try {
2361 2361
 						$sth = $Connection->db->prepare($query);
2362 2362
 						$sth->execute();
2363
-					} catch(PDOException $e) {
2363
+					} catch (PDOException $e) {
2364 2364
 						return "error (check_version): ".$e->getMessage()."\n";
2365 2365
 					}
2366 2366
 					$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Braces   +512 added lines, -188 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -803,12 +855,16 @@  discard block
 block discarded – undo
803 855
 		if ($globalDBdriver == 'mysql') {
804 856
 			if (!$Connection->tableExists('tle')) {
805 857
 				$error .= create_db::import_file('../db/tle.sql');
806
-				if ($error != '') return $error;
858
+				if ($error != '') {
859
+					return $error;
860
+				}
807 861
 			}
808 862
 		} else {
809 863
 			if (!$Connection->tableExists('tle')) {
810 864
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
811
-				if ($error != '') return $error;
865
+				if ($error != '') {
866
+					return $error;
867
+				}
812 868
 			}
813 869
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
814 870
 			try {
@@ -848,7 +904,9 @@  discard block
 block discarded – undo
848 904
 		} else {
849 905
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 906
 		}
851
-		if ($error != '') return 'Import airlines.sql : '.$error;
907
+		if ($error != '') {
908
+			return 'Import airlines.sql : '.$error;
909
+		}
852 910
 		if (!$Connection->checkColumnName('airlines','forsource')) {
853 911
 			// Add forsource to airlines
854 912
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1331,20 +1389,28 @@  discard block
 block discarded – undo
1331 1389
 		}
1332 1390
 		if ($globalDBdriver == 'mysql') {
1333 1391
 			$error .= create_db::import_file('../db/airlines.sql');
1334
-			if ($error != '') return $error;
1392
+			if ($error != '') {
1393
+				return $error;
1394
+			}
1335 1395
 		} else {
1336 1396
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1337
-			if ($error != '') return $error;
1397
+			if ($error != '') {
1398
+				return $error;
1399
+			}
1338 1400
 		}
1339 1401
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1340 1402
 			include_once(dirname(__FILE__).'/class.update_db.php');
1341 1403
 			if (isset($globalVATSIM) && $globalVATSIM) {
1342 1404
 				$error .= update_db::update_vatsim();
1343
-				if ($error != '') return $error;
1405
+				if ($error != '') {
1406
+					return $error;
1407
+				}
1344 1408
 			}
1345 1409
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1346 1410
 				$error .= update_db::update_IVAO();
1347
-				if ($error != '') return $error;
1411
+				if ($error != '') {
1412
+					return $error;
1413
+				}
1348 1414
 			}
1349 1415
 		}
1350 1416
 
@@ -1607,41 +1673,65 @@  discard block
 block discarded – undo
1607 1673
 		if ($globalDBdriver == 'mysql') {
1608 1674
 			if (!$Connection->tableExists('tracker_output')) {
1609 1675
 				$error .= create_db::import_file('../db/tracker_output.sql');
1610
-				if ($error != '') return $error;
1676
+				if ($error != '') {
1677
+					return $error;
1678
+				}
1611 1679
 			}
1612 1680
 			if (!$Connection->tableExists('tracker_live')) {
1613 1681
 				$error .= create_db::import_file('../db/tracker_live.sql');
1614
-				if ($error != '') return $error;
1682
+				if ($error != '') {
1683
+					return $error;
1684
+				}
1615 1685
 			}
1616 1686
 			if (!$Connection->tableExists('marine_output')) {
1617 1687
 				$error .= create_db::import_file('../db/marine_output.sql');
1618
-				if ($error != '') return $error;
1688
+				if ($error != '') {
1689
+					return $error;
1690
+				}
1619 1691
 			}
1620 1692
 			if (!$Connection->tableExists('marine_live')) {
1621 1693
 				$error .= create_db::import_file('../db/marine_live.sql');
1622
-				if ($error != '') return $error;
1694
+				if ($error != '') {
1695
+					return $error;
1696
+				}
1623 1697
 			}
1624 1698
 			if (!$Connection->tableExists('marine_identity')) {
1625 1699
 				$error .= create_db::import_file('../db/marine_identity.sql');
1626
-				if ($error != '') return $error;
1700
+				if ($error != '') {
1701
+					return $error;
1702
+				}
1627 1703
 			}
1628 1704
 			if (!$Connection->tableExists('marine_mid')) {
1629 1705
 				$error .= create_db::import_file('../db/marine_mid.sql');
1630
-				if ($error != '') return $error;
1706
+				if ($error != '') {
1707
+					return $error;
1708
+				}
1631 1709
 			}
1632 1710
 		} else {
1633 1711
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1634
-			if ($error != '') return $error;
1712
+			if ($error != '') {
1713
+				return $error;
1714
+			}
1635 1715
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1636
-			if ($error != '') return $error;
1716
+			if ($error != '') {
1717
+				return $error;
1718
+			}
1637 1719
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1638
-			if ($error != '') return $error;
1720
+			if ($error != '') {
1721
+				return $error;
1722
+			}
1639 1723
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1640
-			if ($error != '') return $error;
1724
+			if ($error != '') {
1725
+				return $error;
1726
+			}
1641 1727
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1642
-			if ($error != '') return $error;
1728
+			if ($error != '') {
1729
+				return $error;
1730
+			}
1643 1731
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1644
-			if ($error != '') return $error;
1732
+			if ($error != '') {
1733
+				return $error;
1734
+			}
1645 1735
 		}
1646 1736
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1647 1737
 		try {
@@ -1660,39 +1750,61 @@  discard block
 block discarded – undo
1660 1750
 		if ($globalDBdriver == 'mysql') {
1661 1751
 			if (!$Connection->tableExists('marine_image')) {
1662 1752
 				$error .= create_db::import_file('../db/marine_image.sql');
1663
-				if ($error != '') return $error;
1753
+				if ($error != '') {
1754
+					return $error;
1755
+				}
1664 1756
 			}
1665 1757
 			if (!$Connection->tableExists('marine_archive')) {
1666 1758
 				$error .= create_db::import_file('../db/marine_archive.sql');
1667
-				if ($error != '') return $error;
1759
+				if ($error != '') {
1760
+					return $error;
1761
+				}
1668 1762
 			}
1669 1763
 			if (!$Connection->tableExists('marine_archive_output')) {
1670 1764
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1671
-				if ($error != '') return $error;
1765
+				if ($error != '') {
1766
+					return $error;
1767
+				}
1672 1768
 			}
1673 1769
 			if (!$Connection->tableExists('tracker_archive')) {
1674 1770
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1675
-				if ($error != '') return $error;
1771
+				if ($error != '') {
1772
+					return $error;
1773
+				}
1676 1774
 			}
1677 1775
 			if (!$Connection->tableExists('tracker_archive_output')) {
1678 1776
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1679
-				if ($error != '') return $error;
1777
+				if ($error != '') {
1778
+					return $error;
1779
+				}
1680 1780
 			}
1681 1781
 			if (!$Connection->tableExists('marine_archive_output')) {
1682 1782
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1683
-				if ($error != '') return $error;
1783
+				if ($error != '') {
1784
+					return $error;
1785
+				}
1684 1786
 			}
1685 1787
 		} else {
1686 1788
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1687
-			if ($error != '') return $error;
1789
+			if ($error != '') {
1790
+				return $error;
1791
+			}
1688 1792
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1689
-			if ($error != '') return $error;
1793
+			if ($error != '') {
1794
+				return $error;
1795
+			}
1690 1796
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1691
-			if ($error != '') return $error;
1797
+			if ($error != '') {
1798
+				return $error;
1799
+			}
1692 1800
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1693
-			if ($error != '') return $error;
1801
+			if ($error != '') {
1802
+				return $error;
1803
+			}
1694 1804
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1695
-			if ($error != '') return $error;
1805
+			if ($error != '') {
1806
+				return $error;
1807
+			}
1696 1808
 		}
1697 1809
 		if ($globalDBdriver == 'mysql') {
1698 1810
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2063,7 +2175,9 @@  discard block
 block discarded – undo
2063 2175
 		if ($globalDBdriver == 'mysql') {
2064 2176
 			if (!$Connection->tableExists('tracker_archive_output')) {
2065 2177
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2066
-				if ($error != '') return $error;
2178
+				if ($error != '') {
2179
+					return $error;
2180
+				}
2067 2181
 			}
2068 2182
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2069 2183
 		} else {
@@ -2091,14 +2205,22 @@  discard block
 block discarded – undo
2091 2205
 		$error = '';
2092 2206
 		if ($globalDBdriver == 'mysql') {
2093 2207
 			$error .= create_db::import_file('../db/airport.sql');
2094
-			if ($error != '') return $error;
2208
+			if ($error != '') {
2209
+				return $error;
2210
+			}
2095 2211
 			$error .= create_db::import_file('../db/airlines.sql');
2096
-			if ($error != '') return $error;
2212
+			if ($error != '') {
2213
+				return $error;
2214
+			}
2097 2215
 		} else {
2098 2216
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2099
-			if ($error != '') return $error;
2217
+			if ($error != '') {
2218
+				return $error;
2219
+			}
2100 2220
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2101
-			if ($error != '') return $error;
2221
+			if ($error != '') {
2222
+				return $error;
2223
+			}
2102 2224
 		}
2103 2225
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2104 2226
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2115,7 +2237,9 @@  discard block
 block discarded – undo
2115 2237
 				$error .= update_db::update_vatsim();
2116 2238
 			}
2117 2239
 		}
2118
-		if ($error != '') return $error;
2240
+		if ($error != '') {
2241
+			return $error;
2242
+		}
2119 2243
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2120 2244
 		try {
2121 2245
 			$sth = $Connection->db->prepare($query);
@@ -2133,10 +2257,14 @@  discard block
 block discarded – undo
2133 2257
 		if (!$Connection->tableExists('satellite')) {
2134 2258
 			if ($globalDBdriver == 'mysql') {
2135 2259
 				$error .= create_db::import_file('../db/satellite.sql');
2136
-				if ($error != '') return $error;
2260
+				if ($error != '') {
2261
+					return $error;
2262
+				}
2137 2263
 			} else {
2138 2264
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2139
-				if ($error != '') return $error;
2265
+				if ($error != '') {
2266
+					return $error;
2267
+				}
2140 2268
 			}
2141 2269
 		}
2142 2270
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2156,37 +2284,53 @@  discard block
 block discarded – undo
2156 2284
 		if (!$Connection->tableExists('stats_marine')) {
2157 2285
 			if ($globalDBdriver == 'mysql') {
2158 2286
 				$error .= create_db::import_file('../db/stats_marine.sql');
2159
-				if ($error != '') return $error;
2287
+				if ($error != '') {
2288
+					return $error;
2289
+				}
2160 2290
 			} else {
2161 2291
 				$error .= create_db::import_file('../db/pgsql/stats_marine.sql');
2162
-				if ($error != '') return $error;
2292
+				if ($error != '') {
2293
+					return $error;
2294
+				}
2163 2295
 			}
2164 2296
 		}
2165 2297
 		if (!$Connection->tableExists('stats_marine_country')) {
2166 2298
 			if ($globalDBdriver == 'mysql') {
2167 2299
 				$error .= create_db::import_file('../db/stats_marine_country.sql');
2168
-				if ($error != '') return $error;
2300
+				if ($error != '') {
2301
+					return $error;
2302
+				}
2169 2303
 			} else {
2170 2304
 				$error .= create_db::import_file('../db/pgsql/stats_marine_country.sql');
2171
-				if ($error != '') return $error;
2305
+				if ($error != '') {
2306
+					return $error;
2307
+				}
2172 2308
 			}
2173 2309
 		}
2174 2310
 		if (!$Connection->tableExists('stats_tracker')) {
2175 2311
 			if ($globalDBdriver == 'mysql') {
2176 2312
 				$error .= create_db::import_file('../db/stats_tracker.sql');
2177
-				if ($error != '') return $error;
2313
+				if ($error != '') {
2314
+					return $error;
2315
+				}
2178 2316
 			} else {
2179 2317
 				$error .= create_db::import_file('../db/pgsql/stats_tracker.sql');
2180
-				if ($error != '') return $error;
2318
+				if ($error != '') {
2319
+					return $error;
2320
+				}
2181 2321
 			}
2182 2322
 		}
2183 2323
 		if (!$Connection->tableExists('stats_tracker_country')) {
2184 2324
 			if ($globalDBdriver == 'mysql') {
2185 2325
 				$error .= create_db::import_file('../db/stats_tracker_country.sql');
2186
-				if ($error != '') return $error;
2326
+				if ($error != '') {
2327
+					return $error;
2328
+				}
2187 2329
 			} else {
2188 2330
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql');
2189
-				if ($error != '') return $error;
2331
+				if ($error != '') {
2332
+					return $error;
2333
+				}
2190 2334
 			}
2191 2335
 		}
2192 2336
 		$query = "UPDATE config SET value = '47' WHERE name = 'schema_version'";
@@ -2206,10 +2350,14 @@  discard block
 block discarded – undo
2206 2350
 		if (!$Connection->tableExists('stats_marine_type')) {
2207 2351
 			if ($globalDBdriver == 'mysql') {
2208 2352
 				$error .= create_db::import_file('../db/stats_marine_type.sql');
2209
-				if ($error != '') return $error;
2353
+				if ($error != '') {
2354
+					return $error;
2355
+				}
2210 2356
 			} else {
2211 2357
 				$error .= create_db::import_file('../db/pgsql/stats_marine_type.sql');
2212
-				if ($error != '') return $error;
2358
+				if ($error != '') {
2359
+					return $error;
2360
+				}
2213 2361
 			}
2214 2362
 		}
2215 2363
 		$query = "UPDATE config SET value = '48' WHERE name = 'schema_version'";
@@ -2229,10 +2377,14 @@  discard block
 block discarded – undo
2229 2377
 		if (!$Connection->tableExists('stats_tracker_type')) {
2230 2378
 			if ($globalDBdriver == 'mysql') {
2231 2379
 				$error .= create_db::import_file('../db/stats_tracker_type.sql');
2232
-				if ($error != '') return $error;
2380
+				if ($error != '') {
2381
+					return $error;
2382
+				}
2233 2383
 			} else {
2234 2384
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_type.sql');
2235
-				if ($error != '') return $error;
2385
+				if ($error != '') {
2386
+					return $error;
2387
+				}
2236 2388
 			}
2237 2389
 		}
2238 2390
 		$query = "UPDATE config SET value = '49' WHERE name = 'schema_version'";
@@ -2251,10 +2403,14 @@  discard block
 block discarded – undo
2251 2403
 		$error = '';
2252 2404
 		if ($globalDBdriver == 'mysql') {
2253 2405
 			$error .= create_db::import_file('../db/airport.sql');
2254
-			if ($error != '') return $error;
2406
+			if ($error != '') {
2407
+				return $error;
2408
+			}
2255 2409
 		} else {
2256 2410
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2257
-			if ($error != '') return $error;
2411
+			if ($error != '') {
2412
+				return $error;
2413
+			}
2258 2414
 		}
2259 2415
 		$query = "UPDATE config SET value = '50' WHERE name = 'schema_version'";
2260 2416
 		try {
@@ -2272,14 +2428,22 @@  discard block
 block discarded – undo
2272 2428
 		$error = '';
2273 2429
 		if ($globalDBdriver == 'mysql') {
2274 2430
 			$error .= create_db::import_file('../db/aircraft.sql');
2275
-			if ($error != '') return $error;
2431
+			if ($error != '') {
2432
+				return $error;
2433
+			}
2276 2434
 			$error .= create_db::import_file('../db/aircraft_block.sql');
2277
-			if ($error != '') return $error;
2435
+			if ($error != '') {
2436
+				return $error;
2437
+			}
2278 2438
 		} else {
2279 2439
 			$error .= create_db::import_file('../db/pgsql/aircraft.sql');
2280
-			if ($error != '') return $error;
2440
+			if ($error != '') {
2441
+				return $error;
2442
+			}
2281 2443
 			$error .= create_db::import_file('../db/pgsql/aircraft_block.sql');
2282
-			if ($error != '') return $error;
2444
+			if ($error != '') {
2445
+				return $error;
2446
+			}
2283 2447
 		}
2284 2448
 		$query = "UPDATE config SET value = '51' WHERE name = 'schema_version'";
2285 2449
 		try {
@@ -2353,8 +2517,11 @@  discard block
 block discarded – undo
2353 2517
 			if ($Connection->tableExists('aircraft')) {
2354 2518
 				if (!$Connection->tableExists('config')) {
2355 2519
 					$version = '1';
2356
-					if ($update) return self::update_from_1();
2357
-					else return $version;
2520
+					if ($update) {
2521
+						return self::update_from_1();
2522
+					} else {
2523
+						return $version;
2524
+					}
2358 2525
 				} else {
2359 2526
 					$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2360 2527
 					try {
@@ -2367,211 +2534,368 @@  discard block
 block discarded – undo
2367 2534
 					if ($update) {
2368 2535
 						if ($result['value'] == '2') {
2369 2536
 							$error = self::update_from_2();
2370
-							if ($error != '') return $error;
2371
-							else return self::check_version(true);
2537
+							if ($error != '') {
2538
+								return $error;
2539
+							} else {
2540
+								return self::check_version(true);
2541
+							}
2372 2542
 						} elseif ($result['value'] == '3') {
2373 2543
 							$error = self::update_from_3();
2374
-							if ($error != '') return $error;
2375
-							else return self::check_version(true);
2544
+							if ($error != '') {
2545
+								return $error;
2546
+							} else {
2547
+								return self::check_version(true);
2548
+							}
2376 2549
 						} elseif ($result['value'] == '4') {
2377 2550
 							$error = self::update_from_4();
2378
-							if ($error != '') return $error;
2379
-							else return self::check_version(true);
2551
+							if ($error != '') {
2552
+								return $error;
2553
+							} else {
2554
+								return self::check_version(true);
2555
+							}
2380 2556
 						} elseif ($result['value'] == '5') {
2381 2557
 							$error = self::update_from_5();
2382
-							if ($error != '') return $error;
2383
-							else return self::check_version(true);
2558
+							if ($error != '') {
2559
+								return $error;
2560
+							} else {
2561
+								return self::check_version(true);
2562
+							}
2384 2563
 						} elseif ($result['value'] == '6') {
2385 2564
 							$error = self::update_from_6();
2386
-							if ($error != '') return $error;
2387
-							else return self::check_version(true);
2565
+							if ($error != '') {
2566
+								return $error;
2567
+							} else {
2568
+								return self::check_version(true);
2569
+							}
2388 2570
 						} elseif ($result['value'] == '7') {
2389 2571
 							$error = self::update_from_7();
2390
-							if ($error != '') return $error;
2391
-							else return self::check_version(true);
2572
+							if ($error != '') {
2573
+								return $error;
2574
+							} else {
2575
+								return self::check_version(true);
2576
+							}
2392 2577
 						} elseif ($result['value'] == '8') {
2393 2578
 							$error = self::update_from_8();
2394
-							if ($error != '') return $error;
2395
-							else return self::check_version(true);
2579
+							if ($error != '') {
2580
+								return $error;
2581
+							} else {
2582
+								return self::check_version(true);
2583
+							}
2396 2584
 						} elseif ($result['value'] == '9') {
2397 2585
 							$error = self::update_from_9();
2398
-							if ($error != '') return $error;
2399
-							else return self::check_version(true);
2586
+							if ($error != '') {
2587
+								return $error;
2588
+							} else {
2589
+								return self::check_version(true);
2590
+							}
2400 2591
 						} elseif ($result['value'] == '10') {
2401 2592
 							$error = self::update_from_10();
2402
-							if ($error != '') return $error;
2403
-							else return self::check_version(true);
2593
+							if ($error != '') {
2594
+								return $error;
2595
+							} else {
2596
+								return self::check_version(true);
2597
+							}
2404 2598
 						} elseif ($result['value'] == '11') {
2405 2599
 							$error = self::update_from_11();
2406
-							if ($error != '') return $error;
2407
-							else return self::check_version(true);
2600
+							if ($error != '') {
2601
+								return $error;
2602
+							} else {
2603
+								return self::check_version(true);
2604
+							}
2408 2605
 						} elseif ($result['value'] == '12') {
2409 2606
 							$error = self::update_from_12();
2410
-							if ($error != '') return $error;
2411
-							else return self::check_version(true);
2607
+							if ($error != '') {
2608
+								return $error;
2609
+							} else {
2610
+								return self::check_version(true);
2611
+							}
2412 2612
 						} elseif ($result['value'] == '13') {
2413 2613
 							$error = self::update_from_13();
2414
-							if ($error != '') return $error;
2415
-							else return self::check_version(true);
2614
+							if ($error != '') {
2615
+								return $error;
2616
+							} else {
2617
+								return self::check_version(true);
2618
+							}
2416 2619
 						} elseif ($result['value'] == '14') {
2417 2620
 							$error = self::update_from_14();
2418
-							if ($error != '') return $error;
2419
-							else return self::check_version(true);
2621
+							if ($error != '') {
2622
+								return $error;
2623
+							} else {
2624
+								return self::check_version(true);
2625
+							}
2420 2626
 						} elseif ($result['value'] == '15') {
2421 2627
 							$error = self::update_from_15();
2422
-							if ($error != '') return $error;
2423
-							else return self::check_version(true);
2628
+							if ($error != '') {
2629
+								return $error;
2630
+							} else {
2631
+								return self::check_version(true);
2632
+							}
2424 2633
 						} elseif ($result['value'] == '16') {
2425 2634
 							$error = self::update_from_16();
2426
-							if ($error != '') return $error;
2427
-							else return self::check_version(true);
2635
+							if ($error != '') {
2636
+								return $error;
2637
+							} else {
2638
+								return self::check_version(true);
2639
+							}
2428 2640
 						} elseif ($result['value'] == '17') {
2429 2641
 							$error = self::update_from_17();
2430
-							if ($error != '') return $error;
2431
-							else return self::check_version(true);
2642
+							if ($error != '') {
2643
+								return $error;
2644
+							} else {
2645
+								return self::check_version(true);
2646
+							}
2432 2647
 						} elseif ($result['value'] == '18') {
2433 2648
 							$error = self::update_from_18();
2434
-							if ($error != '') return $error;
2435
-							else return self::check_version(true);
2649
+							if ($error != '') {
2650
+								return $error;
2651
+							} else {
2652
+								return self::check_version(true);
2653
+							}
2436 2654
 						} elseif ($result['value'] == '19') {
2437 2655
 							$error = self::update_from_19();
2438
-							if ($error != '') return $error;
2439
-							else return self::check_version(true);
2656
+							if ($error != '') {
2657
+								return $error;
2658
+							} else {
2659
+								return self::check_version(true);
2660
+							}
2440 2661
 						} elseif ($result['value'] == '20') {
2441 2662
 							$error = self::update_from_20();
2442
-							if ($error != '') return $error;
2443
-							else return self::check_version(true);
2663
+							if ($error != '') {
2664
+								return $error;
2665
+							} else {
2666
+								return self::check_version(true);
2667
+							}
2444 2668
 						} elseif ($result['value'] == '21') {
2445 2669
 							$error = self::update_from_21();
2446
-							if ($error != '') return $error;
2447
-							else return self::check_version(true);
2670
+							if ($error != '') {
2671
+								return $error;
2672
+							} else {
2673
+								return self::check_version(true);
2674
+							}
2448 2675
 						} elseif ($result['value'] == '22') {
2449 2676
 							$error = self::update_from_22();
2450
-							if ($error != '') return $error;
2451
-							else return self::check_version(true);
2677
+							if ($error != '') {
2678
+								return $error;
2679
+							} else {
2680
+								return self::check_version(true);
2681
+							}
2452 2682
 						} elseif ($result['value'] == '23') {
2453 2683
 							$error = self::update_from_23();
2454
-							if ($error != '') return $error;
2455
-							else return self::check_version(true);
2684
+							if ($error != '') {
2685
+								return $error;
2686
+							} else {
2687
+								return self::check_version(true);
2688
+							}
2456 2689
 						} elseif ($result['value'] == '24') {
2457 2690
 							$error = self::update_from_24();
2458
-							if ($error != '') return $error;
2459
-							else return self::check_version(true);
2691
+							if ($error != '') {
2692
+								return $error;
2693
+							} else {
2694
+								return self::check_version(true);
2695
+							}
2460 2696
 						} elseif ($result['value'] == '25') {
2461 2697
 							$error = self::update_from_25();
2462
-							if ($error != '') return $error;
2463
-							else return self::check_version(true);
2698
+							if ($error != '') {
2699
+								return $error;
2700
+							} else {
2701
+								return self::check_version(true);
2702
+							}
2464 2703
 						} elseif ($result['value'] == '26') {
2465 2704
 							$error = self::update_from_26();
2466
-							if ($error != '') return $error;
2467
-							else return self::check_version(true);
2705
+							if ($error != '') {
2706
+								return $error;
2707
+							} else {
2708
+								return self::check_version(true);
2709
+							}
2468 2710
 						} elseif ($result['value'] == '27') {
2469 2711
 							$error = self::update_from_27();
2470
-							if ($error != '') return $error;
2471
-							else return self::check_version(true);
2712
+							if ($error != '') {
2713
+								return $error;
2714
+							} else {
2715
+								return self::check_version(true);
2716
+							}
2472 2717
 						} elseif ($result['value'] == '28') {
2473 2718
 							$error = self::update_from_28();
2474
-							if ($error != '') return $error;
2475
-							else return self::check_version(true);
2719
+							if ($error != '') {
2720
+								return $error;
2721
+							} else {
2722
+								return self::check_version(true);
2723
+							}
2476 2724
 						} elseif ($result['value'] == '29') {
2477 2725
 							$error = self::update_from_29();
2478
-							if ($error != '') return $error;
2479
-							else return self::check_version(true);
2726
+							if ($error != '') {
2727
+								return $error;
2728
+							} else {
2729
+								return self::check_version(true);
2730
+							}
2480 2731
 						} elseif ($result['value'] == '30') {
2481 2732
 							$error = self::update_from_30();
2482
-							if ($error != '') return $error;
2483
-							else return self::check_version(true);
2733
+							if ($error != '') {
2734
+								return $error;
2735
+							} else {
2736
+								return self::check_version(true);
2737
+							}
2484 2738
 						} elseif ($result['value'] == '31') {
2485 2739
 							$error = self::update_from_31();
2486
-							if ($error != '') return $error;
2487
-							else return self::check_version(true);
2740
+							if ($error != '') {
2741
+								return $error;
2742
+							} else {
2743
+								return self::check_version(true);
2744
+							}
2488 2745
 						} elseif ($result['value'] == '32') {
2489 2746
 							$error = self::update_from_32();
2490
-							if ($error != '') return $error;
2491
-							else return self::check_version(true);
2747
+							if ($error != '') {
2748
+								return $error;
2749
+							} else {
2750
+								return self::check_version(true);
2751
+							}
2492 2752
 						} elseif ($result['value'] == '33') {
2493 2753
 							$error = self::update_from_33();
2494
-							if ($error != '') return $error;
2495
-							else return self::check_version(true);
2754
+							if ($error != '') {
2755
+								return $error;
2756
+							} else {
2757
+								return self::check_version(true);
2758
+							}
2496 2759
 						} elseif ($result['value'] == '34') {
2497 2760
 							$error = self::update_from_34();
2498
-							if ($error != '') return $error;
2499
-							else return self::check_version(true);
2761
+							if ($error != '') {
2762
+								return $error;
2763
+							} else {
2764
+								return self::check_version(true);
2765
+							}
2500 2766
 						} elseif ($result['value'] == '35') {
2501 2767
 							$error = self::update_from_35();
2502
-							if ($error != '') return $error;
2503
-							else return self::check_version(true);
2768
+							if ($error != '') {
2769
+								return $error;
2770
+							} else {
2771
+								return self::check_version(true);
2772
+							}
2504 2773
 						} elseif ($result['value'] == '36') {
2505 2774
 							$error = self::update_from_36();
2506
-							if ($error != '') return $error;
2507
-							else return self::check_version(true);
2775
+							if ($error != '') {
2776
+								return $error;
2777
+							} else {
2778
+								return self::check_version(true);
2779
+							}
2508 2780
 						} elseif ($result['value'] == '37') {
2509 2781
 							$error = self::update_from_37();
2510
-							if ($error != '') return $error;
2511
-							else return self::check_version(true);
2782
+							if ($error != '') {
2783
+								return $error;
2784
+							} else {
2785
+								return self::check_version(true);
2786
+							}
2512 2787
 						} elseif ($result['value'] == '38') {
2513 2788
 							$error = self::update_from_38();
2514
-							if ($error != '') return $error;
2515
-							else return self::check_version(true);
2789
+							if ($error != '') {
2790
+								return $error;
2791
+							} else {
2792
+								return self::check_version(true);
2793
+							}
2516 2794
 						} elseif ($result['value'] == '39') {
2517 2795
 							$error = self::update_from_39();
2518
-							if ($error != '') return $error;
2519
-							else return self::check_version(true);
2796
+							if ($error != '') {
2797
+								return $error;
2798
+							} else {
2799
+								return self::check_version(true);
2800
+							}
2520 2801
 						} elseif ($result['value'] == '40') {
2521 2802
 							$error = self::update_from_40();
2522
-							if ($error != '') return $error;
2523
-							else return self::check_version(true);
2803
+							if ($error != '') {
2804
+								return $error;
2805
+							} else {
2806
+								return self::check_version(true);
2807
+							}
2524 2808
 						} elseif ($result['value'] == '41') {
2525 2809
 							$error = self::update_from_41();
2526
-							if ($error != '') return $error;
2527
-							else return self::check_version(true);
2810
+							if ($error != '') {
2811
+								return $error;
2812
+							} else {
2813
+								return self::check_version(true);
2814
+							}
2528 2815
 						} elseif ($result['value'] == '42') {
2529 2816
 							$error = self::update_from_42();
2530
-							if ($error != '') return $error;
2531
-							else return self::check_version(true);
2817
+							if ($error != '') {
2818
+								return $error;
2819
+							} else {
2820
+								return self::check_version(true);
2821
+							}
2532 2822
 						} elseif ($result['value'] == '43') {
2533 2823
 							$error = self::update_from_43();
2534
-							if ($error != '') return $error;
2535
-							else return self::check_version(true);
2824
+							if ($error != '') {
2825
+								return $error;
2826
+							} else {
2827
+								return self::check_version(true);
2828
+							}
2536 2829
 						} elseif ($result['value'] == '44') {
2537 2830
 							$error = self::update_from_44();
2538
-							if ($error != '') return $error;
2539
-							else return self::check_version(true);
2831
+							if ($error != '') {
2832
+								return $error;
2833
+							} else {
2834
+								return self::check_version(true);
2835
+							}
2540 2836
 						} elseif ($result['value'] == '45') {
2541 2837
 							$error = self::update_from_45();
2542
-							if ($error != '') return $error;
2543
-							else return self::check_version(true);
2838
+							if ($error != '') {
2839
+								return $error;
2840
+							} else {
2841
+								return self::check_version(true);
2842
+							}
2544 2843
 						} elseif ($result['value'] == '46') {
2545 2844
 							$error = self::update_from_46();
2546
-							if ($error != '') return $error;
2547
-							else return self::check_version(true);
2845
+							if ($error != '') {
2846
+								return $error;
2847
+							} else {
2848
+								return self::check_version(true);
2849
+							}
2548 2850
 						} elseif ($result['value'] == '47') {
2549 2851
 							$error = self::update_from_47();
2550
-							if ($error != '') return $error;
2551
-							else return self::check_version(true);
2852
+							if ($error != '') {
2853
+								return $error;
2854
+							} else {
2855
+								return self::check_version(true);
2856
+							}
2552 2857
 						} elseif ($result['value'] == '48') {
2553 2858
 							$error = self::update_from_48();
2554
-							if ($error != '') return $error;
2555
-							else return self::check_version(true);
2859
+							if ($error != '') {
2860
+								return $error;
2861
+							} else {
2862
+								return self::check_version(true);
2863
+							}
2556 2864
 						} elseif ($result['value'] == '49') {
2557 2865
 							$error = self::update_from_49();
2558
-							if ($error != '') return $error;
2559
-							else return self::check_version(true);
2866
+							if ($error != '') {
2867
+								return $error;
2868
+							} else {
2869
+								return self::check_version(true);
2870
+							}
2560 2871
 						} elseif ($result['value'] == '50') {
2561 2872
 							$error = self::update_from_50();
2562
-							if ($error != '') return $error;
2563
-							else return self::check_version(true);
2873
+							if ($error != '') {
2874
+								return $error;
2875
+							} else {
2876
+								return self::check_version(true);
2877
+							}
2564 2878
 						} elseif ($result['value'] == '51') {
2565 2879
 							$error = self::update_from_51();
2566
-							if ($error != '') return $error;
2567
-							else return self::check_version(true);
2568
-						} else return '';
2880
+							if ($error != '') {
2881
+								return $error;
2882
+							} else {
2883
+								return self::check_version(true);
2884
+							}
2885
+						} else {
2886
+							return '';
2887
+						}
2569 2888
 					} else {
2570
-						if (isset($result['value']) && $result['value'] != '') return $result['value'];
2571
-						else return 0;
2889
+						if (isset($result['value']) && $result['value'] != '') {
2890
+							return $result['value'];
2891
+						} else {
2892
+							return 0;
2893
+						}
2572 2894
 					}
2573 2895
 				}
2574
-			} else return $version;
2896
+			} else {
2897
+				return $version;
2898
+			}
2575 2899
 		}
2576 2900
 	}
2577 2901
 }
Please login to merge, or discard this patch.
airline.php 2 patches
Braces   +27 added lines, -9 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  discard block
 block discarded – undo
33 33
 			if (file_exists('images/airlines/'.str_replace(' ','_',$alliance['alliance']).'.png'))
34 34
 			{
35 35
 				print '<img src="'.$globalURL.'/images/airlines/'.str_replace(' ','_',$alliance['alliance']).'.png" alt="'._("Click to see alliance activity").'" title="'._("Click to see alliance activity").'" /> ';
36
-			} else print $alliance['alliance'];
36
+			} else {
37
+				print $alliance['alliance'];
38
+			}
37 39
 			print '</a>';
38 40
 			print '</div>';
39 41
 		}
@@ -42,13 +44,21 @@  discard block
 block discarded – undo
42 44
 	}
43 45
 	print '<div class="select-item"><form action="'.$globalURL.'/airline" method="post"><select name="airline_type" class="selectpicker" data-live-search="true">';
44 46
 	print '<option value="all"';
45
-	if ($airline_type == 'all') print 'selected="selected" ';
47
+	if ($airline_type == 'all') {
48
+		print 'selected="selected" ';
49
+	}
46 50
 	print '>'._("All").'</option><option value="passenger"';
47
-	if ($airline_type == 'passenger') print 'selected="selected" ';
51
+	if ($airline_type == 'passenger') {
52
+		print 'selected="selected" ';
53
+	}
48 54
 	print '>'._("Passenger").'</option><option value="cargo"';
49
-	if ($airline_type == 'cargo') print 'selected="selected" ';
55
+	if ($airline_type == 'cargo') {
56
+		print 'selected="selected" ';
57
+	}
50 58
 	print '>'._("Cargo").'</option><option value="military"';
51
-	if ($airline_type == 'military') print 'selected="selected" ';
59
+	if ($airline_type == 'military') {
60
+		print 'selected="selected" ';
61
+	}
52 62
 	print '>'._("Military").'</option></select>';
53 63
 	print '<button type="submit"><i class="fa fa-angle-double-right"></i></button></form></div>';
54 64
 
@@ -75,7 +85,9 @@  discard block
 block discarded – undo
75 85
 		$firstLetter = strtoupper($Common->replace_mb_substr($value['airline_name'], 0, 1));
76 86
 		if($previous !== $firstLetter)
77 87
 		{
78
-			if ($previous !== null) print ' | ';
88
+			if ($previous !== null) {
89
+				print ' | ';
90
+			}
79 91
 			print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
80 92
 		}
81 93
 		$previous = $firstLetter;
@@ -88,7 +100,9 @@  discard block
 block discarded – undo
88 100
 		{
89 101
 			if($previous !== $firstLetter)
90 102
 			{
91
-				if ($previous !== null) print '</div>';
103
+				if ($previous !== null) {
104
+					print '</div>';
105
+				}
92 106
 				print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
93 107
 			}
94 108
 			$previous = $firstLetter;
@@ -102,10 +116,14 @@  discard block
 block discarded – undo
102 116
 			} elseif (file_exists('images/airlines/'.$value['airline_icao'].'.png'))
103 117
 			{
104 118
 				print '<img src="'.$globalURL.'/images/airlines/'.$value['airline_icao'].'.png" alt="'._("Click to see airline activity").'" title="'._("Click to see airline activity").'" /> ';
105
-				if (isset($value['ban_eu']) && $value['ban_eu'] == 1) print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> ';
119
+				if (isset($value['ban_eu']) && $value['ban_eu'] == 1) {
120
+					print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> ';
121
+				}
106 122
 			} else {
107 123
 				print $value['airline_name'];
108
-				if (isset($value['ban_eu']) && $value['ban_eu'] == 1) print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> ';
124
+				if (isset($value['ban_eu']) && $value['ban_eu'] == 1) {
125
+					print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> ';
126
+				}
109 127
 			}
110 128
 			print '</a>';
111 129
 			print '</div>';
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 if (isset($_POST['airline']))
10 10
 {
11
-	header('Location: '.$globalURL.'/airline/'.filter_input(INPUT_POST,'airline',FILTER_SANITIZE_STRING));
11
+	header('Location: '.$globalURL.'/airline/'.filter_input(INPUT_POST, 'airline', FILTER_SANITIZE_STRING));
12 12
 } else {
13 13
 	$title = "Airlines";
14 14
 	require_once('header.php');
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	print '<div class="column">';
18 18
 	print '<h1>'._("Airlines").'</h1>';
19 19
 	if (isset($_POST['airline_type'])) {
20
-		$airline_type = filter_input(INPUT_POST,'airline_type',FILTER_SANITIZE_STRING);
20
+		$airline_type = filter_input(INPUT_POST, 'airline_type', FILTER_SANITIZE_STRING);
21 21
 		//$airline_names = $Spotter->getAllAirlineNames($airline_type);
22 22
 	} else {
23 23
 		//$airline_names = $Spotter->getAllAirlineNames();
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 		print '<div class="alphabet">';
30 30
 		foreach ($alliances as $alliance) {
31 31
 			print '<div class="alphabet-airline alphabet-item">';
32
-			print '<a href="'.$globalURL.'/airline/alliance_'.str_replace(' ','_',$alliance['alliance']).'">';
33
-			if (file_exists('images/airlines/'.str_replace(' ','_',$alliance['alliance']).'.png'))
32
+			print '<a href="'.$globalURL.'/airline/alliance_'.str_replace(' ', '_', $alliance['alliance']).'">';
33
+			if (file_exists('images/airlines/'.str_replace(' ', '_', $alliance['alliance']).'.png'))
34 34
 			{
35
-				print '<img src="'.$globalURL.'/images/airlines/'.str_replace(' ','_',$alliance['alliance']).'.png" alt="'._("Click to see alliance activity").'" title="'._("Click to see alliance activity").'" /> ';
35
+				print '<img src="'.$globalURL.'/images/airlines/'.str_replace(' ', '_', $alliance['alliance']).'.png" alt="'._("Click to see alliance activity").'" title="'._("Click to see alliance activity").'" /> ';
36 36
 			} else print $alliance['alliance'];
37 37
 			print '</a>';
38 38
 			print '</div>';
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	$Stats = new Stats();
56 56
 	if (isset($_POST['airline_type'])) 
57 57
 	{
58
-		$airline_type = filter_input(INPUT_POST,'airline_type',FILTER_SANITIZE_STRING);
58
+		$airline_type = filter_input(INPUT_POST, 'airline_type', FILTER_SANITIZE_STRING);
59 59
 		//$airline_names = $Stats->getAllAirlineNames($airline_type);
60 60
 		$airline_names = $Spotter->getAllAirlineNames($airline_type);
61 61
 	} else {
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 	}
69 69
 	$previous = null;
70 70
 	print '<div class="alphabet-legend">';
71
-	foreach($airline_names as $value) 
71
+	foreach ($airline_names as $value) 
72 72
 	{
73 73
 		//echo $value['airline_name']."\n";
74 74
 		//echo mb_substr($value['airline_name'],0,1).' - '.$value['airline_name']."\n";
75 75
 		$firstLetter = strtoupper($Common->replace_mb_substr($value['airline_name'], 0, 1));
76
-		if($previous !== $firstLetter)
76
+		if ($previous !== $firstLetter)
77 77
 		{
78 78
 			if ($previous !== null) print ' | ';
79 79
 			print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 	}
83 83
 	print '</div>';
84 84
 	$previous = null;
85
-	foreach($airline_names as $value) {
85
+	foreach ($airline_names as $value) {
86 86
 		$firstLetter = strtoupper($Common->replace_mb_substr($value['airline_name'], 0, 1));
87 87
 		if ($firstLetter != "")
88 88
 		{
89
-			if($previous !== $firstLetter)
89
+			if ($previous !== $firstLetter)
90 90
 			{
91 91
 				if ($previous !== null) print '</div>';
92 92
 				print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
Please login to merge, or discard this patch.
js/map-satellite.2d.js.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
 			}
554 554
                     }
555 555
 		    <?php
556
-            		} else {
557
-            	    ?>
556
+					} else {
557
+					?>
558 558
 		    if (map.getZoom() > 7) {
559 559
                 	var style = {
560 560
                     	    "color": "#1a3151",
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
                 	layer_satellite_data.addLayer(layer);
574 574
 		    }
575 575
 <?php
576
-            		}
576
+					}
577 577
 ?>
578 578
 				}
579 579
 			    }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once('../require/settings.php');
3 3
 require_once('../require/class.Language.php'); 
4 4
 
5
-setcookie("MapFormat",'2d');
5
+setcookie("MapFormat", '2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8 8
 if (!isset($globalJsonCompress)) $compress = true;
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 
19 19
 <?php
20 20
 	if (isset($_GET['famsatid'])) {
21
-		$famsatid = filter_input(INPUT_GET,'famsatid',FILTER_SANITIZE_STRING);
21
+		$famsatid = filter_input(INPUT_GET, 'famsatid', FILTER_SANITIZE_STRING);
22 22
 	}
23 23
 	if (isset($_GET['ident'])) {
24
-		$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
24
+		$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
25 25
 	}
26 26
 	if (!isset($ident) && !isset($famsatid)) {
27 27
 ?>
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 <?php
195 195
 		} else {
196 196
 ?>
197
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
197
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
198 198
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
199 199
 <?php
200 200
 		}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			    /*
211 211
 			    shadowUrl: iconURLShadowpath,
212 212
 			    shadowSize: [<?php print $globalAircraftSize; ?>, <?php print $globalAircraftSize; ?>],
213
-			    shadowAnchor: [<?php print ($globalAircraftSize/2)+1; ?>, <?php print $globalAircraftSize; ?>]
213
+			    shadowAnchor: [<?php print ($globalAircraftSize/2) + 1; ?>, <?php print $globalAircraftSize; ?>]
214 214
 			    */
215 215
 			})
216 216
 		    })
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 <?php
251 251
 		} else {
252 252
 ?>
253
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
253
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
254 254
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
255 255
 <?php
256 256
 		}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 <?php
306 306
 		} else {
307 307
 ?>
308
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
308
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
309 309
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
310 310
 <?php
311 311
 		}
Please login to merge, or discard this patch.
Braces   +42 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 setcookie("MapFormat",'2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8
-if (!isset($globalJsonCompress)) $compress = true;
9
-else $compress = $globalJsonCompress;
8
+if (!isset($globalJsonCompress)) {
9
+	$compress = true;
10
+} else {
11
+	$compress = $globalJsonCompress;
12
+}
10 13
 $compress = false;
11 14
 ?>
12 15
 
@@ -159,9 +162,13 @@  discard block
 block discarded – undo
159 162
 		    if (callsign != ""){ markerSatelliteLabel += callsign; }
160 163
 		    if (type != ""){ markerSatelliteLabel += ' - '+type; }
161 164
 <?php
162
-	if (isset($_COOKIE['SatelliteIconColor'])) $IconColor = $_COOKIE['SatelliteIconColor'];
163
-	elseif (isset($globalSatelliteIconColor)) $IconColor = $globalSatelliteIconColor;
164
-	else $IconColor = '1a3151';
165
+	if (isset($_COOKIE['SatelliteIconColor'])) {
166
+		$IconColor = $_COOKIE['SatelliteIconColor'];
167
+	} elseif (isset($globalSatelliteIconColor)) {
168
+		$IconColor = $globalSatelliteIconColor;
169
+	} else {
170
+		$IconColor = '1a3151';
171
+	}
165 172
 	if (!isset($ident) && !isset($famsatid)) {
166 173
 ?>
167 174
 		    info_satellite_update(feature.properties.fc);
@@ -195,7 +202,12 @@  discard block
 block discarded – undo
195 202
 <?php
196 203
 		} else {
197 204
 ?>
198
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
205
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
206
+	print $archiveupdatetime*1000;
207
+} else {
208
+	print $globalMapRefresh*1000+20000;
209
+}
210
+?>+feature.properties.sqt*1000);
199 211
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
200 212
 <?php
201 213
 		}
@@ -251,7 +263,12 @@  discard block
 block discarded – undo
251 263
 <?php
252 264
 		} else {
253 265
 ?>
254
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
266
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
267
+	print $archiveupdatetime*1000;
268
+} else {
269
+	print $globalMapRefresh*1000+20000;
270
+}
271
+?>+feature.properties.sqt*1000);
255 272
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
256 273
 <?php
257 274
 		}
@@ -306,7 +323,12 @@  discard block
 block discarded – undo
306 323
 <?php
307 324
 		} else {
308 325
 ?>
309
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
326
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
327
+	print $archiveupdatetime*1000;
328
+} else {
329
+	print $globalMapRefresh*1000+20000;
330
+}
331
+?>+feature.properties.sqt*1000);
310 332
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
311 333
 <?php
312 334
 		}
@@ -601,14 +623,24 @@  discard block
 block discarded – undo
601 623
 	if (isset($archive) && $archive) {
602 624
 ?>
603 625
 //then load it again every 30 seconds
604
-//  var reload = setInterval(function(){if (noTimeout) updateSat(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
626
+//  var reload = setInterval(function(){if (noTimeout) updateSat(0)},<?php if (isset($globalMapRefresh)) {
627
+	print ($globalMapRefresh*1000)/2;
628
+} else {
629
+	print '15000';
630
+}
631
+?>);
605 632
 reloadSatellitePage = setInterval(function(){if (noTimeout) updateSat(0)},<?php print $archiveupdatetime*1000; ?>);
606 633
 <?php
607 634
 	} else {
608 635
 ?>
609 636
 //then load it again every 30 seconds
610 637
 reloadSatellitePage = setInterval(
611
-    function(){if (noTimeout) updateSat(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
638
+    function(){if (noTimeout) updateSat(0)},<?php if (isset($globalMapRefresh)) {
639
+	print $globalMapRefresh*1000;
640
+} else {
641
+	print '30000';
642
+}
643
+?>);
612 644
 <?php
613 645
 	}
614 646
 ?>
Please login to merge, or discard this patch.
install/class.create_db.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -8,25 +8,25 @@  discard block
 block discarded – undo
8 8
 	 * @param string $filename
9 9
 	 */
10 10
 	public static function import_file($filename) {
11
-		$filename = filter_var($filename,FILTER_SANITIZE_STRING);
11
+		$filename = filter_var($filename, FILTER_SANITIZE_STRING);
12 12
 		$Connection = new Connection();
13 13
 		if (!$Connection->connectionExists()) return 'error: DB connection failed';
14 14
 		//Connection::$db->beginTransaction();
15 15
 		$templine = '';
16
-		$handle = @fopen($filename,"r");
16
+		$handle = @fopen($filename, "r");
17 17
 		if ($handle) {
18 18
 			//$lines = file($filename);
19 19
 			//foreach ($lines as $line)
20
-			while (($line = fgets($handle,4096)) !== false)
20
+			while (($line = fgets($handle, 4096)) !== false)
21 21
 			{
22
-				if (substr($line,0,2) == '--' || $line == '') continue;
22
+				if (substr($line, 0, 2) == '--' || $line == '') continue;
23 23
 				$templine .= $line;
24
-				if (substr(trim($line), -1,1) == ';')
24
+				if (substr(trim($line), -1, 1) == ';')
25 25
 				{
26 26
 					try {
27 27
 						$sth = $Connection->db->prepare($templine);
28 28
 						$sth->execute();
29
-					} catch(PDOException $e) {
29
+					} catch (PDOException $e) {
30 30
 						return "error (import ".$filename.") : ".$e->getMessage()."\n";
31 31
 					}
32 32
 					$templine = '';
@@ -43,21 +43,21 @@  discard block
 block discarded – undo
43 43
 		$error = '';
44 44
 		$dh = opendir($directory);
45 45
 		//foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename)
46
-		while(false !== ($filename = readdir($dh)))
46
+		while (false !== ($filename = readdir($dh)))
47 47
 		{
48
-			if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename);
48
+			if (preg_match('/\.sql$/', $filename)) $error .= create_db::import_file($directory.$filename);
49 49
 		}
50 50
 		return $error;
51 51
 	}
52 52
 
53
-	public static function create_database($root,$root_pass,$user,$pass,$db,$db_type,$host,$port = '') {
54
-		$root = filter_var($root,FILTER_SANITIZE_STRING);
55
-		$root_pass = filter_var($root_pass,FILTER_SANITIZE_STRING);
56
-		$user = filter_var($user,FILTER_SANITIZE_STRING);
57
-		$password = filter_var($pass,FILTER_SANITIZE_STRING);
58
-		$db = filter_var($db,FILTER_SANITIZE_STRING);
59
-		$db_type = filter_var($db_type,FILTER_SANITIZE_STRING);
60
-		$host = filter_var($host,FILTER_SANITIZE_STRING);
53
+	public static function create_database($root, $root_pass, $user, $pass, $db, $db_type, $host, $port = '') {
54
+		$root = filter_var($root, FILTER_SANITIZE_STRING);
55
+		$root_pass = filter_var($root_pass, FILTER_SANITIZE_STRING);
56
+		$user = filter_var($user, FILTER_SANITIZE_STRING);
57
+		$password = filter_var($pass, FILTER_SANITIZE_STRING);
58
+		$db = filter_var($db, FILTER_SANITIZE_STRING);
59
+		$db_type = filter_var($db_type, FILTER_SANITIZE_STRING);
60
+		$host = filter_var($host, FILTER_SANITIZE_STRING);
61 61
 		if ($db_type == 'mysql' && $port == '') $port = 3306;
62 62
 		elseif ($port == '') $port = 5432;
63 63
 		// Dirty hack
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 			$grantright = $_SERVER['SERVER_ADDR'];
66 66
 		} else $grantright = 'localhost';
67 67
 		try {
68
-			if ($host == 'localhost') $dbh = new PDO($db_type.':host=127.0.0.1',$root,$root_pass);
69
-			else $dbh = new PDO($db_type.':host='.$host.';port='.$port,$root,$root_pass);
68
+			if ($host == 'localhost') $dbh = new PDO($db_type.':host=127.0.0.1', $root, $root_pass);
69
+			else $dbh = new PDO($db_type.':host='.$host.';port='.$port, $root, $root_pass);
70 70
 			$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
71 71
 			if ($db_type == 'mysql') {
72 72
 				$dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 				$dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."';
77 77
 					GRANT ALL PRIVILEGES ON DATABASE ".$db." TO ".$user.";");
78 78
 			}
79
-		} catch(PDOException $e) {
79
+		} catch (PDOException $e) {
80 80
 			$dbh = null;
81 81
 			return "error : ".$e->getMessage();
82 82
 		}
Please login to merge, or discard this patch.
Braces   +25 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
 	public static function import_file($filename) {
11 11
 		$filename = filter_var($filename,FILTER_SANITIZE_STRING);
12 12
 		$Connection = new Connection();
13
-		if (!$Connection->connectionExists()) return 'error: DB connection failed';
13
+		if (!$Connection->connectionExists()) {
14
+			return 'error: DB connection failed';
15
+		}
14 16
 		//Connection::$db->beginTransaction();
15 17
 		$templine = '';
16 18
 		$handle = @fopen($filename,"r");
@@ -19,7 +21,9 @@  discard block
 block discarded – undo
19 21
 			//foreach ($lines as $line)
20 22
 			while (($line = fgets($handle,4096)) !== false)
21 23
 			{
22
-				if (substr($line,0,2) == '--' || $line == '') continue;
24
+				if (substr($line,0,2) == '--' || $line == '') {
25
+					continue;
26
+				}
23 27
 				$templine .= $line;
24 28
 				if (substr(trim($line), -1,1) == ';')
25 29
 				{
@@ -45,7 +49,9 @@  discard block
 block discarded – undo
45 49
 		//foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename)
46 50
 		while(false !== ($filename = readdir($dh)))
47 51
 		{
48
-			if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename);
52
+			if (preg_match('/\.sql$/',$filename)) {
53
+				$error .= create_db::import_file($directory.$filename);
54
+			}
49 55
 		}
50 56
 		return $error;
51 57
 	}
@@ -58,19 +64,29 @@  discard block
 block discarded – undo
58 64
 		$db = filter_var($db,FILTER_SANITIZE_STRING);
59 65
 		$db_type = filter_var($db_type,FILTER_SANITIZE_STRING);
60 66
 		$host = filter_var($host,FILTER_SANITIZE_STRING);
61
-		if ($db_type == 'mysql' && $port == '') $port = 3306;
62
-		elseif ($port == '') $port = 5432;
67
+		if ($db_type == 'mysql' && $port == '') {
68
+			$port = 3306;
69
+		} elseif ($port == '') {
70
+			$port = 5432;
71
+		}
63 72
 		// Dirty hack
64 73
 		if ($host != 'localhost' && $host != '127.0.0.1') {
65 74
 			$grantright = $_SERVER['SERVER_ADDR'];
66
-		} else $grantright = 'localhost';
75
+		} else {
76
+			$grantright = 'localhost';
77
+		}
67 78
 		try {
68
-			if ($host == 'localhost') $dbh = new PDO($db_type.':host=127.0.0.1',$root,$root_pass);
69
-			else $dbh = new PDO($db_type.':host='.$host.';port='.$port,$root,$root_pass);
79
+			if ($host == 'localhost') {
80
+				$dbh = new PDO($db_type.':host=127.0.0.1',$root,$root_pass);
81
+			} else {
82
+				$dbh = new PDO($db_type.':host='.$host.';port='.$port,$root,$root_pass);
83
+			}
70 84
 			$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
71 85
 			if ($db_type == 'mysql') {
72 86
 				$dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
73
-				if ($grantright == 'localhost') $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
87
+				if ($grantright == 'localhost') {
88
+					$dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
89
+				}
74 90
 			} else if ($db_type == 'pgsql') {
75 91
 				$dbh->exec("CREATE DATABASE ".$db.";");
76 92
 				$dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."';
Please login to merge, or discard this patch.
live-sat-geojson.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 		header('Content-disposition: attachment; filename="flightairmap-sat.json"');
14 14
 	}
15 15
 }
16
-$history = urldecode(filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING));
16
+$history = urldecode(filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING));
17 17
 header('Content-Type: text/javascript');
18 18
 
19 19
 $begintime = microtime(true);
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 
22 22
 $spotter_array = array();
23 23
 if (isset($_COOKIE['sattypes']) && $_COOKIE['sattypes'] != '') {
24
-	$sattypes = explode(',',$_COOKIE['sattypes']);
24
+	$sattypes = explode(',', $_COOKIE['sattypes']);
25 25
 	foreach ($sattypes as $sattype) {
26 26
 		//$spotter_array = array_merge($Satellite->position_all_type($sattype,$timeb-$globalLiveInterval,$timeb),$spotter_array);
27
-		$spotter_array = array_merge($Satellite->position_all_type($sattype),$spotter_array);
27
+		$spotter_array = array_merge($Satellite->position_all_type($sattype), $spotter_array);
28 28
 	}
29 29
 }
30 30
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 //$spotter_array = array_unique($spotter_array,SORT_REGULAR);
38 38
 //print_r($spotter_array);
39
-$sqltime = round(microtime(true)-$begintime,2);
39
+$sqltime = round(microtime(true) - $begintime, 2);
40 40
 
41 41
 $output = '{"type":"FeatureCollection","features":[';
42 42
 if (!empty($spotter_array) && is_array($spotter_array))
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	$last_name = '';
45 45
 	$coordinatearray = '';
46 46
 	$timearray = array();
47
-	foreach($spotter_array as $spotter_item)
47
+	foreach ($spotter_array as $spotter_item)
48 48
 	{
49 49
 		$output_data = '';
50 50
 		$output_data .= '{"type":"Feature","properties":{';
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 		}
62 62
 		$output_data .= '"altitude":0,';
63 63
 		$output_data .= '"sqt":'.$sqltime.',';
64
-		$nextlatlon = $Satellite->position($spotter_item['name'],time()+$globalMapRefresh+20);
64
+		$nextlatlon = $Satellite->position($spotter_item['name'], time() + $globalMapRefresh + 20);
65 65
 		$nextlat = $nextlatlon['latitude'];
66
-		if (abs($nextlat-$spotter_item['latitude']) > 90) {
66
+		if (abs($nextlat - $spotter_item['latitude']) > 90) {
67 67
 			if ($spotter_item['latitude'] < 0) $nexlat = -90;
68 68
 			else $nexlat = 90;
69 69
 		}
70 70
 		$nextlon = $nextlatlon['longitude'];
71
-		if (abs($nextlon-$spotter_item['longitude']) > 180) {
71
+		if (abs($nextlon - $spotter_item['longitude']) > 180) {
72 72
 			if ($spotter_item['longitude'] < 0) $nextlon = -180;
73 73
 			else $nextlon = 180;
74 74
 		}
@@ -79,27 +79,27 @@  discard block
 block discarded – undo
79 79
 		$output_data .= ']}},';
80 80
 		$output .= $output_data;
81 81
 		if ($history == $spotter_item['name']) {
82
-			$spotter_history_array = $Satellite->position($spotter_item['name'],time()-6000,time());
82
+			$spotter_history_array = $Satellite->position($spotter_item['name'], time() - 6000, time());
83 83
 			$spotter_history_array = array_reverse($spotter_history_array);
84 84
 			$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['name'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
85 85
 			foreach ($spotter_history_array as $key => $spotter_history) {
86
-				if ((isset($previous_lon) && abs($previous_lon-$spotter_history['longitude']) > 180) || (isset($previous_lat) && abs($previous_lat-$spotter_history['latitude']) > 90)) {
86
+				if ((isset($previous_lon) && abs($previous_lon - $spotter_history['longitude']) > 180) || (isset($previous_lat) && abs($previous_lat - $spotter_history['latitude']) > 90)) {
87 87
 					break;
88 88
 				}
89 89
 				$output_history .= '[';
90
-				$output_history .=  $spotter_history['longitude'].', ';
91
-				$output_history .=  $spotter_history['latitude'];
90
+				$output_history .= $spotter_history['longitude'].', ';
91
+				$output_history .= $spotter_history['latitude'];
92 92
 				$output_history .= '],';
93 93
 				$previous_lon = $spotter_history['longitude'];
94 94
 				$previous_lat = $spotter_history['latitude'];
95 95
 			}
96
-			$output_history = substr($output_history,0,-1);
96
+			$output_history = substr($output_history, 0, -1);
97 97
 			$output_history .= ']}},';
98 98
 			$output .= $output_history;
99 99
 		}
100 100
 	}
101 101
 }
102
-if (isset($output_data)) $output = substr($output,0,-1);
102
+if (isset($output_data)) $output = substr($output, 0, -1);
103 103
 $output .= ']}';
104 104
 print $output;
105 105
 ?>
Please login to merge, or discard this patch.
Braces   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -64,13 +64,19 @@  discard block
 block discarded – undo
64 64
 		$nextlatlon = $Satellite->position($spotter_item['name'],time()+$globalMapRefresh+20);
65 65
 		$nextlat = $nextlatlon['latitude'];
66 66
 		if (abs($nextlat-$spotter_item['latitude']) > 90) {
67
-			if ($spotter_item['latitude'] < 0) $nexlat = -90;
68
-			else $nexlat = 90;
67
+			if ($spotter_item['latitude'] < 0) {
68
+				$nexlat = -90;
69
+			} else {
70
+				$nexlat = 90;
71
+			}
69 72
 		}
70 73
 		$nextlon = $nextlatlon['longitude'];
71 74
 		if (abs($nextlon-$spotter_item['longitude']) > 180) {
72
-			if ($spotter_item['longitude'] < 0) $nextlon = -180;
73
-			else $nextlon = 180;
75
+			if ($spotter_item['longitude'] < 0) {
76
+				$nextlon = -180;
77
+			} else {
78
+				$nextlon = 180;
79
+			}
74 80
 		}
75 81
 		$output_data .= '"nextlatlon":['.$nextlat.','.$nextlon.']},';
76 82
 		//$output_data .= '"heading":"'.$Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$nextlatlon['latitude'],$nextlatlon['longitude']).'",';
@@ -99,7 +105,9 @@  discard block
 block discarded – undo
99 105
 		}
100 106
 	}
101 107
 }
102
-if (isset($output_data)) $output = substr($output,0,-1);
108
+if (isset($output_data)) {
109
+	$output = substr($output,0,-1);
110
+}
103 111
 $output .= ']}';
104 112
 print $output;
105 113
 ?>
Please login to merge, or discard this patch.
live-sat-czml.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -20,17 +20,17 @@  discard block
 block discarded – undo
20 20
 
21 21
 $spotter_array = array();
22 22
 if (isset($_COOKIE['sattypes']) && $_COOKIE['sattypes'] != '') {
23
-	$sattypes = explode(',',$_COOKIE['sattypes']);
23
+	$sattypes = explode(',', $_COOKIE['sattypes']);
24 24
 	foreach ($sattypes as $sattype) {
25
-		$spotter_array = array_merge($Satellite->position_all_type($sattype,$timeb-$globalLiveInterval,$timeb),$spotter_array);
25
+		$spotter_array = array_merge($Satellite->position_all_type($sattype, $timeb - $globalLiveInterval, $timeb), $spotter_array);
26 26
 	}
27 27
 }
28 28
 if ((isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') || !isset($_COOKIE['displayiss'])) {
29
-	$spotter_array = array_merge($Satellite->position('ISS (ZARYA)',time()-$globalLiveInterval,time()),$spotter_array);
30
-	$spotter_array = array_merge($Satellite->position('TIANGONG 1',time()-$globalLiveInterval,time()),$spotter_array);
31
-	$spotter_array = array_merge($Satellite->position('TIANGONG-2',time()-$globalLiveInterval,time()),$spotter_array);
29
+	$spotter_array = array_merge($Satellite->position('ISS (ZARYA)', time() - $globalLiveInterval, time()), $spotter_array);
30
+	$spotter_array = array_merge($Satellite->position('TIANGONG 1', time() - $globalLiveInterval, time()), $spotter_array);
31
+	$spotter_array = array_merge($Satellite->position('TIANGONG-2', time() - $globalLiveInterval, time()), $spotter_array);
32 32
 }
33
-$spotter_array = array_unique($spotter_array,SORT_REGULAR);
33
+$spotter_array = array_unique($spotter_array, SORT_REGULAR);
34 34
 /*
35 35
 $modelsdb = array();
36 36
 if (file_exists('models/space/space_modelsdb')) {
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "LOOP_STOP","step": "SYSTEM_CLOCK_MULTIPLIER"}';
55 55
 
56 56
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
57
-$output .= ',"clock": {"currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
57
+$output .= ',"clock": {"currentTime" : "'.date("c", time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
58 58
 //$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
59 59
 
60 60
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"step": "SYSTEM_CLOCK_MULTIPLIER"}';
61 61
 $output .= '},';
62 62
 if (!empty($spotter_array) && is_array($spotter_array))
63 63
 {
64
-	foreach($spotter_array as $spotter_item)
64
+	foreach ($spotter_array as $spotter_item)
65 65
 	{
66 66
 		$j++;
67 67
 		date_default_timezone_set('UTC');
@@ -115,23 +115,23 @@  discard block
 block discarded – undo
115 115
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/cubiesat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
116 116
 				} elseif ($spotter_item['name'] == 'TERRA') {
117 117
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/terra.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
118
-				} elseif (strpos($spotter_item['name'],'O3B') !== false) {
118
+				} elseif (strpos($spotter_item['name'], 'O3B') !== false) {
119 119
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/o3b.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
120
-				} elseif (strpos($spotter_item['name'],'GLOBALSTAR') !== false) {
120
+				} elseif (strpos($spotter_item['name'], 'GLOBALSTAR') !== false) {
121 121
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/globalstar.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
122
-				} elseif (strpos($spotter_item['name'],'GPS') !== false) {
122
+				} elseif (strpos($spotter_item['name'], 'GPS') !== false) {
123 123
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/gps.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
124
-				} elseif (strpos($spotter_item['name'],'GENESIS') !== false) {
124
+				} elseif (strpos($spotter_item['name'], 'GENESIS') !== false) {
125 125
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/genesis.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
126
-				} elseif (strpos($spotter_item['name'],'OSCAR 7') !== false) {
126
+				} elseif (strpos($spotter_item['name'], 'OSCAR 7') !== false) {
127 127
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/oscar7.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
128
-				} elseif (strpos($spotter_item['name'],'FLOCK') !== false) {
128
+				} elseif (strpos($spotter_item['name'], 'FLOCK') !== false) {
129 129
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/cubesat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
130
-				} elseif (strpos($spotter_item['name'],'PLEIADES') !== false) {
130
+				} elseif (strpos($spotter_item['name'], 'PLEIADES') !== false) {
131 131
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/pleiades.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
132
-				} elseif (strpos($spotter_item['name'],'DUCHIFAT') !== false) {
132
+				} elseif (strpos($spotter_item['name'], 'DUCHIFAT') !== false) {
133 133
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/duchifat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
134
-				} elseif (strpos($spotter_item['name'],'FORMOSAT-2') !== false) {
134
+				} elseif (strpos($spotter_item['name'], 'FORMOSAT-2') !== false) {
135 135
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/formosat2.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
136 136
 				} elseif ($spotter_item['type'] == 'iridium') {
137 137
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/iridium.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
154 154
 			$output .= '"interpolationAlgorithm":"HERMITE","interpolationDegree":3,';
155 155
 			$output .= '"cartographicDegrees": [';
156
-			$output .= '"'.date("c",$spotter_item['timestamp']).'", ';
156
+			$output .= '"'.date("c", $spotter_item['timestamp']).'", ';
157 157
 			$output .= $spotter_item['longitude'].', ';
158 158
 			$output .= $spotter_item['latitude'].', ';
159 159
 			$output .= $spotter_item['altitude']*1000;
160 160
 			$orientation = '"orientation" : { ';
161 161
 			$orientation .= '"unitQuaternion": [';
162 162
 		} else {
163
-			$output .= ',"'.date("c",$spotter_item['timestamp']).'", ';
163
+			$output .= ',"'.date("c", $spotter_item['timestamp']).'", ';
164 164
 			$output .= $spotter_item['longitude'].', ';
165 165
 			$output .= $spotter_item['latitude'].', ';
166 166
 			$output .= $spotter_item['altitude']*1000;
Please login to merge, or discard this patch.
location-data.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 $Source = new Source();
6 6
 
7 7
 if (isset($_GET['sourceid'])) {
8
-	$sourceid = filter_input(INPUT_GET,'sourceid',FILTER_SANITIZE_NUMBER_INT);
8
+	$sourceid = filter_input(INPUT_GET, 'sourceid', FILTER_SANITIZE_NUMBER_INT);
9 9
 	$source_data = $Source->getLocationInfoById($sourceid);
10 10
 	if (isset($source_data[0])) {
11 11
  ?>
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 print '</div>';
38 38
 
39 39
 if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
40
-if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
41
-print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],4).', '.round($spotter_item['longitude'],4).'</div>';
40
+if ($spotter_item['country'] != '') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
41
+print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'], 4).', '.round($spotter_item['longitude'], 4).'</div>';
42 42
 /*
43 43
 if ($spotter_item['atc_range'] > 0) {
44 44
     print '<div><span>'._("Range").'</span>';
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 }
48 48
 */
49 49
 if ($spotter_item['type'] == 'wx') {
50
-	$weather = json_decode($spotter_item['description'],true);
50
+	$weather = json_decode($spotter_item['description'], true);
51 51
 	//print_r($weather);
52 52
 	if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
53 53
 	if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
Please login to merge, or discard this patch.
Braces   +40 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,12 +17,19 @@  discard block
 block discarded – undo
17 17
 date_default_timezone_set('UTC');
18 18
 
19 19
 print '<div class="top">';
20
-if ($spotter_item['name'] != '') print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>';
21
-elseif ($spotter_item['location_id'] != 0) print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>';
22
-elseif ($spotter_item['type'] == 'lightning') print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Lightning").'</div>';
23
-elseif ($spotter_item['type'] == 'wx') print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Weather Station").'</div>';
24
-elseif ($spotter_item['type'] == 'fires') print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Fire").'</div>';
25
-else print '<div class="right"><div class="callsign-details"><div class="callsign"></div>';
20
+if ($spotter_item['name'] != '') {
21
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>';
22
+} elseif ($spotter_item['location_id'] != 0) {
23
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>';
24
+} elseif ($spotter_item['type'] == 'lightning') {
25
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Lightning").'</div>';
26
+} elseif ($spotter_item['type'] == 'wx') {
27
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Weather Station").'</div>';
28
+} elseif ($spotter_item['type'] == 'fires') {
29
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Fire").'</div>';
30
+} else {
31
+	print '<div class="right"><div class="callsign-details"><div class="callsign"></div>';
32
+}
26 33
 print '</div>';
27 34
 
28 35
 print '</div></div>';
@@ -40,8 +47,12 @@  discard block
 block discarded – undo
40 47
 print $spotter_item['last_seen'].' UTC';
41 48
 print '</div>';
42 49
 
43
-if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
44
-if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
50
+if ($spotter_item['city'] != '') {
51
+	print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
52
+}
53
+if ($spotter_item['country'] !='') {
54
+	print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
55
+}
45 56
 print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],4).', '.round($spotter_item['longitude'],4).'</div>';
46 57
 /*
47 58
 if ($spotter_item['atc_range'] > 0) {
@@ -53,13 +64,27 @@  discard block
 block discarded – undo
53 64
 if ($spotter_item['type'] == 'wx') {
54 65
 	$weather = json_decode($spotter_item['description'],true);
55 66
 	//print_r($weather);
56
-	if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
57
-	if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
58
-	if (isset($weather['wind_gust'])) print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>';
59
-	if (isset($weather['humidity'])) print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>';
60
-	if (isset($weather['rain'])) print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>';
61
-	if (isset($weather['precipitation'])) print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>';
62
-	if (isset($weather['precipitation24h'])) print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>';
67
+	if (isset($weather['temp'])) {
68
+		print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
69
+	}
70
+	if (isset($weather['pressure'])) {
71
+		print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
72
+	}
73
+	if (isset($weather['wind_gust'])) {
74
+		print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>';
75
+	}
76
+	if (isset($weather['humidity'])) {
77
+		print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>';
78
+	}
79
+	if (isset($weather['rain'])) {
80
+		print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>';
81
+	}
82
+	if (isset($weather['precipitation'])) {
83
+		print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>';
84
+	}
85
+	if (isset($weather['precipitation24h'])) {
86
+		print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>';
87
+	}
63 88
 	$spotter_item['description'] = $weather['comment'];
64 89
 } elseif ($spotter_item['type'] == 'fires') {
65 90
 	//print_r(json_decode($spotter_item['description'],true));
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	/**
15 15
 	* Get SQL query part for filter used
16 16
 	* @param Array $filter the filter
17
-	* @return Array the SQL part
17
+	* @return string the SQL part
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
Please login to merge, or discard this patch.
Braces   +40 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	public function __construct($dbc = null) {
7 7
 		$Connection = new Connection($dbc);
8 8
 		$this->db = $Connection->db;
9
-		if ($this->db === null) die('Error: No DB connection. (SpotterArchive)');
9
+		if ($this->db === null) {
10
+			die('Error: No DB connection. (SpotterArchive)');
11
+		}
10 12
 	}
11 13
 
12 14
 	/**
@@ -27,7 +29,9 @@  discard block
 block discarded – undo
27 29
 		if (isset($filter[0]['source'])) {
28 30
 			$filters = array_merge($filters,$filter);
29 31
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
31 35
 		$filter_query_join = '';
32 36
 		$filter_query_where = '';
33 37
 		foreach($filters as $flt) {
@@ -119,8 +123,11 @@  discard block
 block discarded – undo
119 123
 			}
120 124
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
121 125
 		}
122
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
123
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
126
+		if ($filter_query_where == '' && $where) {
127
+			$filter_query_where = ' WHERE';
128
+		} elseif ($filter_query_where != '' && $and) {
129
+			$filter_query_where .= ' AND';
130
+		}
124 131
 		if ($filter_query_where != '') {
125 132
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
126 133
 		}
@@ -134,10 +141,17 @@  discard block
 block discarded – undo
134 141
 		if ($over_country == '') {
135 142
 			$Spotter = new Spotter($this->db);
136 143
 			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
137
-			if (!empty($data_country)) $country = $data_country['iso2'];
138
-			else $country = '';
139
-		} else $country = $over_country;
140
-		if ($airline_type === NULL) $airline_type ='';
144
+			if (!empty($data_country)) {
145
+				$country = $data_country['iso2'];
146
+			} else {
147
+				$country = '';
148
+			}
149
+		} else {
150
+			$country = $over_country;
151
+		}
152
+		if ($airline_type === NULL) {
153
+			$airline_type ='';
154
+		}
141 155
 
142 156
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
143 157
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
@@ -598,7 +612,9 @@  discard block
 block discarded – undo
598 612
 					$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
599 613
 					$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
600 614
 					$translate = $Translation->ident2icao($q_item);
601
-					if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
615
+					if ($translate != $q_item) {
616
+						$additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
617
+					}
602 618
 					$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
603 619
 					$additional_query .= ")";
604 620
 				}
@@ -778,7 +794,9 @@  discard block
 block discarded – undo
778 794
 				date_default_timezone_set($globalTimezone);
779 795
 				$datetime = new DateTime();
780 796
 				$offset = $datetime->format('P');
781
-			} else $offset = '+00:00';
797
+			} else {
798
+				$offset = '+00:00';
799
+			}
782 800
 			if ($date_array[1] != "") {
783 801
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
784 802
 				$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
@@ -1021,9 +1039,13 @@  discard block
 block discarded – undo
1021 1039
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1022 1040
 			}
1023 1041
 		}
1024
-		if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1042
+		if ($sincedate != '') {
1043
+			$query .= "AND date > '".$sincedate."' ";
1044
+		}
1025 1045
 		$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1026
-		if ($limit) $query .= " LIMIT 0,10";
1046
+		if ($limit) {
1047
+			$query .= " LIMIT 0,10";
1048
+		}
1027 1049
 
1028 1050
 
1029 1051
 		$sth = $this->db->prepare($query);
@@ -1065,9 +1087,13 @@  discard block
 block discarded – undo
1065 1087
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1066 1088
 			}
1067 1089
 		}
1068
-		if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1090
+		if ($sincedate != '') {
1091
+			$query .= "AND s.date > '".$sincedate."' ";
1092
+		}
1069 1093
 		$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1070
-		if ($limit) $query .= " LIMIT 0,10";
1094
+		if ($limit) {
1095
+			$query .= " LIMIT 0,10";
1096
+		}
1071 1097
 
1072 1098
 
1073 1099
 		$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 	}
11 11
 
12 12
 	/**
13
-	* Get SQL query part for filter used
14
-	* @param Array $filter the filter
15
-	* @return Array the SQL part
16
-	*/
13
+	 * Get SQL query part for filter used
14
+	 * @param Array $filter the filter
15
+	 * @return Array the SQL part
16
+	 */
17 17
 	public function getFilter($filter = array(),$where = false,$and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 
160 160
 
161 161
 	/**
162
-	* Gets all the spotter information based on a particular callsign
163
-	*
164
-	* @return Array the spotter information
165
-	*
166
-	*/
162
+	 * Gets all the spotter information based on a particular callsign
163
+	 *
164
+	 * @return Array the spotter information
165
+	 *
166
+	 */
167 167
 	public function getLastArchiveSpotterDataByIdent($ident) {
168 168
 		$Spotter = new Spotter($this->db);
169 169
 		date_default_timezone_set('UTC');
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 
180 180
 
181 181
 	/**
182
-	* Gets last the spotter information based on a particular id
183
-	*
184
-	* @return Array the spotter information
185
-	*
186
-	*/
182
+	 * Gets last the spotter information based on a particular id
183
+	 *
184
+	 * @return Array the spotter information
185
+	 *
186
+	 */
187 187
 	public function getLastArchiveSpotterDataById($id) {
188 188
 		$Spotter = new Spotter($this->db);
189 189
 		date_default_timezone_set('UTC');
@@ -209,11 +209,11 @@  discard block
 block discarded – undo
209 209
 	}
210 210
 
211 211
 	/**
212
-	* Gets all the spotter information based on a particular id
213
-	*
214
-	* @return Array the spotter information
215
-	*
216
-	*/
212
+	 * Gets all the spotter information based on a particular id
213
+	 *
214
+	 * @return Array the spotter information
215
+	 *
216
+	 */
217 217
 	public function getAllArchiveSpotterDataById($id) {
218 218
 		date_default_timezone_set('UTC');
219 219
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
 	}
235 235
 
236 236
 	/**
237
-	* Gets coordinate & time spotter information based on a particular id
238
-	*
239
-	* @return Array the spotter information
240
-	*
241
-	*/
237
+	 * Gets coordinate & time spotter information based on a particular id
238
+	 *
239
+	 * @return Array the spotter information
240
+	 *
241
+	 */
242 242
 	public function getCoordArchiveSpotterDataById($id) {
243 243
 		date_default_timezone_set('UTC');
244 244
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 	}
256 256
 
257 257
 	/**
258
-	* Gets coordinate & time spotter information based on a particular id
259
-	*
260
-	* @return Array the spotter information
261
-	*
262
-	*/
258
+	 * Gets coordinate & time spotter information based on a particular id
259
+	 *
260
+	 * @return Array the spotter information
261
+	 *
262
+	 */
263 263
 	public function getCoordArchiveSpotterDataByIdDate($id,$begindate,$enddate) {
264 264
 		date_default_timezone_set('UTC');
265 265
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
 
278 278
 
279 279
 	/**
280
-	* Gets altitude information based on a particular callsign
281
-	*
282
-	* @return Array the spotter information
283
-	*
284
-	*/
280
+	 * Gets altitude information based on a particular callsign
281
+	 *
282
+	 * @return Array the spotter information
283
+	 *
284
+	 */
285 285
 	public function getAltitudeArchiveSpotterDataByIdent($ident) {
286 286
 
287 287
 		date_default_timezone_set('UTC');
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
 	}
303 303
 
304 304
 	/**
305
-	* Gets altitude information based on a particular id
306
-	*
307
-	* @return Array the spotter information
308
-	*
309
-	*/
305
+	 * Gets altitude information based on a particular id
306
+	 *
307
+	 * @return Array the spotter information
308
+	 *
309
+	 */
310 310
 	public function getAltitudeArchiveSpotterDataById($id) {
311 311
 
312 312
 		date_default_timezone_set('UTC');
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
 	}
328 328
 
329 329
 	/**
330
-	* Gets altitude & speed information based on a particular id
331
-	*
332
-	* @return Array the spotter information
333
-	*
334
-	*/
330
+	 * Gets altitude & speed information based on a particular id
331
+	 *
332
+	 * @return Array the spotter information
333
+	 *
334
+	 */
335 335
 	public function getAltitudeSpeedArchiveSpotterDataById($id) {
336 336
 		date_default_timezone_set('UTC');
337 337
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -348,11 +348,11 @@  discard block
 block discarded – undo
348 348
 	}
349 349
 
350 350
 	/**
351
-	* Gets altitude information based on a particular callsign
352
-	*
353
-	* @return Array the spotter information
354
-	*
355
-	*/
351
+	 * Gets altitude information based on a particular callsign
352
+	 *
353
+	 * @return Array the spotter information
354
+	 *
355
+	 */
356 356
 	public function getLastAltitudeArchiveSpotterDataByIdent($ident) {
357 357
 		date_default_timezone_set('UTC');
358 358
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
 	}
403 403
 
404 404
 	/**
405
-	    * Gets Minimal Live Spotter data
406
-	    *
407
-	    * @return Array the spotter information
408
-	    *
409
-	    */
405
+	 * Gets Minimal Live Spotter data
406
+	 *
407
+	 * @return Array the spotter information
408
+	 *
409
+	 */
410 410
 	public function getMinLiveSpotterData($begindate,$enddate,$filter = array(),$part = 0) {
411 411
 		global $globalDBdriver, $globalLiveInterval;
412 412
 		date_default_timezone_set('UTC');
@@ -466,11 +466,11 @@  discard block
 block discarded – undo
466 466
 	}
467 467
 
468 468
 	/**
469
-	    * Gets Minimal Live Spotter data
470
-	    *
471
-	    * @return Array the spotter information
472
-	    *
473
-	    */
469
+	 * Gets Minimal Live Spotter data
470
+	 *
471
+	 * @return Array the spotter information
472
+	 *
473
+	 */
474 474
 	public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) {
475 475
 		global $globalDBdriver, $globalLiveInterval;
476 476
 		date_default_timezone_set('UTC');
@@ -537,11 +537,11 @@  discard block
 block discarded – undo
537 537
 	}
538 538
 
539 539
 	/**
540
-	   * Gets count Live Spotter data
541
-	   *
542
-	   * @return Array the spotter information
543
-	   *
544
-	   */
540
+	 * Gets count Live Spotter data
541
+	 *
542
+	 * @return Array the spotter information
543
+	 *
544
+	 */
545 545
 	public function getLiveSpotterCount($begindate,$enddate,$filter = array()) {
546 546
 		global $globalDBdriver, $globalLiveInterval;
547 547
 		date_default_timezone_set('UTC');
@@ -587,11 +587,11 @@  discard block
 block discarded – undo
587 587
 	// Spotter_Archive_output
588 588
 
589 589
 	/**
590
-	* Gets all the spotter information
591
-	*
592
-	* @return Array the spotter information
593
-	*
594
-	*/
590
+	 * Gets all the spotter information
591
+	 *
592
+	 * @return Array the spotter information
593
+	 *
594
+	 */
595 595
 	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) {
596 596
 		global $globalTimezone, $globalDBdriver;
597 597
 		require_once(dirname(__FILE__).'/class.Translation.php');
@@ -883,11 +883,11 @@  discard block
 block discarded – undo
883 883
 	}
884 884
 
885 885
 	/**
886
-	* Gets all the spotter information based on the callsign
887
-	*
888
-	* @return Array the spotter information
889
-	*
890
-	*/
886
+	 * Gets all the spotter information based on the callsign
887
+	 *
888
+	 * @return Array the spotter information
889
+	 *
890
+	 */
891 891
 	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') {
892 892
 		$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
893 893
 
@@ -935,11 +935,11 @@  discard block
 block discarded – undo
935 935
 
936 936
 
937 937
 	/**
938
-	* Gets all the spotter information based on the owner
939
-	*
940
-	* @return Array the spotter information
941
-	*
942
-	*/
938
+	 * Gets all the spotter information based on the owner
939
+	 *
940
+	 * @return Array the spotter information
941
+	 *
942
+	 */
943 943
 	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) {
944 944
 		$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
945 945
 
@@ -987,11 +987,11 @@  discard block
 block discarded – undo
987 987
 	}
988 988
 
989 989
 	/**
990
-	* Gets all the spotter information based on the pilot
991
-	*
992
-	* @return Array the spotter information
993
-	*
994
-	*/
990
+	 * Gets all the spotter information based on the pilot
991
+	 *
992
+	 * @return Array the spotter information
993
+	 *
994
+	 */
995 995
 	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) {
996 996
 		$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
997 997
 
@@ -1035,11 +1035,11 @@  discard block
 block discarded – undo
1035 1035
 	}
1036 1036
 
1037 1037
 	/**
1038
-	* Gets all number of flight over countries
1039
-	*
1040
-	* @return Array the airline country list
1041
-	*
1042
-	*/
1038
+	 * Gets all number of flight over countries
1039
+	 *
1040
+	 * @return Array the airline country list
1041
+	 *
1042
+	 */
1043 1043
 	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') {
1044 1044
 		global $globalDBdriver;
1045 1045
 		/*
@@ -1079,11 +1079,11 @@  discard block
 block discarded – undo
1079 1079
 	}
1080 1080
 
1081 1081
 	/**
1082
-	* Gets all number of flight over countries
1083
-	*
1084
-	* @return Array the airline country list
1085
-	*
1086
-	*/
1082
+	 * Gets all number of flight over countries
1083
+	 *
1084
+	 * @return Array the airline country list
1085
+	 *
1086
+	 */
1087 1087
 	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') {
1088 1088
 		global $globalDBdriver;
1089 1089
 		/*
@@ -1124,11 +1124,11 @@  discard block
 block discarded – undo
1124 1124
 	}
1125 1125
 
1126 1126
 	/**
1127
-	* Gets last spotter information based on a particular callsign
1128
-	*
1129
-	* @return Array the spotter information
1130
-	*
1131
-	*/
1127
+	 * Gets last spotter information based on a particular callsign
1128
+	 *
1129
+	 * @return Array the spotter information
1130
+	 *
1131
+	 */
1132 1132
 	public function getDateArchiveSpotterDataById($id,$date) {
1133 1133
 		$Spotter = new Spotter($this->db);
1134 1134
 		date_default_timezone_set('UTC');
@@ -1140,11 +1140,11 @@  discard block
 block discarded – undo
1140 1140
 	}
1141 1141
 
1142 1142
 	/**
1143
-	* Gets all the spotter information based on a particular callsign
1144
-	*
1145
-	* @return Array the spotter information
1146
-	*
1147
-	*/
1143
+	 * Gets all the spotter information based on a particular callsign
1144
+	 *
1145
+	 * @return Array the spotter information
1146
+	 *
1147
+	 */
1148 1148
 	public function getDateArchiveSpotterDataByIdent($ident,$date) {
1149 1149
 		$Spotter = new Spotter($this->db);
1150 1150
 		date_default_timezone_set('UTC');
@@ -1156,11 +1156,11 @@  discard block
 block discarded – undo
1156 1156
 	}
1157 1157
 
1158 1158
 	/**
1159
-	* Gets all the spotter information based on the airport
1160
-	*
1161
-	* @return Array the spotter information
1162
-	*
1163
-	*/
1159
+	 * Gets all the spotter information based on the airport
1160
+	 *
1161
+	 * @return Array the spotter information
1162
+	 *
1163
+	 */
1164 1164
 	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) {
1165 1165
 		global $global_query;
1166 1166
 		$Spotter = new Spotter($this->db);
Please login to merge, or discard this patch.
Spacing   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -14,75 +14,75 @@  discard block
 block discarded – undo
14 14
 	* @param Array $filter the filter
15 15
 	* @return Array the SQL part
16 16
 	*/
17
-	public function getFilter($filter = array(),$where = false,$and = false) {
17
+	public function getFilter($filter = array(), $where = false, $and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
20 20
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 				$filters = $globalStatsFilters[$globalFilterName];
23 23
 			} else {
24
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
24
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
25 25
 			}
26 26
 		}
27 27
 		if (isset($filter[0]['source'])) {
28
-			$filters = array_merge($filters,$filter);
28
+			$filters = array_merge($filters, $filter);
29 29
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
30
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
31 31
 		$filter_query_join = '';
32 32
 		$filter_query_where = '';
33
-		foreach($filters as $flt) {
33
+		foreach ($filters as $flt) {
34 34
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
35 35
 				if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') {
36 36
 					if (isset($flt['source'])) {
37
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
37
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
38 38
 					} else {
39
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
39
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
40 40
 					}
41 41
 				}
42 42
 			}
43 43
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
44 44
 				if (isset($flt['source'])) {
45
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
45
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
46 46
 				} else {
47
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
47
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
48 48
 				}
49 49
 			}
50 50
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
51 51
 				if (isset($flt['source'])) {
52
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
52
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
53 53
 				} else {
54
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
54
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
55 55
 				}
56 56
 			}
57 57
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
58 58
 				if (isset($flt['source'])) {
59
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
59
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
60 60
 				} else {
61
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
61
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
62 62
 				}
63 63
 			}
64 64
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
65 65
 				if (isset($flt['source'])) {
66
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
66
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
67 67
 				}
68 68
 			}
69 69
 		}
70 70
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
71 71
 			if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') {
72
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
72
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
73 73
 			}
74 74
 		}
75 75
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
76 76
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
77 77
 		}
78 78
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
79
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
79
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
80 80
 		}
81 81
 		if (isset($filter['source']) && !empty($filter['source'])) {
82 82
 			if (count($filter['source']) == 1) {
83 83
 				$filter_query_where .= " AND format_source = '".$filter['source'][0]."'";
84 84
 			} else {
85
-				$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
85
+				$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
86 86
 			}
87 87
 		}
88 88
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 			$filter_query_where .= " AND flightaware_id = '".$filter['id']."'";
93 93
 		}
94 94
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
95
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
95
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
96 96
 		}
97 97
 		if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
98 98
 			$filter_query_date = '';
@@ -117,41 +117,41 @@  discard block
 block discarded – undo
117 117
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
118 118
 				}
119 119
 			}
120
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
120
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
121 121
 		}
122 122
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
123 123
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
124 124
 		if ($filter_query_where != '') {
125
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
125
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
126 126
 		}
127 127
 		$filter_query = $filter_query_join.$filter_query_where;
128 128
 		return $filter_query;
129 129
 	}
130 130
 
131 131
 	// Spotter_archive
132
-	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
132
+	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
133 133
 		require_once(dirname(__FILE__).'/class.Spotter.php');
134 134
 		if ($over_country == '') {
135 135
 			$Spotter = new Spotter($this->db);
136
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
136
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
137 137
 			if (!empty($data_country)) $country = $data_country['iso2'];
138 138
 			else $country = '';
139 139
 		} else $country = $over_country;
140
-		if ($airline_type === NULL) $airline_type ='';
140
+		if ($airline_type === NULL) $airline_type = '';
141 141
 
142 142
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
143 143
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
144 144
 
145 145
 		// Route is not added in spotter_archive
146
-		$query  = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude)
146
+		$query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude)
147 147
 		          VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name,:real_altitude)";
148 148
 
149
-		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name,':real_altitude' => $real_altitude);
149
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name, ':real_altitude' => $real_altitude);
150 150
 		try {
151 151
 			$sth = $this->db->prepare($query);
152 152
 			$sth->execute($query_values);
153 153
 			$sth->closeCursor();
154
-		} catch(PDOException $e) {
154
+		} catch (PDOException $e) {
155 155
 			return "error : ".$e->getMessage();
156 156
 		}
157 157
 		return "success";
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 
171 171
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
172 172
 		//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
173
-		$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
173
+		$query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
174 174
 
175
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
175
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
176 176
 
177 177
 		return $spotter_array;
178 178
 	}
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
191 191
 		//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
192 192
 		//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
193
-		$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
193
+		$query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
194 194
 
195 195
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
196 196
 		/*
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		}
204 204
 		$spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
205 205
 		*/
206
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
206
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
207 207
 
208 208
 		return $spotter_array;
209 209
 	}
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 	public function getAllArchiveSpotterDataById($id) {
218 218
 		date_default_timezone_set('UTC');
219 219
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
220
-		$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
220
+		$query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
221 221
 
222 222
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
223 223
 
224 224
 		try {
225 225
 			$sth = $this->db->prepare($query);
226 226
 			$sth->execute(array(':id' => $id));
227
-		} catch(PDOException $e) {
227
+		} catch (PDOException $e) {
228 228
 			echo $e->getMessage();
229 229
 			die;
230 230
 		}
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
 	public function getCoordArchiveSpotterDataById($id) {
243 243
 		date_default_timezone_set('UTC');
244 244
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
245
-		$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER by spotter_archive.date ASC";
245
+		$query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER by spotter_archive.date ASC";
246 246
 		try {
247 247
 			$sth = $this->db->prepare($query);
248 248
 			$sth->execute(array(':id' => $id));
249
-		} catch(PDOException $e) {
249
+		} catch (PDOException $e) {
250 250
 			echo $e->getMessage();
251 251
 			die;
252 252
 		}
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
 	* @return Array the spotter information
261 261
 	*
262 262
 	*/
263
-	public function getCoordArchiveSpotterDataByIdDate($id,$begindate,$enddate) {
263
+	public function getCoordArchiveSpotterDataByIdDate($id, $begindate, $enddate) {
264 264
 		date_default_timezone_set('UTC');
265 265
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
266
-		$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.date BETWEEN :begindate AND :enddate ORDER by spotter_archive.date ASC";
266
+		$query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.date BETWEEN :begindate AND :enddate ORDER by spotter_archive.date ASC";
267 267
 		try {
268 268
 			$sth = $this->db->prepare($query);
269
-			$sth->execute(array(':id' => $id,':begindate' => $begindate,':enddate' => $enddate));
270
-		} catch(PDOException $e) {
269
+			$sth->execute(array(':id' => $id, ':begindate' => $begindate, ':enddate' => $enddate));
270
+		} catch (PDOException $e) {
271 271
 			echo $e->getMessage();
272 272
 			die;
273 273
 		}
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
 		date_default_timezone_set('UTC');
288 288
 
289 289
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
290
-		$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
290
+		$query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
291 291
 
292 292
 		try {
293 293
 			$sth = $this->db->prepare($query);
294 294
 			$sth->execute(array(':ident' => $ident));
295
-		} catch(PDOException $e) {
295
+		} catch (PDOException $e) {
296 296
 			echo $e->getMessage();
297 297
 			die;
298 298
 		}
@@ -312,12 +312,12 @@  discard block
 block discarded – undo
312 312
 		date_default_timezone_set('UTC');
313 313
 
314 314
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
315
-		$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
315
+		$query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
316 316
 
317 317
 		try {
318 318
 			$sth = $this->db->prepare($query);
319 319
 			$sth->execute(array(':id' => $id));
320
-		} catch(PDOException $e) {
320
+		} catch (PDOException $e) {
321 321
 			echo $e->getMessage();
322 322
 			die;
323 323
 		}
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 	public function getAltitudeSpeedArchiveSpotterDataById($id) {
336 336
 		date_default_timezone_set('UTC');
337 337
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
338
-		$query  = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
338
+		$query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
339 339
 		try {
340 340
 			$sth = $this->db->prepare($query);
341 341
 			$sth->execute(array(':id' => $id));
342
-		} catch(PDOException $e) {
342
+		} catch (PDOException $e) {
343 343
 			echo $e->getMessage();
344 344
 			die;
345 345
 		}
@@ -356,12 +356,12 @@  discard block
 block discarded – undo
356 356
 	public function getLastAltitudeArchiveSpotterDataByIdent($ident) {
357 357
 		date_default_timezone_set('UTC');
358 358
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
359
-		$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
359
+		$query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
360 360
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
361 361
 		try {
362 362
 			$sth = $this->db->prepare($query);
363 363
 			$sth->execute(array(':ident' => $ident));
364
-		} catch(PDOException $e) {
364
+		} catch (PDOException $e) {
365 365
 			echo $e->getMessage();
366 366
 			die;
367 367
 		}
@@ -377,11 +377,11 @@  discard block
 block discarded – undo
377 377
 	 * @return Array the spotter information
378 378
 	 *
379 379
 	 */
380
-	public function getSpotterArchiveData($ident,$flightaware_id,$date) {
380
+	public function getSpotterArchiveData($ident, $flightaware_id, $date) {
381 381
 		$Spotter = new Spotter($this->db);
382 382
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
383
-		$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
384
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
383
+		$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
384
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
385 385
 		return $spotter_array;
386 386
 	}
387 387
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 		try {
396 396
 			$sth = $this->db->prepare($query);
397 397
 			$sth->execute();
398
-		} catch(PDOException $e) {
398
+		} catch (PDOException $e) {
399 399
 			echo $e->getMessage();
400 400
 			die;
401 401
 		}
@@ -407,39 +407,39 @@  discard block
 block discarded – undo
407 407
 	    * @return Array the spotter information
408 408
 	    *
409 409
 	    */
410
-	public function getMinLiveSpotterData($begindate,$enddate,$filter = array(),$part = 0) {
410
+	public function getMinLiveSpotterData($begindate, $enddate, $filter = array(), $part = 0) {
411 411
 		global $globalDBdriver, $globalLiveInterval;
412 412
 		date_default_timezone_set('UTC');
413 413
 		//$filter_query = $this->getFilter($filter,true,true);
414 414
 
415 415
 		$filter_query = '';
416 416
 		if (isset($filter['source']) && !empty($filter['source'])) {
417
-			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
417
+			$filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
418 418
 		}
419 419
 		// Use spotter_output also ?
420 420
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
421
-			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
421
+			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
422 422
 		}
423 423
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
424 424
 			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
425 425
 		}
426 426
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
427
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
427
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
428 428
 		}
429 429
 
430 430
 		$limit = '';
431 431
 		if ($part != 0) {
432
-			$limit = ' LIMIT 100 OFFSET '.($part-1)*100;
432
+			$limit = ' LIMIT 100 OFFSET '.($part - 1)*100;
433 433
 		}
434 434
 		if ($globalDBdriver == 'mysql') {
435
-			$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category
435
+			$query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category
436 436
 			          FROM spotter_archive
437 437
 			          INNER JOIN aircraft a on spotter_archive.aircraft_icao = a.icao
438 438
 			          WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".'
439 439
 			          '.$filter_query.' ORDER BY flightaware_id'.$limit;
440 440
 		} else {
441 441
 			
442
-			$query  = 'SELECT spotter_archive.flightaware_id, spotter_archive.date, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category
442
+			$query = 'SELECT spotter_archive.flightaware_id, spotter_archive.date, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category
443 443
 			          FROM spotter_archive
444 444
 			          INNER JOIN aircraft a on spotter_archive.aircraft_icao = a.icao
445 445
 			          WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".'
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 		try {
458 458
 			$sth = $this->db->prepare($query);
459 459
 			$sth->execute();
460
-		} catch(PDOException $e) {
460
+		} catch (PDOException $e) {
461 461
 			echo $e->getMessage();
462 462
 			die;
463 463
 		}
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	    * @return Array the spotter information
472 472
 	    *
473 473
 	    */
474
-	public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) {
474
+	public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) {
475 475
 		global $globalDBdriver, $globalLiveInterval;
476 476
 		date_default_timezone_set('UTC');
477 477
 
@@ -479,17 +479,17 @@  discard block
 block discarded – undo
479 479
 
480 480
 		$filter_query = '';
481 481
 		if (isset($filter['source']) && !empty($filter['source'])) {
482
-			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
482
+			$filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
483 483
 		}
484 484
 		// Use spotter_output also ?
485 485
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
486
-			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
486
+			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
487 487
 		}
488 488
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
489 489
 			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
490 490
 		}
491 491
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
492
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
492
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
493 493
 		}
494 494
 
495 495
 
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 				    FROM spotter_archive
501 501
 				    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
502 502
 			*/
503
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk
503
+			$query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk
504 504
 			          FROM spotter_archive_output
505 505
 			          LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao
506 506
 			          WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".')
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 			 	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
516 516
 			 	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
517 517
 			 */
518
-			$query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
518
+			$query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
519 519
 			          FROM spotter_archive_output
520 520
 			          INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
521 521
 			          WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 		try {
528 528
 			$sth = $this->db->prepare($query);
529 529
 			$sth->execute();
530
-		} catch(PDOException $e) {
530
+		} catch (PDOException $e) {
531 531
 			echo $e->getMessage();
532 532
 			die;
533 533
 		}
@@ -542,22 +542,22 @@  discard block
 block discarded – undo
542 542
 	   * @return Array the spotter information
543 543
 	   *
544 544
 	   */
545
-	public function getLiveSpotterCount($begindate,$enddate,$filter = array()) {
545
+	public function getLiveSpotterCount($begindate, $enddate, $filter = array()) {
546 546
 		global $globalDBdriver, $globalLiveInterval;
547 547
 		date_default_timezone_set('UTC');
548 548
 
549 549
 		$filter_query = '';
550 550
 		if (isset($filter['source']) && !empty($filter['source'])) {
551
-			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
551
+			$filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
552 552
 		}
553 553
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
554
-			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
554
+			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
555 555
 		}
556 556
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
557 557
 			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
558 558
 		}
559 559
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
560
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
560
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
561 561
 		}
562 562
 
563 563
 		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 		try {
573 573
 			$sth = $this->db->prepare($query);
574 574
 			$sth->execute();
575
-		} catch(PDOException $e) {
575
+		} catch (PDOException $e) {
576 576
 			echo $e->getMessage();
577 577
 			die;
578 578
 		}
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 	* @return Array the spotter information
593 593
 	*
594 594
 	*/
595
-	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) {
595
+	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) {
596 596
 		global $globalTimezone, $globalDBdriver;
597 597
 		require_once(dirname(__FILE__).'/class.Translation.php');
598 598
 		$Translation = new Translation($this->db);
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 		}
643 643
 
644 644
 		if ($registration != "") {
645
-			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
645
+			$registration = filter_var($registration, FILTER_SANITIZE_STRING);
646 646
 			if (!is_string($registration)) {
647 647
 				return array();
648 648
 			} else {
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 
653 653
 		if ($aircraft_icao != "") {
654
-			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
654
+			$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
655 655
 			if (!is_string($aircraft_icao)) {
656 656
 				return array();
657 657
 			} else {
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 		}
661 661
 
662 662
 		if ($aircraft_manufacturer != "") {
663
-			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
663
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
664 664
 			if (!is_string($aircraft_manufacturer)) {
665 665
 				return array();
666 666
 			} else {
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 		}
678 678
 
679 679
 		if ($airline_icao != "") {
680
-			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
680
+			$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
681 681
 			if (!is_string($airline_icao)) {
682 682
 				return array();
683 683
 			} else {
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 		}
687 687
 
688 688
 		if ($airline_country != "") {
689
-			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
689
+			$airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
690 690
 			if (!is_string($airline_country)) {
691 691
 				return array();
692 692
 			} else {
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 		}
696 696
 
697 697
 		if ($airline_type != "") {
698
-			$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
698
+			$airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
699 699
 			if (!is_string($airline_type)) {
700 700
 				return array();
701 701
 			} else {
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 		}
713 713
 
714 714
 		if ($airport != "") {
715
-			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
715
+			$airport = filter_var($airport, FILTER_SANITIZE_STRING);
716 716
 			if (!is_string($airport)) {
717 717
 				return array();
718 718
 			} else {
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 		}
722 722
 
723 723
 		if ($airport_country != "") {
724
-			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
724
+			$airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
725 725
 			if (!is_string($airport_country)) {
726 726
 				return array();
727 727
 			} else {
@@ -730,14 +730,14 @@  discard block
 block discarded – undo
730 730
 		}
731 731
 
732 732
 		if ($callsign != "") {
733
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
733
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
734 734
 			if (!is_string($callsign)) {
735 735
 				return array();
736 736
 			} else {
737 737
 				$translate = $Translation->ident2icao($callsign);
738 738
 				if ($translate != $callsign) {
739 739
 					$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
740
-					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
740
+					$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
741 741
 				} else {
742 742
 					$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
743 743
 				}
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 		}
746 746
 
747 747
 		if ($owner != "") {
748
-			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
748
+			$owner = filter_var($owner, FILTER_SANITIZE_STRING);
749 749
 			if (!is_string($owner)) {
750 750
 				return array();
751 751
 			} else {
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 		}
755 755
 
756 756
 		if ($pilot_name != "") {
757
-			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
757
+			$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
758 758
 			if (!is_string($pilot_name)) {
759 759
 				return array();
760 760
 			} else {
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 		}
764 764
 
765 765
 		if ($pilot_id != "") {
766
-			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
766
+			$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
767 767
 			if (!is_string($pilot_id)) {
768 768
 				return array();
769 769
 			} else {
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 		}
773 773
 
774 774
 		if ($departure_airport_route != "") {
775
-			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
775
+			$departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
776 776
 			if (!is_string($departure_airport_route)) {
777 777
 				return array();
778 778
 			} else {
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 		}
782 782
 
783 783
 		if ($arrival_airport_route != "") {
784
-			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
784
+			$arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
785 785
 			if (!is_string($arrival_airport_route)) {
786 786
 				return array();
787 787
 			} else {
@@ -792,8 +792,8 @@  discard block
 block discarded – undo
792 792
 		if ($altitude != "") {
793 793
 			$altitude_array = explode(",", $altitude);
794 794
 
795
-			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
796
-			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
795
+			$altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
796
+			$altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
797 797
 
798 798
 
799 799
 			if ($altitude_array[1] != "") {
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 
809 809
 		if ($date_posted != "") {
810 810
 			$date_array = explode(",", $date_posted);
811
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
812
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
811
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
812
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
813 813
 			if ($globalTimezone != '') {
814 814
 				date_default_timezone_set($globalTimezone);
815 815
 				$datetime = new DateTime();
@@ -834,16 +834,16 @@  discard block
 block discarded – undo
834 834
 		}
835 835
 		if ($limit != "") {
836 836
 			$limit_array = explode(",", $limit);
837
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
838
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
837
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
838
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
839 839
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) {
840 840
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
841 841
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
842 842
 			}
843 843
 		}
844 844
 		if ($origLat != "" && $origLon != "" && $dist != "") {
845
-			$dist = number_format($dist*0.621371,2,'.','');
846
-			$query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance
845
+			$dist = number_format($dist*0.621371, 2, '.', '');
846
+			$query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance
847 847
 			       FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69))
848 848
 			       AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
849 849
 		} else {
@@ -857,12 +857,12 @@  discard block
 block discarded – undo
857 857
 				$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
858 858
 			}
859 859
 
860
-			$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output
860
+			$query = "SELECT spotter_archive_output.* FROM spotter_archive_output
861 861
 			          WHERE spotter_archive_output.ident <> ''
862 862
 			          ".$additional_query."
863 863
 			          ".$filter_query.$orderby_query;
864 864
 		}
865
-		$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
865
+		$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
866 866
 		return $spotter_array;
867 867
 	}
868 868
 
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 		try {
878 878
 			$sth = $this->db->prepare($query);
879 879
 			$sth->execute();
880
-		} catch(PDOException $e) {
880
+		} catch (PDOException $e) {
881 881
 			return "error";
882 882
 		}
883 883
 	}
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 		if ($limit != "") {
911 911
 			$limit_array = explode(",", $limit);
912 912
 
913
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
914
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
913
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
914
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
915 915
 
916 916
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) {
917 917
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 		$query_values = array();
950 950
 		$limit_query = '';
951 951
 		$additional_query = '';
952
-		$filter_query = $this->getFilter($filter,true,true);
952
+		$filter_query = $this->getFilter($filter, true, true);
953 953
 
954 954
 		if ($owner != "") {
955 955
 			if (!is_string($owner)) {
@@ -963,8 +963,8 @@  discard block
 block discarded – undo
963 963
 		if ($limit != "") {
964 964
 			$limit_array = explode(",", $limit);
965 965
 
966
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
967
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
966
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
967
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
968 968
 
969 969
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) {
970 970
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
 		$query_values = array();
1002 1002
 		$limit_query = '';
1003 1003
 		$additional_query = '';
1004
-		$filter_query = $this->getFilter($filter,true,true);
1004
+		$filter_query = $this->getFilter($filter, true, true);
1005 1005
 
1006 1006
 		if ($pilot != "") {
1007 1007
 			$additional_query = " AND (spotter_archive_output.pilot_id = :pilot OR spotter_archive_output.pilot_name = :pilot)";
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
 		if ($limit != "") {
1012 1012
 			$limit_array = explode(",", $limit);
1013 1013
 
1014
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1015
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1014
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1015
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1016 1016
 
1017 1017
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) {
1018 1018
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 	* @return Array the airline country list
1041 1041
 	*
1042 1042
 	*/
1043
-	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') {
1043
+	public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') {
1044 1044
 		global $globalDBdriver;
1045 1045
 		/*
1046 1046
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 		$flight_array = array();
1069 1069
 		$temp_array = array();
1070 1070
 
1071
-		while($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1071
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1072 1072
 			$temp_array['flight_count'] = $row['nb'];
1073 1073
 			$temp_array['flight_country'] = $row['name'];
1074 1074
 			$temp_array['flight_country_iso3'] = $row['iso3'];
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
 	* @return Array the airline country list
1085 1085
 	*
1086 1086
 	*/
1087
-	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') {
1087
+	public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') {
1088 1088
 		global $globalDBdriver;
1089 1089
 		/*
1090 1090
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 		$flight_array = array();
1113 1113
 		$temp_array = array();
1114 1114
 
1115
-		while($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1115
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1116 1116
 			$temp_array['airline_icao'] = $row['airline_icao'];
1117 1117
 			$temp_array['flight_count'] = $row['nb'];
1118 1118
 			$temp_array['flight_country'] = $row['name'];
@@ -1129,13 +1129,13 @@  discard block
 block discarded – undo
1129 1129
 	* @return Array the spotter information
1130 1130
 	*
1131 1131
 	*/
1132
-	public function getDateArchiveSpotterDataById($id,$date) {
1132
+	public function getDateArchiveSpotterDataById($id, $date) {
1133 1133
 		$Spotter = new Spotter($this->db);
1134 1134
 		date_default_timezone_set('UTC');
1135 1135
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
1136
-		$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1137
-		$date = date('c',$date);
1138
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1136
+		$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1137
+		$date = date('c', $date);
1138
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1139 1139
 		return $spotter_array;
1140 1140
 	}
1141 1141
 
@@ -1145,13 +1145,13 @@  discard block
 block discarded – undo
1145 1145
 	* @return Array the spotter information
1146 1146
 	*
1147 1147
 	*/
1148
-	public function getDateArchiveSpotterDataByIdent($ident,$date) {
1148
+	public function getDateArchiveSpotterDataByIdent($ident, $date) {
1149 1149
 		$Spotter = new Spotter($this->db);
1150 1150
 		date_default_timezone_set('UTC');
1151 1151
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1152
-		$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1153
-		$date = date('c',$date);
1154
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1152
+		$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1153
+		$date = date('c', $date);
1154
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1155 1155
 		return $spotter_array;
1156 1156
 	}
1157 1157
 
@@ -1161,14 +1161,14 @@  discard block
 block discarded – undo
1161 1161
 	* @return Array the spotter information
1162 1162
 	*
1163 1163
 	*/
1164
-	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) {
1164
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) {
1165 1165
 		global $global_query;
1166 1166
 		$Spotter = new Spotter($this->db);
1167 1167
 		date_default_timezone_set('UTC');
1168 1168
 		$query_values = array();
1169 1169
 		$limit_query = '';
1170 1170
 		$additional_query = '';
1171
-		$filter_query = $this->getFilter($filters,true,true);
1171
+		$filter_query = $this->getFilter($filters, true, true);
1172 1172
 
1173 1173
 		if ($airport != "") {
1174 1174
 			if (!is_string($airport)) {
@@ -1182,8 +1182,8 @@  discard block
 block discarded – undo
1182 1182
 		if ($limit != "") {
1183 1183
 			$limit_array = explode(",", $limit);
1184 1184
 
1185
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1186
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1185
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1186
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1187 1187
 
1188 1188
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) {
1189 1189
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
Please login to merge, or discard this patch.
require/class.Stats.php 4 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -405,17 +405,17 @@  discard block
 block discarded – undo
405 405
 			}
406 406
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
407 407
 		} else $all = array();
408
-                if (empty($all)) {
409
-	                $Spotter = new Spotter($this->db);
410
-            		$filters = array();
408
+				if (empty($all)) {
409
+					$Spotter = new Spotter($this->db);
410
+					$filters = array();
411 411
 			$filters = array('year' => $year,'month' => $month);
412
-            		if ($filter_name != '') {
413
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
412
+					if ($filter_name != '') {
413
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
414 414
 			}
415 415
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
416
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
417
-                }
418
-                return $all;
416
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters);
417
+				}
418
+				return $all;
419 419
 	}
420 420
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
421 421
 		global $globalStatsFilters;
@@ -1612,7 +1612,7 @@  discard block
 block discarded – undo
1612 1612
 			return "error : ".$e->getMessage();
1613 1613
 		}
1614 1614
 	}
1615
-        /*
1615
+		/*
1616 1616
 	public function getStatsSource($date,$stats_type = '') {
1617 1617
 		if ($stats_type == '') {
1618 1618
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -2574,8 +2574,8 @@  discard block
 block discarded – undo
2574 2574
 					}
2575 2575
 					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2576 2576
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
2577
-				    	foreach ($alldata as $number) {
2578
-			    			$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2577
+						foreach ($alldata as $number) {
2578
+							$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2579 2579
 					}
2580 2580
 					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2581 2581
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
Please login to merge, or discard this patch.
Doc Comments   +51 added lines patch added patch discarded remove patch
@@ -21,6 +21,10 @@  discard block
 block discarded – undo
21 21
 		if ($this->db === null) die('Error: No DB connection. (Stats)');
22 22
 	}
23 23
 
24
+	/**
25
+	 * @param string $type
26
+	 * @param string $stats_date
27
+	 */
24 28
 	public function addLastStatsUpdate($type,$stats_date) {
25 29
 		$query = "DELETE FROM config WHERE name = :type;
26 30
 			    INSERT INTO config (name,value) VALUES (:type,:stats_date);";
@@ -1415,6 +1419,10 @@  discard block
 block discarded – undo
1415 1419
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1416 1420
 		return $all;
1417 1421
 	}
1422
+
1423
+	/**
1424
+	 * @param string $type
1425
+	 */
1418 1426
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1419 1427
 		if ($filter_name == '') $filter_name = $this->filter_name;
1420 1428
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1426,6 +1434,11 @@  discard block
 block discarded – undo
1426 1434
 			echo "error : ".$e->getMessage();
1427 1435
 		}
1428 1436
 	}
1437
+
1438
+	/**
1439
+	 * @param string $type
1440
+	 * @param string $year
1441
+	 */
1429 1442
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1430 1443
 		if ($filter_name == '') $filter_name = $this->filter_name;
1431 1444
 		global $globalArchiveMonths, $globalDBdriver;
@@ -1625,6 +1638,10 @@  discard block
 block discarded – undo
1625 1638
 		else return 0;
1626 1639
 	}
1627 1640
 
1641
+	/**
1642
+	 * @param string $type
1643
+	 * @param string $stats_date
1644
+	 */
1628 1645
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1629 1646
 		global $globalDBdriver;
1630 1647
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -1678,6 +1695,9 @@  discard block
 block discarded – undo
1678 1695
         }
1679 1696
         */
1680 1697
 
1698
+	/**
1699
+	 * @param string $stats_type
1700
+	 */
1681 1701
 	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1682 1702
 		global $globalDBdriver;
1683 1703
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
@@ -1721,6 +1741,9 @@  discard block
 block discarded – undo
1721 1741
 		return $all;
1722 1742
 	}
1723 1743
 
1744
+	/**
1745
+	 * @param string $stats_type
1746
+	 */
1724 1747
 	public function addStatSource($data,$source_name,$stats_type,$date) {
1725 1748
 		global $globalDBdriver;
1726 1749
 		if ($globalDBdriver == 'mysql') {
@@ -1736,6 +1759,10 @@  discard block
 block discarded – undo
1736 1759
 			return "error : ".$e->getMessage();
1737 1760
 		}
1738 1761
 	}
1762
+
1763
+	/**
1764
+	 * @param string $type
1765
+	 */
1739 1766
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1740 1767
 		$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1741 1768
 		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
@@ -1746,6 +1773,10 @@  discard block
 block discarded – undo
1746 1773
 			return "error : ".$e->getMessage();
1747 1774
 		}
1748 1775
 	}
1776
+
1777
+	/**
1778
+	 * @param string $type
1779
+	 */
1749 1780
 	public function addStatMarine($type,$date_name,$cnt,$filter_name = '') {
1750 1781
 		$query = "INSERT INTO stats_marine (stats_type,marine_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
1751 1782
 		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
@@ -1756,6 +1787,10 @@  discard block
 block discarded – undo
1756 1787
 			return "error : ".$e->getMessage();
1757 1788
 		}
1758 1789
 	}
1790
+
1791
+	/**
1792
+	 * @param string $type
1793
+	 */
1759 1794
 	public function addStatTracker($type,$date_name,$cnt,$filter_name = '') {
1760 1795
 		$query = "INSERT INTO stats_tracker (stats_type,tracker_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
1761 1796
 		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
@@ -2068,6 +2103,10 @@  discard block
 block discarded – undo
2068 2103
 			return "error : ".$e->getMessage();
2069 2104
 		}
2070 2105
 	}
2106
+
2107
+	/**
2108
+	 * @param string $type
2109
+	 */
2071 2110
 	public function deleteStatFlight($type) {
2072 2111
 		$query = "DELETE FROM stats_flight WHERE stats_type = :type";
2073 2112
 		$query_values = array(':type' => $type);
@@ -2078,6 +2117,10 @@  discard block
 block discarded – undo
2078 2117
 			return "error : ".$e->getMessage();
2079 2118
 		}
2080 2119
 	}
2120
+
2121
+	/**
2122
+	 * @param string $type
2123
+	 */
2081 2124
 	public function deleteStatMarine($type) {
2082 2125
 		$query = "DELETE FROM stats_marine WHERE stats_type = :type";
2083 2126
 		$query_values = array(':type' => $type);
@@ -2088,6 +2131,10 @@  discard block
 block discarded – undo
2088 2131
 			return "error : ".$e->getMessage();
2089 2132
 		}
2090 2133
 	}
2134
+
2135
+	/**
2136
+	 * @param string $type
2137
+	 */
2091 2138
 	public function deleteStatTracker($type) {
2092 2139
 		$query = "DELETE FROM stats_tracker WHERE stats_type = :type";
2093 2140
 		$query_values = array(':type' => $type);
@@ -2098,6 +2145,10 @@  discard block
 block discarded – undo
2098 2145
 			return "error : ".$e->getMessage();
2099 2146
 		}
2100 2147
 	}
2148
+
2149
+	/**
2150
+	 * @param string $type
2151
+	 */
2101 2152
 	public function deleteStatAirport($type) {
2102 2153
 		$query = "DELETE FROM stats_airport WHERE stats_type = :type";
2103 2154
 		$query_values = array(':type' => $type);
Please login to merge, or discard this patch.
Spacing   +643 added lines, -643 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 		if ($this->db === null) die('Error: No DB connection. (Stats)');
29 29
 	}
30 30
 
31
-	public function addLastStatsUpdate($type,$stats_date) {
31
+	public function addLastStatsUpdate($type, $stats_date) {
32 32
 		$query = "DELETE FROM config WHERE name = :type;
33 33
 			    INSERT INTO config (name,value) VALUES (:type,:stats_date);";
34
-		$query_values = array('type' => $type,':stats_date' => $stats_date);
34
+		$query_values = array('type' => $type, ':stats_date' => $stats_date);
35 35
 		try {
36 36
 			$sth = $this->db->prepare($query);
37 37
 			$sth->execute($query_values);
38
-		} catch(PDOException $e) {
38
+		} catch (PDOException $e) {
39 39
 			return "error : ".$e->getMessage();
40 40
 		}
41 41
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		try {
46 46
 			$sth = $this->db->prepare($query);
47 47
 			$sth->execute(array(':type' => $type));
48
-		} catch(PDOException $e) {
48
+		} catch (PDOException $e) {
49 49
 			echo "error : ".$e->getMessage();
50 50
 		}
51 51
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		try {
67 67
 			$sth = $this->db->prepare($query);
68 68
 			$sth->execute(array(':filter_name' => $filter_name));
69
-		} catch(PDOException $e) {
69
+		} catch (PDOException $e) {
70 70
 			return "error : ".$e->getMessage();
71 71
 		}
72 72
 	}
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 		try {
80 80
 			$sth = $this->db->prepare($query);
81 81
 			$sth->execute();
82
-		} catch(PDOException $e) {
82
+		} catch (PDOException $e) {
83 83
 			return "error : ".$e->getMessage();
84 84
 		}
85 85
 		$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;";
86 86
 		try {
87 87
 			$sth = $this->db->prepare($query);
88 88
 			$sth->execute(array(':filter_name' => $filter_name));
89
-		} catch(PDOException $e) {
89
+		} catch (PDOException $e) {
90 90
 			return "error : ".$e->getMessage();
91 91
 		}
92 92
 	}
@@ -98,77 +98,77 @@  discard block
 block discarded – undo
98 98
 		 try {
99 99
 			$sth = $this->db->prepare($query);
100 100
 			$sth->execute(array(':filter_name' => $filter_name));
101
-		} catch(PDOException $e) {
101
+		} catch (PDOException $e) {
102 102
 			echo "error : ".$e->getMessage();
103 103
 		}
104 104
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
105 105
 		if (empty($all)) {
106 106
 			$filters = array();
107 107
 			if ($filter_name != '') {
108
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
108
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
109 109
 			}
110 110
 			$Spotter = new Spotter($this->db);
111
-			$all = $Spotter->getAllAirlineNames('',NULL,$filters);
111
+			$all = $Spotter->getAllAirlineNames('', NULL, $filters);
112 112
 		}
113 113
 		return $all;
114 114
 	}
115
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
115
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117 117
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
118 118
 		try {
119 119
 			$sth = $this->db->prepare($query);
120
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-		} catch(PDOException $e) {
120
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
121
+		} catch (PDOException $e) {
122 122
 			echo "error : ".$e->getMessage();
123 123
 		}
124 124
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
125 125
 		return $all;
126 126
 	}
127
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
127
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
128 128
 		if ($filter_name == '') $filter_name = $this->filter_name;
129 129
 		$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";
130 130
 		try {
131 131
 			$sth = $this->db->prepare($query);
132
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
133
-		} catch(PDOException $e) {
132
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
133
+		} catch (PDOException $e) {
134 134
 			echo "error : ".$e->getMessage();
135 135
 		}
136 136
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
137 137
 		return $all;
138 138
 	}
139
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
139
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
140 140
 		if ($filter_name == '') $filter_name = $this->filter_name;
141 141
 		$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";
142 142
 		try {
143 143
 			$sth = $this->db->prepare($query);
144
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
145
-		} catch(PDOException $e) {
144
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
145
+		} catch (PDOException $e) {
146 146
 			echo "error : ".$e->getMessage();
147 147
 		}
148 148
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
149 149
 		return $all;
150 150
 	}
151 151
 
152
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
152
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
153 153
 		if ($filter_name == '') $filter_name = $this->filter_name;
154 154
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
155 155
 		try {
156 156
 			$sth = $this->db->prepare($query);
157
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
158
-		} catch(PDOException $e) {
157
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
158
+		} catch (PDOException $e) {
159 159
 			echo "error : ".$e->getMessage();
160 160
 		}
161 161
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
162 162
 		return $all;
163 163
 	}
164 164
 
165
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
165
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
166 166
 		if ($filter_name == '') $filter_name = $this->filter_name;
167 167
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
168 168
 		try {
169 169
 			$sth = $this->db->prepare($query);
170
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
171
-		} catch(PDOException $e) {
170
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
171
+		} catch (PDOException $e) {
172 172
 			echo "error : ".$e->getMessage();
173 173
 		}
174 174
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -176,23 +176,23 @@  discard block
 block discarded – undo
176 176
 	}
177 177
 
178 178
 
179
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
179
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
180 180
 		global $globalStatsFilters;
181 181
 		if ($filter_name == '') $filter_name = $this->filter_name;
182
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
182
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
183 183
 			$Spotter = new Spotter($this->db);
184
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
184
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
185 185
 			$alliance_airlines = array();
186 186
 			foreach ($airlines as $airline) {
187
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
187
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
188 188
 			}
189 189
 			if ($year == '' && $month == '') {
190
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
191
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
190
+				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
191
+				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
192 192
 				try {
193 193
 					$sth = $this->db->prepare($query);
194 194
 					$sth->execute(array(':filter_name' => $filter_name));
195
-				} catch(PDOException $e) {
195
+				} catch (PDOException $e) {
196 196
 					echo "error : ".$e->getMessage();
197 197
 				}
198 198
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -203,29 +203,29 @@  discard block
 block discarded – undo
203 203
 				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
204 204
 				try {
205 205
 					$sth = $this->db->prepare($query);
206
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
207
-				} catch(PDOException $e) {
206
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
207
+				} catch (PDOException $e) {
208 208
 					echo "error : ".$e->getMessage();
209 209
 				}
210 210
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
211 211
 			} else $all = array();
212 212
 		}
213 213
 		if (empty($all)) {
214
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
215
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
214
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
215
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
216 216
 			} else {
217
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
217
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
218 218
 			}
219 219
 			if ($filter_name != '') {
220
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
220
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
221 221
 			}
222 222
 			$Spotter = new Spotter($this->db);
223 223
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
224
-			$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
224
+			$all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
225 225
 		}
226 226
 		return $all;
227 227
 	}
228
-	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
228
+	public function countAllMarineTypes($limit = true, $filter_name = '', $year = '', $month = '') {
229 229
 		global $globalStatsFilters;
230 230
 		if ($filter_name == '') $filter_name = $this->filter_name;
231 231
 		if ($year == '' && $month == '') {
@@ -234,23 +234,23 @@  discard block
 block discarded – undo
234 234
 			try {
235 235
 				$sth = $this->db->prepare($query);
236 236
 				$sth->execute(array(':filter_name' => $filter_name));
237
-			} catch(PDOException $e) {
237
+			} catch (PDOException $e) {
238 238
 				echo "error : ".$e->getMessage();
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241 241
 		} else $all = array();
242 242
 		if (empty($all)) {
243
-			$filters = array('year' => $year,'month' => $month);
243
+			$filters = array('year' => $year, 'month' => $month);
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
 			$Marine = new Marine($this->db);
248 248
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
249
-			$all = $Marine->countAllMarineTypes($limit,0,'',$filters);
249
+			$all = $Marine->countAllMarineTypes($limit, 0, '', $filters);
250 250
 		}
251 251
 		return $all;
252 252
 	}
253
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
253
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
254 254
 		global $globalStatsFilters;
255 255
 		if ($filter_name == '') $filter_name = $this->filter_name;
256 256
 		if ($year == '' && $month == '') {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			try {
260 260
 				$sth = $this->db->prepare($query);
261 261
 				$sth->execute(array(':filter_name' => $filter_name));
262
-			} catch(PDOException $e) {
262
+			} catch (PDOException $e) {
263 263
 				echo "error : ".$e->getMessage();
264 264
 			}
265 265
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -267,32 +267,32 @@  discard block
 block discarded – undo
267 267
 		if (empty($all)) {
268 268
 			$Spotter = new Spotter($this->db);
269 269
 			$filters = array();
270
-			$filters = array('year' => $year,'month' => $month);
270
+			$filters = array('year' => $year, 'month' => $month);
271 271
 			if ($filter_name != '') {
272
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
272
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
273 273
 			}
274 274
 			//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
275
-			$all = $Spotter->countAllAirlineCountries($limit,$filters);
275
+			$all = $Spotter->countAllAirlineCountries($limit, $filters);
276 276
 		}
277 277
 		return $all;
278 278
 	}
279
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
279
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
280 280
 		global $globalStatsFilters;
281 281
 		if ($filter_name == '') $filter_name = $this->filter_name;
282
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
282
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
283 283
 			$Spotter = new Spotter($this->db);
284
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
284
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
285 285
 			$alliance_airlines = array();
286 286
 			foreach ($airlines as $airline) {
287
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
287
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
288 288
 			}
289 289
 			if ($year == '' && $month == '') {
290
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
291
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
290
+				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
291
+				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
292 292
 				try {
293 293
 					$sth = $this->db->prepare($query);
294 294
 					$sth->execute(array(':filter_name' => $filter_name));
295
-				} catch(PDOException $e) {
295
+				} catch (PDOException $e) {
296 296
 					echo "error : ".$e->getMessage();
297 297
 				}
298 298
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -303,21 +303,21 @@  discard block
 block discarded – undo
303 303
 				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
304 304
 				try {
305 305
 					$sth = $this->db->prepare($query);
306
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
307
-				} catch(PDOException $e) {
306
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
307
+				} catch (PDOException $e) {
308 308
 					echo "error : ".$e->getMessage();
309 309
 				}
310 310
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
311 311
 			} else $all = array();
312 312
 		}
313 313
 		if (empty($all)) {
314
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
315
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
314
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
315
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
316 316
 			} else {
317
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
317
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
318 318
 			}
319 319
 			if ($filter_name != '') {
320
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
320
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
321 321
 			}
322 322
 			$Spotter = new Spotter($this->db);
323 323
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -326,23 +326,23 @@  discard block
 block discarded – undo
326 326
 		return $all;
327 327
 	}
328 328
 
329
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
329
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
330 330
 		global $globalStatsFilters;
331 331
 		if ($filter_name == '') $filter_name = $this->filter_name;
332
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
332
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
333 333
 			$Spotter = new Spotter($this->db);
334
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
334
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
335 335
 			$alliance_airlines = array();
336 336
 			foreach ($airlines as $airline) {
337
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
337
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
338 338
 			}
339 339
 			if ($year == '' && $month == '') {
340
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
341
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
340
+				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
341
+				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
342 342
 				try {
343 343
 					$sth = $this->db->prepare($query);
344 344
 					$sth->execute(array(':filter_name' => $filter_name));
345
-				} catch(PDOException $e) {
345
+				} catch (PDOException $e) {
346 346
 					echo "error : ".$e->getMessage();
347 347
 				}
348 348
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -353,61 +353,61 @@  discard block
 block discarded – undo
353 353
 				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
354 354
 				try {
355 355
 					$sth = $this->db->prepare($query);
356
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
357
-				} catch(PDOException $e) {
356
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
357
+				} catch (PDOException $e) {
358 358
 					echo "error : ".$e->getMessage();
359 359
 				}
360 360
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
361 361
 			} else $all = array();
362 362
 		}
363 363
 		if (empty($all)) {
364
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
365
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
364
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
365
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
366 366
 			} else {
367
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
367
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
368 368
 			}
369 369
 			if ($filter_name != '') {
370
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
370
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
371 371
 			}
372 372
 			$Spotter = new Spotter($this->db);
373 373
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
374
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
374
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
375 375
 		}
376 376
 		return $all;
377 377
 	}
378 378
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
379 379
 		global $globalStatsFilters;
380 380
 		if ($filter_name == '') $filter_name = $this->filter_name;
381
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
381
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
382 382
 			$Spotter = new Spotter($this->db);
383
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
383
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
384 384
 			$alliance_airlines = array();
385 385
 			foreach ($airlines as $airline) {
386
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
386
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
387 387
 			}
388
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
389
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
388
+			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
389
+			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
390 390
 			$query_values = array(':filter_name' => $filter_name);
391 391
 		} else {
392 392
 			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
393 393
 			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
394
-			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
394
+			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
395 395
 		}
396 396
 		try {
397 397
 			$sth = $this->db->prepare($query);
398 398
 			$sth->execute($query_values);
399
-		} catch(PDOException $e) {
399
+		} catch (PDOException $e) {
400 400
 			echo "error : ".$e->getMessage();
401 401
 		}
402 402
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
403 403
 		if (empty($all)) {
404
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
405
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
404
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
405
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
406 406
 			} else {
407
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
407
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
408 408
 			}
409 409
 			if ($filter_name != '') {
410
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
410
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
411 411
 			}
412 412
 			$Spotter = new Spotter($this->db);
413 413
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 		return $all;
417 417
 	}
418 418
 
419
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
419
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
420 420
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
421 421
 		if ($filter_name == '') $filter_name = $this->filter_name;
422 422
 		if ($year == '' && $month == '') {
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 			if (isset($forsource)) {
426 426
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
427 427
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
428
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
428
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
429 429
 			} else {
430 430
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
431 431
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 			try {
435 435
 				$sth = $this->db->prepare($query);
436 436
 				$sth->execute($query_values);
437
-			} catch(PDOException $e) {
437
+			} catch (PDOException $e) {
438 438
 				echo "error : ".$e->getMessage();
439 439
 			}
440 440
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -442,32 +442,32 @@  discard block
 block discarded – undo
442 442
                 if (empty($all)) {
443 443
 	                $Spotter = new Spotter($this->db);
444 444
             		$filters = array();
445
-			$filters = array('year' => $year,'month' => $month);
445
+			$filters = array('year' => $year, 'month' => $month);
446 446
             		if ($filter_name != '') {
447
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
447
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
448 448
 			}
449 449
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
450
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
450
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
451 451
                 }
452 452
                 return $all;
453 453
 	}
454
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
454
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
455 455
 		global $globalStatsFilters;
456 456
 		if ($filter_name == '') $filter_name = $this->filter_name;
457
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
457
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
458 458
 			$Spotter = new Spotter($this->db);
459
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
459
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
460 460
 			$alliance_airlines = array();
461 461
 			foreach ($airlines as $airline) {
462
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
462
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
463 463
 			}
464 464
 			if ($year == '' && $month == '') {
465
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
466
-				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
465
+				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
466
+				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
467 467
 				try {
468 468
 					$sth = $this->db->prepare($query);
469 469
 					$sth->execute(array(':filter_name' => $filter_name));
470
-				} catch(PDOException $e) {
470
+				} catch (PDOException $e) {
471 471
 					echo "error : ".$e->getMessage();
472 472
 				}
473 473
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -478,45 +478,45 @@  discard block
 block discarded – undo
478 478
 				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
479 479
 				try {
480 480
 					$sth = $this->db->prepare($query);
481
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
482
-				} catch(PDOException $e) {
481
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
482
+				} catch (PDOException $e) {
483 483
 					echo "error : ".$e->getMessage();
484 484
 				}
485 485
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
486 486
 			} else $all = array();
487 487
 		}
488 488
 		if (empty($all)) {
489
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
490
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
489
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
490
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
491 491
 			} else {
492
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
492
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
493 493
 			}
494 494
 			if ($filter_name != '') {
495
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
495
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
496 496
 			}
497 497
 			$Spotter = new Spotter($this->db);
498 498
 			//$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
499
-			$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
499
+			$all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
500 500
 		}
501 501
 		return $all;
502 502
 	}
503
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
503
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
504 504
 		global $globalStatsFilters;
505 505
 		if ($filter_name == '') $filter_name = $this->filter_name;
506
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
506
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
507 507
 			$Spotter = new Spotter($this->db);
508
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
508
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
509 509
 			$alliance_airlines = array();
510 510
 			foreach ($airlines as $airline) {
511
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
511
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
512 512
 			}
513 513
 			if ($year == '' && $month == '') {
514
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
515
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
514
+				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
515
+				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
516 516
 				 try {
517 517
 					$sth = $this->db->prepare($query);
518 518
 					$sth->execute(array(':filter_name' => $filter_name));
519
-				} catch(PDOException $e) {
519
+				} catch (PDOException $e) {
520 520
 					echo "error : ".$e->getMessage();
521 521
 				}
522 522
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -527,46 +527,46 @@  discard block
 block discarded – undo
527 527
 				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
528 528
 				 try {
529 529
 					$sth = $this->db->prepare($query);
530
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
531
-				} catch(PDOException $e) {
530
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
531
+				} catch (PDOException $e) {
532 532
 					echo "error : ".$e->getMessage();
533 533
 				}
534 534
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
535 535
 			} else $all = array();
536 536
 		}
537 537
 		if (empty($all)) {
538
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
539
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
538
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
539
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
540 540
 			} else {
541
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
541
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
542 542
 			}
543 543
 			if ($filter_name != '') {
544
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
544
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
545 545
 			}
546 546
 			$Spotter = new Spotter($this->db);
547 547
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
548
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
548
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
549 549
 		}
550 550
 		return $all;
551 551
 	}
552
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
552
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
553 553
 		$Connection = new Connection($this->db);
554 554
 		if ($filter_name == '') $filter_name = $this->filter_name;
555 555
 		if ($Connection->tableExists('countries')) {
556
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
556
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
557 557
 				$Spotter = new Spotter($this->db);
558
-				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
558
+				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
559 559
 				if ($year == '' && $month == '') {
560 560
 					$alliance_airlines = array();
561 561
 					foreach ($airlines as $airline) {
562
-						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
562
+						$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
563 563
 					}
564
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
565
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
564
+					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
565
+					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
566 566
 					 try {
567 567
 						$sth = $this->db->prepare($query);
568 568
 						$sth->execute(array(':filter_name' => $filter_name));
569
-					} catch(PDOException $e) {
569
+					} catch (PDOException $e) {
570 570
 						echo "error : ".$e->getMessage();
571 571
 					}
572 572
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -578,8 +578,8 @@  discard block
 block discarded – undo
578 578
 					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
579 579
 					 try {
580 580
 						$sth = $this->db->prepare($query);
581
-						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
582
-					} catch(PDOException $e) {
581
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
582
+					} catch (PDOException $e) {
583 583
 						echo "error : ".$e->getMessage();
584 584
 					}
585 585
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 			return $Spotter->countAllFlightOverCountries($limit);
591 591
 		} else return array();
592 592
 	}
593
-	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
593
+	public function countAllMarineOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
594 594
 		$Connection = new Connection($this->db);
595 595
 		if ($filter_name == '') $filter_name = $this->filter_name;
596 596
 		if ($Connection->tableExists('countries')) {
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 				 try {
602 602
 					$sth = $this->db->prepare($query);
603 603
 					$sth->execute(array(':filter_name' => $filter_name));
604
-				} catch(PDOException $e) {
604
+				} catch (PDOException $e) {
605 605
 					echo "error : ".$e->getMessage();
606 606
 				}
607 607
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -609,15 +609,15 @@  discard block
 block discarded – undo
609 609
 			if (empty($all)) {
610 610
 				$filters = array();
611 611
 				if ($filter_name != '') {
612
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
612
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
613 613
 				}
614 614
 				$Marine = new Marine($this->db);
615
-				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
615
+				$all = $Marine->countAllMarineOverCountries($limit, 0, '', $filters);
616 616
 			}
617 617
 			return $all;
618 618
 		} else return array();
619 619
 	}
620
-	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
620
+	public function countAllTrackerOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
621 621
 		global $globalStatsFilters;
622 622
 		$Connection = new Connection($this->db);
623 623
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 				 try {
630 630
 					$sth = $this->db->prepare($query);
631 631
 					$sth->execute(array(':filter_name' => $filter_name));
632
-				} catch(PDOException $e) {
632
+				} catch (PDOException $e) {
633 633
 					echo "error : ".$e->getMessage();
634 634
 				}
635 635
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -638,15 +638,15 @@  discard block
 block discarded – undo
638 638
 			if (empty($all)) {
639 639
 				$filters = array();
640 640
 				if ($filter_name != '') {
641
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
641
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
642 642
 				}
643 643
 				$Tracker = new Tracker($this->db);
644
-				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
644
+				$all = $Tracker->countAllTrackerOverCountries($limit, 0, '', $filters);
645 645
 			}
646 646
 			return $all;
647 647
 		} else return array();
648 648
 	}
649
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
649
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
650 650
 		global $globalStatsFilters;
651 651
 		if ($filter_name == '') $filter_name = $this->filter_name;
652 652
 		if ($year == '' && $month == '') {
@@ -654,41 +654,41 @@  discard block
 block discarded – undo
654 654
 			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
655 655
 			try {
656 656
 				$sth = $this->db->prepare($query);
657
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
658
-			} catch(PDOException $e) {
657
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
658
+			} catch (PDOException $e) {
659 659
 				echo "error : ".$e->getMessage();
660 660
 			}
661 661
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
662 662
 		} else $all = array();
663 663
 		if (empty($all)) {
664
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
664
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
665 665
 			if ($filter_name != '') {
666
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
666
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
667 667
 			}
668 668
 			$Spotter = new Spotter($this->db);
669 669
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
670
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
670
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
671 671
 		}
672 672
 		return $all;
673 673
 	}
674 674
 
675
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
675
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
676 676
 		global $globalStatsFilters;
677 677
 		if ($filter_name == '') $filter_name = $this->filter_name;
678
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
678
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
679 679
 			$Spotter = new Spotter($this->db);
680
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
680
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
681 681
 			if ($year == '' && $month == '') {
682 682
 				$alliance_airlines = array();
683 683
 				foreach ($airlines as $airline) {
684
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
684
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
685 685
 				}
686
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
687
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
686
+				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
687
+				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
688 688
 				try {
689 689
 					$sth = $this->db->prepare($query);
690 690
 					$sth->execute(array(':filter_name' => $filter_name));
691
-				} catch(PDOException $e) {
691
+				} catch (PDOException $e) {
692 692
 					echo "error : ".$e->getMessage();
693 693
 				}
694 694
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -699,45 +699,45 @@  discard block
 block discarded – undo
699 699
 				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
700 700
 				try {
701 701
 					$sth = $this->db->prepare($query);
702
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
703
-				} catch(PDOException $e) {
702
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
703
+				} catch (PDOException $e) {
704 704
 					echo "error : ".$e->getMessage();
705 705
 				}
706 706
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
707 707
 			} else $all = array();
708 708
 		}
709 709
 		if (empty($all)) {
710
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
711
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
710
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
711
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
712 712
 			} else {
713
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
713
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
714 714
 			}
715 715
 			if ($filter_name != '') {
716
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
716
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
717 717
 			}
718 718
 			$Spotter = new Spotter($this->db);
719 719
 			//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
720
-			$all = $Spotter->countAllOwners($limit,0,'',$filters);
720
+			$all = $Spotter->countAllOwners($limit, 0, '', $filters);
721 721
 		}
722 722
 		return $all;
723 723
 	}
724
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
724
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
725 725
 		global $globalStatsFilters;
726 726
 		if ($filter_name == '') $filter_name = $this->filter_name;
727
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
727
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
728 728
 			$Spotter = new Spotter($this->db);
729
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
729
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
730 730
 			if ($year == '' && $month == '') {
731 731
 				$alliance_airlines = array();
732 732
 				foreach ($airlines as $airline) {
733
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
733
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
734 734
 				}
735
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
736
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
735
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
736
+				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
737 737
 				try {
738 738
 					$sth = $this->db->prepare($query);
739 739
 					$sth->execute(array(':filter_name' => $filter_name));
740
-				} catch(PDOException $e) {
740
+				} catch (PDOException $e) {
741 741
 					echo "error : ".$e->getMessage();
742 742
 				}
743 743
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -748,27 +748,27 @@  discard block
 block discarded – undo
748 748
 				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
749 749
 				try {
750 750
 					$sth = $this->db->prepare($query);
751
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
752
-				} catch(PDOException $e) {
751
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
752
+				} catch (PDOException $e) {
753 753
 					echo "error : ".$e->getMessage();
754 754
 				}
755 755
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
756 756
 			} else $all = array();
757 757
 		}
758 758
 		if (empty($all)) {
759
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
760
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
759
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
760
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
761 761
 			} else {
762
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
762
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
763 763
 			}
764 764
 			if ($filter_name != '') {
765
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
765
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
766 766
 			}
767 767
 			$Spotter = new Spotter($this->db);
768 768
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
769 769
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
770
-			$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
771
-			$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
770
+			$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
771
+			$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
772 772
 			$all = array();
773 773
 			foreach ($pall as $value) {
774 774
 				$icao = $value['airport_departure_icao'];
@@ -784,27 +784,27 @@  discard block
 block discarded – undo
784 784
 			foreach ($all as $key => $row) {
785 785
 				$count[$key] = $row['airport_departure_icao_count'];
786 786
 			}
787
-			array_multisort($count,SORT_DESC,$all);
787
+			array_multisort($count, SORT_DESC, $all);
788 788
 		}
789 789
 		return $all;
790 790
 	}
791
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
791
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
792 792
 		global $globalStatsFilters;
793 793
 		if ($filter_name == '') $filter_name = $this->filter_name;
794
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
794
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
795 795
 			$Spotter = new Spotter($this->db);
796
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
796
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
797 797
 			if ($year == '' && $month == '') {
798 798
 				$alliance_airlines = array();
799 799
 				foreach ($airlines as $airline) {
800
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
800
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
801 801
 				}
802
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
803
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
802
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
803
+				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
804 804
 				try {
805 805
 					$sth = $this->db->prepare($query);
806 806
 					$sth->execute(array(':filter_name' => $filter_name));
807
-				} catch(PDOException $e) {
807
+				} catch (PDOException $e) {
808 808
 					echo "error : ".$e->getMessage();
809 809
 				}
810 810
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -815,27 +815,27 @@  discard block
 block discarded – undo
815 815
 				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
816 816
 				try {
817 817
 					$sth = $this->db->prepare($query);
818
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
819
-				} catch(PDOException $e) {
818
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
819
+				} catch (PDOException $e) {
820 820
 					echo "error : ".$e->getMessage();
821 821
 				}
822 822
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
823 823
 			} else $all = array();
824 824
 		}
825 825
 		if (empty($all)) {
826
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
827
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
826
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
827
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
828 828
 			} else {
829
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
829
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
830 830
 			}
831 831
 			if ($filter_name != '') {
832
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
832
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
833 833
 			}
834 834
 			$Spotter = new Spotter($this->db);
835 835
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
836 836
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
837
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
838
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
837
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
838
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
839 839
 			$all = array();
840 840
 			foreach ($pall as $value) {
841 841
 				$icao = $value['airport_arrival_icao'];
@@ -851,26 +851,26 @@  discard block
 block discarded – undo
851 851
 			foreach ($all as $key => $row) {
852 852
 				$count[$key] = $row['airport_arrival_icao_count'];
853 853
 			}
854
-			array_multisort($count,SORT_DESC,$all);
854
+			array_multisort($count, SORT_DESC, $all);
855 855
 		}
856 856
 		return $all;
857 857
 	}
858
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
858
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
859 859
 		global $globalDBdriver, $globalStatsFilters;
860 860
 		if ($filter_name == '') $filter_name = $this->filter_name;
861
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
861
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
862 862
 			$Spotter = new Spotter($this->db);
863
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
863
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
864 864
 			$alliance_airlines = array();
865 865
 			foreach ($airlines as $airline) {
866
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
866
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
867 867
 			}
868 868
 			if ($globalDBdriver == 'mysql') {
869
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
870
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
869
+				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
870
+				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
871 871
 			} else {
872
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
873
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
872
+				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
873
+				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
874 874
 			}
875 875
 			$query_data = array(':filter_name' => $filter_name);
876 876
 		} else {
@@ -881,23 +881,23 @@  discard block
 block discarded – undo
881 881
 				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
882 882
 				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";
883 883
 			}
884
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
884
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
885 885
 		}
886 886
 		try {
887 887
 			$sth = $this->db->prepare($query);
888 888
 			$sth->execute($query_data);
889
-		} catch(PDOException $e) {
889
+		} catch (PDOException $e) {
890 890
 			echo "error : ".$e->getMessage();
891 891
 		}
892 892
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
893 893
 		if (empty($all)) {
894
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
895
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
894
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
895
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
896 896
 			} else {
897 897
 				$filters = array('airlines' => array($stats_airline));
898 898
 			}
899 899
 			if ($filter_name != '') {
900
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
900
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
901 901
 			}
902 902
 			$Spotter = new Spotter($this->db);
903 903
 			$all = $Spotter->countAllMonthsLastYear($filters);
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 		return $all;
906 906
 	}
907 907
 
908
-	public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') {
908
+	public function countAllMarineMonthsLastYear($limit = true, $filter_name = '') {
909 909
 		global $globalDBdriver, $globalStatsFilters;
910 910
 		if ($filter_name == '') $filter_name = $this->filter_name;
911 911
 		if ($globalDBdriver == 'mysql') {
@@ -919,14 +919,14 @@  discard block
 block discarded – undo
919 919
 		try {
920 920
 			$sth = $this->db->prepare($query);
921 921
 			$sth->execute($query_data);
922
-		} catch(PDOException $e) {
922
+		} catch (PDOException $e) {
923 923
 			echo "error : ".$e->getMessage();
924 924
 		}
925 925
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
926 926
 		if (empty($all)) {
927 927
 			$filters = array();
928 928
 			if ($filter_name != '') {
929
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
929
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
930 930
 			}
931 931
 			$Marine = new Marine($this->db);
932 932
 			$all = $Marine->countAllMonthsLastYear($filters);
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 		return $all;
935 935
 	}
936 936
 
937
-	public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') {
937
+	public function countAllTrackerMonthsLastYear($limit = true, $filter_name = '') {
938 938
 		global $globalDBdriver, $globalStatsFilters;
939 939
 		if ($filter_name == '') $filter_name = $this->filter_name;
940 940
 		if ($globalDBdriver == 'mysql') {
@@ -948,14 +948,14 @@  discard block
 block discarded – undo
948 948
 		try {
949 949
 			$sth = $this->db->prepare($query);
950 950
 			$sth->execute($query_data);
951
-		} catch(PDOException $e) {
951
+		} catch (PDOException $e) {
952 952
 			echo "error : ".$e->getMessage();
953 953
 		}
954 954
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
955 955
 		if (empty($all)) {
956 956
 			$filters = array();
957 957
 			if ($filter_name != '') {
958
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
958
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
959 959
 			}
960 960
 			$Tracker = new Tracker($this->db);
961 961
 			$all = $Tracker->countAllMonthsLastYear($filters);
@@ -963,37 +963,37 @@  discard block
 block discarded – undo
963 963
 		return $all;
964 964
 	}
965 965
 	
966
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
966
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
967 967
 		global $globalStatsFilters;
968 968
 		if ($filter_name == '') $filter_name = $this->filter_name;
969
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
969
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
970 970
 			$Spotter = new Spotter($this->db);
971
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
971
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
972 972
 			$alliance_airlines = array();
973 973
 			foreach ($airlines as $airline) {
974
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
974
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
975 975
 			}
976
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
976
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
977 977
 			$query_data = array(':filter_name' => $filter_name);
978 978
 		} else {
979 979
 			$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";
980
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
980
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
981 981
 		}
982 982
 		try {
983 983
 			$sth = $this->db->prepare($query);
984 984
 			$sth->execute($query_data);
985
-		} catch(PDOException $e) {
985
+		} catch (PDOException $e) {
986 986
 			echo "error : ".$e->getMessage();
987 987
 		}
988 988
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
989 989
 		if (empty($all)) {
990
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
991
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
990
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
991
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
992 992
 			} else {
993 993
 				$filters = array('airlines' => array($stats_airline));
994 994
 			}
995 995
 			if ($filter_name != '') {
996
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
996
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
997 997
 			}
998 998
 			$Spotter = new Spotter($this->db);
999 999
 			$all = $Spotter->countAllDatesLastMonth($filters);
@@ -1008,14 +1008,14 @@  discard block
 block discarded – undo
1008 1008
 		try {
1009 1009
 			$sth = $this->db->prepare($query);
1010 1010
 			$sth->execute($query_data);
1011
-		} catch(PDOException $e) {
1011
+		} catch (PDOException $e) {
1012 1012
 			echo "error : ".$e->getMessage();
1013 1013
 		}
1014 1014
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1015 1015
 		if (empty($all)) {
1016 1016
 			$filters = array();
1017 1017
 			if ($filter_name != '') {
1018
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1018
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1019 1019
 			}
1020 1020
 			$Marine = new Marine($this->db);
1021 1021
 			$all = $Marine->countAllDatesLastMonth($filters);
@@ -1030,34 +1030,34 @@  discard block
 block discarded – undo
1030 1030
 		try {
1031 1031
 			$sth = $this->db->prepare($query);
1032 1032
 			$sth->execute($query_data);
1033
-		} catch(PDOException $e) {
1033
+		} catch (PDOException $e) {
1034 1034
 			echo "error : ".$e->getMessage();
1035 1035
 		}
1036 1036
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1037 1037
 		if (empty($all)) {
1038 1038
 			$filters = array();
1039 1039
 			if ($filter_name != '') {
1040
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1040
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1041 1041
 			}
1042 1042
 			$Tracker = new Tracker($this->db);
1043 1043
 			$all = $Tracker->countAllDatesLastMonth($filters);
1044 1044
 		}
1045 1045
 		return $all;
1046 1046
 	}
1047
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
1047
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
1048 1048
 		global $globalDBdriver, $globalStatsFilters;
1049 1049
 		if ($filter_name == '') $filter_name = $this->filter_name;
1050
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1050
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1051 1051
 			$Spotter = new Spotter($this->db);
1052
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1052
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1053 1053
 			$alliance_airlines = array();
1054 1054
 			foreach ($airlines as $airline) {
1055
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1055
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1056 1056
 			}
1057 1057
 			if ($globalDBdriver == 'mysql') {
1058
-				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1058
+				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1059 1059
 			} else {
1060
-				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1060
+				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1061 1061
 			}
1062 1062
 			$query_data = array(':filter_name' => $filter_name);
1063 1063
 		} else {
@@ -1066,23 +1066,23 @@  discard block
 block discarded – undo
1066 1066
 			} else {
1067 1067
 				$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";
1068 1068
 			}
1069
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1069
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1070 1070
 		}
1071 1071
 		try {
1072 1072
 			$sth = $this->db->prepare($query);
1073 1073
 			$sth->execute($query_data);
1074
-		} catch(PDOException $e) {
1074
+		} catch (PDOException $e) {
1075 1075
 			echo "error : ".$e->getMessage();
1076 1076
 		}
1077 1077
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1078 1078
 		if (empty($all)) {
1079
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1080
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1079
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1080
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1081 1081
 			} else {
1082 1082
 				$filters = array('airlines' => array($stats_airline));
1083 1083
 			}
1084 1084
 			if ($filter_name != '') {
1085
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1085
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1086 1086
 			}
1087 1087
 			$Spotter = new Spotter($this->db);
1088 1088
 			$all = $Spotter->countAllDatesLast7Days($filters);
@@ -1101,14 +1101,14 @@  discard block
 block discarded – undo
1101 1101
 		try {
1102 1102
 			$sth = $this->db->prepare($query);
1103 1103
 			$sth->execute($query_data);
1104
-		} catch(PDOException $e) {
1104
+		} catch (PDOException $e) {
1105 1105
 			echo "error : ".$e->getMessage();
1106 1106
 		}
1107 1107
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1108 1108
 		if (empty($all)) {
1109 1109
 			$filters = array();
1110 1110
 			if ($filter_name != '') {
1111
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1111
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1112 1112
 			}
1113 1113
 			$Marine = new Marine($this->db);
1114 1114
 			$all = $Marine->countAllDatesLast7Days($filters);
@@ -1127,51 +1127,51 @@  discard block
 block discarded – undo
1127 1127
 		try {
1128 1128
 			$sth = $this->db->prepare($query);
1129 1129
 			$sth->execute($query_data);
1130
-		} catch(PDOException $e) {
1130
+		} catch (PDOException $e) {
1131 1131
 			echo "error : ".$e->getMessage();
1132 1132
 		}
1133 1133
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1134 1134
 		if (empty($all)) {
1135 1135
 			$filters = array();
1136 1136
 			if ($filter_name != '') {
1137
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1137
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1138 1138
 			}
1139 1139
 			$Tracker = new Tracker($this->db);
1140 1140
 			$all = $Tracker->countAllDatesLast7Days($filters);
1141 1141
 		}
1142 1142
 		return $all;
1143 1143
 	}
1144
-	public function countAllDates($stats_airline = '',$filter_name = '') {
1144
+	public function countAllDates($stats_airline = '', $filter_name = '') {
1145 1145
 		global $globalStatsFilters;
1146 1146
 		if ($filter_name == '') $filter_name = $this->filter_name;
1147
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1147
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1148 1148
 			$Spotter = new Spotter($this->db);
1149
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1149
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1150 1150
 			$alliance_airlines = array();
1151 1151
 			foreach ($airlines as $airline) {
1152
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1152
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1153 1153
 			}
1154
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
1154
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
1155 1155
 			$query_data = array(':filter_name' => $filter_name);
1156 1156
 		} else {
1157 1157
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC";
1158
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1158
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1159 1159
 		}
1160 1160
 		try {
1161 1161
 			$sth = $this->db->prepare($query);
1162 1162
 			$sth->execute($query_data);
1163
-		} catch(PDOException $e) {
1163
+		} catch (PDOException $e) {
1164 1164
 			echo "error : ".$e->getMessage();
1165 1165
 		}
1166 1166
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1167 1167
 		if (empty($all)) {
1168
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1169
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1168
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1169
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1170 1170
 			} else {
1171 1171
 				$filters = array('airlines' => array($stats_airline));
1172 1172
 			}
1173 1173
 			if ($filter_name != '') {
1174
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1174
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1175 1175
 			}
1176 1176
 			$Spotter = new Spotter($this->db);
1177 1177
 			$all = $Spotter->countAllDates($filters);
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		try {
1187 1187
 			$sth = $this->db->prepare($query);
1188 1188
 			$sth->execute($query_data);
1189
-		} catch(PDOException $e) {
1189
+		} catch (PDOException $e) {
1190 1190
 			echo "error : ".$e->getMessage();
1191 1191
 		}
1192 1192
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 		try {
1209 1209
 			$sth = $this->db->prepare($query);
1210 1210
 			$sth->execute($query_data);
1211
-		} catch(PDOException $e) {
1211
+		} catch (PDOException $e) {
1212 1212
 			echo "error : ".$e->getMessage();
1213 1213
 		}
1214 1214
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1230,34 +1230,34 @@  discard block
 block discarded – undo
1230 1230
 		try {
1231 1231
 			$sth = $this->db->prepare($query);
1232 1232
 			$sth->execute($query_data);
1233
-		} catch(PDOException $e) {
1233
+		} catch (PDOException $e) {
1234 1234
 			echo "error : ".$e->getMessage();
1235 1235
 		}
1236 1236
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1237 1237
 		if (empty($all)) {
1238 1238
 			$filters = array();
1239 1239
 			if ($filter_name != '') {
1240
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1240
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1241 1241
 			}
1242 1242
 			$Spotter = new Spotter($this->db);
1243 1243
 			$all = $Spotter->countAllDatesByAirlines($filters);
1244 1244
 		}
1245 1245
 		return $all;
1246 1246
 	}
1247
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
1247
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
1248 1248
 		global $globalStatsFilters, $globalDBdriver;
1249 1249
 		if ($filter_name == '') $filter_name = $this->filter_name;
1250
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1250
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1251 1251
 			$Spotter = new Spotter($this->db);
1252
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1252
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1253 1253
 			$alliance_airlines = array();
1254 1254
 			foreach ($airlines as $airline) {
1255
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1255
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1256 1256
 			}
1257 1257
 			if ($globalDBdriver == 'mysql') {
1258
-				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1258
+				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1259 1259
 			} else {
1260
-				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1260
+				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1261 1261
 			}
1262 1262
 			$query_data = array(':filter_name' => $filter_name);
1263 1263
 		} else {
@@ -1271,18 +1271,18 @@  discard block
 block discarded – undo
1271 1271
 		try {
1272 1272
 			$sth = $this->db->prepare($query);
1273 1273
 			$sth->execute($query_data);
1274
-		} catch(PDOException $e) {
1274
+		} catch (PDOException $e) {
1275 1275
 			echo "error : ".$e->getMessage();
1276 1276
 		}
1277 1277
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1278 1278
 		if (empty($all)) {
1279
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1280
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1279
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1280
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1281 1281
 			} else {
1282 1282
 				$filters = array('airlines' => array($stats_airline));
1283 1283
 			}
1284 1284
 			if ($filter_name != '') {
1285
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1285
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1286 1286
 			}
1287 1287
 			$Spotter = new Spotter($this->db);
1288 1288
 			$all = $Spotter->countAllMonths($filters);
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
 		try {
1300 1300
 			$sth = $this->db->prepare($query);
1301 1301
 			$sth->execute();
1302
-		} catch(PDOException $e) {
1302
+		} catch (PDOException $e) {
1303 1303
 			echo "error : ".$e->getMessage();
1304 1304
 		}
1305 1305
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
 		try {
1320 1320
 			$sth = $this->db->prepare($query);
1321 1321
 			$sth->execute();
1322
-		} catch(PDOException $e) {
1322
+		} catch (PDOException $e) {
1323 1323
 			echo "error : ".$e->getMessage();
1324 1324
 		}
1325 1325
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1336,32 +1336,32 @@  discard block
 block discarded – undo
1336 1336
 		try {
1337 1337
 			$sth = $this->db->prepare($query);
1338 1338
 			$sth->execute(array(':filter_name' => $filter_name));
1339
-		} catch(PDOException $e) {
1339
+		} catch (PDOException $e) {
1340 1340
 			echo "error : ".$e->getMessage();
1341 1341
 		}
1342 1342
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1343 1343
 		if (empty($all)) {
1344 1344
 			$filters = array();
1345 1345
 			if ($filter_name != '') {
1346
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1346
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1347 1347
 			}
1348 1348
 			$Spotter = new Spotter($this->db);
1349 1349
 			$all = $Spotter->countAllMilitaryMonths($filters);
1350 1350
 		}
1351 1351
 		return $all;
1352 1352
 	}
1353
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1353
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
1354 1354
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1355 1355
 		if ($filter_name == '') $filter_name = $this->filter_name;
1356
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1356
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1357 1357
 			$Spotter = new Spotter($this->db);
1358
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1358
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1359 1359
 			$alliance_airlines = array();
1360 1360
 			foreach ($airlines as $airline) {
1361
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1361
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1362 1362
 			}
1363
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1364
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1363
+			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1364
+			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1365 1365
 			$query_data = array(':filter_name' => $filter_name);
1366 1366
 		} else {
1367 1367
 			if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1379,25 +1379,25 @@  discard block
 block discarded – undo
1379 1379
 		try {
1380 1380
 			$sth = $this->db->prepare($query);
1381 1381
 			$sth->execute($query_data);
1382
-		} catch(PDOException $e) {
1382
+		} catch (PDOException $e) {
1383 1383
 			echo "error : ".$e->getMessage();
1384 1384
 		}
1385 1385
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1386 1386
 		if (empty($all)) {
1387
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1388
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1387
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1388
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1389 1389
 			} else {
1390 1390
 				$filters = array('airlines' => array($stats_airline));
1391 1391
 			}
1392 1392
 			if ($filter_name != '') {
1393
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1393
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1394 1394
 			}
1395 1395
 			$Spotter = new Spotter($this->db);
1396
-			$all = $Spotter->countAllHours($orderby,$filters);
1396
+			$all = $Spotter->countAllHours($orderby, $filters);
1397 1397
 		}
1398 1398
 		return $all;
1399 1399
 	}
1400
-	public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') {
1400
+	public function countAllMarineHours($orderby = 'hour', $limit = true, $filter_name = '') {
1401 1401
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1402 1402
 		if ($filter_name == '') $filter_name = $this->filter_name;
1403 1403
 		if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
@@ -1414,21 +1414,21 @@  discard block
 block discarded – undo
1414 1414
 		try {
1415 1415
 			$sth = $this->db->prepare($query);
1416 1416
 			$sth->execute($query_data);
1417
-		} catch(PDOException $e) {
1417
+		} catch (PDOException $e) {
1418 1418
 			echo "error : ".$e->getMessage();
1419 1419
 		}
1420 1420
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1421 1421
 		if (empty($all)) {
1422 1422
 			$filters = array();
1423 1423
 			if ($filter_name != '') {
1424
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1424
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1425 1425
 			}
1426 1426
 			$Marine = new Marine($this->db);
1427
-			$all = $Marine->countAllHours($orderby,$filters);
1427
+			$all = $Marine->countAllHours($orderby, $filters);
1428 1428
 		}
1429 1429
 		return $all;
1430 1430
 	}
1431
-	public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') {
1431
+	public function countAllTrackerHours($orderby = 'hour', $limit = true, $filter_name = '') {
1432 1432
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1433 1433
 		if ($filter_name == '') $filter_name = $this->filter_name;
1434 1434
 		if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
@@ -1445,33 +1445,33 @@  discard block
 block discarded – undo
1445 1445
 		try {
1446 1446
 			$sth = $this->db->prepare($query);
1447 1447
 			$sth->execute($query_data);
1448
-		} catch(PDOException $e) {
1448
+		} catch (PDOException $e) {
1449 1449
 			echo "error : ".$e->getMessage();
1450 1450
 		}
1451 1451
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1452 1452
 		if (empty($all)) {
1453 1453
 			$filters = array();
1454 1454
 			if ($filter_name != '') {
1455
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1455
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1456 1456
 			}
1457 1457
 			$Tracker = new Tracker($this->db);
1458
-			$all = $Tracker->countAllHours($orderby,$filters);
1458
+			$all = $Tracker->countAllHours($orderby, $filters);
1459 1459
 		}
1460 1460
 		return $all;
1461 1461
 	}
1462
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1462
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1463 1463
 		global $globalStatsFilters;
1464 1464
 		if ($filter_name == '') $filter_name = $this->filter_name;
1465 1465
 		if ($year == '') $year = date('Y');
1466
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1466
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
1467 1467
 		if (empty($all)) {
1468
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1469
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1468
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1469
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1470 1470
 			} else {
1471
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1471
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1472 1472
 			}
1473 1473
 			if ($filter_name != '') {
1474
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1474
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1475 1475
 			}
1476 1476
 			$Spotter = new Spotter($this->db);
1477 1477
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1479,15 +1479,15 @@  discard block
 block discarded – undo
1479 1479
 		}
1480 1480
 		return $all;
1481 1481
 	}
1482
-	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1482
+	public function countOverallMarine($filter_name = '', $year = '', $month = '') {
1483 1483
 		global $globalStatsFilters;
1484 1484
 		if ($filter_name == '') $filter_name = $this->filter_name;
1485 1485
 		if ($year == '') $year = date('Y');
1486
-		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1486
+		$all = $this->getSumStats('marine_bymonth', $year, '', $filter_name, $month);
1487 1487
 		if (empty($all)) {
1488
-			$filters = array('year' => $year,'month' => $month);
1488
+			$filters = array('year' => $year, 'month' => $month);
1489 1489
 			if ($filter_name != '') {
1490
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1490
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1491 1491
 			}
1492 1492
 			$Marine = new Marine($this->db);
1493 1493
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1495,15 +1495,15 @@  discard block
 block discarded – undo
1495 1495
 		}
1496 1496
 		return $all;
1497 1497
 	}
1498
-	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1498
+	public function countOverallTracker($filter_name = '', $year = '', $month = '') {
1499 1499
 		global $globalStatsFilters;
1500 1500
 		if ($filter_name == '') $filter_name = $this->filter_name;
1501 1501
 		if ($year == '') $year = date('Y');
1502
-		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1502
+		$all = $this->getSumStats('tracker_bymonth', $year, '', $filter_name, $month);
1503 1503
 		if (empty($all)) {
1504
-			$filters = array('year' => $year,'month' => $month);
1504
+			$filters = array('year' => $year, 'month' => $month);
1505 1505
 			if ($filter_name != '') {
1506
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1506
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1507 1507
 			}
1508 1508
 			$Tracker = new Tracker($this->db);
1509 1509
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1511,16 +1511,16 @@  discard block
 block discarded – undo
1511 1511
 		}
1512 1512
 		return $all;
1513 1513
 	}
1514
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1514
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
1515 1515
 		global $globalStatsFilters;
1516 1516
 		if ($filter_name == '') $filter_name = $this->filter_name;
1517 1517
 		if ($year == '') $year = date('Y');
1518
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1518
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
1519 1519
 		if (empty($all)) {
1520 1520
 			$filters = array();
1521
-			$filters = array('year' => $year,'month' => $month);
1521
+			$filters = array('year' => $year, 'month' => $month);
1522 1522
 			if ($filter_name != '') {
1523
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1523
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1524 1524
 			}
1525 1525
 			$Spotter = new Spotter($this->db);
1526 1526
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -1528,19 +1528,19 @@  discard block
 block discarded – undo
1528 1528
 		}
1529 1529
 		return $all;
1530 1530
 	}
1531
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1531
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1532 1532
 		global $globalStatsFilters;
1533 1533
 		if ($filter_name == '') $filter_name = $this->filter_name;
1534 1534
 		if ($year == '') $year = date('Y');
1535
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1535
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
1536 1536
 		if (empty($all)) {
1537
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1538
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1537
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1538
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1539 1539
 			} else {
1540
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1540
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1541 1541
 			}
1542 1542
 			if ($filter_name != '') {
1543
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1543
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1544 1544
 			}
1545 1545
 			$Spotter = new Spotter($this->db);
1546 1546
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -1548,48 +1548,48 @@  discard block
 block discarded – undo
1548 1548
 		}
1549 1549
 		return $all;
1550 1550
 	}
1551
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1551
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1552 1552
 		global $globalStatsFilters;
1553 1553
 		if ($filter_name == '') $filter_name = $this->filter_name;
1554
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1554
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1555 1555
 			$Spotter = new Spotter($this->db);
1556
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1556
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1557 1557
 			if ($year == '' && $month == '') {
1558 1558
 				$alliance_airlines = array();
1559 1559
 				foreach ($airlines as $airline) {
1560
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1560
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1561 1561
 				}
1562
-				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1562
+				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1563 1563
 				try {
1564 1564
 					$sth = $this->db->prepare($query);
1565 1565
 					$sth->execute(array(':filter_name' => $filter_name));
1566
-				} catch(PDOException $e) {
1566
+				} catch (PDOException $e) {
1567 1567
 					echo "error : ".$e->getMessage();
1568 1568
 				}
1569 1569
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1570 1570
 				$all = $result[0]['nb'];
1571
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1571
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1572 1572
 		} else {
1573 1573
 			if ($year == '' && $month == '') {
1574 1574
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1575 1575
 				try {
1576 1576
 					$sth = $this->db->prepare($query);
1577
-					$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
1578
-				} catch(PDOException $e) {
1577
+					$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
1578
+				} catch (PDOException $e) {
1579 1579
 					echo "error : ".$e->getMessage();
1580 1580
 				}
1581 1581
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1582 1582
 				$all = $result[0]['nb'];
1583
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1583
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1584 1584
 		}
1585 1585
 		if (empty($all)) {
1586
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1587
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1586
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1587
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1588 1588
 			} else {
1589
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1589
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1590 1590
 			}
1591 1591
 			if ($filter_name != '') {
1592
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1592
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1593 1593
 			}
1594 1594
 			$Spotter = new Spotter($this->db);
1595 1595
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -1597,7 +1597,7 @@  discard block
 block discarded – undo
1597 1597
 		}
1598 1598
 		return $all;
1599 1599
 	}
1600
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1600
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
1601 1601
 		global $globalStatsFilters;
1602 1602
 		if ($filter_name == '') $filter_name = $this->filter_name;
1603 1603
 		if ($year == '' && $month == '') {
@@ -1605,17 +1605,17 @@  discard block
 block discarded – undo
1605 1605
 			try {
1606 1606
 				$sth = $this->db->prepare($query);
1607 1607
 				$sth->execute(array(':filter_name' => $filter_name));
1608
-			} catch(PDOException $e) {
1608
+			} catch (PDOException $e) {
1609 1609
 				echo "error : ".$e->getMessage();
1610 1610
 			}
1611 1611
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1612 1612
 			$all = $result[0]['nb_airline'];
1613
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1613
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
1614 1614
 		if (empty($all)) {
1615 1615
 			$filters = array();
1616
-			$filters = array('year' => $year,'month' => $month);
1616
+			$filters = array('year' => $year, 'month' => $month);
1617 1617
 			if ($filter_name != '') {
1618
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1618
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1619 1619
 			}
1620 1620
 			$Spotter = new Spotter($this->db);
1621 1621
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
 		}
1624 1624
 		return $all;
1625 1625
 	}
1626
-	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1626
+	public function countOverallMarineTypes($filter_name = '', $year = '', $month = '') {
1627 1627
 		global $globalStatsFilters;
1628 1628
 		if ($filter_name == '') $filter_name = $this->filter_name;
1629 1629
 		$all = array();
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 			try {
1633 1633
 				$sth = $this->db->prepare($query);
1634 1634
 				$sth->execute(array(':filter_name' => $filter_name));
1635
-			} catch(PDOException $e) {
1635
+			} catch (PDOException $e) {
1636 1636
 				echo "error : ".$e->getMessage();
1637 1637
 			}
1638 1638
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1640,9 +1640,9 @@  discard block
 block discarded – undo
1640 1640
 		}
1641 1641
 		if (empty($all)) {
1642 1642
 			$filters = array();
1643
-			$filters = array('year' => $year,'month' => $month);
1643
+			$filters = array('year' => $year, 'month' => $month);
1644 1644
 			if ($filter_name != '') {
1645
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1645
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1646 1646
 			}
1647 1647
 			$Marine = new Marine($this->db);
1648 1648
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1650,29 +1650,29 @@  discard block
 block discarded – undo
1650 1650
 		}
1651 1651
 		return $all;
1652 1652
 	}
1653
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1653
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1654 1654
 		global $globalStatsFilters;
1655 1655
 		if ($filter_name == '') $filter_name = $this->filter_name;
1656
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1656
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1657 1657
 			$Spotter = new Spotter($this->db);
1658
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1658
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1659 1659
 			if ($year == '' && $month == '') {
1660 1660
 				$alliance_airlines = array();
1661 1661
 				foreach ($airlines as $airline) {
1662
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1662
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1663 1663
 				}
1664
-				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1664
+				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1665 1665
 				$query_values = array(':filter_name' => $filter_name);
1666 1666
 				try {
1667 1667
 					$sth = $this->db->prepare($query);
1668 1668
 					$sth->execute($query_values);
1669
-				} catch(PDOException $e) {
1669
+				} catch (PDOException $e) {
1670 1670
 					echo "error : ".$e->getMessage();
1671 1671
 				}
1672 1672
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1673 1673
 				$all = $result[0]['nb'];
1674 1674
 			} else {
1675
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1675
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1676 1676
 			}
1677 1677
 		} else {
1678 1678
 			if ($year == '' && $month == '') {
@@ -1681,23 +1681,23 @@  discard block
 block discarded – undo
1681 1681
 				try {
1682 1682
 					$sth = $this->db->prepare($query);
1683 1683
 					$sth->execute($query_values);
1684
-				} catch(PDOException $e) {
1684
+				} catch (PDOException $e) {
1685 1685
 					echo "error : ".$e->getMessage();
1686 1686
 				}
1687 1687
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1688 1688
 				$all = $result[0]['nb'];
1689 1689
 			} else {
1690
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1690
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1691 1691
 			}
1692 1692
 		}
1693 1693
 		if (empty($all)) {
1694
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1695
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1694
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1695
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1696 1696
 			} else {
1697
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1697
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1698 1698
 			}
1699 1699
 			if ($filter_name != '') {
1700
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1700
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1701 1701
 			}
1702 1702
 			$Spotter = new Spotter($this->db);
1703 1703
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 		}
1706 1706
 		return $all;
1707 1707
 	}
1708
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1708
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1709 1709
 		global $globalStatsFilters;
1710 1710
 		if ($filter_name == '') $filter_name = $this->filter_name;
1711 1711
 		//if ($year == '') $year = date('Y');
@@ -1715,18 +1715,18 @@  discard block
 block discarded – undo
1715 1715
 			try {
1716 1716
 				$sth = $this->db->prepare($query);
1717 1717
 				$sth->execute($query_values);
1718
-			} catch(PDOException $e) {
1718
+			} catch (PDOException $e) {
1719 1719
 				echo "error : ".$e->getMessage();
1720 1720
 			}
1721 1721
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1722 1722
 			$all = $result[0]['nb'];
1723 1723
 		} else {
1724
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
1724
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
1725 1725
 		}
1726 1726
 		if (empty($all)) {
1727
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1727
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1728 1728
 			if ($filter_name != '') {
1729
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1729
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1730 1730
 			}
1731 1731
 			$Spotter = new Spotter($this->db);
1732 1732
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -1735,104 +1735,104 @@  discard block
 block discarded – undo
1735 1735
 		return $all;
1736 1736
 	}
1737 1737
 
1738
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1738
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
1739 1739
 		if ($filter_name == '') $filter_name = $this->filter_name;
1740
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1740
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1741 1741
 			$Spotter = new Spotter($this->db);
1742
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1742
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1743 1743
 			$alliance_airlines = array();
1744 1744
 			foreach ($airlines as $airline) {
1745
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1745
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1746 1746
 			}
1747
-			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1748
-			$query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name);
1747
+			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1748
+			$query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name);
1749 1749
 		} else {
1750 1750
 			$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";
1751
-			$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1751
+			$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1752 1752
 		}
1753 1753
 		try {
1754 1754
 			$sth = $this->db->prepare($query);
1755 1755
 			$sth->execute($query_values);
1756
-		} catch(PDOException $e) {
1756
+		} catch (PDOException $e) {
1757 1757
 			echo "error : ".$e->getMessage();
1758 1758
 		}
1759 1759
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1760 1760
 		return $all;
1761 1761
 	}
1762
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
1762
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
1763 1763
 		if ($filter_name == '') $filter_name = $this->filter_name;
1764 1764
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1765
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1765
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1766 1766
 		try {
1767 1767
 			$sth = $this->db->prepare($query);
1768 1768
 			$sth->execute($query_values);
1769
-		} catch(PDOException $e) {
1769
+		} catch (PDOException $e) {
1770 1770
 			echo "error : ".$e->getMessage();
1771 1771
 		}
1772 1772
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1773 1773
 		return $all;
1774 1774
 	}
1775
-	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1775
+	public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') {
1776 1776
 		if ($filter_name == '') $filter_name = $this->filter_name;
1777 1777
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1778
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1778
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1779 1779
 		try {
1780 1780
 			$sth = $this->db->prepare($query);
1781 1781
 			$sth->execute($query_values);
1782
-		} catch(PDOException $e) {
1782
+		} catch (PDOException $e) {
1783 1783
 			echo "error : ".$e->getMessage();
1784 1784
 		}
1785 1785
 	}
1786
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1786
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
1787 1787
 		if ($filter_name == '') $filter_name = $this->filter_name;
1788 1788
 		global $globalArchiveMonths, $globalDBdriver;
1789
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1789
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1790 1790
 			$Spotter = new Spotter($this->db);
1791
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1791
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1792 1792
 			$alliance_airlines = array();
1793 1793
 			foreach ($airlines as $airline) {
1794
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1794
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1795 1795
 			}
1796 1796
 			if ($globalDBdriver == 'mysql') {
1797 1797
 				if ($month == '') {
1798
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1798
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1799 1799
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1800 1800
 				} else {
1801
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1802
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1801
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1802
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1803 1803
 				}
1804 1804
 			} else {
1805 1805
 				if ($month == '') {
1806
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1806
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1807 1807
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1808 1808
 				} else {
1809
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1810
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1809
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1810
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1811 1811
 				}
1812 1812
 			}
1813 1813
 		} else {
1814 1814
 			if ($globalDBdriver == 'mysql') {
1815 1815
 				if ($month == '') {
1816 1816
 					$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";
1817
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1817
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1818 1818
 				} else {
1819 1819
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
1820
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1820
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1821 1821
 				}
1822 1822
 			} else {
1823 1823
 				if ($month == '') {
1824 1824
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
1825
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1825
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1826 1826
 				} else {
1827 1827
 					$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";
1828
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1828
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1829 1829
 				}
1830 1830
 			}
1831 1831
 		}
1832 1832
 		try {
1833 1833
 			$sth = $this->db->prepare($query);
1834 1834
 			$sth->execute($query_values);
1835
-		} catch(PDOException $e) {
1835
+		} catch (PDOException $e) {
1836 1836
 			echo "error : ".$e->getMessage();
1837 1837
 		}
1838 1838
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1841,17 +1841,17 @@  discard block
 block discarded – undo
1841 1841
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1842 1842
 		global $globalArchiveMonths, $globalDBdriver;
1843 1843
 		if ($filter_name == '') $filter_name = $this->filter_name;
1844
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1844
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1845 1845
 			$Spotter = new Spotter($this->db);
1846
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1846
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1847 1847
 			$alliance_airlines = array();
1848 1848
 			foreach ($airlines as $airline) {
1849
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1849
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1850 1850
 			}
1851 1851
 			if ($globalDBdriver == 'mysql') {
1852
-				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1852
+				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1853 1853
 			} else {
1854
-				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1854
+				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1855 1855
 			}
1856 1856
 			$query_values = array(':type' => $type, ':filter_name' => $filter_name);
1857 1857
 		} else {
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
 		try {
1866 1866
 			$sth = $this->db->prepare($query);
1867 1867
 			$sth->execute($query_values);
1868
-		} catch(PDOException $e) {
1868
+		} catch (PDOException $e) {
1869 1869
 			echo "error : ".$e->getMessage();
1870 1870
 		}
1871 1871
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1874,17 +1874,17 @@  discard block
 block discarded – undo
1874 1874
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1875 1875
 		global $globalArchiveMonths, $globalDBdriver;
1876 1876
 		if ($filter_name == '') $filter_name = $this->filter_name;
1877
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1877
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1878 1878
 			$Spotter = new Spotter($this->db);
1879
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1879
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1880 1880
 			$alliance_airlines = array();
1881 1881
 			foreach ($airlines as $airline) {
1882
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1882
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1883 1883
 			}
1884 1884
 			if ($globalDBdriver == 'mysql') {
1885
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1885
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1886 1886
 			} else {
1887
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1887
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1888 1888
 			}
1889 1889
 		} else {
1890 1890
 			if ($globalDBdriver == 'mysql') {
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 		try {
1897 1897
 			$sth = $this->db->prepare($query);
1898 1898
 			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1899
-		} catch(PDOException $e) {
1899
+		} catch (PDOException $e) {
1900 1900
 			echo "error : ".$e->getMessage();
1901 1901
 		}
1902 1902
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
 		try {
1914 1914
 			$sth = $this->db->prepare($query);
1915 1915
 			$sth->execute(array(':filter_name' => $filter_name));
1916
-		} catch(PDOException $e) {
1916
+		} catch (PDOException $e) {
1917 1917
 			echo "error : ".$e->getMessage();
1918 1918
 		}
1919 1919
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1930,20 +1930,20 @@  discard block
 block discarded – undo
1930 1930
 		try {
1931 1931
 			$sth = $this->db->prepare($query);
1932 1932
 			$sth->execute(array(':filter_name' => $filter_name));
1933
-		} catch(PDOException $e) {
1933
+		} catch (PDOException $e) {
1934 1934
 			echo "error : ".$e->getMessage();
1935 1935
 		}
1936 1936
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1937 1937
 		return $all[0]['total'];
1938 1938
 	}
1939
-	public function getStatsOwner($owner_name,$filter_name = '') {
1939
+	public function getStatsOwner($owner_name, $filter_name = '') {
1940 1940
 		global $globalArchiveMonths, $globalDBdriver;
1941 1941
 		if ($filter_name == '') $filter_name = $this->filter_name;
1942 1942
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1943 1943
 		try {
1944 1944
 			$sth = $this->db->prepare($query);
1945
-			$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1946
-		} catch(PDOException $e) {
1945
+			$sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1946
+		} catch (PDOException $e) {
1947 1947
 			echo "error : ".$e->getMessage();
1948 1948
 		}
1949 1949
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1961,20 +1961,20 @@  discard block
 block discarded – undo
1961 1961
 		try {
1962 1962
 			$sth = $this->db->prepare($query);
1963 1963
 			$sth->execute(array(':filter_name' => $filter_name));
1964
-		} catch(PDOException $e) {
1964
+		} catch (PDOException $e) {
1965 1965
 			echo "error : ".$e->getMessage();
1966 1966
 		}
1967 1967
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1968 1968
 		return $all[0]['total'];
1969 1969
 	}
1970
-	public function getStatsPilot($pilot,$filter_name = '') {
1970
+	public function getStatsPilot($pilot, $filter_name = '') {
1971 1971
 		global $globalArchiveMonths, $globalDBdriver;
1972 1972
 		if ($filter_name == '') $filter_name = $this->filter_name;
1973 1973
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1974 1974
 		try {
1975 1975
 			$sth = $this->db->prepare($query);
1976
-			$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1977
-		} catch(PDOException $e) {
1976
+			$sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1977
+		} catch (PDOException $e) {
1978 1978
 			echo "error : ".$e->getMessage();
1979 1979
 		}
1980 1980
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
 		else return 0;
1983 1983
 	}
1984 1984
 
1985
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1985
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1986 1986
 		global $globalDBdriver;
1987 1987
 		if ($filter_name == '') $filter_name = $this->filter_name;
1988 1988
 		if ($globalDBdriver == 'mysql') {
@@ -1990,15 +1990,15 @@  discard block
 block discarded – undo
1990 1990
 		} else {
1991 1991
 			$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);"; 
1992 1992
 		}
1993
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1993
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1994 1994
 		try {
1995 1995
 			$sth = $this->db->prepare($query);
1996 1996
 			$sth->execute($query_values);
1997
-		} catch(PDOException $e) {
1997
+		} catch (PDOException $e) {
1998 1998
 			return "error : ".$e->getMessage();
1999 1999
 		}
2000 2000
 	}
2001
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
2001
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
2002 2002
 		global $globalDBdriver;
2003 2003
 		if ($filter_name == '') $filter_name = $this->filter_name;
2004 2004
 		if ($globalDBdriver == 'mysql') {
@@ -2007,11 +2007,11 @@  discard block
 block discarded – undo
2007 2007
 			//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
2008 2008
 			$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);"; 
2009 2009
 		}
2010
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2010
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2011 2011
 		try {
2012 2012
 			$sth = $this->db->prepare($query);
2013 2013
 			$sth->execute($query_values);
2014
-		} catch(PDOException $e) {
2014
+		} catch (PDOException $e) {
2015 2015
 			return "error : ".$e->getMessage();
2016 2016
 		}
2017 2017
 	}
@@ -2035,95 +2035,95 @@  discard block
 block discarded – undo
2035 2035
         }
2036 2036
         */
2037 2037
 
2038
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
2038
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
2039 2039
 		global $globalDBdriver;
2040 2040
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
2041 2041
 		$query_values = array();
2042 2042
 		if ($globalDBdriver == 'mysql') {
2043 2043
 			if ($year != '') {
2044 2044
 				$query .= ' AND YEAR(stats_date) = :year';
2045
-				$query_values = array_merge($query_values,array(':year' => $year));
2045
+				$query_values = array_merge($query_values, array(':year' => $year));
2046 2046
 			}
2047 2047
 			if ($month != '') {
2048 2048
 				$query .= ' AND MONTH(stats_date) = :month';
2049
-				$query_values = array_merge($query_values,array(':month' => $month));
2049
+				$query_values = array_merge($query_values, array(':month' => $month));
2050 2050
 			}
2051 2051
 			if ($day != '') {
2052 2052
 				$query .= ' AND DAY(stats_date) = :day';
2053
-				$query_values = array_merge($query_values,array(':day' => $day));
2053
+				$query_values = array_merge($query_values, array(':day' => $day));
2054 2054
 			}
2055 2055
 		} else {
2056 2056
 			if ($year != '') {
2057 2057
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
2058
-				$query_values = array_merge($query_values,array(':year' => $year));
2058
+				$query_values = array_merge($query_values, array(':year' => $year));
2059 2059
 			}
2060 2060
 			if ($month != '') {
2061 2061
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
2062
-				$query_values = array_merge($query_values,array(':month' => $month));
2062
+				$query_values = array_merge($query_values, array(':month' => $month));
2063 2063
 			}
2064 2064
 			if ($day != '') {
2065 2065
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
2066
-				$query_values = array_merge($query_values,array(':day' => $day));
2066
+				$query_values = array_merge($query_values, array(':day' => $day));
2067 2067
 			}
2068 2068
 		}
2069 2069
 		$query .= " ORDER BY source_name";
2070
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
2070
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
2071 2071
 		try {
2072 2072
 			$sth = $this->db->prepare($query);
2073 2073
 			$sth->execute($query_values);
2074
-		} catch(PDOException $e) {
2074
+		} catch (PDOException $e) {
2075 2075
 			echo "error : ".$e->getMessage();
2076 2076
 		}
2077 2077
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
2078 2078
 		return $all;
2079 2079
 	}
2080 2080
 
2081
-	public function addStatSource($data,$source_name,$stats_type,$date) {
2081
+	public function addStatSource($data, $source_name, $stats_type, $date) {
2082 2082
 		global $globalDBdriver;
2083 2083
 		if ($globalDBdriver == 'mysql') {
2084 2084
 			$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";
2085 2085
 		} else {
2086 2086
 			$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);"; 
2087 2087
 		}
2088
-		$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
2088
+		$query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
2089 2089
 		try {
2090 2090
 			$sth = $this->db->prepare($query);
2091 2091
 			$sth->execute($query_values);
2092
-		} catch(PDOException $e) {
2092
+		} catch (PDOException $e) {
2093 2093
 			return "error : ".$e->getMessage();
2094 2094
 		}
2095 2095
 	}
2096
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
2096
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
2097 2097
 		$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
2098
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2098
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2099 2099
 		try {
2100 2100
 			$sth = $this->db->prepare($query);
2101 2101
 			$sth->execute($query_values);
2102
-		} catch(PDOException $e) {
2102
+		} catch (PDOException $e) {
2103 2103
 			return "error : ".$e->getMessage();
2104 2104
 		}
2105 2105
 	}
2106
-	public function addStatMarine($type,$date_name,$cnt,$filter_name = '') {
2106
+	public function addStatMarine($type, $date_name, $cnt, $filter_name = '') {
2107 2107
 		$query = "INSERT INTO stats_marine (stats_type,marine_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
2108
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
2108
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2109 2109
 		try {
2110 2110
 			$sth = $this->db->prepare($query);
2111 2111
 			$sth->execute($query_values);
2112
-		} catch(PDOException $e) {
2112
+		} catch (PDOException $e) {
2113 2113
 			return "error : ".$e->getMessage();
2114 2114
 		}
2115 2115
 	}
2116
-	public function addStatTracker($type,$date_name,$cnt,$filter_name = '') {
2116
+	public function addStatTracker($type, $date_name, $cnt, $filter_name = '') {
2117 2117
 		$query = "INSERT INTO stats_tracker (stats_type,tracker_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
2118
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
2118
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2119 2119
 		try {
2120 2120
 			$sth = $this->db->prepare($query);
2121 2121
 			$sth->execute($query_values);
2122
-		} catch(PDOException $e) {
2122
+		} catch (PDOException $e) {
2123 2123
 			return "error : ".$e->getMessage();
2124 2124
 		}
2125 2125
 	}
2126
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
2126
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
2127 2127
 		global $globalDBdriver;
2128 2128
 		if ($globalDBdriver == 'mysql') {
2129 2129
 			if ($reset) {
@@ -2138,15 +2138,15 @@  discard block
 block discarded – undo
2138 2138
 				$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);"; 
2139 2139
 			}
2140 2140
 		}
2141
-		$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2141
+		$query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2142 2142
 		try {
2143 2143
 			$sth = $this->db->prepare($query);
2144 2144
 			$sth->execute($query_values);
2145
-		} catch(PDOException $e) {
2145
+		} catch (PDOException $e) {
2146 2146
 			return "error : ".$e->getMessage();
2147 2147
 		}
2148 2148
 	}
2149
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
2149
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
2150 2150
 		global $globalDBdriver;
2151 2151
 		if ($globalDBdriver == 'mysql') {
2152 2152
 			if ($reset) {
@@ -2161,15 +2161,15 @@  discard block
 block discarded – undo
2161 2161
 				$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);"; 
2162 2162
 			}
2163 2163
 		}
2164
-		$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
2164
+		$query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
2165 2165
 		try {
2166 2166
 			$sth = $this->db->prepare($query);
2167 2167
 			$sth->execute($query_values);
2168
-		} catch(PDOException $e) {
2168
+		} catch (PDOException $e) {
2169 2169
 			return "error : ".$e->getMessage();
2170 2170
 		}
2171 2171
 	}
2172
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
2172
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
2173 2173
 		global $globalDBdriver;
2174 2174
 		if ($globalDBdriver == 'mysql') {
2175 2175
 			if ($reset) {
@@ -2184,15 +2184,15 @@  discard block
 block discarded – undo
2184 2184
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
2185 2185
 			}
2186 2186
 		}
2187
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
2187
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
2188 2188
 		try {
2189 2189
 			$sth = $this->db->prepare($query);
2190 2190
 			$sth->execute($query_values);
2191
-		} catch(PDOException $e) {
2191
+		} catch (PDOException $e) {
2192 2192
 			return "error : ".$e->getMessage();
2193 2193
 		}
2194 2194
 	}
2195
-	public function addStatCountryMarine($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
2195
+	public function addStatCountryMarine($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
2196 2196
 		global $globalDBdriver;
2197 2197
 		if ($globalDBdriver == 'mysql') {
2198 2198
 			if ($reset) {
@@ -2207,15 +2207,15 @@  discard block
 block discarded – undo
2207 2207
 				$query = "UPDATE stats_marine_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_marine_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
2208 2208
 			}
2209 2209
 		}
2210
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
2210
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2211 2211
 		try {
2212 2212
 			$sth = $this->db->prepare($query);
2213 2213
 			$sth->execute($query_values);
2214
-		} catch(PDOException $e) {
2214
+		} catch (PDOException $e) {
2215 2215
 			return "error : ".$e->getMessage();
2216 2216
 		}
2217 2217
 	}
2218
-	public function addStatCountryTracker($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
2218
+	public function addStatCountryTracker($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
2219 2219
 		global $globalDBdriver;
2220 2220
 		if ($globalDBdriver == 'mysql') {
2221 2221
 			if ($reset) {
@@ -2230,15 +2230,15 @@  discard block
 block discarded – undo
2230 2230
 				$query = "UPDATE stats_tracker_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_tracker_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
2231 2231
 			}
2232 2232
 		}
2233
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
2233
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2234 2234
 		try {
2235 2235
 			$sth = $this->db->prepare($query);
2236 2236
 			$sth->execute($query_values);
2237
-		} catch(PDOException $e) {
2237
+		} catch (PDOException $e) {
2238 2238
 			return "error : ".$e->getMessage();
2239 2239
 		}
2240 2240
 	}
2241
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2241
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2242 2242
 		global $globalDBdriver;
2243 2243
 		if ($globalDBdriver == 'mysql') {
2244 2244
 			if ($reset) {
@@ -2253,15 +2253,15 @@  discard block
 block discarded – undo
2253 2253
 				$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);"; 
2254 2254
 			}
2255 2255
 		}
2256
-		$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);
2256
+		$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);
2257 2257
 		try {
2258 2258
 			$sth = $this->db->prepare($query);
2259 2259
 			$sth->execute($query_values);
2260
-		} catch(PDOException $e) {
2260
+		} catch (PDOException $e) {
2261 2261
 			return "error : ".$e->getMessage();
2262 2262
 		}
2263 2263
 	}
2264
-	public function addStatMarineType($type,$type_id,$cnt, $filter_name = '', $reset = false) {
2264
+	public function addStatMarineType($type, $type_id, $cnt, $filter_name = '', $reset = false) {
2265 2265
 		global $globalDBdriver;
2266 2266
 		if ($globalDBdriver == 'mysql') {
2267 2267
 			if ($reset) {
@@ -2276,15 +2276,15 @@  discard block
 block discarded – undo
2276 2276
 				$query = "UPDATE stats_marine_type SET cnt = cnt+:cnt, type = :type, filter_name = :filter_name WHERE type_id = :type_id AND filter_name = :filter_name; INSERT INTO stats_marine_type (type,type_id,cnt,filter_name) SELECT :type,:type_id,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_type WHERE type_id = :type_id AND filter_name = :filter_name);"; 
2277 2277
 			}
2278 2278
 		}
2279
-		$query_values = array(':type' => $type,':type_id' => $type_id,':cnt' => $cnt, ':filter_name' => $filter_name);
2279
+		$query_values = array(':type' => $type, ':type_id' => $type_id, ':cnt' => $cnt, ':filter_name' => $filter_name);
2280 2280
 		try {
2281 2281
 			$sth = $this->db->prepare($query);
2282 2282
 			$sth->execute($query_values);
2283
-		} catch(PDOException $e) {
2283
+		} catch (PDOException $e) {
2284 2284
 			return "error : ".$e->getMessage();
2285 2285
 		}
2286 2286
 	}
2287
-	public function addStatTrackerType($type,$cnt, $filter_name = '', $reset = false) {
2287
+	public function addStatTrackerType($type, $cnt, $filter_name = '', $reset = false) {
2288 2288
 		global $globalDBdriver;
2289 2289
 		if ($globalDBdriver == 'mysql') {
2290 2290
 			if ($reset) {
@@ -2299,15 +2299,15 @@  discard block
 block discarded – undo
2299 2299
 				$query = "UPDATE stats_tracker_type SET cnt = cnt+:cnt WHERE type = :type AND filter_name = :filter_name; INSERT INTO stats_tracker_type (type,cnt,filter_name) SELECT :type,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_type WHERE type = :type AND filter_name = :filter_name);"; 
2300 2300
 			}
2301 2301
 		}
2302
-		$query_values = array(':type' => $type,':cnt' => $cnt, ':filter_name' => $filter_name);
2302
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':filter_name' => $filter_name);
2303 2303
 		try {
2304 2304
 			$sth = $this->db->prepare($query);
2305 2305
 			$sth->execute($query_values);
2306
-		} catch(PDOException $e) {
2306
+		} catch (PDOException $e) {
2307 2307
 			return "error : ".$e->getMessage();
2308 2308
 		}
2309 2309
 	}
2310
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
2310
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
2311 2311
 		global $globalDBdriver;
2312 2312
 		if ($globalDBdriver == 'mysql') {
2313 2313
 			if ($reset) {
@@ -2322,15 +2322,15 @@  discard block
 block discarded – undo
2322 2322
 				$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);"; 
2323 2323
 			}
2324 2324
 		}
2325
-		$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
2325
+		$query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2326 2326
 		try {
2327 2327
 			$sth = $this->db->prepare($query);
2328 2328
 			$sth->execute($query_values);
2329
-		} catch(PDOException $e) {
2329
+		} catch (PDOException $e) {
2330 2330
 			return "error : ".$e->getMessage();
2331 2331
 		}
2332 2332
 	}
2333
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
2333
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
2334 2334
 		global $globalDBdriver;
2335 2335
 		if ($globalDBdriver == 'mysql') {
2336 2336
 			if ($reset) {
@@ -2345,15 +2345,15 @@  discard block
 block discarded – undo
2345 2345
 				$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);"; 
2346 2346
 			}
2347 2347
 		}
2348
-		$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2348
+		$query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2349 2349
 		try {
2350 2350
 			$sth = $this->db->prepare($query);
2351 2351
 			$sth->execute($query_values);
2352
-		} catch(PDOException $e) {
2352
+		} catch (PDOException $e) {
2353 2353
 			return "error : ".$e->getMessage();
2354 2354
 		}
2355 2355
 	}
2356
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
2356
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
2357 2357
 		global $globalDBdriver;
2358 2358
 		if ($globalDBdriver == 'mysql') {
2359 2359
 			if ($reset) {
@@ -2368,15 +2368,15 @@  discard block
 block discarded – undo
2368 2368
 				$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);"; 
2369 2369
 			}
2370 2370
 		}
2371
-		$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);
2371
+		$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);
2372 2372
 		try {
2373 2373
 			$sth = $this->db->prepare($query);
2374 2374
 			$sth->execute($query_values);
2375
-		} catch(PDOException $e) {
2375
+		} catch (PDOException $e) {
2376 2376
 			return "error : ".$e->getMessage();
2377 2377
 		}
2378 2378
 	}
2379
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
2379
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
2380 2380
 		global $globalDBdriver;
2381 2381
 		if ($airport_icao != '') {
2382 2382
 			if ($globalDBdriver == 'mysql') {
@@ -2392,16 +2392,16 @@  discard block
 block discarded – undo
2392 2392
 					$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
2393 2393
 				}
2394 2394
 			}
2395
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2395
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2396 2396
 			try {
2397 2397
 				$sth = $this->db->prepare($query);
2398 2398
 				$sth->execute($query_values);
2399
-			} catch(PDOException $e) {
2399
+			} catch (PDOException $e) {
2400 2400
 				return "error : ".$e->getMessage();
2401 2401
 			}
2402 2402
 		}
2403 2403
 	}
2404
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
2404
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
2405 2405
 		global $globalDBdriver;
2406 2406
 		if ($airport_icao != '') {
2407 2407
 			if ($globalDBdriver == 'mysql') {
@@ -2409,16 +2409,16 @@  discard block
 block discarded – undo
2409 2409
 			} else {
2410 2410
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2411 2411
 			}
2412
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2412
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2413 2413
 			 try {
2414 2414
 				$sth = $this->db->prepare($query);
2415 2415
 				$sth->execute($query_values);
2416
-			} catch(PDOException $e) {
2416
+			} catch (PDOException $e) {
2417 2417
 				return "error : ".$e->getMessage();
2418 2418
 			}
2419 2419
 		}
2420 2420
 	}
2421
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
2421
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
2422 2422
 		global $globalDBdriver;
2423 2423
 		if ($airport_icao != '') {
2424 2424
 			if ($globalDBdriver == 'mysql') {
@@ -2434,16 +2434,16 @@  discard block
 block discarded – undo
2434 2434
 					$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);"; 
2435 2435
 				}
2436 2436
 			}
2437
-			$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);
2437
+			$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);
2438 2438
 			try {
2439 2439
 				$sth = $this->db->prepare($query);
2440 2440
 				$sth->execute($query_values);
2441
-			} catch(PDOException $e) {
2441
+			} catch (PDOException $e) {
2442 2442
 				return "error : ".$e->getMessage();
2443 2443
 			}
2444 2444
 		}
2445 2445
 	}
2446
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
2446
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
2447 2447
 		global $globalDBdriver;
2448 2448
 		if ($airport_icao != '') {
2449 2449
 			if ($globalDBdriver == 'mysql') {
@@ -2451,11 +2451,11 @@  discard block
 block discarded – undo
2451 2451
 			} else {
2452 2452
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2453 2453
 			}
2454
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2454
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2455 2455
 			try {
2456 2456
 				$sth = $this->db->prepare($query);
2457 2457
 				$sth->execute($query_values);
2458
-			} catch(PDOException $e) {
2458
+			} catch (PDOException $e) {
2459 2459
 				return "error : ".$e->getMessage();
2460 2460
 			}
2461 2461
 		}
@@ -2467,7 +2467,7 @@  discard block
 block discarded – undo
2467 2467
 		try {
2468 2468
 			$sth = $this->db->prepare($query);
2469 2469
 			$sth->execute($query_values);
2470
-		} catch(PDOException $e) {
2470
+		} catch (PDOException $e) {
2471 2471
 			return "error : ".$e->getMessage();
2472 2472
 		}
2473 2473
 	}
@@ -2477,7 +2477,7 @@  discard block
 block discarded – undo
2477 2477
 		try {
2478 2478
 			$sth = $this->db->prepare($query);
2479 2479
 			$sth->execute($query_values);
2480
-		} catch(PDOException $e) {
2480
+		} catch (PDOException $e) {
2481 2481
 			return "error : ".$e->getMessage();
2482 2482
 		}
2483 2483
 	}
@@ -2487,7 +2487,7 @@  discard block
 block discarded – undo
2487 2487
 		try {
2488 2488
 			$sth = $this->db->prepare($query);
2489 2489
 			$sth->execute($query_values);
2490
-		} catch(PDOException $e) {
2490
+		} catch (PDOException $e) {
2491 2491
 			return "error : ".$e->getMessage();
2492 2492
 		}
2493 2493
 	}
@@ -2497,7 +2497,7 @@  discard block
 block discarded – undo
2497 2497
 		try {
2498 2498
 			$sth = $this->db->prepare($query);
2499 2499
 			$sth->execute($query_values);
2500
-		} catch(PDOException $e) {
2500
+		} catch (PDOException $e) {
2501 2501
 			return "error : ".$e->getMessage();
2502 2502
 		}
2503 2503
 	}
@@ -2507,13 +2507,13 @@  discard block
 block discarded – undo
2507 2507
 		try {
2508 2508
 			$sth = $this->db->prepare($query);
2509 2509
 			$sth->execute($query_values);
2510
-		} catch(PDOException $e) {
2510
+		} catch (PDOException $e) {
2511 2511
 			return "error : ".$e->getMessage();
2512 2512
 		}
2513 2513
 	}
2514 2514
 
2515 2515
 	public function addOldStats() {
2516
-		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents;
2516
+		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents;
2517 2517
 		$Common = new Common();
2518 2518
 		$Connection = new Connection($this->db);
2519 2519
 		date_default_timezone_set('UTC');
@@ -2528,9 +2528,9 @@  discard block
 block discarded – undo
2528 2528
 			$filtername = 'marine';
2529 2529
 			if ($Connection->tableExists('countries')) {
2530 2530
 				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2531
-				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2531
+				$alldata = $Marine->countAllMarineOverCountries(false, 0, $last_update_day);
2532 2532
 				foreach ($alldata as $number) {
2533
-					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2533
+					echo $this->addStatCountryMarine($number['marine_country_iso2'], $number['marine_country_iso3'], $number['marine_country'], $number['marine_count'], '', '', $reset);
2534 2534
 				}
2535 2535
 			}
2536 2536
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2540,44 +2540,44 @@  discard block
 block discarded – undo
2540 2540
 			$lastyear = false;
2541 2541
 			foreach ($alldata as $number) {
2542 2542
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2543
-				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2543
+				$this->addStat('marine_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2544 2544
 			}
2545 2545
 			echo 'Marine data...'."\n";
2546 2546
 			$this->deleteStatMarine('month');
2547 2547
 			echo '-> countAllDatesLastMonth...'."\n";
2548 2548
 			$alldata = $Marine->countAllDatesLastMonth($filter_last_month);
2549 2549
 			foreach ($alldata as $number) {
2550
-				$this->addStatMarine('month',$number['date_name'],$number['date_count']);
2550
+				$this->addStatMarine('month', $number['date_name'], $number['date_count']);
2551 2551
 			}
2552 2552
 			echo '-> countAllDates...'."\n";
2553 2553
 			$previousdata = $this->countAllDatesMarine();
2554 2554
 			$this->deleteStatMarine('date');
2555
-			$alldata = $Common->array_merge_noappend($previousdata,$Marine->countAllDates($filter_last_month));
2555
+			$alldata = $Common->array_merge_noappend($previousdata, $Marine->countAllDates($filter_last_month));
2556 2556
 			$values = array();
2557 2557
 			foreach ($alldata as $cnt) {
2558 2558
 				$values[] = $cnt['date_count'];
2559 2559
 			}
2560
-			array_multisort($values,SORT_DESC,$alldata);
2561
-			array_splice($alldata,11);
2560
+			array_multisort($values, SORT_DESC, $alldata);
2561
+			array_splice($alldata, 11);
2562 2562
 			foreach ($alldata as $number) {
2563
-				$this->addStatMarine('date',$number['date_name'],$number['date_count']);
2563
+				$this->addStatMarine('date', $number['date_name'], $number['date_count']);
2564 2564
 			}
2565 2565
 			
2566 2566
 			$this->deleteStatMarine('hour');
2567 2567
 			echo '-> countAllHours...'."\n";
2568
-			$alldata = $Marine->countAllHours('hour',$filter_last_month);
2568
+			$alldata = $Marine->countAllHours('hour', $filter_last_month);
2569 2569
 			foreach ($alldata as $number) {
2570
-				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2570
+				$this->addStatMarine('hour', $number['hour_name'], $number['hour_count']);
2571 2571
 			}
2572 2572
 			if ($globalDebug) echo 'Count all types...'."\n";
2573
-			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2573
+			$alldata = $Marine->countAllMarineTypes(false, 0, $last_update_day);
2574 2574
 			foreach ($alldata as $number) {
2575
-				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
2575
+				$this->addStatMarineType($number['marine_type'], $number['marine_type_id'], $number['marine_type_count'], '', $reset);
2576 2576
 			}
2577 2577
 
2578 2578
 			echo 'Insert last stats update date...'."\n";
2579 2579
 			date_default_timezone_set('UTC');
2580
-			$this->addLastStatsUpdate('last_update_stats_marine',date('Y-m-d G:i:s'));
2580
+			$this->addLastStatsUpdate('last_update_stats_marine', date('Y-m-d G:i:s'));
2581 2581
 		}
2582 2582
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2583 2583
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
@@ -2589,9 +2589,9 @@  discard block
 block discarded – undo
2589 2589
 			$Tracker = new Tracker($this->db);
2590 2590
 			if ($Connection->tableExists('countries')) {
2591 2591
 				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2592
-				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2592
+				$alldata = $Tracker->countAllTrackerOverCountries(false, 0, $last_update_day);
2593 2593
 				foreach ($alldata as $number) {
2594
-					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2594
+					$this->addStatCountryTracker($number['tracker_country_iso2'], $number['tracker_country_iso3'], $number['tracker_country'], $number['tracker_count'], '', '', $reset);
2595 2595
 				}
2596 2596
 			}
2597 2597
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2601,43 +2601,43 @@  discard block
 block discarded – undo
2601 2601
 			$lastyear = false;
2602 2602
 			foreach ($alldata as $number) {
2603 2603
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2604
-				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2604
+				$this->addStat('tracker_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2605 2605
 			}
2606 2606
 			echo 'Tracker data...'."\n";
2607 2607
 			$this->deleteStatTracker('month');
2608 2608
 			echo '-> countAllDatesLastMonth...'."\n";
2609 2609
 			$alldata = $Tracker->countAllDatesLastMonth($filter_last_month);
2610 2610
 			foreach ($alldata as $number) {
2611
-				$this->addStatTracker('month',$number['date_name'],$number['date_count']);
2611
+				$this->addStatTracker('month', $number['date_name'], $number['date_count']);
2612 2612
 			}
2613 2613
 			echo '-> countAllDates...'."\n";
2614 2614
 			$previousdata = $this->countAllDatesTracker();
2615 2615
 			$this->deleteStatTracker('date');
2616
-			$alldata = $Common->array_merge_noappend($previousdata,$Tracker->countAllDates($filter_last_month));
2616
+			$alldata = $Common->array_merge_noappend($previousdata, $Tracker->countAllDates($filter_last_month));
2617 2617
 			$values = array();
2618 2618
 			foreach ($alldata as $cnt) {
2619 2619
 				$values[] = $cnt['date_count'];
2620 2620
 			}
2621
-			array_multisort($values,SORT_DESC,$alldata);
2622
-			array_splice($alldata,11);
2621
+			array_multisort($values, SORT_DESC, $alldata);
2622
+			array_splice($alldata, 11);
2623 2623
 			foreach ($alldata as $number) {
2624
-				$this->addStatTracker('date',$number['date_name'],$number['date_count']);
2624
+				$this->addStatTracker('date', $number['date_name'], $number['date_count']);
2625 2625
 			}
2626 2626
 			
2627 2627
 			$this->deleteStatTracker('hour');
2628 2628
 			echo '-> countAllHours...'."\n";
2629
-			$alldata = $Tracker->countAllHours('hour',$filter_last_month);
2629
+			$alldata = $Tracker->countAllHours('hour', $filter_last_month);
2630 2630
 			foreach ($alldata as $number) {
2631
-				$this->addStatTracker('hour',$number['hour_name'],$number['hour_count']);
2631
+				$this->addStatTracker('hour', $number['hour_name'], $number['hour_count']);
2632 2632
 			}
2633 2633
 			if ($globalDebug) echo 'Count all types...'."\n";
2634
-			$alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day);
2634
+			$alldata = $Tracker->countAllTrackerTypes(false, 0, $last_update_day);
2635 2635
 			foreach ($alldata as $number) {
2636
-				$this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset);
2636
+				$this->addStatTrackerType($number['tracker_type'], $number['tracker_type_count'], '', $reset);
2637 2637
 			}
2638 2638
 			echo 'Insert last stats update date...'."\n";
2639 2639
 			date_default_timezone_set('UTC');
2640
-			$this->addLastStatsUpdate('last_update_stats_tracker',date('Y-m-d G:i:s'));
2640
+			$this->addLastStatsUpdate('last_update_stats_tracker', date('Y-m-d G:i:s'));
2641 2641
 		}
2642 2642
 
2643 2643
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
@@ -2655,41 +2655,41 @@  discard block
 block discarded – undo
2655 2655
 			$Spotter = new Spotter($this->db);
2656 2656
 
2657 2657
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2658
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2658
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
2659 2659
 			foreach ($alldata as $number) {
2660
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2660
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
2661 2661
 			}
2662 2662
 			if ($globalDebug) echo 'Count all airlines...'."\n";
2663
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2663
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
2664 2664
 			foreach ($alldata as $number) {
2665
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2665
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
2666 2666
 			}
2667 2667
 			if ($globalDebug) echo 'Count all registrations...'."\n";
2668
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2668
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
2669 2669
 			foreach ($alldata as $number) {
2670
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2670
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
2671 2671
 			}
2672 2672
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
2673
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2673
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
2674 2674
 			foreach ($alldata as $number) {
2675
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2675
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2676 2676
 			}
2677 2677
 			if ($globalDebug) echo 'Count all owners...'."\n";
2678
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2678
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
2679 2679
 			foreach ($alldata as $number) {
2680
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2680
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
2681 2681
 			}
2682 2682
 			if ($globalDebug) echo 'Count all pilots...'."\n";
2683
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2683
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
2684 2684
 			foreach ($alldata as $number) {
2685 2685
 				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2686
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2686
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
2687 2687
 			}
2688 2688
 			
2689 2689
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
2690
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2690
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
2691 2691
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2692
-			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2692
+			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
2693 2693
 			if ($globalDebug) echo 'Order departure airports...'."\n";
2694 2694
 			$alldata = array();
2695 2695
 			foreach ($pall as $value) {
@@ -2706,14 +2706,14 @@  discard block
 block discarded – undo
2706 2706
 			foreach ($alldata as $key => $row) {
2707 2707
 				$count[$key] = $row['airport_departure_icao_count'];
2708 2708
 			}
2709
-			array_multisort($count,SORT_DESC,$alldata);
2709
+			array_multisort($count, SORT_DESC, $alldata);
2710 2710
 			foreach ($alldata as $number) {
2711
-				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);
2711
+				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);
2712 2712
 			}
2713 2713
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2714
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2714
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
2715 2715
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2716
-			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2716
+			$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
2717 2717
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
2718 2718
 			$alldata = array();
2719 2719
 			foreach ($pall as $value) {
@@ -2730,18 +2730,18 @@  discard block
 block discarded – undo
2730 2730
 			foreach ($alldata as $key => $row) {
2731 2731
 				$count[$key] = $row['airport_arrival_icao_count'];
2732 2732
 			}
2733
-			array_multisort($count,SORT_DESC,$alldata);
2733
+			array_multisort($count, SORT_DESC, $alldata);
2734 2734
 			foreach ($alldata as $number) {
2735
-				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);
2735
+				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);
2736 2736
 			}
2737 2737
 			if ($Connection->tableExists('countries')) {
2738 2738
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2739 2739
 				//$SpotterArchive = new SpotterArchive();
2740 2740
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2741 2741
 				$Spotter = new Spotter($this->db);
2742
-				$alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day);
2742
+				$alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day);
2743 2743
 				foreach ($alldata as $number) {
2744
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
2744
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
2745 2745
 				}
2746 2746
 			}
2747 2747
 			
@@ -2751,12 +2751,12 @@  discard block
 block discarded – undo
2751 2751
 				$this->deleteStatsByType('fatalities_byyear');
2752 2752
 				$alldata = $Accident->countFatalitiesByYear();
2753 2753
 				foreach ($alldata as $number) {
2754
-					$this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year'])));
2754
+					$this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year'])));
2755 2755
 				}
2756 2756
 				$this->deleteStatsByType('fatalities_bymonth');
2757 2757
 				$alldata = $Accident->countFatalitiesLast12Months();
2758 2758
 				foreach ($alldata as $number) {
2759
-					$this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year'])));
2759
+					$this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year'])));
2760 2760
 				}
2761 2761
 			}
2762 2762
 
@@ -2770,37 +2770,37 @@  discard block
 block discarded – undo
2770 2770
 			$lastyear = false;
2771 2771
 			foreach ($alldata as $number) {
2772 2772
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2773
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2773
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2774 2774
 			}
2775 2775
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2776 2776
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2777 2777
 			foreach ($alldata as $number) {
2778
-				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2778
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2779 2779
 			}
2780 2780
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
2781 2781
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2782 2782
 			foreach ($alldata as $number) {
2783
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2783
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2784 2784
 			}
2785 2785
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2786 2786
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2787 2787
 			foreach ($alldata as $number) {
2788
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2788
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2789 2789
 			}
2790 2790
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2791 2791
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2792 2792
 			foreach ($alldata as $number) {
2793
-				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2793
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2794 2794
 			}
2795 2795
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2796 2796
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2797 2797
 			foreach ($alldata as $number) {
2798
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2798
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2799 2799
 			}
2800 2800
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2801 2801
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2802 2802
 			foreach ($alldata as $number) {
2803
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2803
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2804 2804
 			}
2805 2805
 			if ($globalDebug) echo 'Airports data...'."\n";
2806 2806
 			if ($globalDebug) echo '...Departure'."\n";
@@ -2845,7 +2845,7 @@  discard block
 block discarded – undo
2845 2845
 			}
2846 2846
 			$alldata = $pall;
2847 2847
 			foreach ($alldata as $number) {
2848
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
2848
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
2849 2849
 			}
2850 2850
 			echo '...Arrival'."\n";
2851 2851
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -2886,7 +2886,7 @@  discard block
 block discarded – undo
2886 2886
 			}
2887 2887
 			$alldata = $pall;
2888 2888
 			foreach ($alldata as $number) {
2889
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
2889
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
2890 2890
 			}
2891 2891
 
2892 2892
 			echo 'Flights data...'."\n";
@@ -2894,28 +2894,28 @@  discard block
 block discarded – undo
2894 2894
 			echo '-> countAllDatesLastMonth...'."\n";
2895 2895
 			$alldata = $Spotter->countAllDatesLastMonth($filter_last_month);
2896 2896
 			foreach ($alldata as $number) {
2897
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
2897
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
2898 2898
 			}
2899 2899
 			echo '-> countAllDates...'."\n";
2900 2900
 			$previousdata = $this->countAllDates();
2901 2901
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
2902 2902
 			$this->deleteStatFlight('date');
2903
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month));
2903
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month));
2904 2904
 			$values = array();
2905 2905
 			foreach ($alldata as $cnt) {
2906 2906
 				$values[] = $cnt['date_count'];
2907 2907
 			}
2908
-			array_multisort($values,SORT_DESC,$alldata);
2909
-			array_splice($alldata,11);
2908
+			array_multisort($values, SORT_DESC, $alldata);
2909
+			array_splice($alldata, 11);
2910 2910
 			foreach ($alldata as $number) {
2911
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
2911
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
2912 2912
 			}
2913 2913
 			
2914 2914
 			$this->deleteStatFlight('hour');
2915 2915
 			echo '-> countAllHours...'."\n";
2916
-			$alldata = $Spotter->countAllHours('hour',$filter_last_month);
2916
+			$alldata = $Spotter->countAllHours('hour', $filter_last_month);
2917 2917
 			foreach ($alldata as $number) {
2918
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
2918
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
2919 2919
 			}
2920 2920
 
2921 2921
 			// Count by airlines
@@ -2924,42 +2924,42 @@  discard block
 block discarded – undo
2924 2924
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2925 2925
 				$SpotterArchive = new SpotterArchive($this->db);
2926 2926
 				//$Spotter = new Spotter($this->db);
2927
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2927
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
2928 2928
 				//$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2929 2929
 				foreach ($alldata as $number) {
2930
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2930
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
2931 2931
 				}
2932 2932
 			}
2933 2933
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2934 2934
 			$Spotter = new Spotter($this->db);
2935
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2935
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
2936 2936
 			foreach ($alldata as $number) {
2937
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2937
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
2938 2938
 			}
2939 2939
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2940
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2940
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
2941 2941
 			foreach ($alldata as $number) {
2942
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2942
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
2943 2943
 			}
2944 2944
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2945
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2945
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
2946 2946
 			foreach ($alldata as $number) {
2947
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2947
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2948 2948
 			}
2949 2949
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2950
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2950
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
2951 2951
 			foreach ($alldata as $number) {
2952
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2952
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
2953 2953
 			}
2954 2954
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2955
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2955
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
2956 2956
 			foreach ($alldata as $number) {
2957
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2957
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
2958 2958
 			}
2959 2959
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2960
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2960
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
2961 2961
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2962
-			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2962
+			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
2963 2963
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2964 2964
 			//$alldata = array();
2965 2965
 			foreach ($dall as $value) {
@@ -2979,12 +2979,12 @@  discard block
 block discarded – undo
2979 2979
 			}
2980 2980
 			$alldata = $pall;
2981 2981
 			foreach ($alldata as $number) {
2982
-				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);
2982
+				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);
2983 2983
 			}
2984 2984
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2985
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2985
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
2986 2986
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2987
-			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2987
+			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
2988 2988
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2989 2989
 			//$alldata = array();
2990 2990
 			foreach ($dall as $value) {
@@ -3004,7 +3004,7 @@  discard block
 block discarded – undo
3004 3004
 			}
3005 3005
 			$alldata = $pall;
3006 3006
 			foreach ($alldata as $number) {
3007
-				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);
3007
+				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);
3008 3008
 			}
3009 3009
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
3010 3010
 			$Spotter = new Spotter($this->db);
@@ -3012,27 +3012,27 @@  discard block
 block discarded – undo
3012 3012
 			$lastyear = false;
3013 3013
 			foreach ($alldata as $number) {
3014 3014
 				if ($number['year_name'] != date('Y')) $lastyear = true;
3015
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3015
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3016 3016
 			}
3017 3017
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3018 3018
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
3019 3019
 			foreach ($alldata as $number) {
3020
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3020
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3021 3021
 			}
3022 3022
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3023 3023
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
3024 3024
 			foreach ($alldata as $number) {
3025
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3025
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3026 3026
 			}
3027 3027
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3028 3028
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
3029 3029
 			foreach ($alldata as $number) {
3030
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3030
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3031 3031
 			}
3032 3032
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3033 3033
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
3034 3034
 			foreach ($alldata as $number) {
3035
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3035
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3036 3036
 			}
3037 3037
 			if ($globalDebug) echo '...Departure'."\n";
3038 3038
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -3055,7 +3055,7 @@  discard block
 block discarded – undo
3055 3055
 			}
3056 3056
 			$alldata = $pall;
3057 3057
 			foreach ($alldata as $number) {
3058
-				$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']);
3058
+				$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']);
3059 3059
 			}
3060 3060
 			if ($globalDebug) echo '...Arrival'."\n";
3061 3061
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -3078,32 +3078,32 @@  discard block
 block discarded – undo
3078 3078
 			}
3079 3079
 			$alldata = $pall;
3080 3080
 			foreach ($alldata as $number) {
3081
-				$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']);
3081
+				$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']);
3082 3082
 			}
3083 3083
 
3084 3084
 			if ($globalDebug) echo 'Flights data...'."\n";
3085 3085
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3086 3086
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
3087 3087
 			foreach ($alldata as $number) {
3088
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
3088
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
3089 3089
 			}
3090 3090
 			if ($globalDebug) echo '-> countAllDates...'."\n";
3091 3091
 			//$previousdata = $this->countAllDatesByAirlines();
3092
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
3092
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month));
3093 3093
 			$values = array();
3094 3094
 			foreach ($alldata as $cnt) {
3095 3095
 				$values[] = $cnt['date_count'];
3096 3096
 			}
3097
-			array_multisort($values,SORT_DESC,$alldata);
3098
-			array_splice($alldata,11);
3097
+			array_multisort($values, SORT_DESC, $alldata);
3098
+			array_splice($alldata, 11);
3099 3099
 			foreach ($alldata as $number) {
3100
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
3100
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
3101 3101
 			}
3102 3102
 			
3103 3103
 			if ($globalDebug) echo '-> countAllHours...'."\n";
3104
-			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
3104
+			$alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month);
3105 3105
 			foreach ($alldata as $number) {
3106
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
3106
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
3107 3107
 			}
3108 3108
 
3109 3109
 			// Stats by filters
@@ -3127,7 +3127,7 @@  discard block
 block discarded – undo
3127 3127
 							$last_update_day = date('Y').'-01-01 00:00:00';
3128 3128
 						}
3129 3129
 					}
3130
-					if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
3130
+					if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
3131 3131
 						$last_update_day = date('Y').'-01-01 00:00:00';
3132 3132
 						$reset = true;
3133 3133
 					}
@@ -3135,38 +3135,38 @@  discard block
 block discarded – undo
3135 3135
 					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3136 3136
 					$Spotter = new Spotter($this->db);
3137 3137
 					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3138
-					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
3138
+					$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
3139 3139
 					foreach ($alldata as $number) {
3140
-						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
3140
+						$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
3141 3141
 					}
3142 3142
 					if ($globalDebug) echo 'Count all airlines...'."\n";
3143
-					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
3143
+					$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
3144 3144
 					foreach ($alldata as $number) {
3145
-						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
3145
+						$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
3146 3146
 					}
3147 3147
 					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3148
-					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
3148
+					$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
3149 3149
 					foreach ($alldata as $number) {
3150
-						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
3150
+						$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
3151 3151
 					}
3152 3152
 					if ($globalDebug) echo 'Count all callsigns...'."\n";
3153
-					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
3153
+					$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
3154 3154
 					foreach ($alldata as $number) {
3155
-						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
3155
+						$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
3156 3156
 					}
3157 3157
 					if ($globalDebug) echo 'Count all owners...'."\n";
3158
-					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
3158
+					$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
3159 3159
 					foreach ($alldata as $number) {
3160
-						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
3160
+						$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
3161 3161
 					}
3162 3162
 					if ($globalDebug) echo 'Count all pilots...'."\n";
3163
-					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
3163
+					$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
3164 3164
 					foreach ($alldata as $number) {
3165
-						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
3165
+						$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
3166 3166
 					}
3167 3167
 					if ($globalDebug) echo 'Count departure airports...'."\n";
3168
-					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
3169
-					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
3168
+					$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
3169
+					$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
3170 3170
 					$alldata = array();
3171 3171
 					foreach ($pall as $value) {
3172 3172
 						$icao = $value['airport_departure_icao'];
@@ -3182,13 +3182,13 @@  discard block
 block discarded – undo
3182 3182
 					foreach ($alldata as $key => $row) {
3183 3183
 						$count[$key] = $row['airport_departure_icao_count'];
3184 3184
 					}
3185
-					array_multisort($count,SORT_DESC,$alldata);
3185
+					array_multisort($count, SORT_DESC, $alldata);
3186 3186
 					foreach ($alldata as $number) {
3187
-						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);
3187
+						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);
3188 3188
 					}
3189 3189
 					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3190
-					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
3191
-					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
3190
+					$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
3191
+					$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
3192 3192
 					$alldata = array();
3193 3193
 					foreach ($pall as $value) {
3194 3194
 						$icao = $value['airport_arrival_icao'];
@@ -3204,9 +3204,9 @@  discard block
 block discarded – undo
3204 3204
 					foreach ($alldata as $key => $row) {
3205 3205
 						$count[$key] = $row['airport_arrival_icao_count'];
3206 3206
 					}
3207
-					array_multisort($count,SORT_DESC,$alldata);
3207
+					array_multisort($count, SORT_DESC, $alldata);
3208 3208
 					foreach ($alldata as $number) {
3209
-						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);
3209
+						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);
3210 3210
 					}
3211 3211
 					if ($globalDebug) echo 'Count all months...'."\n";
3212 3212
 					$Spotter = new Spotter($this->db);
@@ -3214,36 +3214,36 @@  discard block
 block discarded – undo
3214 3214
 					$lastyear = false;
3215 3215
 					foreach ($alldata as $number) {
3216 3216
 						if ($number['year_name'] != date('Y')) $lastyear = true;
3217
-						$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3217
+						$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3218 3218
 					}
3219 3219
 					if ($globalDebug) echo 'Count all owners by months...'."\n";
3220 3220
 					$alldata = $Spotter->countAllMonthsOwners($filter);
3221 3221
 					foreach ($alldata as $number) {
3222
-						$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3222
+						$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3223 3223
 					}
3224 3224
 					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3225 3225
 					$alldata = $Spotter->countAllMonthsPilots($filter);
3226 3226
 					foreach ($alldata as $number) {
3227
-						$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3227
+						$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3228 3228
 					}
3229 3229
 					if ($globalDebug) echo 'Count all military by months...'."\n";
3230 3230
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
3231 3231
 					foreach ($alldata as $number) {
3232
-						$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3232
+						$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3233 3233
 					}
3234 3234
 					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3235 3235
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
3236 3236
 				    	foreach ($alldata as $number) {
3237
-			    			$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3237
+			    			$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3238 3238
 					}
3239 3239
 					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3240 3240
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
3241 3241
 					foreach ($alldata as $number) {
3242
-						$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3242
+						$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3243 3243
 					}
3244 3244
 					echo '...Departure'."\n";
3245
-					$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
3246
-					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
3245
+					$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
3246
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
3247 3247
 					foreach ($dall as $value) {
3248 3248
 						$icao = $value['departure_airport_icao'];
3249 3249
 						$ddate = $value['date'];
@@ -3261,11 +3261,11 @@  discard block
 block discarded – undo
3261 3261
 					}
3262 3262
 					$alldata = $pall;
3263 3263
 					foreach ($alldata as $number) {
3264
-						$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);
3264
+						$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);
3265 3265
 					}
3266 3266
 					echo '...Arrival'."\n";
3267
-					$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
3268
-					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
3267
+					$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
3268
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
3269 3269
 					foreach ($dall as $value) {
3270 3270
 						$icao = $value['arrival_airport_icao'];
3271 3271
 						$ddate = $value['date'];
@@ -3283,39 +3283,39 @@  discard block
 block discarded – undo
3283 3283
 					}
3284 3284
 					$alldata = $pall;
3285 3285
 					foreach ($alldata as $number) {
3286
-						$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);
3286
+						$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);
3287 3287
 					}
3288 3288
 					echo 'Flights data...'."\n";
3289 3289
 					echo '-> countAllDatesLastMonth...'."\n";
3290 3290
 					$alldata = $Spotter->countAllDatesLastMonth($filter);
3291 3291
 					foreach ($alldata as $number) {
3292
-						$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
3292
+						$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
3293 3293
 					}
3294 3294
 					echo '-> countAllDates...'."\n";
3295
-					$previousdata = $this->countAllDates('',$filter_name);
3296
-					$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
3295
+					$previousdata = $this->countAllDates('', $filter_name);
3296
+					$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
3297 3297
 					$values = array();
3298 3298
 					foreach ($alldata as $cnt) {
3299 3299
 						$values[] = $cnt['date_count'];
3300 3300
 					}
3301
-					array_multisort($values,SORT_DESC,$alldata);
3302
-					array_splice($alldata,11);
3301
+					array_multisort($values, SORT_DESC, $alldata);
3302
+					array_splice($alldata, 11);
3303 3303
 					foreach ($alldata as $number) {
3304
-						$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
3304
+						$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
3305 3305
 					}
3306 3306
 				
3307 3307
 					echo '-> countAllHours...'."\n";
3308
-					$alldata = $Spotter->countAllHours('hour',$filter);
3308
+					$alldata = $Spotter->countAllHours('hour', $filter);
3309 3309
 					foreach ($alldata as $number) {
3310
-						$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
3310
+						$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
3311 3311
 					}
3312 3312
 					echo 'Insert last stats update date...'."\n";
3313 3313
 					date_default_timezone_set('UTC');
3314
-					$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
3314
+					$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
3315 3315
 					if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
3316
-						if (date('Y',strtotime($last_update_day)) != date('Y')) {
3316
+						if (date('Y', strtotime($last_update_day)) != date('Y')) {
3317 3317
 							$this->deleteOldStats($filter_name);
3318
-							$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
3318
+							$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
3319 3319
 						}
3320 3320
 					}
3321 3321
 				}
@@ -3328,16 +3328,16 @@  discard block
 block discarded – undo
3328 3328
 				// SUM all previous month to put as year
3329 3329
 				$previous_year = date('Y');
3330 3330
 				$previous_year--;
3331
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3332
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3333
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3334
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3331
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3332
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3333
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3334
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3335 3335
 				$allairlines = $this->getAllAirlineNames();
3336 3336
 				foreach ($allairlines as $data) {
3337
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3338
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3339
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3340
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3337
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3338
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3339
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3340
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3341 3341
 				}
3342 3342
 				
3343 3343
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -3346,21 +3346,21 @@  discard block
 block discarded – undo
3346 3346
 						try {
3347 3347
 							$sth = $this->db->prepare($query);
3348 3348
 							$sth->execute();
3349
-						} catch(PDOException $e) {
3349
+						} catch (PDOException $e) {
3350 3350
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3351 3351
 						}
3352 3352
 						$query = "INSERT INTO tracker_archive_output SELECT * FROM tracker_output WHERE tracker_output.date < '".date('Y')."-01-01 00:00:00'";
3353 3353
 						try {
3354 3354
 							$sth = $this->db->prepare($query);
3355 3355
 							$sth->execute();
3356
-						} catch(PDOException $e) {
3356
+						} catch (PDOException $e) {
3357 3357
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3358 3358
 						}
3359 3359
 						$query = "INSERT INTO marine_archive_output SELECT * FROM marine_output WHERE marine_output.date < '".date('Y')."-01-01 00:00:00'";
3360 3360
 						try {
3361 3361
 							$sth = $this->db->prepare($query);
3362 3362
 							$sth->execute();
3363
-						} catch(PDOException $e) {
3363
+						} catch (PDOException $e) {
3364 3364
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3365 3365
 						}
3366 3366
 					}
@@ -3373,7 +3373,7 @@  discard block
 block discarded – undo
3373 3373
 					try {
3374 3374
 						$sth = $this->db->prepare($query);
3375 3375
 						$sth->execute();
3376
-					} catch(PDOException $e) {
3376
+					} catch (PDOException $e) {
3377 3377
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3378 3378
 					}
3379 3379
 					if ($globalDBdriver == 'mysql') {
@@ -3384,7 +3384,7 @@  discard block
 block discarded – undo
3384 3384
 					try {
3385 3385
 						$sth = $this->db->prepare($query);
3386 3386
 						$sth->execute();
3387
-					} catch(PDOException $e) {
3387
+					} catch (PDOException $e) {
3388 3388
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3389 3389
 					}
3390 3390
 					if ($globalDBdriver == 'mysql') {
@@ -3395,15 +3395,15 @@  discard block
 block discarded – undo
3395 3395
 					try {
3396 3396
 						$sth = $this->db->prepare($query);
3397 3397
 						$sth->execute();
3398
-					} catch(PDOException $e) {
3398
+					} catch (PDOException $e) {
3399 3399
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3400 3400
 					}
3401 3401
 				}
3402 3402
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
3403 3403
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
3404
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
3404
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
3405 3405
 						$this->deleteOldStats();
3406
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
3406
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
3407 3407
 						$lastyearupdate = true;
3408 3408
 					}
3409 3409
 				}
@@ -3425,7 +3425,7 @@  discard block
 block discarded – undo
3425 3425
 					try {
3426 3426
 						$sth = $this->db->prepare($query);
3427 3427
 						$sth->execute();
3428
-					} catch(PDOException $e) {
3428
+					} catch (PDOException $e) {
3429 3429
 						return "error : ".$e->getMessage();
3430 3430
 					}
3431 3431
 					echo 'Archive old tracker data...'."\n";
@@ -3441,7 +3441,7 @@  discard block
 block discarded – undo
3441 3441
 					try {
3442 3442
 						$sth = $this->db->prepare($query);
3443 3443
 						$sth->execute();
3444
-					} catch(PDOException $e) {
3444
+					} catch (PDOException $e) {
3445 3445
 						return "error : ".$e->getMessage();
3446 3446
 					}
3447 3447
 					echo 'Archive old marine data...'."\n";
@@ -3457,7 +3457,7 @@  discard block
 block discarded – undo
3457 3457
 					try {
3458 3458
 						$sth = $this->db->prepare($query);
3459 3459
 						$sth->execute();
3460
-					} catch(PDOException $e) {
3460
+					} catch (PDOException $e) {
3461 3461
 						return "error : ".$e->getMessage();
3462 3462
 					}
3463 3463
 				}
@@ -3470,7 +3470,7 @@  discard block
 block discarded – undo
3470 3470
 				try {
3471 3471
 					$sth = $this->db->prepare($query);
3472 3472
 					$sth->execute();
3473
-				} catch(PDOException $e) {
3473
+				} catch (PDOException $e) {
3474 3474
 					return "error : ".$e->getMessage();
3475 3475
 				}
3476 3476
 				echo 'Deleting old tracker data...'."\n";
@@ -3482,7 +3482,7 @@  discard block
 block discarded – undo
3482 3482
 				try {
3483 3483
 					$sth = $this->db->prepare($query);
3484 3484
 					$sth->execute();
3485
-				} catch(PDOException $e) {
3485
+				} catch (PDOException $e) {
3486 3486
 					return "error : ".$e->getMessage();
3487 3487
 				}
3488 3488
 				echo 'Deleting old marine data...'."\n";
@@ -3494,14 +3494,14 @@  discard block
 block discarded – undo
3494 3494
 				try {
3495 3495
 					$sth = $this->db->prepare($query);
3496 3496
 					$sth->execute();
3497
-				} catch(PDOException $e) {
3497
+				} catch (PDOException $e) {
3498 3498
 					return "error : ".$e->getMessage();
3499 3499
 				}
3500 3500
 			}
3501 3501
 			if (!isset($lastyearupdate)) {
3502 3502
 				echo 'Insert last stats update date...'."\n";
3503 3503
 				date_default_timezone_set('UTC');
3504
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
3504
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
3505 3505
 			}
3506 3506
 			if ($globalStatsResetYear) {
3507 3507
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +778 added lines, -273 removed lines patch added patch discarded remove patch
@@ -22,10 +22,14 @@  discard block
 block discarded – undo
22 22
 	*/
23 23
 	public function __construct($dbc = null) {
24 24
 		global $globalFilterName;
25
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
25
+		if (isset($globalFilterName)) {
26
+			$this->filter_name = $globalFilterName;
27
+		}
26 28
 		$Connection = new Connection($dbc);
27 29
 		$this->db = $Connection->db();
28
-		if ($this->db === null) die('Error: No DB connection. (Stats)');
30
+		if ($this->db === null) {
31
+			die('Error: No DB connection. (Stats)');
32
+		}
29 33
 	}
30 34
 
31 35
 	public function addLastStatsUpdate($type,$stats_date) {
@@ -93,7 +97,9 @@  discard block
 block discarded – undo
93 97
 
94 98
 	public function getAllAirlineNames($filter_name = '') {
95 99
 		global $globalStatsFilters;
96
-		if ($filter_name == '') $filter_name = $this->filter_name;
100
+		if ($filter_name == '') {
101
+			$filter_name = $this->filter_name;
102
+		}
97 103
 		$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
98 104
 		 try {
99 105
 			$sth = $this->db->prepare($query);
@@ -113,7 +119,9 @@  discard block
 block discarded – undo
113 119
 		return $all;
114 120
 	}
115 121
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
122
+		if ($filter_name == '') {
123
+			$filter_name = $this->filter_name;
124
+		}
117 125
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
118 126
 		try {
119 127
 			$sth = $this->db->prepare($query);
@@ -125,7 +133,9 @@  discard block
 block discarded – undo
125 133
 		return $all;
126 134
 	}
127 135
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
128
-		if ($filter_name == '') $filter_name = $this->filter_name;
136
+		if ($filter_name == '') {
137
+			$filter_name = $this->filter_name;
138
+		}
129 139
 		$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";
130 140
 		try {
131 141
 			$sth = $this->db->prepare($query);
@@ -137,7 +147,9 @@  discard block
 block discarded – undo
137 147
 		return $all;
138 148
 	}
139 149
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
140
-		if ($filter_name == '') $filter_name = $this->filter_name;
150
+		if ($filter_name == '') {
151
+			$filter_name = $this->filter_name;
152
+		}
141 153
 		$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";
142 154
 		try {
143 155
 			$sth = $this->db->prepare($query);
@@ -150,7 +162,9 @@  discard block
 block discarded – undo
150 162
 	}
151 163
 
152 164
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
153
-		if ($filter_name == '') $filter_name = $this->filter_name;
165
+		if ($filter_name == '') {
166
+			$filter_name = $this->filter_name;
167
+		}
154 168
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
155 169
 		try {
156 170
 			$sth = $this->db->prepare($query);
@@ -163,7 +177,9 @@  discard block
 block discarded – undo
163 177
 	}
164 178
 
165 179
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
166
-		if ($filter_name == '') $filter_name = $this->filter_name;
180
+		if ($filter_name == '') {
181
+			$filter_name = $this->filter_name;
182
+		}
167 183
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
168 184
 		try {
169 185
 			$sth = $this->db->prepare($query);
@@ -178,7 +194,9 @@  discard block
 block discarded – undo
178 194
 
179 195
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
180 196
 		global $globalStatsFilters;
181
-		if ($filter_name == '') $filter_name = $this->filter_name;
197
+		if ($filter_name == '') {
198
+			$filter_name = $this->filter_name;
199
+		}
182 200
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
183 201
 			$Spotter = new Spotter($this->db);
184 202
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -187,8 +205,11 @@  discard block
 block discarded – undo
187 205
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
188 206
 			}
189 207
 			if ($year == '' && $month == '') {
190
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
191
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
208
+				if ($limit) {
209
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
210
+				} else {
211
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
212
+				}
192 213
 				try {
193 214
 					$sth = $this->db->prepare($query);
194 215
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -196,11 +217,16 @@  discard block
 block discarded – undo
196 217
 					echo "error : ".$e->getMessage();
197 218
 				}
198 219
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
199
-			} else $all = array();
220
+			} else {
221
+				$all = array();
222
+			}
200 223
 		} else {
201 224
 			if ($year == '' && $month == '') {
202
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
203
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
225
+				if ($limit) {
226
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
227
+				} else {
228
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
229
+				}
204 230
 				try {
205 231
 					$sth = $this->db->prepare($query);
206 232
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -208,7 +234,9 @@  discard block
 block discarded – undo
208 234
 					echo "error : ".$e->getMessage();
209 235
 				}
210 236
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
211
-			} else $all = array();
237
+			} else {
238
+				$all = array();
239
+			}
212 240
 		}
213 241
 		if (empty($all)) {
214 242
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -227,10 +255,15 @@  discard block
 block discarded – undo
227 255
 	}
228 256
 	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
229 257
 		global $globalStatsFilters;
230
-		if ($filter_name == '') $filter_name = $this->filter_name;
258
+		if ($filter_name == '') {
259
+			$filter_name = $this->filter_name;
260
+		}
231 261
 		if ($year == '' && $month == '') {
232
-			if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
233
-			else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
262
+			if ($limit) {
263
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
264
+			} else {
265
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
266
+			}
234 267
 			try {
235 268
 				$sth = $this->db->prepare($query);
236 269
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -238,7 +271,9 @@  discard block
 block discarded – undo
238 271
 				echo "error : ".$e->getMessage();
239 272
 			}
240 273
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241
-		} else $all = array();
274
+		} else {
275
+			$all = array();
276
+		}
242 277
 		if (empty($all)) {
243 278
 			$filters = array('year' => $year,'month' => $month);
244 279
 			if ($filter_name != '') {
@@ -252,10 +287,15 @@  discard block
 block discarded – undo
252 287
 	}
253 288
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
254 289
 		global $globalStatsFilters;
255
-		if ($filter_name == '') $filter_name = $this->filter_name;
290
+		if ($filter_name == '') {
291
+			$filter_name = $this->filter_name;
292
+		}
256 293
 		if ($year == '' && $month == '') {
257
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
258
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
294
+			if ($limit) {
295
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
296
+			} else {
297
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
298
+			}
259 299
 			try {
260 300
 				$sth = $this->db->prepare($query);
261 301
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -263,7 +303,9 @@  discard block
 block discarded – undo
263 303
 				echo "error : ".$e->getMessage();
264 304
 			}
265 305
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
266
-		} else $all = array();
306
+		} else {
307
+			$all = array();
308
+		}
267 309
 		if (empty($all)) {
268 310
 			$Spotter = new Spotter($this->db);
269 311
 			$filters = array();
@@ -278,7 +320,9 @@  discard block
 block discarded – undo
278 320
 	}
279 321
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
280 322
 		global $globalStatsFilters;
281
-		if ($filter_name == '') $filter_name = $this->filter_name;
323
+		if ($filter_name == '') {
324
+			$filter_name = $this->filter_name;
325
+		}
282 326
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
283 327
 			$Spotter = new Spotter($this->db);
284 328
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -287,8 +331,11 @@  discard block
 block discarded – undo
287 331
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
288 332
 			}
289 333
 			if ($year == '' && $month == '') {
290
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
291
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
334
+				if ($limit) {
335
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
336
+				} else {
337
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
338
+				}
292 339
 				try {
293 340
 					$sth = $this->db->prepare($query);
294 341
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -296,11 +343,16 @@  discard block
 block discarded – undo
296 343
 					echo "error : ".$e->getMessage();
297 344
 				}
298 345
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
299
-			} else $all = array();
346
+			} else {
347
+				$all = array();
348
+			}
300 349
 		} else {
301 350
 			if ($year == '' && $month == '') {
302
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
303
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
351
+				if ($limit) {
352
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
353
+				} else {
354
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
355
+				}
304 356
 				try {
305 357
 					$sth = $this->db->prepare($query);
306 358
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -308,7 +360,9 @@  discard block
 block discarded – undo
308 360
 					echo "error : ".$e->getMessage();
309 361
 				}
310 362
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
311
-			} else $all = array();
363
+			} else {
364
+				$all = array();
365
+			}
312 366
 		}
313 367
 		if (empty($all)) {
314 368
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -328,7 +382,9 @@  discard block
 block discarded – undo
328 382
 
329 383
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
330 384
 		global $globalStatsFilters;
331
-		if ($filter_name == '') $filter_name = $this->filter_name;
385
+		if ($filter_name == '') {
386
+			$filter_name = $this->filter_name;
387
+		}
332 388
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
333 389
 			$Spotter = new Spotter($this->db);
334 390
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -337,8 +393,11 @@  discard block
 block discarded – undo
337 393
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
338 394
 			}
339 395
 			if ($year == '' && $month == '') {
340
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
341
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
396
+				if ($limit) {
397
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
398
+				} else {
399
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
400
+				}
342 401
 				try {
343 402
 					$sth = $this->db->prepare($query);
344 403
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -346,11 +405,16 @@  discard block
 block discarded – undo
346 405
 					echo "error : ".$e->getMessage();
347 406
 				}
348 407
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
349
-			} else $all = array();
408
+			} else {
409
+				$all = array();
410
+			}
350 411
 		} else {
351 412
 			if ($year == '' && $month == '') {
352
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
353
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
413
+				if ($limit) {
414
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
415
+				} else {
416
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
417
+				}
354 418
 				try {
355 419
 					$sth = $this->db->prepare($query);
356 420
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -358,7 +422,9 @@  discard block
 block discarded – undo
358 422
 					echo "error : ".$e->getMessage();
359 423
 				}
360 424
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
361
-			} else $all = array();
425
+			} else {
426
+				$all = array();
427
+			}
362 428
 		}
363 429
 		if (empty($all)) {
364 430
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -377,7 +443,9 @@  discard block
 block discarded – undo
377 443
 	}
378 444
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
379 445
 		global $globalStatsFilters;
380
-		if ($filter_name == '') $filter_name = $this->filter_name;
446
+		if ($filter_name == '') {
447
+			$filter_name = $this->filter_name;
448
+		}
381 449
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
382 450
 			$Spotter = new Spotter($this->db);
383 451
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -385,12 +453,18 @@  discard block
 block discarded – undo
385 453
 			foreach ($airlines as $airline) {
386 454
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
387 455
 			}
388
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
389
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
456
+			if ($limit) {
457
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
458
+			} else {
459
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
460
+			}
390 461
 			$query_values = array(':filter_name' => $filter_name);
391 462
 		} else {
392
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
393
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
463
+			if ($limit) {
464
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
465
+			} else {
466
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
467
+			}
394 468
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
395 469
 		}
396 470
 		try {
@@ -418,17 +492,29 @@  discard block
 block discarded – undo
418 492
 
419 493
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
420 494
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
421
-		if ($filter_name == '') $filter_name = $this->filter_name;
495
+		if ($filter_name == '') {
496
+			$filter_name = $this->filter_name;
497
+		}
422 498
 		if ($year == '' && $month == '') {
423
-			if ($globalVATSIM) $forsource = 'vatsim';
424
-			if ($globalIVAO) $forsource = 'ivao';
499
+			if ($globalVATSIM) {
500
+				$forsource = 'vatsim';
501
+			}
502
+			if ($globalIVAO) {
503
+				$forsource = 'ivao';
504
+			}
425 505
 			if (isset($forsource)) {
426
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
427
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
506
+				if ($limit) {
507
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
508
+				} else {
509
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
510
+				}
428 511
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
429 512
 			} else {
430
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
431
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
513
+				if ($limit) {
514
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
515
+				} else {
516
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
517
+				}
432 518
 				$query_values = array(':filter_name' => $filter_name);
433 519
 			}
434 520
 			try {
@@ -438,7 +524,9 @@  discard block
 block discarded – undo
438 524
 				echo "error : ".$e->getMessage();
439 525
 			}
440 526
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
441
-		} else $all = array();
527
+		} else {
528
+			$all = array();
529
+		}
442 530
                 if (empty($all)) {
443 531
 	                $Spotter = new Spotter($this->db);
444 532
             		$filters = array();
@@ -453,7 +541,9 @@  discard block
 block discarded – undo
453 541
 	}
454 542
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
455 543
 		global $globalStatsFilters;
456
-		if ($filter_name == '') $filter_name = $this->filter_name;
544
+		if ($filter_name == '') {
545
+			$filter_name = $this->filter_name;
546
+		}
457 547
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
458 548
 			$Spotter = new Spotter($this->db);
459 549
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -462,8 +552,11 @@  discard block
 block discarded – undo
462 552
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
463 553
 			}
464 554
 			if ($year == '' && $month == '') {
465
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
466
-				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
555
+				if ($limit) {
556
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
557
+				} else {
558
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
559
+				}
467 560
 				try {
468 561
 					$sth = $this->db->prepare($query);
469 562
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -471,11 +564,16 @@  discard block
 block discarded – undo
471 564
 					echo "error : ".$e->getMessage();
472 565
 				}
473 566
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
474
-			} else $all = array();
567
+			} else {
568
+				$all = array();
569
+			}
475 570
 		} else {
476 571
 			if ($year == '' && $month == '') {
477
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
478
-				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
572
+				if ($limit) {
573
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
574
+				} else {
575
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
576
+				}
479 577
 				try {
480 578
 					$sth = $this->db->prepare($query);
481 579
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -483,7 +581,9 @@  discard block
 block discarded – undo
483 581
 					echo "error : ".$e->getMessage();
484 582
 				}
485 583
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
486
-			} else $all = array();
584
+			} else {
585
+				$all = array();
586
+			}
487 587
 		}
488 588
 		if (empty($all)) {
489 589
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -502,7 +602,9 @@  discard block
 block discarded – undo
502 602
 	}
503 603
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
504 604
 		global $globalStatsFilters;
505
-		if ($filter_name == '') $filter_name = $this->filter_name;
605
+		if ($filter_name == '') {
606
+			$filter_name = $this->filter_name;
607
+		}
506 608
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
507 609
 			$Spotter = new Spotter($this->db);
508 610
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -511,8 +613,11 @@  discard block
 block discarded – undo
511 613
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
512 614
 			}
513 615
 			if ($year == '' && $month == '') {
514
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
515
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
616
+				if ($limit) {
617
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
618
+				} else {
619
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
620
+				}
516 621
 				 try {
517 622
 					$sth = $this->db->prepare($query);
518 623
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -520,11 +625,16 @@  discard block
 block discarded – undo
520 625
 					echo "error : ".$e->getMessage();
521 626
 				}
522 627
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
523
-			} else $all = array();
628
+			} else {
629
+				$all = array();
630
+			}
524 631
 		} else {
525 632
 			if ($year == '' && $month == '') {
526
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
527
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
633
+				if ($limit) {
634
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
635
+				} else {
636
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
637
+				}
528 638
 				 try {
529 639
 					$sth = $this->db->prepare($query);
530 640
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -532,7 +642,9 @@  discard block
 block discarded – undo
532 642
 					echo "error : ".$e->getMessage();
533 643
 				}
534 644
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
535
-			} else $all = array();
645
+			} else {
646
+				$all = array();
647
+			}
536 648
 		}
537 649
 		if (empty($all)) {
538 650
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -551,7 +663,9 @@  discard block
 block discarded – undo
551 663
 	}
552 664
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
553 665
 		$Connection = new Connection($this->db);
554
-		if ($filter_name == '') $filter_name = $this->filter_name;
666
+		if ($filter_name == '') {
667
+			$filter_name = $this->filter_name;
668
+		}
555 669
 		if ($Connection->tableExists('countries')) {
556 670
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
557 671
 				$Spotter = new Spotter($this->db);
@@ -561,8 +675,11 @@  discard block
 block discarded – undo
561 675
 					foreach ($airlines as $airline) {
562 676
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
563 677
 					}
564
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
565
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
678
+					if ($limit) {
679
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
680
+					} else {
681
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
682
+					}
566 683
 					 try {
567 684
 						$sth = $this->db->prepare($query);
568 685
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -571,11 +688,16 @@  discard block
 block discarded – undo
571 688
 					}
572 689
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
573 690
 					return $all;
574
-				} else return array();
691
+				} else {
692
+					return array();
693
+				}
575 694
 			} else {
576 695
 				if ($year == '' && $month == '') {
577
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
578
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
696
+					if ($limit) {
697
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
698
+					} else {
699
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
700
+					}
579 701
 					 try {
580 702
 						$sth = $this->db->prepare($query);
581 703
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -584,20 +706,29 @@  discard block
 block discarded – undo
584 706
 					}
585 707
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
586 708
 					return $all;
587
-				} else return array();
709
+				} else {
710
+					return array();
711
+				}
588 712
 			}
589 713
 			$Spotter = new Spotter($this->db);
590 714
 			return $Spotter->countAllFlightOverCountries($limit);
591
-		} else return array();
715
+		} else {
716
+			return array();
717
+		}
592 718
 	}
593 719
 	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
594 720
 		$Connection = new Connection($this->db);
595
-		if ($filter_name == '') $filter_name = $this->filter_name;
721
+		if ($filter_name == '') {
722
+			$filter_name = $this->filter_name;
723
+		}
596 724
 		if ($Connection->tableExists('countries')) {
597 725
 			$all = array();
598 726
 			if ($year == '' && $month == '') {
599
-				if ($limit) $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
600
-				else $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
727
+				if ($limit) {
728
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
729
+				} else {
730
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
731
+				}
601 732
 				 try {
602 733
 					$sth = $this->db->prepare($query);
603 734
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -615,17 +746,24 @@  discard block
 block discarded – undo
615 746
 				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
616 747
 			}
617 748
 			return $all;
618
-		} else return array();
749
+		} else {
750
+			return array();
751
+		}
619 752
 	}
620 753
 	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
621 754
 		global $globalStatsFilters;
622 755
 		$Connection = new Connection($this->db);
623
-		if ($filter_name == '') $filter_name = $this->filter_name;
756
+		if ($filter_name == '') {
757
+			$filter_name = $this->filter_name;
758
+		}
624 759
 		if ($Connection->tableExists('countries')) {
625 760
 			$all = array();
626 761
 			if ($year == '' && $month == '') {
627
-				if ($limit) $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
628
-				else $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
762
+				if ($limit) {
763
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
764
+				} else {
765
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
766
+				}
629 767
 				 try {
630 768
 					$sth = $this->db->prepare($query);
631 769
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -644,14 +782,21 @@  discard block
 block discarded – undo
644 782
 				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
645 783
 			}
646 784
 			return $all;
647
-		} else return array();
785
+		} else {
786
+			return array();
787
+		}
648 788
 	}
649 789
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
650 790
 		global $globalStatsFilters;
651
-		if ($filter_name == '') $filter_name = $this->filter_name;
791
+		if ($filter_name == '') {
792
+			$filter_name = $this->filter_name;
793
+		}
652 794
 		if ($year == '' && $month == '') {
653
-			if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
654
-			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
795
+			if ($limit) {
796
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
797
+			} else {
798
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
799
+			}
655 800
 			try {
656 801
 				$sth = $this->db->prepare($query);
657 802
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -659,7 +804,9 @@  discard block
 block discarded – undo
659 804
 				echo "error : ".$e->getMessage();
660 805
 			}
661 806
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
662
-		} else $all = array();
807
+		} else {
808
+			$all = array();
809
+		}
663 810
 		if (empty($all)) {
664 811
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
665 812
 			if ($filter_name != '') {
@@ -674,7 +821,9 @@  discard block
 block discarded – undo
674 821
 
675 822
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
676 823
 		global $globalStatsFilters;
677
-		if ($filter_name == '') $filter_name = $this->filter_name;
824
+		if ($filter_name == '') {
825
+			$filter_name = $this->filter_name;
826
+		}
678 827
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
679 828
 			$Spotter = new Spotter($this->db);
680 829
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -683,8 +832,11 @@  discard block
 block discarded – undo
683 832
 				foreach ($airlines as $airline) {
684 833
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
685 834
 				}
686
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
687
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
835
+				if ($limit) {
836
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
837
+				} else {
838
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
839
+				}
688 840
 				try {
689 841
 					$sth = $this->db->prepare($query);
690 842
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -692,11 +844,16 @@  discard block
 block discarded – undo
692 844
 					echo "error : ".$e->getMessage();
693 845
 				}
694 846
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
-			} else $all = array();
847
+			} else {
848
+				$all = array();
849
+			}
696 850
 		} else {
697 851
 			if ($year == '' && $month == '') {
698
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
699
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
852
+				if ($limit) {
853
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
854
+				} else {
855
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
856
+				}
700 857
 				try {
701 858
 					$sth = $this->db->prepare($query);
702 859
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -704,7 +861,9 @@  discard block
 block discarded – undo
704 861
 					echo "error : ".$e->getMessage();
705 862
 				}
706 863
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
707
-			} else $all = array();
864
+			} else {
865
+				$all = array();
866
+			}
708 867
 		}
709 868
 		if (empty($all)) {
710 869
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -723,7 +882,9 @@  discard block
 block discarded – undo
723 882
 	}
724 883
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
725 884
 		global $globalStatsFilters;
726
-		if ($filter_name == '') $filter_name = $this->filter_name;
885
+		if ($filter_name == '') {
886
+			$filter_name = $this->filter_name;
887
+		}
727 888
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
728 889
 			$Spotter = new Spotter($this->db);
729 890
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -732,8 +893,11 @@  discard block
 block discarded – undo
732 893
 				foreach ($airlines as $airline) {
733 894
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
734 895
 				}
735
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
736
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
896
+				if ($limit) {
897
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
898
+				} else {
899
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
900
+				}
737 901
 				try {
738 902
 					$sth = $this->db->prepare($query);
739 903
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -741,11 +905,16 @@  discard block
 block discarded – undo
741 905
 					echo "error : ".$e->getMessage();
742 906
 				}
743 907
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
744
-			} else $all = array();
908
+			} else {
909
+				$all = array();
910
+			}
745 911
 		} else {
746 912
 			if ($year == '' && $month == '') {
747
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
748
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
913
+				if ($limit) {
914
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
915
+				} else {
916
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
917
+				}
749 918
 				try {
750 919
 					$sth = $this->db->prepare($query);
751 920
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -753,7 +922,9 @@  discard block
 block discarded – undo
753 922
 					echo "error : ".$e->getMessage();
754 923
 				}
755 924
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
756
-			} else $all = array();
925
+			} else {
926
+				$all = array();
927
+			}
757 928
 		}
758 929
 		if (empty($all)) {
759 930
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -778,7 +949,9 @@  discard block
 block discarded – undo
778 949
 				$icao = $value['airport_departure_icao'];
779 950
 				if (isset($all[$icao])) {
780 951
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
781
-				} else $all[$icao] = $value;
952
+				} else {
953
+					$all[$icao] = $value;
954
+				}
782 955
 			}
783 956
 			$count = array();
784 957
 			foreach ($all as $key => $row) {
@@ -790,7 +963,9 @@  discard block
 block discarded – undo
790 963
 	}
791 964
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
792 965
 		global $globalStatsFilters;
793
-		if ($filter_name == '') $filter_name = $this->filter_name;
966
+		if ($filter_name == '') {
967
+			$filter_name = $this->filter_name;
968
+		}
794 969
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
795 970
 			$Spotter = new Spotter($this->db);
796 971
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -799,8 +974,11 @@  discard block
 block discarded – undo
799 974
 				foreach ($airlines as $airline) {
800 975
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
801 976
 				}
802
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
803
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
977
+				if ($limit) {
978
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
979
+				} else {
980
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
981
+				}
804 982
 				try {
805 983
 					$sth = $this->db->prepare($query);
806 984
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -808,11 +986,16 @@  discard block
 block discarded – undo
808 986
 					echo "error : ".$e->getMessage();
809 987
 				}
810 988
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
811
-			} else $all = array();
989
+			} else {
990
+				$all = array();
991
+			}
812 992
 		} else {
813 993
 			if ($year == '' && $month == '') {
814
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
815
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
994
+				if ($limit) {
995
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
996
+				} else {
997
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
998
+				}
816 999
 				try {
817 1000
 					$sth = $this->db->prepare($query);
818 1001
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -820,7 +1003,9 @@  discard block
 block discarded – undo
820 1003
 					echo "error : ".$e->getMessage();
821 1004
 				}
822 1005
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
823
-			} else $all = array();
1006
+			} else {
1007
+				$all = array();
1008
+			}
824 1009
 		}
825 1010
 		if (empty($all)) {
826 1011
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -845,7 +1030,9 @@  discard block
 block discarded – undo
845 1030
 				$icao = $value['airport_arrival_icao'];
846 1031
 				if (isset($all[$icao])) {
847 1032
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
848
-				} else $all[$icao] = $value;
1033
+				} else {
1034
+					$all[$icao] = $value;
1035
+				}
849 1036
 			}
850 1037
 			$count = array();
851 1038
 			foreach ($all as $key => $row) {
@@ -857,7 +1044,9 @@  discard block
 block discarded – undo
857 1044
 	}
858 1045
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
859 1046
 		global $globalDBdriver, $globalStatsFilters;
860
-		if ($filter_name == '') $filter_name = $this->filter_name;
1047
+		if ($filter_name == '') {
1048
+			$filter_name = $this->filter_name;
1049
+		}
861 1050
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
862 1051
 			$Spotter = new Spotter($this->db);
863 1052
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -866,20 +1055,32 @@  discard block
 block discarded – undo
866 1055
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
867 1056
 			}
868 1057
 			if ($globalDBdriver == 'mysql') {
869
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
870
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1058
+				if ($limit) {
1059
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1060
+				} else {
1061
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1062
+				}
871 1063
 			} else {
872
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
873
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1064
+				if ($limit) {
1065
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1066
+				} else {
1067
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1068
+				}
874 1069
 			}
875 1070
 			$query_data = array(':filter_name' => $filter_name);
876 1071
 		} else {
877 1072
 			if ($globalDBdriver == 'mysql') {
878
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
879
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1073
+				if ($limit) {
1074
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
1075
+				} else {
1076
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1077
+				}
880 1078
 			} else {
881
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
882
-				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";
1079
+				if ($limit) {
1080
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1081
+				} else {
1082
+					$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";
1083
+				}
883 1084
 			}
884 1085
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
885 1086
 		}
@@ -907,13 +1108,21 @@  discard block
 block discarded – undo
907 1108
 
908 1109
 	public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') {
909 1110
 		global $globalDBdriver, $globalStatsFilters;
910
-		if ($filter_name == '') $filter_name = $this->filter_name;
1111
+		if ($filter_name == '') {
1112
+			$filter_name = $this->filter_name;
1113
+		}
911 1114
 		if ($globalDBdriver == 'mysql') {
912
-			if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
913
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name";
1115
+			if ($limit) {
1116
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
1117
+			} else {
1118
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name";
1119
+			}
914 1120
 		} else {
915
-			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
916
-			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 = 'marine_bymonth' AND filter_name = :filter_name";
1121
+			if ($limit) {
1122
+				$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 = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
1123
+			} else {
1124
+				$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 = 'marine_bymonth' AND filter_name = :filter_name";
1125
+			}
917 1126
 		}
918 1127
 		$query_data = array(':filter_name' => $filter_name);
919 1128
 		try {
@@ -936,13 +1145,21 @@  discard block
 block discarded – undo
936 1145
 
937 1146
 	public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') {
938 1147
 		global $globalDBdriver, $globalStatsFilters;
939
-		if ($filter_name == '') $filter_name = $this->filter_name;
1148
+		if ($filter_name == '') {
1149
+			$filter_name = $this->filter_name;
1150
+		}
940 1151
 		if ($globalDBdriver == 'mysql') {
941
-			if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
942
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name";
1152
+			if ($limit) {
1153
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
1154
+			} else {
1155
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name";
1156
+			}
943 1157
 		} else {
944
-			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
945
-			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 = 'tracker_bymonth' AND filter_name = :filter_name";
1158
+			if ($limit) {
1159
+				$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 = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
1160
+			} else {
1161
+				$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 = 'tracker_bymonth' AND filter_name = :filter_name";
1162
+			}
946 1163
 		}
947 1164
 		$query_data = array(':filter_name' => $filter_name);
948 1165
 		try {
@@ -965,7 +1182,9 @@  discard block
 block discarded – undo
965 1182
 	
966 1183
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
967 1184
 		global $globalStatsFilters;
968
-		if ($filter_name == '') $filter_name = $this->filter_name;
1185
+		if ($filter_name == '') {
1186
+			$filter_name = $this->filter_name;
1187
+		}
969 1188
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
970 1189
 			$Spotter = new Spotter($this->db);
971 1190
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1002,7 +1221,9 @@  discard block
 block discarded – undo
1002 1221
 	}
1003 1222
 	public function countAllMarineDatesLastMonth($filter_name = '') {
1004 1223
 		global $globalStatsFilters;
1005
-		if ($filter_name == '') $filter_name = $this->filter_name;
1224
+		if ($filter_name == '') {
1225
+			$filter_name = $this->filter_name;
1226
+		}
1006 1227
 		$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND filter_name = :filter_name";
1007 1228
 		$query_data = array(':filter_name' => $filter_name);
1008 1229
 		try {
@@ -1024,7 +1245,9 @@  discard block
 block discarded – undo
1024 1245
 	}
1025 1246
 	public function countAllTrackerDatesLastMonth($filter_name = '') {
1026 1247
 		global $globalStatsFilters;
1027
-		if ($filter_name == '') $filter_name = $this->filter_name;
1248
+		if ($filter_name == '') {
1249
+			$filter_name = $this->filter_name;
1250
+		}
1028 1251
 		$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND filter_name = :filter_name";
1029 1252
 		$query_data = array(':filter_name' => $filter_name);
1030 1253
 		try {
@@ -1046,7 +1269,9 @@  discard block
 block discarded – undo
1046 1269
 	}
1047 1270
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
1048 1271
 		global $globalDBdriver, $globalStatsFilters;
1049
-		if ($filter_name == '') $filter_name = $this->filter_name;
1272
+		if ($filter_name == '') {
1273
+			$filter_name = $this->filter_name;
1274
+		}
1050 1275
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1051 1276
 			$Spotter = new Spotter($this->db);
1052 1277
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1091,7 +1316,9 @@  discard block
 block discarded – undo
1091 1316
 	}
1092 1317
 	public function countAllMarineDatesLast7Days($filter_name = '') {
1093 1318
 		global $globalDBdriver, $globalStatsFilters;
1094
-		if ($filter_name == '') $filter_name = $this->filter_name;
1319
+		if ($filter_name == '') {
1320
+			$filter_name = $this->filter_name;
1321
+		}
1095 1322
 		if ($globalDBdriver == 'mysql') {
1096 1323
 			$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND marine_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name";
1097 1324
 		} else {
@@ -1117,7 +1344,9 @@  discard block
 block discarded – undo
1117 1344
 	}
1118 1345
 	public function countAllTrackerDatesLast7Days($filter_name = '') {
1119 1346
 		global $globalDBdriver, $globalStatsFilters;
1120
-		if ($filter_name == '') $filter_name = $this->filter_name;
1347
+		if ($filter_name == '') {
1348
+			$filter_name = $this->filter_name;
1349
+		}
1121 1350
 		if ($globalDBdriver == 'mysql') {
1122 1351
 			$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND tracker_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name";
1123 1352
 		} else {
@@ -1143,7 +1372,9 @@  discard block
 block discarded – undo
1143 1372
 	}
1144 1373
 	public function countAllDates($stats_airline = '',$filter_name = '') {
1145 1374
 		global $globalStatsFilters;
1146
-		if ($filter_name == '') $filter_name = $this->filter_name;
1375
+		if ($filter_name == '') {
1376
+			$filter_name = $this->filter_name;
1377
+		}
1147 1378
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1148 1379
 			$Spotter = new Spotter($this->db);
1149 1380
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1180,7 +1411,9 @@  discard block
 block discarded – undo
1180 1411
 	}
1181 1412
 	public function countAllDatesMarine($filter_name = '') {
1182 1413
 		global $globalStatsFilters;
1183
-		if ($filter_name == '') $filter_name = $this->filter_name;
1414
+		if ($filter_name == '') {
1415
+			$filter_name = $this->filter_name;
1416
+		}
1184 1417
 		$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
1185 1418
 		$query_data = array(':filter_name' => $filter_name);
1186 1419
 		try {
@@ -1202,7 +1435,9 @@  discard block
 block discarded – undo
1202 1435
 	}
1203 1436
 	public function countAllDatesTracker($filter_name = '') {
1204 1437
 		global $globalStatsFilters;
1205
-		if ($filter_name == '') $filter_name = $this->filter_name;
1438
+		if ($filter_name == '') {
1439
+			$filter_name = $this->filter_name;
1440
+		}
1206 1441
 		$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
1207 1442
 		$query_data = array(':filter_name' => $filter_name);
1208 1443
 		try {
@@ -1224,7 +1459,9 @@  discard block
 block discarded – undo
1224 1459
 	}
1225 1460
 	public function countAllDatesByAirlines($filter_name = '') {
1226 1461
 		global $globalStatsFilters;
1227
-		if ($filter_name == '') $filter_name = $this->filter_name;
1462
+		if ($filter_name == '') {
1463
+			$filter_name = $this->filter_name;
1464
+		}
1228 1465
 		$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";
1229 1466
 		$query_data = array('filter_name' => $filter_name);
1230 1467
 		try {
@@ -1246,7 +1483,9 @@  discard block
 block discarded – undo
1246 1483
 	}
1247 1484
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
1248 1485
 		global $globalStatsFilters, $globalDBdriver;
1249
-		if ($filter_name == '') $filter_name = $this->filter_name;
1486
+		if ($filter_name == '') {
1487
+			$filter_name = $this->filter_name;
1488
+		}
1250 1489
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1251 1490
 			$Spotter = new Spotter($this->db);
1252 1491
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1331,7 +1570,9 @@  discard block
 block discarded – undo
1331 1570
 	}
1332 1571
 	public function countAllMilitaryMonths($filter_name = '') {
1333 1572
 		global $globalStatsFilters;
1334
-		if ($filter_name == '') $filter_name = $this->filter_name;
1573
+		if ($filter_name == '') {
1574
+			$filter_name = $this->filter_name;
1575
+		}
1335 1576
 		$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";
1336 1577
 		try {
1337 1578
 			$sth = $this->db->prepare($query);
@@ -1352,7 +1593,9 @@  discard block
 block discarded – undo
1352 1593
 	}
1353 1594
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1354 1595
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1355
-		if ($filter_name == '') $filter_name = $this->filter_name;
1596
+		if ($filter_name == '') {
1597
+			$filter_name = $this->filter_name;
1598
+		}
1356 1599
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1357 1600
 			$Spotter = new Spotter($this->db);
1358 1601
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1360,12 +1603,18 @@  discard block
 block discarded – undo
1360 1603
 			foreach ($airlines as $airline) {
1361 1604
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1362 1605
 			}
1363
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1364
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1606
+			if ($limit) {
1607
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1608
+			} else {
1609
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1610
+			}
1365 1611
 			$query_data = array(':filter_name' => $filter_name);
1366 1612
 		} else {
1367
-			if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1368
-			else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1613
+			if ($limit) {
1614
+				$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1615
+			} else {
1616
+				$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1617
+			}
1369 1618
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1370 1619
 		}
1371 1620
 		if ($orderby == 'hour') {
@@ -1375,7 +1624,9 @@  discard block
 block discarded – undo
1375 1624
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1376 1625
 			}
1377 1626
 		}
1378
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1627
+		if ($orderby == 'count') {
1628
+			$query .= " ORDER BY hour_count DESC";
1629
+		}
1379 1630
 		try {
1380 1631
 			$sth = $this->db->prepare($query);
1381 1632
 			$sth->execute($query_data);
@@ -1399,9 +1650,14 @@  discard block
 block discarded – undo
1399 1650
 	}
1400 1651
 	public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') {
1401 1652
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1402
-		if ($filter_name == '') $filter_name = $this->filter_name;
1403
-		if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1404
-		else $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1653
+		if ($filter_name == '') {
1654
+			$filter_name = $this->filter_name;
1655
+		}
1656
+		if ($limit) {
1657
+			$query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1658
+		} else {
1659
+			$query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1660
+		}
1405 1661
 		$query_data = array(':filter_name' => $filter_name);
1406 1662
 		if ($orderby == 'hour') {
1407 1663
 			if ($globalDBdriver == 'mysql') {
@@ -1410,7 +1666,9 @@  discard block
 block discarded – undo
1410 1666
 				$query .= " ORDER BY CAST(marine_date AS integer) ASC";
1411 1667
 			}
1412 1668
 		}
1413
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1669
+		if ($orderby == 'count') {
1670
+			$query .= " ORDER BY hour_count DESC";
1671
+		}
1414 1672
 		try {
1415 1673
 			$sth = $this->db->prepare($query);
1416 1674
 			$sth->execute($query_data);
@@ -1430,9 +1688,14 @@  discard block
 block discarded – undo
1430 1688
 	}
1431 1689
 	public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') {
1432 1690
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1433
-		if ($filter_name == '') $filter_name = $this->filter_name;
1434
-		if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1435
-		else $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1691
+		if ($filter_name == '') {
1692
+			$filter_name = $this->filter_name;
1693
+		}
1694
+		if ($limit) {
1695
+			$query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1696
+		} else {
1697
+			$query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1698
+		}
1436 1699
 		$query_data = array(':filter_name' => $filter_name);
1437 1700
 		if ($orderby == 'hour') {
1438 1701
 			if ($globalDBdriver == 'mysql') {
@@ -1441,7 +1704,9 @@  discard block
 block discarded – undo
1441 1704
 				$query .= " ORDER BY CAST(tracker_date AS integer) ASC";
1442 1705
 			}
1443 1706
 		}
1444
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1707
+		if ($orderby == 'count') {
1708
+			$query .= " ORDER BY hour_count DESC";
1709
+		}
1445 1710
 		try {
1446 1711
 			$sth = $this->db->prepare($query);
1447 1712
 			$sth->execute($query_data);
@@ -1461,8 +1726,12 @@  discard block
 block discarded – undo
1461 1726
 	}
1462 1727
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1463 1728
 		global $globalStatsFilters;
1464
-		if ($filter_name == '') $filter_name = $this->filter_name;
1465
-		if ($year == '') $year = date('Y');
1729
+		if ($filter_name == '') {
1730
+			$filter_name = $this->filter_name;
1731
+		}
1732
+		if ($year == '') {
1733
+			$year = date('Y');
1734
+		}
1466 1735
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1467 1736
 		if (empty($all)) {
1468 1737
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1481,8 +1750,12 @@  discard block
 block discarded – undo
1481 1750
 	}
1482 1751
 	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1483 1752
 		global $globalStatsFilters;
1484
-		if ($filter_name == '') $filter_name = $this->filter_name;
1485
-		if ($year == '') $year = date('Y');
1753
+		if ($filter_name == '') {
1754
+			$filter_name = $this->filter_name;
1755
+		}
1756
+		if ($year == '') {
1757
+			$year = date('Y');
1758
+		}
1486 1759
 		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1487 1760
 		if (empty($all)) {
1488 1761
 			$filters = array('year' => $year,'month' => $month);
@@ -1497,8 +1770,12 @@  discard block
 block discarded – undo
1497 1770
 	}
1498 1771
 	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1499 1772
 		global $globalStatsFilters;
1500
-		if ($filter_name == '') $filter_name = $this->filter_name;
1501
-		if ($year == '') $year = date('Y');
1773
+		if ($filter_name == '') {
1774
+			$filter_name = $this->filter_name;
1775
+		}
1776
+		if ($year == '') {
1777
+			$year = date('Y');
1778
+		}
1502 1779
 		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1503 1780
 		if (empty($all)) {
1504 1781
 			$filters = array('year' => $year,'month' => $month);
@@ -1513,8 +1790,12 @@  discard block
 block discarded – undo
1513 1790
 	}
1514 1791
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1515 1792
 		global $globalStatsFilters;
1516
-		if ($filter_name == '') $filter_name = $this->filter_name;
1517
-		if ($year == '') $year = date('Y');
1793
+		if ($filter_name == '') {
1794
+			$filter_name = $this->filter_name;
1795
+		}
1796
+		if ($year == '') {
1797
+			$year = date('Y');
1798
+		}
1518 1799
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1519 1800
 		if (empty($all)) {
1520 1801
 			$filters = array();
@@ -1530,8 +1811,12 @@  discard block
 block discarded – undo
1530 1811
 	}
1531 1812
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1532 1813
 		global $globalStatsFilters;
1533
-		if ($filter_name == '') $filter_name = $this->filter_name;
1534
-		if ($year == '') $year = date('Y');
1814
+		if ($filter_name == '') {
1815
+			$filter_name = $this->filter_name;
1816
+		}
1817
+		if ($year == '') {
1818
+			$year = date('Y');
1819
+		}
1535 1820
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1536 1821
 		if (empty($all)) {
1537 1822
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1550,7 +1835,9 @@  discard block
 block discarded – undo
1550 1835
 	}
1551 1836
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1552 1837
 		global $globalStatsFilters;
1553
-		if ($filter_name == '') $filter_name = $this->filter_name;
1838
+		if ($filter_name == '') {
1839
+			$filter_name = $this->filter_name;
1840
+		}
1554 1841
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1555 1842
 			$Spotter = new Spotter($this->db);
1556 1843
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1568,7 +1855,9 @@  discard block
 block discarded – undo
1568 1855
 				}
1569 1856
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1570 1857
 				$all = $result[0]['nb'];
1571
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1858
+			} else {
1859
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1860
+			}
1572 1861
 		} else {
1573 1862
 			if ($year == '' && $month == '') {
1574 1863
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1580,7 +1869,9 @@  discard block
 block discarded – undo
1580 1869
 				}
1581 1870
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1582 1871
 				$all = $result[0]['nb'];
1583
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1872
+			} else {
1873
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1874
+			}
1584 1875
 		}
1585 1876
 		if (empty($all)) {
1586 1877
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1599,7 +1890,9 @@  discard block
 block discarded – undo
1599 1890
 	}
1600 1891
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1601 1892
 		global $globalStatsFilters;
1602
-		if ($filter_name == '') $filter_name = $this->filter_name;
1893
+		if ($filter_name == '') {
1894
+			$filter_name = $this->filter_name;
1895
+		}
1603 1896
 		if ($year == '' && $month == '') {
1604 1897
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1605 1898
 			try {
@@ -1610,7 +1903,9 @@  discard block
 block discarded – undo
1610 1903
 			}
1611 1904
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1612 1905
 			$all = $result[0]['nb_airline'];
1613
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1906
+		} else {
1907
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1908
+		}
1614 1909
 		if (empty($all)) {
1615 1910
 			$filters = array();
1616 1911
 			$filters = array('year' => $year,'month' => $month);
@@ -1625,7 +1920,9 @@  discard block
 block discarded – undo
1625 1920
 	}
1626 1921
 	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1627 1922
 		global $globalStatsFilters;
1628
-		if ($filter_name == '') $filter_name = $this->filter_name;
1923
+		if ($filter_name == '') {
1924
+			$filter_name = $this->filter_name;
1925
+		}
1629 1926
 		$all = array();
1630 1927
 		if ($year == '' && $month == '') {
1631 1928
 			$query = "SELECT COUNT(*) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name";
@@ -1652,7 +1949,9 @@  discard block
 block discarded – undo
1652 1949
 	}
1653 1950
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1654 1951
 		global $globalStatsFilters;
1655
-		if ($filter_name == '') $filter_name = $this->filter_name;
1952
+		if ($filter_name == '') {
1953
+			$filter_name = $this->filter_name;
1954
+		}
1656 1955
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1657 1956
 			$Spotter = new Spotter($this->db);
1658 1957
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1707,7 +2006,9 @@  discard block
 block discarded – undo
1707 2006
 	}
1708 2007
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1709 2008
 		global $globalStatsFilters;
1710
-		if ($filter_name == '') $filter_name = $this->filter_name;
2009
+		if ($filter_name == '') {
2010
+			$filter_name = $this->filter_name;
2011
+		}
1711 2012
 		//if ($year == '') $year = date('Y');
1712 2013
 		if ($year == '' && $month == '') {
1713 2014
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1736,7 +2037,9 @@  discard block
 block discarded – undo
1736 2037
 	}
1737 2038
 
1738 2039
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1739
-		if ($filter_name == '') $filter_name = $this->filter_name;
2040
+		if ($filter_name == '') {
2041
+			$filter_name = $this->filter_name;
2042
+		}
1740 2043
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1741 2044
 			$Spotter = new Spotter($this->db);
1742 2045
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1760,7 +2063,9 @@  discard block
 block discarded – undo
1760 2063
 		return $all;
1761 2064
 	}
1762 2065
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1763
-		if ($filter_name == '') $filter_name = $this->filter_name;
2066
+		if ($filter_name == '') {
2067
+			$filter_name = $this->filter_name;
2068
+		}
1764 2069
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1765 2070
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1766 2071
 		try {
@@ -1773,7 +2078,9 @@  discard block
 block discarded – undo
1773 2078
 		return $all;
1774 2079
 	}
1775 2080
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1776
-		if ($filter_name == '') $filter_name = $this->filter_name;
2081
+		if ($filter_name == '') {
2082
+			$filter_name = $this->filter_name;
2083
+		}
1777 2084
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1778 2085
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1779 2086
 		try {
@@ -1784,7 +2091,9 @@  discard block
 block discarded – undo
1784 2091
 		}
1785 2092
 	}
1786 2093
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1787
-		if ($filter_name == '') $filter_name = $this->filter_name;
2094
+		if ($filter_name == '') {
2095
+			$filter_name = $this->filter_name;
2096
+		}
1788 2097
 		global $globalArchiveMonths, $globalDBdriver;
1789 2098
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1790 2099
 			$Spotter = new Spotter($this->db);
@@ -1840,7 +2149,9 @@  discard block
 block discarded – undo
1840 2149
 	}
1841 2150
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1842 2151
 		global $globalArchiveMonths, $globalDBdriver;
1843
-		if ($filter_name == '') $filter_name = $this->filter_name;
2152
+		if ($filter_name == '') {
2153
+			$filter_name = $this->filter_name;
2154
+		}
1844 2155
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1845 2156
 			$Spotter = new Spotter($this->db);
1846 2157
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1873,7 +2184,9 @@  discard block
 block discarded – undo
1873 2184
 	}
1874 2185
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1875 2186
 		global $globalArchiveMonths, $globalDBdriver;
1876
-		if ($filter_name == '') $filter_name = $this->filter_name;
2187
+		if ($filter_name == '') {
2188
+			$filter_name = $this->filter_name;
2189
+		}
1877 2190
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1878 2191
 			$Spotter = new Spotter($this->db);
1879 2192
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1904,7 +2217,9 @@  discard block
 block discarded – undo
1904 2217
 	}
1905 2218
 	public function getStatsAirlineTotal($filter_name = '') {
1906 2219
 		global $globalArchiveMonths, $globalDBdriver;
1907
-		if ($filter_name == '') $filter_name = $this->filter_name;
2220
+		if ($filter_name == '') {
2221
+			$filter_name = $this->filter_name;
2222
+		}
1908 2223
 		if ($globalDBdriver == 'mysql') {
1909 2224
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1910 2225
 		} else {
@@ -1921,7 +2236,9 @@  discard block
 block discarded – undo
1921 2236
 	}
1922 2237
 	public function getStatsOwnerTotal($filter_name = '') {
1923 2238
 		global $globalArchiveMonths, $globalDBdriver;
1924
-		if ($filter_name == '') $filter_name = $this->filter_name;
2239
+		if ($filter_name == '') {
2240
+			$filter_name = $this->filter_name;
2241
+		}
1925 2242
 		if ($globalDBdriver == 'mysql') {
1926 2243
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1927 2244
 		} else {
@@ -1938,7 +2255,9 @@  discard block
 block discarded – undo
1938 2255
 	}
1939 2256
 	public function getStatsOwner($owner_name,$filter_name = '') {
1940 2257
 		global $globalArchiveMonths, $globalDBdriver;
1941
-		if ($filter_name == '') $filter_name = $this->filter_name;
2258
+		if ($filter_name == '') {
2259
+			$filter_name = $this->filter_name;
2260
+		}
1942 2261
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1943 2262
 		try {
1944 2263
 			$sth = $this->db->prepare($query);
@@ -1947,12 +2266,17 @@  discard block
 block discarded – undo
1947 2266
 			echo "error : ".$e->getMessage();
1948 2267
 		}
1949 2268
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1950
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1951
-		else return 0;
2269
+		if (isset($all[0]['cnt'])) {
2270
+			return $all[0]['cnt'];
2271
+		} else {
2272
+			return 0;
2273
+		}
1952 2274
 	}
1953 2275
 	public function getStatsPilotTotal($filter_name = '') {
1954 2276
 		global $globalArchiveMonths, $globalDBdriver;
1955
-		if ($filter_name == '') $filter_name = $this->filter_name;
2277
+		if ($filter_name == '') {
2278
+			$filter_name = $this->filter_name;
2279
+		}
1956 2280
 		if ($globalDBdriver == 'mysql') {
1957 2281
 			$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1958 2282
 		} else {
@@ -1969,7 +2293,9 @@  discard block
 block discarded – undo
1969 2293
 	}
1970 2294
 	public function getStatsPilot($pilot,$filter_name = '') {
1971 2295
 		global $globalArchiveMonths, $globalDBdriver;
1972
-		if ($filter_name == '') $filter_name = $this->filter_name;
2296
+		if ($filter_name == '') {
2297
+			$filter_name = $this->filter_name;
2298
+		}
1973 2299
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1974 2300
 		try {
1975 2301
 			$sth = $this->db->prepare($query);
@@ -1978,13 +2304,18 @@  discard block
 block discarded – undo
1978 2304
 			echo "error : ".$e->getMessage();
1979 2305
 		}
1980 2306
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1981
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1982
-		else return 0;
2307
+		if (isset($all[0]['cnt'])) {
2308
+			return $all[0]['cnt'];
2309
+		} else {
2310
+			return 0;
2311
+		}
1983 2312
 	}
1984 2313
 
1985 2314
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1986 2315
 		global $globalDBdriver;
1987
-		if ($filter_name == '') $filter_name = $this->filter_name;
2316
+		if ($filter_name == '') {
2317
+			$filter_name = $this->filter_name;
2318
+		}
1988 2319
 		if ($globalDBdriver == 'mysql') {
1989 2320
 			$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";
1990 2321
 		} else {
@@ -2000,7 +2331,9 @@  discard block
 block discarded – undo
2000 2331
 	}
2001 2332
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
2002 2333
 		global $globalDBdriver;
2003
-		if ($filter_name == '') $filter_name = $this->filter_name;
2334
+		if ($filter_name == '') {
2335
+			$filter_name = $this->filter_name;
2336
+		}
2004 2337
 		if ($globalDBdriver == 'mysql') {
2005 2338
 			$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";
2006 2339
 		} else {
@@ -2519,27 +2852,37 @@  discard block
 block discarded – undo
2519 2852
 		date_default_timezone_set('UTC');
2520 2853
 		if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) {
2521 2854
 			$last_update = $this->getLastStatsUpdate('last_update_stats_marine');
2522
-			if ($globalDebug) echo '!!! Update Marine stats !!!'."\n";
2855
+			if ($globalDebug) {
2856
+				echo '!!! Update Marine stats !!!'."\n";
2857
+			}
2523 2858
 			if (isset($last_update[0]['value'])) {
2524 2859
 				$last_update_day = $last_update[0]['value'];
2525
-			} else $last_update_day = '2012-12-12 12:12:12';
2860
+			} else {
2861
+				$last_update_day = '2012-12-12 12:12:12';
2862
+			}
2526 2863
 			$reset = false;
2527 2864
 			$Marine = new Marine($this->db);
2528 2865
 			$filtername = 'marine';
2529 2866
 			if ($Connection->tableExists('countries')) {
2530
-				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2867
+				if ($globalDebug) {
2868
+					echo 'Count all vessels by countries...'."\n";
2869
+				}
2531 2870
 				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2532 2871
 				foreach ($alldata as $number) {
2533 2872
 					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2534 2873
 				}
2535 2874
 			}
2536
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2875
+			if ($globalDebug) {
2876
+				echo 'Count all vessels by months...'."\n";
2877
+			}
2537 2878
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2538 2879
 			$filter_last_month = array('since_date' => $last_month);
2539 2880
 			$alldata = $Marine->countAllMonths($filter_last_month);
2540 2881
 			$lastyear = false;
2541 2882
 			foreach ($alldata as $number) {
2542
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2883
+				if ($number['year_name'] != date('Y')) {
2884
+					$lastyear = true;
2885
+				}
2543 2886
 				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2544 2887
 			}
2545 2888
 			echo 'Marine data...'."\n";
@@ -2569,7 +2912,9 @@  discard block
 block discarded – undo
2569 2912
 			foreach ($alldata as $number) {
2570 2913
 				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2571 2914
 			}
2572
-			if ($globalDebug) echo 'Count all types...'."\n";
2915
+			if ($globalDebug) {
2916
+				echo 'Count all types...'."\n";
2917
+			}
2573 2918
 			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2574 2919
 			foreach ($alldata as $number) {
2575 2920
 				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
@@ -2581,26 +2926,36 @@  discard block
 block discarded – undo
2581 2926
 		}
2582 2927
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2583 2928
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
2584
-			if ($globalDebug) echo '!!! Update tracker stats !!!'."\n";
2929
+			if ($globalDebug) {
2930
+				echo '!!! Update tracker stats !!!'."\n";
2931
+			}
2585 2932
 			if (isset($last_update[0]['value'])) {
2586 2933
 				$last_update_day = $last_update[0]['value'];
2587
-			} else $last_update_day = '2012-12-12 12:12:12';
2934
+			} else {
2935
+				$last_update_day = '2012-12-12 12:12:12';
2936
+			}
2588 2937
 			$reset = false;
2589 2938
 			$Tracker = new Tracker($this->db);
2590 2939
 			if ($Connection->tableExists('countries')) {
2591
-				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2940
+				if ($globalDebug) {
2941
+					echo 'Count all trackers by countries...'."\n";
2942
+				}
2592 2943
 				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2593 2944
 				foreach ($alldata as $number) {
2594 2945
 					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2595 2946
 				}
2596 2947
 			}
2597
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2948
+			if ($globalDebug) {
2949
+				echo 'Count all vessels by months...'."\n";
2950
+			}
2598 2951
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2599 2952
 			$filter_last_month = array('since_date' => $last_month);
2600 2953
 			$alldata = $Tracker->countAllMonths($filter_last_month);
2601 2954
 			$lastyear = false;
2602 2955
 			foreach ($alldata as $number) {
2603
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2956
+				if ($number['year_name'] != date('Y')) {
2957
+					$lastyear = true;
2958
+				}
2604 2959
 				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2605 2960
 			}
2606 2961
 			echo 'Tracker data...'."\n";
@@ -2630,7 +2985,9 @@  discard block
 block discarded – undo
2630 2985
 			foreach ($alldata as $number) {
2631 2986
 				$this->addStatTracker('hour',$number['hour_name'],$number['hour_count']);
2632 2987
 			}
2633
-			if ($globalDebug) echo 'Count all types...'."\n";
2988
+			if ($globalDebug) {
2989
+				echo 'Count all types...'."\n";
2990
+			}
2634 2991
 			$alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day);
2635 2992
 			foreach ($alldata as $number) {
2636 2993
 				$this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset);
@@ -2642,10 +2999,14 @@  discard block
 block discarded – undo
2642 2999
 
2643 3000
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
2644 3001
 			$last_update = $this->getLastStatsUpdate('last_update_stats');
2645
-			if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n";
3002
+			if ($globalDebug) {
3003
+				echo '!!! Update aicraft stats !!!'."\n";
3004
+			}
2646 3005
 			if (isset($last_update[0]['value'])) {
2647 3006
 				$last_update_day = $last_update[0]['value'];
2648
-			} else $last_update_day = '2012-12-12 12:12:12';
3007
+			} else {
3008
+				$last_update_day = '2012-12-12 12:12:12';
3009
+			}
2649 3010
 			$reset = false;
2650 3011
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
2651 3012
 			if ($globalStatsResetYear) {
@@ -2654,43 +3015,63 @@  discard block
 block discarded – undo
2654 3015
 			}
2655 3016
 			$Spotter = new Spotter($this->db);
2656 3017
 
2657
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
3018
+			if ($globalDebug) {
3019
+				echo 'Count all aircraft types...'."\n";
3020
+			}
2658 3021
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2659 3022
 			foreach ($alldata as $number) {
2660 3023
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2661 3024
 			}
2662
-			if ($globalDebug) echo 'Count all airlines...'."\n";
3025
+			if ($globalDebug) {
3026
+				echo 'Count all airlines...'."\n";
3027
+			}
2663 3028
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2664 3029
 			foreach ($alldata as $number) {
2665 3030
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2666 3031
 			}
2667
-			if ($globalDebug) echo 'Count all registrations...'."\n";
3032
+			if ($globalDebug) {
3033
+				echo 'Count all registrations...'."\n";
3034
+			}
2668 3035
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2669 3036
 			foreach ($alldata as $number) {
2670 3037
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2671 3038
 			}
2672
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
3039
+			if ($globalDebug) {
3040
+				echo 'Count all callsigns...'."\n";
3041
+			}
2673 3042
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2674 3043
 			foreach ($alldata as $number) {
2675 3044
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2676 3045
 			}
2677
-			if ($globalDebug) echo 'Count all owners...'."\n";
3046
+			if ($globalDebug) {
3047
+				echo 'Count all owners...'."\n";
3048
+			}
2678 3049
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2679 3050
 			foreach ($alldata as $number) {
2680 3051
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2681 3052
 			}
2682
-			if ($globalDebug) echo 'Count all pilots...'."\n";
3053
+			if ($globalDebug) {
3054
+				echo 'Count all pilots...'."\n";
3055
+			}
2683 3056
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2684 3057
 			foreach ($alldata as $number) {
2685
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
3058
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
3059
+					$number['pilot_id'] = $number['pilot_name'];
3060
+				}
2686 3061
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2687 3062
 			}
2688 3063
 			
2689
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
3064
+			if ($globalDebug) {
3065
+				echo 'Count all departure airports...'."\n";
3066
+			}
2690 3067
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2691
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
3068
+			if ($globalDebug) {
3069
+				echo 'Count all detected departure airports...'."\n";
3070
+			}
2692 3071
 			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2693
-			if ($globalDebug) echo 'Order departure airports...'."\n";
3072
+			if ($globalDebug) {
3073
+				echo 'Order departure airports...'."\n";
3074
+			}
2694 3075
 			$alldata = array();
2695 3076
 			foreach ($pall as $value) {
2696 3077
 				$icao = $value['airport_departure_icao'];
@@ -2700,7 +3081,9 @@  discard block
 block discarded – undo
2700 3081
 				$icao = $value['airport_departure_icao'];
2701 3082
 				if (isset($alldata[$icao])) {
2702 3083
 					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2703
-				} else $alldata[$icao] = $value;
3084
+				} else {
3085
+					$alldata[$icao] = $value;
3086
+				}
2704 3087
 			}
2705 3088
 			$count = array();
2706 3089
 			foreach ($alldata as $key => $row) {
@@ -2710,11 +3093,17 @@  discard block
 block discarded – undo
2710 3093
 			foreach ($alldata as $number) {
2711 3094
 				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);
2712 3095
 			}
2713
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
3096
+			if ($globalDebug) {
3097
+				echo 'Count all arrival airports...'."\n";
3098
+			}
2714 3099
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2715
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
3100
+			if ($globalDebug) {
3101
+				echo 'Count all detected arrival airports...'."\n";
3102
+			}
2716 3103
 			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2717
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
3104
+			if ($globalDebug) {
3105
+				echo 'Order arrival airports...'."\n";
3106
+			}
2718 3107
 			$alldata = array();
2719 3108
 			foreach ($pall as $value) {
2720 3109
 				$icao = $value['airport_arrival_icao'];
@@ -2724,7 +3113,9 @@  discard block
 block discarded – undo
2724 3113
 				$icao = $value['airport_arrival_icao'];
2725 3114
 				if (isset($alldata[$icao])) {
2726 3115
 					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2727
-				} else $alldata[$icao] = $value;
3116
+				} else {
3117
+					$alldata[$icao] = $value;
3118
+				}
2728 3119
 			}
2729 3120
 			$count = array();
2730 3121
 			foreach ($alldata as $key => $row) {
@@ -2735,7 +3126,9 @@  discard block
 block discarded – undo
2735 3126
 				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);
2736 3127
 			}
2737 3128
 			if ($Connection->tableExists('countries')) {
2738
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
3129
+				if ($globalDebug) {
3130
+					echo 'Count all flights by countries...'."\n";
3131
+				}
2739 3132
 				//$SpotterArchive = new SpotterArchive();
2740 3133
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2741 3134
 				$Spotter = new Spotter($this->db);
@@ -2746,7 +3139,9 @@  discard block
 block discarded – undo
2746 3139
 			}
2747 3140
 			
2748 3141
 			if (isset($globalAccidents) && $globalAccidents) {
2749
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
3142
+				if ($globalDebug) {
3143
+					echo 'Count fatalities stats...'."\n";
3144
+				}
2750 3145
 				$Accident = new Accident($this->db);
2751 3146
 				$this->deleteStatsByType('fatalities_byyear');
2752 3147
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2762,48 +3157,68 @@  discard block
 block discarded – undo
2762 3157
 
2763 3158
 			// Add by month using getstat if month finish...
2764 3159
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2765
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
3160
+			if ($globalDebug) {
3161
+				echo 'Count all flights by months...'."\n";
3162
+			}
2766 3163
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2767 3164
 			$filter_last_month = array('since_date' => $last_month);
2768 3165
 			$Spotter = new Spotter($this->db);
2769 3166
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2770 3167
 			$lastyear = false;
2771 3168
 			foreach ($alldata as $number) {
2772
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3169
+				if ($number['year_name'] != date('Y')) {
3170
+					$lastyear = true;
3171
+				}
2773 3172
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2774 3173
 			}
2775
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
3174
+			if ($globalDebug) {
3175
+				echo 'Count all military flights by months...'."\n";
3176
+			}
2776 3177
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2777 3178
 			foreach ($alldata as $number) {
2778 3179
 				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2779 3180
 			}
2780
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
3181
+			if ($globalDebug) {
3182
+				echo 'Count all owners by months...'."\n";
3183
+			}
2781 3184
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2782 3185
 			foreach ($alldata as $number) {
2783 3186
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2784 3187
 			}
2785
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
3188
+			if ($globalDebug) {
3189
+				echo 'Count all pilots by months...'."\n";
3190
+			}
2786 3191
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2787 3192
 			foreach ($alldata as $number) {
2788 3193
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2789 3194
 			}
2790
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
3195
+			if ($globalDebug) {
3196
+				echo 'Count all airlines by months...'."\n";
3197
+			}
2791 3198
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2792 3199
 			foreach ($alldata as $number) {
2793 3200
 				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2794 3201
 			}
2795
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3202
+			if ($globalDebug) {
3203
+				echo 'Count all aircrafts by months...'."\n";
3204
+			}
2796 3205
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2797 3206
 			foreach ($alldata as $number) {
2798 3207
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2799 3208
 			}
2800
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3209
+			if ($globalDebug) {
3210
+				echo 'Count all real arrivals by months...'."\n";
3211
+			}
2801 3212
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2802 3213
 			foreach ($alldata as $number) {
2803 3214
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2804 3215
 			}
2805
-			if ($globalDebug) echo 'Airports data...'."\n";
2806
-			if ($globalDebug) echo '...Departure'."\n";
3216
+			if ($globalDebug) {
3217
+				echo 'Airports data...'."\n";
3218
+			}
3219
+			if ($globalDebug) {
3220
+				echo '...Departure'."\n";
3221
+			}
2807 3222
 			$this->deleteStatAirport('daily');
2808 3223
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2809 3224
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2921,7 +3336,9 @@  discard block
 block discarded – undo
2921 3336
 			// Count by airlines
2922 3337
 			echo '--- Stats by airlines ---'."\n";
2923 3338
 			if ($Connection->tableExists('countries')) {
2924
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
3339
+				if ($globalDebug) {
3340
+					echo 'Count all flights by countries by airlines...'."\n";
3341
+				}
2925 3342
 				$SpotterArchive = new SpotterArchive($this->db);
2926 3343
 				//$Spotter = new Spotter($this->db);
2927 3344
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2930,37 +3347,53 @@  discard block
 block discarded – undo
2930 3347
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2931 3348
 				}
2932 3349
 			}
2933
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
3350
+			if ($globalDebug) {
3351
+				echo 'Count all aircraft types by airlines...'."\n";
3352
+			}
2934 3353
 			$Spotter = new Spotter($this->db);
2935 3354
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2936 3355
 			foreach ($alldata as $number) {
2937 3356
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2938 3357
 			}
2939
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
3358
+			if ($globalDebug) {
3359
+				echo 'Count all aircraft registrations by airlines...'."\n";
3360
+			}
2940 3361
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2941 3362
 			foreach ($alldata as $number) {
2942 3363
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2943 3364
 			}
2944
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
3365
+			if ($globalDebug) {
3366
+				echo 'Count all callsigns by airlines...'."\n";
3367
+			}
2945 3368
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2946 3369
 			foreach ($alldata as $number) {
2947 3370
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2948 3371
 			}
2949
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
3372
+			if ($globalDebug) {
3373
+				echo 'Count all owners by airlines...'."\n";
3374
+			}
2950 3375
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2951 3376
 			foreach ($alldata as $number) {
2952 3377
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2953 3378
 			}
2954
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
3379
+			if ($globalDebug) {
3380
+				echo 'Count all pilots by airlines...'."\n";
3381
+			}
2955 3382
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2956 3383
 			foreach ($alldata as $number) {
2957 3384
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2958 3385
 			}
2959
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
3386
+			if ($globalDebug) {
3387
+				echo 'Count all departure airports by airlines...'."\n";
3388
+			}
2960 3389
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2961
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
3390
+			if ($globalDebug) {
3391
+				echo 'Count all detected departure airports by airlines...'."\n";
3392
+			}
2962 3393
 			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2963
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
3394
+			if ($globalDebug) {
3395
+				echo 'Order detected departure airports by airlines...'."\n";
3396
+			}
2964 3397
 			//$alldata = array();
2965 3398
 			foreach ($dall as $value) {
2966 3399
 				$icao = $value['airport_departure_icao'];
@@ -2981,11 +3414,17 @@  discard block
 block discarded – undo
2981 3414
 			foreach ($alldata as $number) {
2982 3415
 				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);
2983 3416
 			}
2984
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
3417
+			if ($globalDebug) {
3418
+				echo 'Count all arrival airports by airlines...'."\n";
3419
+			}
2985 3420
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2986
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
3421
+			if ($globalDebug) {
3422
+				echo 'Count all detected arrival airports by airlines...'."\n";
3423
+			}
2987 3424
 			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2988
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
3425
+			if ($globalDebug) {
3426
+				echo 'Order arrival airports by airlines...'."\n";
3427
+			}
2989 3428
 			//$alldata = array();
2990 3429
 			foreach ($dall as $value) {
2991 3430
 				$icao = $value['airport_arrival_icao'];
@@ -3004,37 +3443,53 @@  discard block
 block discarded – undo
3004 3443
 			}
3005 3444
 			$alldata = $pall;
3006 3445
 			foreach ($alldata as $number) {
3007
-				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);
3446
+				if ($number['airline_icao'] != '') {
3447
+					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);
3448
+				}
3449
+			}
3450
+			if ($globalDebug) {
3451
+				echo 'Count all flights by months by airlines...'."\n";
3008 3452
 			}
3009
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
3010 3453
 			$Spotter = new Spotter($this->db);
3011 3454
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
3012 3455
 			$lastyear = false;
3013 3456
 			foreach ($alldata as $number) {
3014
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3457
+				if ($number['year_name'] != date('Y')) {
3458
+					$lastyear = true;
3459
+				}
3015 3460
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3016 3461
 			}
3017
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3462
+			if ($globalDebug) {
3463
+				echo 'Count all owners by months by airlines...'."\n";
3464
+			}
3018 3465
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
3019 3466
 			foreach ($alldata as $number) {
3020 3467
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3021 3468
 			}
3022
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3469
+			if ($globalDebug) {
3470
+				echo 'Count all pilots by months by airlines...'."\n";
3471
+			}
3023 3472
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
3024 3473
 			foreach ($alldata as $number) {
3025 3474
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3026 3475
 			}
3027
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3476
+			if ($globalDebug) {
3477
+				echo 'Count all aircrafts by months by airlines...'."\n";
3478
+			}
3028 3479
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
3029 3480
 			foreach ($alldata as $number) {
3030 3481
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3031 3482
 			}
3032
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3483
+			if ($globalDebug) {
3484
+				echo 'Count all real arrivals by months by airlines...'."\n";
3485
+			}
3033 3486
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
3034 3487
 			foreach ($alldata as $number) {
3035 3488
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3036 3489
 			}
3037
-			if ($globalDebug) echo '...Departure'."\n";
3490
+			if ($globalDebug) {
3491
+				echo '...Departure'."\n";
3492
+			}
3038 3493
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
3039 3494
 			$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
3040 3495
 			foreach ($dall as $value) {
@@ -3057,7 +3512,9 @@  discard block
 block discarded – undo
3057 3512
 			foreach ($alldata as $number) {
3058 3513
 				$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']);
3059 3514
 			}
3060
-			if ($globalDebug) echo '...Arrival'."\n";
3515
+			if ($globalDebug) {
3516
+				echo '...Arrival'."\n";
3517
+			}
3061 3518
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
3062 3519
 			$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
3063 3520
 			foreach ($dall as $value) {
@@ -3081,13 +3538,19 @@  discard block
 block discarded – undo
3081 3538
 				$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']);
3082 3539
 			}
3083 3540
 
3084
-			if ($globalDebug) echo 'Flights data...'."\n";
3085
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3541
+			if ($globalDebug) {
3542
+				echo 'Flights data...'."\n";
3543
+			}
3544
+			if ($globalDebug) {
3545
+				echo '-> countAllDatesLastMonth...'."\n";
3546
+			}
3086 3547
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
3087 3548
 			foreach ($alldata as $number) {
3088 3549
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
3089 3550
 			}
3090
-			if ($globalDebug) echo '-> countAllDates...'."\n";
3551
+			if ($globalDebug) {
3552
+				echo '-> countAllDates...'."\n";
3553
+			}
3091 3554
 			//$previousdata = $this->countAllDatesByAirlines();
3092 3555
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
3093 3556
 			$values = array();
@@ -3100,14 +3563,18 @@  discard block
 block discarded – undo
3100 3563
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
3101 3564
 			}
3102 3565
 			
3103
-			if ($globalDebug) echo '-> countAllHours...'."\n";
3566
+			if ($globalDebug) {
3567
+				echo '-> countAllHours...'."\n";
3568
+			}
3104 3569
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
3105 3570
 			foreach ($alldata as $number) {
3106 3571
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
3107 3572
 			}
3108 3573
 
3109 3574
 			// Stats by filters
3110
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
3575
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
3576
+				$globalStatsFilters = array();
3577
+			}
3111 3578
 			foreach ($globalStatsFilters as $name => $filter) {
3112 3579
 				if (!empty($filter)) {
3113 3580
 					//$filter_name = $filter['name'];
@@ -3115,7 +3582,9 @@  discard block
 block discarded – undo
3115 3582
 					$reset = false;
3116 3583
 					$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
3117 3584
 					if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
3118
-						if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3585
+						if ($globalDebug) {
3586
+							echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3587
+						}
3119 3588
 						$this->deleteOldStats($filter_name);
3120 3589
 						unset($last_update);
3121 3590
 					}
@@ -3132,39 +3601,55 @@  discard block
 block discarded – undo
3132 3601
 						$reset = true;
3133 3602
 					}
3134 3603
 					// Count by filter
3135
-					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3604
+					if ($globalDebug) {
3605
+						echo '--- Stats for filter '.$filter_name.' ---'."\n";
3606
+					}
3136 3607
 					$Spotter = new Spotter($this->db);
3137
-					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3608
+					if ($globalDebug) {
3609
+						echo 'Count all aircraft types...'."\n";
3610
+					}
3138 3611
 					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
3139 3612
 					foreach ($alldata as $number) {
3140 3613
 						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
3141 3614
 					}
3142
-					if ($globalDebug) echo 'Count all airlines...'."\n";
3615
+					if ($globalDebug) {
3616
+						echo 'Count all airlines...'."\n";
3617
+					}
3143 3618
 					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
3144 3619
 					foreach ($alldata as $number) {
3145 3620
 						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
3146 3621
 					}
3147
-					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3622
+					if ($globalDebug) {
3623
+						echo 'Count all aircraft registrations...'."\n";
3624
+					}
3148 3625
 					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
3149 3626
 					foreach ($alldata as $number) {
3150 3627
 						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
3151 3628
 					}
3152
-					if ($globalDebug) echo 'Count all callsigns...'."\n";
3629
+					if ($globalDebug) {
3630
+						echo 'Count all callsigns...'."\n";
3631
+					}
3153 3632
 					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
3154 3633
 					foreach ($alldata as $number) {
3155 3634
 						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
3156 3635
 					}
3157
-					if ($globalDebug) echo 'Count all owners...'."\n";
3636
+					if ($globalDebug) {
3637
+						echo 'Count all owners...'."\n";
3638
+					}
3158 3639
 					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
3159 3640
 					foreach ($alldata as $number) {
3160 3641
 						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
3161 3642
 					}
3162
-					if ($globalDebug) echo 'Count all pilots...'."\n";
3643
+					if ($globalDebug) {
3644
+						echo 'Count all pilots...'."\n";
3645
+					}
3163 3646
 					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
3164 3647
 					foreach ($alldata as $number) {
3165 3648
 						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
3166 3649
 					}
3167
-					if ($globalDebug) echo 'Count departure airports...'."\n";
3650
+					if ($globalDebug) {
3651
+						echo 'Count departure airports...'."\n";
3652
+					}
3168 3653
 					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
3169 3654
 					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
3170 3655
 					$alldata = array();
@@ -3176,7 +3661,9 @@  discard block
 block discarded – undo
3176 3661
 						$icao = $value['airport_departure_icao'];
3177 3662
 						if (isset($alldata[$icao])) {
3178 3663
 							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
3179
-						} else $alldata[$icao] = $value;
3664
+						} else {
3665
+							$alldata[$icao] = $value;
3666
+						}
3180 3667
 					}
3181 3668
 					$count = array();
3182 3669
 					foreach ($alldata as $key => $row) {
@@ -3186,7 +3673,9 @@  discard block
 block discarded – undo
3186 3673
 					foreach ($alldata as $number) {
3187 3674
 						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);
3188 3675
 					}
3189
-					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3676
+					if ($globalDebug) {
3677
+						echo 'Count all arrival airports...'."\n";
3678
+					}
3190 3679
 					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
3191 3680
 					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
3192 3681
 					$alldata = array();
@@ -3198,7 +3687,9 @@  discard block
 block discarded – undo
3198 3687
 						$icao = $value['airport_arrival_icao'];
3199 3688
 						if (isset($alldata[$icao])) {
3200 3689
 							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
3201
-						} else $alldata[$icao] = $value;
3690
+						} else {
3691
+							$alldata[$icao] = $value;
3692
+						}
3202 3693
 					}
3203 3694
 					$count = array();
3204 3695
 					foreach ($alldata as $key => $row) {
@@ -3208,35 +3699,49 @@  discard block
 block discarded – undo
3208 3699
 					foreach ($alldata as $number) {
3209 3700
 						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);
3210 3701
 					}
3211
-					if ($globalDebug) echo 'Count all months...'."\n";
3702
+					if ($globalDebug) {
3703
+						echo 'Count all months...'."\n";
3704
+					}
3212 3705
 					$Spotter = new Spotter($this->db);
3213 3706
 					$alldata = $Spotter->countAllMonths($filter);
3214 3707
 					$lastyear = false;
3215 3708
 					foreach ($alldata as $number) {
3216
-						if ($number['year_name'] != date('Y')) $lastyear = true;
3709
+						if ($number['year_name'] != date('Y')) {
3710
+							$lastyear = true;
3711
+						}
3217 3712
 						$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3218 3713
 					}
3219
-					if ($globalDebug) echo 'Count all owners by months...'."\n";
3714
+					if ($globalDebug) {
3715
+						echo 'Count all owners by months...'."\n";
3716
+					}
3220 3717
 					$alldata = $Spotter->countAllMonthsOwners($filter);
3221 3718
 					foreach ($alldata as $number) {
3222 3719
 						$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3223 3720
 					}
3224
-					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3721
+					if ($globalDebug) {
3722
+						echo 'Count all pilots by months...'."\n";
3723
+					}
3225 3724
 					$alldata = $Spotter->countAllMonthsPilots($filter);
3226 3725
 					foreach ($alldata as $number) {
3227 3726
 						$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3228 3727
 					}
3229
-					if ($globalDebug) echo 'Count all military by months...'."\n";
3728
+					if ($globalDebug) {
3729
+						echo 'Count all military by months...'."\n";
3730
+					}
3230 3731
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
3231 3732
 					foreach ($alldata as $number) {
3232 3733
 						$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3233 3734
 					}
3234
-					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3735
+					if ($globalDebug) {
3736
+						echo 'Count all aircrafts by months...'."\n";
3737
+					}
3235 3738
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
3236 3739
 				    	foreach ($alldata as $number) {
3237 3740
 			    			$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3238 3741
 					}
3239
-					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3742
+					if ($globalDebug) {
3743
+						echo 'Count all real arrivals by months...'."\n";
3744
+					}
3240 3745
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
3241 3746
 					foreach ($alldata as $number) {
3242 3747
 						$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
Please login to merge, or discard this patch.