Completed
Push — master ( e17801...597a61 )
by Yannick
25:55
created
footer.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@
 block discarded – undo
6 6
 </div>
7 7
 <footer class="container">
8 8
 	<?php
9
-	    if (isset($sql_time)) {
9
+		if (isset($sql_time)) {
10 10
 	?>
11 11
 	<i><?php echo _("Page generated in").' '.round($sql_time+$page_time,2); ?>s (<?php print round($page_time,2); ?>ms PHP - <?php print round($sql_time,2); ?>ms SQL)</i>
12 12
 	<br />
13 13
 	<?php
14
-	    }
14
+		}
15 15
 	?>
16 16
 	<span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) print $globalURL; ?>/about#source">Source &amp; Credits</a></span> - <span><a href="https://www.flightairmap.fr/" target="_blank">Get source code</a></span>
17 17
 </footer>
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Indentation   +642 added lines, -642 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
 
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824
+				$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828 828
 			} catch(PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830
-    			}
831
-    		}
830
+				}
831
+			}
832 832
 		
833 833
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
834 834
 		try {
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 			} catch(PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179
-                }
1179
+				}
1180 1180
 		if (!$Connection->checkColumnName('aircraft','mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 			} catch(PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253
-                }
1253
+				}
1254 1254
 		if (!$Connection->indexExists('accidents','registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
 			} catch(PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263
-                }
1263
+				}
1264 1264
 		if (!$Connection->indexExists('accidents','rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			} catch(PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273
-                }
1273
+				}
1274 1274
 
1275 1275
 		$query = "UPDATE config SET value = '31' WHERE name = 'schema_version'";
1276 1276
 		try {
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 			} catch(PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565
-                }
1565
+				}
1566 1566
 		$query = "UPDATE config SET value = '36' WHERE name = 'schema_version'";
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
 			} catch(PDOException $e) {
1724 1724
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1725 1725
 			}
1726
-                }
1726
+				}
1727 1727
 		$query = "UPDATE config SET value = '38' WHERE name = 'schema_version'";
1728 1728
 		try {
1729 1729
 			$sth = $Connection->db->prepare($query);
@@ -2129,205 +2129,205 @@  discard block
 block discarded – undo
2129 2129
 
2130 2130
 
2131 2131
 
2132
-    	public static function check_version($update = false) {
2133
-    	    global $globalDBname;
2134
-    	    $version = 0;
2135
-    	    $Connection = new Connection();
2136
-    	    if ($Connection->tableExists('aircraft')) {
2137
-    		if (!$Connection->tableExists('config')) {
2138
-    		    $version = '1';
2139
-    		    if ($update) return self::update_from_1();
2140
-    		    else return $version;
2132
+		public static function check_version($update = false) {
2133
+			global $globalDBname;
2134
+			$version = 0;
2135
+			$Connection = new Connection();
2136
+			if ($Connection->tableExists('aircraft')) {
2137
+			if (!$Connection->tableExists('config')) {
2138
+				$version = '1';
2139
+				if ($update) return self::update_from_1();
2140
+				else return $version;
2141 2141
 		} else {
2142
-    		    $Connection = new Connection();
2143
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2144
-		    try {
2145
-            		$sth = $Connection->db->prepare($query);
2146
-		        $sth->execute();
2147
-		    } catch(PDOException $e) {
2142
+				$Connection = new Connection();
2143
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2144
+			try {
2145
+					$sth = $Connection->db->prepare($query);
2146
+				$sth->execute();
2147
+			} catch(PDOException $e) {
2148 2148
 			return "error : ".$e->getMessage()."\n";
2149
-    		    }
2150
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
2151
-    		    if ($update) {
2152
-    			if ($result['value'] == '2') {
2153
-    			    $error = self::update_from_2();
2154
-    			    if ($error != '') return $error;
2155
-    			    else return self::check_version(true);
2156
-    			} elseif ($result['value'] == '3') {
2157
-    			    $error = self::update_from_3();
2158
-    			    if ($error != '') return $error;
2159
-    			    else return self::check_version(true);
2160
-    			} elseif ($result['value'] == '4') {
2161
-    			    $error = self::update_from_4();
2162
-    			    if ($error != '') return $error;
2163
-    			    else return self::check_version(true);
2164
-    			} elseif ($result['value'] == '5') {
2165
-    			    $error = self::update_from_5();
2166
-    			    if ($error != '') return $error;
2167
-    			    else return self::check_version(true);
2168
-    			} elseif ($result['value'] == '6') {
2169
-    			    $error = self::update_from_6();
2170
-    			    if ($error != '') return $error;
2171
-    			    else return self::check_version(true);
2172
-    			} elseif ($result['value'] == '7') {
2173
-    			    $error = self::update_from_7();
2174
-    			    if ($error != '') return $error;
2175
-    			    else return self::check_version(true);
2176
-    			} elseif ($result['value'] == '8') {
2177
-    			    $error = self::update_from_8();
2178
-    			    if ($error != '') return $error;
2179
-    			    else return self::check_version(true);
2180
-    			} elseif ($result['value'] == '9') {
2181
-    			    $error = self::update_from_9();
2182
-    			    if ($error != '') return $error;
2183
-    			    else return self::check_version(true);
2184
-    			} elseif ($result['value'] == '10') {
2185
-    			    $error = self::update_from_10();
2186
-    			    if ($error != '') return $error;
2187
-    			    else return self::check_version(true);
2188
-    			} elseif ($result['value'] == '11') {
2189
-    			    $error = self::update_from_11();
2190
-    			    if ($error != '') return $error;
2191
-    			    else return self::check_version(true);
2192
-    			} elseif ($result['value'] == '12') {
2193
-    			    $error = self::update_from_12();
2194
-    			    if ($error != '') return $error;
2195
-    			    else return self::check_version(true);
2196
-    			} elseif ($result['value'] == '13') {
2197
-    			    $error = self::update_from_13();
2198
-    			    if ($error != '') return $error;
2199
-    			    else return self::check_version(true);
2200
-    			} elseif ($result['value'] == '14') {
2201
-    			    $error = self::update_from_14();
2202
-    			    if ($error != '') return $error;
2203
-    			    else return self::check_version(true);
2204
-    			} elseif ($result['value'] == '15') {
2205
-    			    $error = self::update_from_15();
2206
-    			    if ($error != '') return $error;
2207
-    			    else return self::check_version(true);
2208
-    			} elseif ($result['value'] == '16') {
2209
-    			    $error = self::update_from_16();
2210
-    			    if ($error != '') return $error;
2211
-    			    else return self::check_version(true);
2212
-    			} elseif ($result['value'] == '17') {
2213
-    			    $error = self::update_from_17();
2214
-    			    if ($error != '') return $error;
2215
-    			    else return self::check_version(true);
2216
-    			} elseif ($result['value'] == '18') {
2217
-    			    $error = self::update_from_18();
2218
-    			    if ($error != '') return $error;
2219
-    			    else return self::check_version(true);
2220
-    			} elseif ($result['value'] == '19') {
2221
-    			    $error = self::update_from_19();
2222
-    			    if ($error != '') return $error;
2223
-    			    else return self::check_version(true);
2224
-    			} elseif ($result['value'] == '20') {
2225
-    			    $error = self::update_from_20();
2226
-    			    if ($error != '') return $error;
2227
-    			    else return self::check_version(true);
2228
-    			} elseif ($result['value'] == '21') {
2229
-    			    $error = self::update_from_21();
2230
-    			    if ($error != '') return $error;
2231
-    			    else return self::check_version(true);
2232
-    			} elseif ($result['value'] == '22') {
2233
-    			    $error = self::update_from_22();
2234
-    			    if ($error != '') return $error;
2235
-    			    else return self::check_version(true);
2236
-    			} elseif ($result['value'] == '23') {
2237
-    			    $error = self::update_from_23();
2238
-    			    if ($error != '') return $error;
2239
-    			    else return self::check_version(true);
2240
-    			} elseif ($result['value'] == '24') {
2241
-    			    $error = self::update_from_24();
2242
-    			    if ($error != '') return $error;
2243
-    			    else return self::check_version(true);
2244
-    			} elseif ($result['value'] == '25') {
2245
-    			    $error = self::update_from_25();
2246
-    			    if ($error != '') return $error;
2247
-    			    else return self::check_version(true);
2248
-    			} elseif ($result['value'] == '26') {
2249
-    			    $error = self::update_from_26();
2250
-    			    if ($error != '') return $error;
2251
-    			    else return self::check_version(true);
2252
-    			} elseif ($result['value'] == '27') {
2253
-    			    $error = self::update_from_27();
2254
-    			    if ($error != '') return $error;
2255
-    			    else return self::check_version(true);
2256
-    			} elseif ($result['value'] == '28') {
2257
-    			    $error = self::update_from_28();
2258
-    			    if ($error != '') return $error;
2259
-    			    else return self::check_version(true);
2260
-    			} elseif ($result['value'] == '29') {
2261
-    			    $error = self::update_from_29();
2262
-    			    if ($error != '') return $error;
2263
-    			    else return self::check_version(true);
2264
-    			} elseif ($result['value'] == '30') {
2265
-    			    $error = self::update_from_30();
2266
-    			    if ($error != '') return $error;
2267
-    			    else return self::check_version(true);
2268
-    			} elseif ($result['value'] == '31') {
2269
-    			    $error = self::update_from_31();
2270
-    			    if ($error != '') return $error;
2271
-    			    else return self::check_version(true);
2272
-    			} elseif ($result['value'] == '32') {
2273
-    			    $error = self::update_from_32();
2274
-    			    if ($error != '') return $error;
2275
-    			    else return self::check_version(true);
2276
-    			} elseif ($result['value'] == '33') {
2277
-    			    $error = self::update_from_33();
2278
-    			    if ($error != '') return $error;
2279
-    			    else return self::check_version(true);
2280
-    			} elseif ($result['value'] == '34') {
2281
-    			    $error = self::update_from_34();
2282
-    			    if ($error != '') return $error;
2283
-    			    else return self::check_version(true);
2284
-    			} elseif ($result['value'] == '35') {
2285
-    			    $error = self::update_from_35();
2286
-    			    if ($error != '') return $error;
2287
-    			    else return self::check_version(true);
2288
-    			} elseif ($result['value'] == '36') {
2289
-    			    $error = self::update_from_36();
2290
-    			    if ($error != '') return $error;
2291
-    			    else return self::check_version(true);
2292
-    			} elseif ($result['value'] == '37') {
2293
-    			    $error = self::update_from_37();
2294
-    			    if ($error != '') return $error;
2295
-    			    else return self::check_version(true);
2296
-    			} elseif ($result['value'] == '38') {
2297
-    			    $error = self::update_from_38();
2298
-    			    if ($error != '') return $error;
2299
-    			    else return self::check_version(true);
2300
-    			} elseif ($result['value'] == '39') {
2301
-    			    $error = self::update_from_39();
2302
-    			    if ($error != '') return $error;
2303
-    			    else return self::check_version(true);
2304
-    			} elseif ($result['value'] == '40') {
2305
-    			    $error = self::update_from_40();
2306
-    			    if ($error != '') return $error;
2307
-    			    else return self::check_version(true);
2308
-    			} elseif ($result['value'] == '41') {
2309
-    			    $error = self::update_from_41();
2310
-    			    if ($error != '') return $error;
2311
-    			    else return self::check_version(true);
2312
-    			} elseif ($result['value'] == '42') {
2313
-    			    $error = self::update_from_42();
2314
-    			    if ($error != '') return $error;
2315
-    			    else return self::check_version(true);
2316
-    			} elseif ($result['value'] == '43') {
2317
-    			    $error = self::update_from_43();
2318
-    			    if ($error != '') return $error;
2319
-    			    else return self::check_version(true);
2320
-    			} elseif ($result['value'] == '44') {
2321
-    			    $error = self::update_from_44();
2322
-    			    if ($error != '') return $error;
2323
-    			    else return self::check_version(true);
2324
-    			} else return '';
2325
-    		    }
2326
-    		    else return $result['value'];
2149
+				}
2150
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
2151
+				if ($update) {
2152
+				if ($result['value'] == '2') {
2153
+					$error = self::update_from_2();
2154
+					if ($error != '') return $error;
2155
+					else return self::check_version(true);
2156
+				} elseif ($result['value'] == '3') {
2157
+					$error = self::update_from_3();
2158
+					if ($error != '') return $error;
2159
+					else return self::check_version(true);
2160
+				} elseif ($result['value'] == '4') {
2161
+					$error = self::update_from_4();
2162
+					if ($error != '') return $error;
2163
+					else return self::check_version(true);
2164
+				} elseif ($result['value'] == '5') {
2165
+					$error = self::update_from_5();
2166
+					if ($error != '') return $error;
2167
+					else return self::check_version(true);
2168
+				} elseif ($result['value'] == '6') {
2169
+					$error = self::update_from_6();
2170
+					if ($error != '') return $error;
2171
+					else return self::check_version(true);
2172
+				} elseif ($result['value'] == '7') {
2173
+					$error = self::update_from_7();
2174
+					if ($error != '') return $error;
2175
+					else return self::check_version(true);
2176
+				} elseif ($result['value'] == '8') {
2177
+					$error = self::update_from_8();
2178
+					if ($error != '') return $error;
2179
+					else return self::check_version(true);
2180
+				} elseif ($result['value'] == '9') {
2181
+					$error = self::update_from_9();
2182
+					if ($error != '') return $error;
2183
+					else return self::check_version(true);
2184
+				} elseif ($result['value'] == '10') {
2185
+					$error = self::update_from_10();
2186
+					if ($error != '') return $error;
2187
+					else return self::check_version(true);
2188
+				} elseif ($result['value'] == '11') {
2189
+					$error = self::update_from_11();
2190
+					if ($error != '') return $error;
2191
+					else return self::check_version(true);
2192
+				} elseif ($result['value'] == '12') {
2193
+					$error = self::update_from_12();
2194
+					if ($error != '') return $error;
2195
+					else return self::check_version(true);
2196
+				} elseif ($result['value'] == '13') {
2197
+					$error = self::update_from_13();
2198
+					if ($error != '') return $error;
2199
+					else return self::check_version(true);
2200
+				} elseif ($result['value'] == '14') {
2201
+					$error = self::update_from_14();
2202
+					if ($error != '') return $error;
2203
+					else return self::check_version(true);
2204
+				} elseif ($result['value'] == '15') {
2205
+					$error = self::update_from_15();
2206
+					if ($error != '') return $error;
2207
+					else return self::check_version(true);
2208
+				} elseif ($result['value'] == '16') {
2209
+					$error = self::update_from_16();
2210
+					if ($error != '') return $error;
2211
+					else return self::check_version(true);
2212
+				} elseif ($result['value'] == '17') {
2213
+					$error = self::update_from_17();
2214
+					if ($error != '') return $error;
2215
+					else return self::check_version(true);
2216
+				} elseif ($result['value'] == '18') {
2217
+					$error = self::update_from_18();
2218
+					if ($error != '') return $error;
2219
+					else return self::check_version(true);
2220
+				} elseif ($result['value'] == '19') {
2221
+					$error = self::update_from_19();
2222
+					if ($error != '') return $error;
2223
+					else return self::check_version(true);
2224
+				} elseif ($result['value'] == '20') {
2225
+					$error = self::update_from_20();
2226
+					if ($error != '') return $error;
2227
+					else return self::check_version(true);
2228
+				} elseif ($result['value'] == '21') {
2229
+					$error = self::update_from_21();
2230
+					if ($error != '') return $error;
2231
+					else return self::check_version(true);
2232
+				} elseif ($result['value'] == '22') {
2233
+					$error = self::update_from_22();
2234
+					if ($error != '') return $error;
2235
+					else return self::check_version(true);
2236
+				} elseif ($result['value'] == '23') {
2237
+					$error = self::update_from_23();
2238
+					if ($error != '') return $error;
2239
+					else return self::check_version(true);
2240
+				} elseif ($result['value'] == '24') {
2241
+					$error = self::update_from_24();
2242
+					if ($error != '') return $error;
2243
+					else return self::check_version(true);
2244
+				} elseif ($result['value'] == '25') {
2245
+					$error = self::update_from_25();
2246
+					if ($error != '') return $error;
2247
+					else return self::check_version(true);
2248
+				} elseif ($result['value'] == '26') {
2249
+					$error = self::update_from_26();
2250
+					if ($error != '') return $error;
2251
+					else return self::check_version(true);
2252
+				} elseif ($result['value'] == '27') {
2253
+					$error = self::update_from_27();
2254
+					if ($error != '') return $error;
2255
+					else return self::check_version(true);
2256
+				} elseif ($result['value'] == '28') {
2257
+					$error = self::update_from_28();
2258
+					if ($error != '') return $error;
2259
+					else return self::check_version(true);
2260
+				} elseif ($result['value'] == '29') {
2261
+					$error = self::update_from_29();
2262
+					if ($error != '') return $error;
2263
+					else return self::check_version(true);
2264
+				} elseif ($result['value'] == '30') {
2265
+					$error = self::update_from_30();
2266
+					if ($error != '') return $error;
2267
+					else return self::check_version(true);
2268
+				} elseif ($result['value'] == '31') {
2269
+					$error = self::update_from_31();
2270
+					if ($error != '') return $error;
2271
+					else return self::check_version(true);
2272
+				} elseif ($result['value'] == '32') {
2273
+					$error = self::update_from_32();
2274
+					if ($error != '') return $error;
2275
+					else return self::check_version(true);
2276
+				} elseif ($result['value'] == '33') {
2277
+					$error = self::update_from_33();
2278
+					if ($error != '') return $error;
2279
+					else return self::check_version(true);
2280
+				} elseif ($result['value'] == '34') {
2281
+					$error = self::update_from_34();
2282
+					if ($error != '') return $error;
2283
+					else return self::check_version(true);
2284
+				} elseif ($result['value'] == '35') {
2285
+					$error = self::update_from_35();
2286
+					if ($error != '') return $error;
2287
+					else return self::check_version(true);
2288
+				} elseif ($result['value'] == '36') {
2289
+					$error = self::update_from_36();
2290
+					if ($error != '') return $error;
2291
+					else return self::check_version(true);
2292
+				} elseif ($result['value'] == '37') {
2293
+					$error = self::update_from_37();
2294
+					if ($error != '') return $error;
2295
+					else return self::check_version(true);
2296
+				} elseif ($result['value'] == '38') {
2297
+					$error = self::update_from_38();
2298
+					if ($error != '') return $error;
2299
+					else return self::check_version(true);
2300
+				} elseif ($result['value'] == '39') {
2301
+					$error = self::update_from_39();
2302
+					if ($error != '') return $error;
2303
+					else return self::check_version(true);
2304
+				} elseif ($result['value'] == '40') {
2305
+					$error = self::update_from_40();
2306
+					if ($error != '') return $error;
2307
+					else return self::check_version(true);
2308
+				} elseif ($result['value'] == '41') {
2309
+					$error = self::update_from_41();
2310
+					if ($error != '') return $error;
2311
+					else return self::check_version(true);
2312
+				} elseif ($result['value'] == '42') {
2313
+					$error = self::update_from_42();
2314
+					if ($error != '') return $error;
2315
+					else return self::check_version(true);
2316
+				} elseif ($result['value'] == '43') {
2317
+					$error = self::update_from_43();
2318
+					if ($error != '') return $error;
2319
+					else return self::check_version(true);
2320
+				} elseif ($result['value'] == '44') {
2321
+					$error = self::update_from_44();
2322
+					if ($error != '') return $error;
2323
+					else return self::check_version(true);
2324
+				} else return '';
2325
+				}
2326
+				else return $result['value'];
2327 2327
 		}
2328 2328
 		
2329
-	    } else return $version;
2330
-    	}
2329
+		} else return $version;
2330
+		}
2331 2331
     	
2332 2332
 }
2333 2333
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
require/class.Connection.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  discard block
 block discarded – undo
7 7
 	public $latest_schema = 45;
8 8
 	
9 9
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10
-	    global $globalDBdriver, $globalNoDB;
11
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
10
+		global $globalDBdriver, $globalNoDB;
11
+		if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 		$this->db = null;
13
-	    } else {
13
+		} else {
14 14
 		if ($dbc === null) {
15
-		    if ($this->db === null && $dbname === null) {
15
+			if ($this->db === null && $dbname === null) {
16 16
 			if ($user === null && $pass === null) {
17
-			    $this->createDBConnection();
17
+				$this->createDBConnection();
18 18
 			} else {
19
-			    $this->createDBConnection(null,$user,$pass);
19
+				$this->createDBConnection(null,$user,$pass);
20 20
 			}
21
-		    } else {
21
+			} else {
22 22
 			$this->createDBConnection($dbname);
23
-		    }
23
+			}
24 24
 		} elseif ($dbname === null || $dbname === 'default') {
25
-	    	    $this->db = $dbc;
26
-	    	    if ($this->connectionExists() === false) {
25
+				$this->db = $dbc;
26
+				if ($this->connectionExists() === false) {
27 27
 			/*
28 28
 			echo 'Restart Connection !!!'."\n";
29 29
 			$e = new \Exception;
30 30
 			var_dump($e->getTraceAsString());
31 31
 			*/
32 32
 			$this->createDBConnection();
33
-		    }
33
+			}
34 34
 		} else {
35
-		    //$this->connectionExists();
36
-		    $this->dbs[$dbname] = $dbc;
35
+			//$this->connectionExists();
36
+			$this->dbs[$dbname] = $dbc;
37
+		}
37 38
 		}
38
-	    }
39 39
 	}
40 40
 
41 41
 	public function db() {
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 	}
57 57
 
58 58
 	/**
59
-	* Creates the database connection
60
-	*
61
-	* @return Boolean of the database connection
62
-	*
63
-	*/
59
+	 * Creates the database connection
60
+	 *
61
+	 * @return Boolean of the database connection
62
+	 *
63
+	 */
64 64
 
65 65
 	public function createDBConnection($DBname = null, $user = null, $pass = null)
66 66
 	{
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 			return false;
158 158
 		}
159 159
 		if($results->rowCount()>0) {
160
-		    return true; 
160
+			return true; 
161 161
 		}
162 162
 		else return false;
163 163
 	}
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 				$sum = $sum->fetchColumn(0);
175 175
 			} else $sum = 0;
176 176
 			if (intval($sum) !== 2) {
177
-			     return false;
177
+				 return false;
178 178
 			}
179 179
 			
180 180
 		} catch(PDOException $e) {
181 181
 			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
182
-            			throw $e;
183
-	                }
184
-	                //echo 'error ! '.$e->getMessage();
182
+						throw $e;
183
+					}
184
+					//echo 'error ! '.$e->getMessage();
185 185
 			return false;
186 186
 		}
187 187
 		return true; 
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 		$version = 0;
286 286
 		if ($this->tableExists('aircraft')) {
287 287
 			if (!$this->tableExists('config')) {
288
-	    			$version = '1';
289
-	    			return $version;
288
+					$version = '1';
289
+					return $version;
290 290
 			} else {
291 291
 				$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
292 292
 				try {
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	* @return Boolean if latest version or not
308 308
 	*/
309 309
 	public function latest() {
310
-	    global $globalNoDB;
311
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
312
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
313
-	    else return false;
310
+		global $globalNoDB;
311
+		if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
312
+		if ($this->check_schema_version() == $this->latest_schema) return true;
313
+		else return false;
314 314
 	}
315 315
 
316 316
 }
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Indentation   +820 added lines, -820 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
17 17
 		$Connection = new Connection($dbc);
18 18
 		$this->db = $Connection->db();
19
-        }
19
+		}
20 20
               
21 21
 	public function addLastStatsUpdate($type,$stats_date) {
22
-                $query = "DELETE FROM config WHERE name = :type;
22
+				$query = "DELETE FROM config WHERE name = :type;
23 23
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
24
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
25
-                 try {
26
-                        $sth = $this->db->prepare($query);
27
-                        $sth->execute($query_values);
28
-                } catch(PDOException $e) {
29
-                        return "error : ".$e->getMessage();
30
-                }
31
-        }
24
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
25
+				 try {
26
+						$sth = $this->db->prepare($query);
27
+						$sth->execute($query_values);
28
+				} catch(PDOException $e) {
29
+						return "error : ".$e->getMessage();
30
+				}
31
+		}
32 32
 
33 33
 	public function getLastStatsUpdate($type = 'last_update_stats') {
34
-                $query = "SELECT value FROM config WHERE name = :type";
35
-                 try {
36
-                        $sth = $this->db->prepare($query);
37
-                        $sth->execute(array(':type' => $type));
38
-                } catch(PDOException $e) {
39
-                        echo "error : ".$e->getMessage();
40
-                }
41
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
42
-                return $all;
43
-        }
44
-        public function deleteStats($filter_name = '') {
45
-        	/*
34
+				$query = "SELECT value FROM config WHERE name = :type";
35
+				 try {
36
+						$sth = $this->db->prepare($query);
37
+						$sth->execute(array(':type' => $type));
38
+				} catch(PDOException $e) {
39
+						echo "error : ".$e->getMessage();
40
+				}
41
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
42
+				return $all;
43
+		}
44
+		public function deleteStats($filter_name = '') {
45
+			/*
46 46
         	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
47 47
                  try {
48 48
                         $sth = $this->db->prepare($query);
@@ -51,109 +51,109 @@  discard block
 block discarded – undo
51 51
                         return "error : ".$e->getMessage();
52 52
                 }
53 53
                 */
54
-        	$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
55
-                 try {
56
-                        $sth = $this->db->prepare($query);
57
-                        $sth->execute(array(':filter_name' => $filter_name));
58
-                } catch(PDOException $e) {
59
-                        return "error : ".$e->getMessage();
60
-                }
61
-        }
62
-        public function deleteOldStats($filter_name = '') {
63
-        	if ($filter_name == '') {
64
-        		$query = "DELETE FROM config WHERE name = 'last_update_stats'";
65
-        	} else {
66
-        		$query = "DELETE FROM config WHERE name = 'last_update_stats_".$filter_name."'";
67
-        	}
68
-                 try {
69
-                        $sth = $this->db->prepare($query);
70
-                        $sth->execute();
71
-                } catch(PDOException $e) {
72
-                        return "error : ".$e->getMessage();
73
-                }
54
+			$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
55
+				 try {
56
+						$sth = $this->db->prepare($query);
57
+						$sth->execute(array(':filter_name' => $filter_name));
58
+				} catch(PDOException $e) {
59
+						return "error : ".$e->getMessage();
60
+				}
61
+		}
62
+		public function deleteOldStats($filter_name = '') {
63
+			if ($filter_name == '') {
64
+				$query = "DELETE FROM config WHERE name = 'last_update_stats'";
65
+			} else {
66
+				$query = "DELETE FROM config WHERE name = 'last_update_stats_".$filter_name."'";
67
+			}
68
+				 try {
69
+						$sth = $this->db->prepare($query);
70
+						$sth->execute();
71
+				} catch(PDOException $e) {
72
+						return "error : ".$e->getMessage();
73
+				}
74 74
                 
75
-        	$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
76
-                 try {
77
-                        $sth = $this->db->prepare($query);
78
-                        $sth->execute(array(':filter_name' => $filter_name));
79
-                } catch(PDOException $e) {
80
-                        return "error : ".$e->getMessage();
81
-                }
82
-        }
75
+			$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
76
+				 try {
77
+						$sth = $this->db->prepare($query);
78
+						$sth->execute(array(':filter_name' => $filter_name));
79
+				} catch(PDOException $e) {
80
+						return "error : ".$e->getMessage();
81
+				}
82
+		}
83 83
 	public function getAllAirlineNames($filter_name = '') {
84 84
 		if ($filter_name == '') $filter_name = $this->filter_name;
85
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
86
-                 try {
87
-                        $sth = $this->db->prepare($query);
88
-                        $sth->execute(array(':filter_name' => $filter_name));
89
-                } catch(PDOException $e) {
90
-                        echo "error : ".$e->getMessage();
91
-                }
92
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
93
-                return $all;
94
-        }
85
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
86
+				 try {
87
+						$sth = $this->db->prepare($query);
88
+						$sth->execute(array(':filter_name' => $filter_name));
89
+				} catch(PDOException $e) {
90
+						echo "error : ".$e->getMessage();
91
+				}
92
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
93
+				return $all;
94
+		}
95 95
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
96 96
 		if ($filter_name == '') $filter_name = $this->filter_name;
97
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
98
-                 try {
99
-                        $sth = $this->db->prepare($query);
100
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
101
-                } catch(PDOException $e) {
102
-                        echo "error : ".$e->getMessage();
103
-                }
104
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
105
-                return $all;
106
-        }
97
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
98
+				 try {
99
+						$sth = $this->db->prepare($query);
100
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
101
+				} catch(PDOException $e) {
102
+						echo "error : ".$e->getMessage();
103
+				}
104
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
105
+				return $all;
106
+		}
107 107
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
108 108
 		if ($filter_name == '') $filter_name = $this->filter_name;
109
-                $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";
110
-                 try {
111
-                        $sth = $this->db->prepare($query);
112
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
113
-                } catch(PDOException $e) {
114
-                        echo "error : ".$e->getMessage();
115
-                }
116
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
117
-                return $all;
118
-        }
109
+				$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";
110
+				 try {
111
+						$sth = $this->db->prepare($query);
112
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
113
+				} catch(PDOException $e) {
114
+						echo "error : ".$e->getMessage();
115
+				}
116
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
117
+				return $all;
118
+		}
119 119
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
120 120
 		if ($filter_name == '') $filter_name = $this->filter_name;
121
-                $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";
122
-                 try {
123
-                        $sth = $this->db->prepare($query);
124
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
125
-                } catch(PDOException $e) {
126
-                        echo "error : ".$e->getMessage();
127
-                }
128
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
129
-                return $all;
130
-        }
121
+				$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";
122
+				 try {
123
+						$sth = $this->db->prepare($query);
124
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
125
+				} catch(PDOException $e) {
126
+						echo "error : ".$e->getMessage();
127
+				}
128
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
129
+				return $all;
130
+		}
131 131
 
132 132
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
133 133
 		if ($filter_name == '') $filter_name = $this->filter_name;
134
-                $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
135
-                 try {
136
-                        $sth = $this->db->prepare($query);
137
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
138
-                } catch(PDOException $e) {
139
-                        echo "error : ".$e->getMessage();
140
-                }
141
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
142
-                return $all;
143
-        }
134
+				$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
135
+				 try {
136
+						$sth = $this->db->prepare($query);
137
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
138
+				} catch(PDOException $e) {
139
+						echo "error : ".$e->getMessage();
140
+				}
141
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
142
+				return $all;
143
+		}
144 144
 
145 145
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
146 146
 		if ($filter_name == '') $filter_name = $this->filter_name;
147
-                $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
148
-                 try {
149
-                        $sth = $this->db->prepare($query);
150
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
151
-                } catch(PDOException $e) {
152
-                        echo "error : ".$e->getMessage();
153
-                }
154
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
155
-                return $all;
156
-        }
147
+				$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
148
+				 try {
149
+						$sth = $this->db->prepare($query);
150
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
151
+				} catch(PDOException $e) {
152
+						echo "error : ".$e->getMessage();
153
+				}
154
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
155
+				return $all;
156
+		}
157 157
 
158 158
 
159 159
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
 			}
171 171
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
172 172
 		} else $all = array();
173
-                if (empty($all)) {
174
-            	    $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
175
-            	    if ($filter_name != '') {
176
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
177
-            	    }
178
-            	    $Spotter = new Spotter($this->db);
179
-            	    //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
180
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
181
-                }
182
-                return $all;
173
+				if (empty($all)) {
174
+					$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
175
+					if ($filter_name != '') {
176
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
177
+					}
178
+					$Spotter = new Spotter($this->db);
179
+					//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
180
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
181
+				}
182
+				return $all;
183 183
 	}
184 184
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
185 185
 		global $globalStatsFilters;
@@ -195,17 +195,17 @@  discard block
 block discarded – undo
195 195
 			}
196 196
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
197 197
 		} else $all = array();
198
-                if (empty($all)) {
199
-            		$Spotter = new Spotter($this->db);
200
-            		$filters = array();
201
-            		$filters = array('year' => $year,'month' => $month);
202
-            		if ($filter_name != '') {
203
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
204
-			}
205
-            		//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
206
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
207
-                }
208
-                return $all;
198
+				if (empty($all)) {
199
+					$Spotter = new Spotter($this->db);
200
+					$filters = array();
201
+					$filters = array('year' => $year,'month' => $month);
202
+					if ($filter_name != '') {
203
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
204
+			}
205
+					//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
206
+					$all = $Spotter->countAllAirlineCountries($limit,$filters);
207
+				}
208
+				return $all;
209 209
 	}
210 210
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
211 211
 		global $globalStatsFilters;
@@ -247,39 +247,39 @@  discard block
 block discarded – undo
247 247
 			}
248 248
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
249 249
 		} else $all = array();
250
-                if (empty($all)) {
250
+				if (empty($all)) {
251 251
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
252 252
 			if ($filter_name != '') {
253
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
253
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
254 254
 			}
255 255
 			$Spotter = new Spotter($this->db);
256 256
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
257 257
 			$all = $Spotter->countAllArrivalCountries($limit,$filters);
258
-                }
259
-                return $all;
258
+				}
259
+				return $all;
260 260
 	}
261 261
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
262 262
 		global $globalStatsFilters;
263 263
 		if ($filter_name == '') $filter_name = $this->filter_name;
264 264
 		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";
265 265
 		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";
266
-                 try {
267
-                        $sth = $this->db->prepare($query);
268
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
269
-                } catch(PDOException $e) {
270
-                        echo "error : ".$e->getMessage();
271
-                }
272
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
273
-                if (empty($all)) {
266
+				 try {
267
+						$sth = $this->db->prepare($query);
268
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
269
+				} catch(PDOException $e) {
270
+						echo "error : ".$e->getMessage();
271
+				}
272
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
273
+				if (empty($all)) {
274 274
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
275 275
 			if ($filter_name != '') {
276
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
276
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
277 277
 			}
278 278
 			$Spotter = new Spotter($this->db);
279 279
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
280 280
 			$all = $Spotter->countAllDepartureCountries($filters);
281
-                }
282
-                return $all;
281
+				}
282
+				return $all;
283 283
 	}
284 284
 
285 285
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
@@ -305,17 +305,17 @@  discard block
 block discarded – undo
305 305
 			}
306 306
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
307 307
 		} else $all = array();
308
-                if (empty($all)) {
309
-	                $Spotter = new Spotter($this->db);
310
-            		$filters = array();
308
+				if (empty($all)) {
309
+					$Spotter = new Spotter($this->db);
310
+					$filters = array();
311 311
 			$filters = array('year' => $year,'month' => $month);
312
-            		if ($filter_name != '') {
313
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
312
+					if ($filter_name != '') {
313
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
314 314
 			}
315 315
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
316
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
317
-                }
318
-                return $all;
316
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters);
317
+				}
318
+				return $all;
319 319
 	}
320 320
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
321 321
 		global $globalStatsFilters;
@@ -331,16 +331,16 @@  discard block
 block discarded – undo
331 331
 			}
332 332
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
333 333
 		} else $all = array();
334
-                if (empty($all)) {
334
+				if (empty($all)) {
335 335
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
336 336
 			if ($filter_name != '') {
337 337
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
338 338
 			}
339
-	                $Spotter = new Spotter($this->db);
340
-    		        //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
341
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
342
-                }
343
-                return $all;
339
+					$Spotter = new Spotter($this->db);
340
+					//$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
341
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
342
+				}
343
+				return $all;
344 344
 	}
345 345
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
346 346
 		global $globalStatsFilters;
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 					echo "error : ".$e->getMessage();
382 382
 				}
383 383
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
384
-                /*
384
+				/*
385 385
                 if (empty($all)) {
386 386
 	                $Spotter = new Spotter($this->db);
387 387
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -433,16 +433,16 @@  discard block
 block discarded – undo
433 433
 			}
434 434
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
435 435
 		} else $all = array();
436
-                if (empty($all)) {
436
+				if (empty($all)) {
437 437
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
438 438
 			if ($filter_name != '') {
439 439
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
440 440
 			}
441
-            		$Spotter = new Spotter($this->db);
442
-            		//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
443
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
444
-                }
445
-                return $all;
441
+					$Spotter = new Spotter($this->db);
442
+					//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
443
+					$all = $Spotter->countAllOwners($limit,0,'',$filters);
444
+				}
445
+				return $all;
446 446
 	}
447 447
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
448 448
 		global $globalStatsFilters;
@@ -458,35 +458,35 @@  discard block
 block discarded – undo
458 458
 			}
459 459
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
460 460
 		} else $all = array();
461
-                if (empty($all)) {
461
+				if (empty($all)) {
462 462
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
463
-            		if ($filter_name != '') {
464
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
463
+					if ($filter_name != '') {
464
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
465 465
 			}
466
-            		$Spotter = new Spotter($this->db);
466
+					$Spotter = new Spotter($this->db);
467 467
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
468 468
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
469
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
470
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
471
-        		$all = array();
472
-        		foreach ($pall as $value) {
473
-        			$icao = $value['airport_departure_icao'];
474
-        			$all[$icao] = $value;
475
-        		}
469
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
470
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
471
+				$all = array();
472
+				foreach ($pall as $value) {
473
+					$icao = $value['airport_departure_icao'];
474
+					$all[$icao] = $value;
475
+				}
476 476
         		
477
-        		foreach ($dall as $value) {
478
-        			$icao = $value['airport_departure_icao'];
479
-        			if (isset($all[$icao])) {
480
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
481
-        			} else $all[$icao] = $value;
482
-        		}
483
-        		$count = array();
484
-        		foreach ($all as $key => $row) {
485
-        			$count[$key] = $row['airport_departure_icao_count'];
486
-        		}
487
-        		array_multisort($count,SORT_DESC,$all);
488
-                }
489
-                return $all;
477
+				foreach ($dall as $value) {
478
+					$icao = $value['airport_departure_icao'];
479
+					if (isset($all[$icao])) {
480
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
481
+					} else $all[$icao] = $value;
482
+				}
483
+				$count = array();
484
+				foreach ($all as $key => $row) {
485
+					$count[$key] = $row['airport_departure_icao_count'];
486
+				}
487
+				array_multisort($count,SORT_DESC,$all);
488
+				}
489
+				return $all;
490 490
 	}
491 491
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
492 492
 		global $globalStatsFilters;
@@ -512,26 +512,26 @@  discard block
 block discarded – undo
512 512
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
513 513
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
514 514
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
515
-        		$all = array();
516
-        		foreach ($pall as $value) {
517
-        			$icao = $value['airport_arrival_icao'];
518
-        			$all[$icao] = $value;
519
-        		}
515
+				$all = array();
516
+				foreach ($pall as $value) {
517
+					$icao = $value['airport_arrival_icao'];
518
+					$all[$icao] = $value;
519
+				}
520 520
         		
521
-        		foreach ($dall as $value) {
522
-        			$icao = $value['airport_arrival_icao'];
523
-        			if (isset($all[$icao])) {
524
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
525
-        			} else $all[$icao] = $value;
526
-        		}
527
-        		$count = array();
528
-        		foreach ($all as $key => $row) {
529
-        			$count[$key] = $row['airport_arrival_icao_count'];
530
-        		}
531
-        		array_multisort($count,SORT_DESC,$all);
532
-                }
521
+				foreach ($dall as $value) {
522
+					$icao = $value['airport_arrival_icao'];
523
+					if (isset($all[$icao])) {
524
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
525
+					} else $all[$icao] = $value;
526
+				}
527
+				$count = array();
528
+				foreach ($all as $key => $row) {
529
+					$count[$key] = $row['airport_arrival_icao_count'];
530
+				}
531
+				array_multisort($count,SORT_DESC,$all);
532
+				}
533 533
  
534
-                return $all;
534
+				return $all;
535 535
 	}
536 536
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
537 537
 		global $globalDBdriver, $globalStatsFilters;
@@ -544,23 +544,23 @@  discard block
 block discarded – undo
544 544
 			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";
545 545
 		}
546 546
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
547
-                 try {
548
-                        $sth = $this->db->prepare($query);
549
-                        $sth->execute($query_data);
550
-                } catch(PDOException $e) {
551
-                        echo "error : ".$e->getMessage();
552
-                }
553
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
554
-                if (empty($all)) {
547
+				 try {
548
+						$sth = $this->db->prepare($query);
549
+						$sth->execute($query_data);
550
+				} catch(PDOException $e) {
551
+						echo "error : ".$e->getMessage();
552
+				}
553
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
554
+				if (empty($all)) {
555 555
 			$filters = array('airlines' => array($stats_airline));
556 556
 			if ($filter_name != '') {
557 557
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
558 558
 			}
559
-            		$Spotter = new Spotter($this->db);
560
-            		$all = $Spotter->countAllMonthsLastYear($filters);
561
-                }
559
+					$Spotter = new Spotter($this->db);
560
+					$all = $Spotter->countAllMonthsLastYear($filters);
561
+				}
562 562
                 
563
-                return $all;
563
+				return $all;
564 564
 	}
565 565
 	
566 566
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -568,22 +568,22 @@  discard block
 block discarded – undo
568 568
 		if ($filter_name == '') $filter_name = $this->filter_name;
569 569
 		$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";
570 570
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
571
-                 try {
572
-                        $sth = $this->db->prepare($query);
573
-                        $sth->execute($query_data);
574
-                } catch(PDOException $e) {
575
-                        echo "error : ".$e->getMessage();
576
-                }
577
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
578
-                if (empty($all)) {
571
+				 try {
572
+						$sth = $this->db->prepare($query);
573
+						$sth->execute($query_data);
574
+				} catch(PDOException $e) {
575
+						echo "error : ".$e->getMessage();
576
+				}
577
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
578
+				if (empty($all)) {
579 579
 			$filters = array('airlines' => array($stats_airline));
580 580
 			if ($filter_name != '') {
581 581
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
582 582
 			}
583
-            		$Spotter = new Spotter($this->db);
584
-            		$all = $Spotter->countAllDatesLastMonth($filters);
585
-                }
586
-                return $all;
583
+					$Spotter = new Spotter($this->db);
584
+					$all = $Spotter->countAllDatesLastMonth($filters);
585
+				}
586
+				return $all;
587 587
 	}
588 588
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
589 589
 		global $globalDBdriver, $globalStatsFilters;
@@ -594,66 +594,66 @@  discard block
 block discarded – undo
594 594
 			$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";
595 595
 		}
596 596
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
597
-                 try {
598
-                        $sth = $this->db->prepare($query);
599
-                        $sth->execute($query_data);
600
-                } catch(PDOException $e) {
601
-                        echo "error : ".$e->getMessage();
602
-                }
603
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
604
-                if (empty($all)) {
597
+				 try {
598
+						$sth = $this->db->prepare($query);
599
+						$sth->execute($query_data);
600
+				} catch(PDOException $e) {
601
+						echo "error : ".$e->getMessage();
602
+				}
603
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
604
+				if (empty($all)) {
605 605
 			$filters = array('airlines' => array($stats_airline));
606 606
 			if ($filter_name != '') {
607 607
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
608 608
 			}
609
-            		$Spotter = new Spotter($this->db);
610
-            		$all = $Spotter->countAllDatesLast7Days($filters);
611
-                }
612
-                return $all;
609
+					$Spotter = new Spotter($this->db);
610
+					$all = $Spotter->countAllDatesLast7Days($filters);
611
+				}
612
+				return $all;
613 613
 	}
614 614
 	public function countAllDates($stats_airline = '',$filter_name = '') {
615 615
 		global $globalStatsFilters;
616 616
 		if ($filter_name == '') $filter_name = $this->filter_name;
617 617
 		$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";
618 618
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
619
-                 try {
620
-                        $sth = $this->db->prepare($query);
621
-                        $sth->execute($query_data);
622
-                } catch(PDOException $e) {
623
-                        echo "error : ".$e->getMessage();
624
-                }
625
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
626
-                if (empty($all)) {
619
+				 try {
620
+						$sth = $this->db->prepare($query);
621
+						$sth->execute($query_data);
622
+				} catch(PDOException $e) {
623
+						echo "error : ".$e->getMessage();
624
+				}
625
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
626
+				if (empty($all)) {
627 627
 			$filters = array('airlines' => array($stats_airline));
628 628
 			if ($filter_name != '') {
629
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
629
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
630 630
 			}
631
-            		$Spotter = new Spotter($this->db);
632
-            		$all = $Spotter->countAllDates($filters);
633
-                }
634
-                return $all;
631
+					$Spotter = new Spotter($this->db);
632
+					$all = $Spotter->countAllDates($filters);
633
+				}
634
+				return $all;
635 635
 	}
636 636
 	public function countAllDatesByAirlines($filter_name = '') {
637 637
 		global $globalStatsFilters;
638 638
 		if ($filter_name == '') $filter_name = $this->filter_name;
639 639
 		$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";
640 640
 		$query_data = array('filter_name' => $filter_name);
641
-                 try {
642
-                        $sth = $this->db->prepare($query);
643
-                        $sth->execute($query_data);
644
-                } catch(PDOException $e) {
645
-                        echo "error : ".$e->getMessage();
646
-                }
647
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
648
-                if (empty($all)) {
649
-            		$filters = array();
650
-            		if ($filter_name != '') {
651
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
641
+				 try {
642
+						$sth = $this->db->prepare($query);
643
+						$sth->execute($query_data);
644
+				} catch(PDOException $e) {
645
+						echo "error : ".$e->getMessage();
646
+				}
647
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
648
+				if (empty($all)) {
649
+					$filters = array();
650
+					if ($filter_name != '') {
651
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
652 652
 			}
653
-            		$Spotter = new Spotter($this->db);
654
-            		$all = $Spotter->countAllDatesByAirlines($filters);
655
-                }
656
-                return $all;
653
+					$Spotter = new Spotter($this->db);
654
+					$all = $Spotter->countAllDatesByAirlines($filters);
655
+				}
656
+				return $all;
657 657
 	}
658 658
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
659 659
 		global $globalStatsFilters, $globalDBdriver;
@@ -663,24 +663,24 @@  discard block
 block discarded – undo
663 663
 		} else {
664 664
 			$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC";
665 665
 		}
666
-                 try {
667
-                        $sth = $this->db->prepare($query);
668
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
669
-                } catch(PDOException $e) {
670
-                        echo "error : ".$e->getMessage();
671
-                }
672
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
666
+				 try {
667
+						$sth = $this->db->prepare($query);
668
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
669
+				} catch(PDOException $e) {
670
+						echo "error : ".$e->getMessage();
671
+				}
672
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
673 673
                 
674
-                if (empty($all)) {
674
+				if (empty($all)) {
675 675
 			$filters = array('airlines' => array($stats_airline));
676 676
 			if ($filter_name != '') {
677 677
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
678 678
 			}
679
-            		$Spotter = new Spotter($this->db);
680
-            		$all = $Spotter->countAllMonths($filters);
681
-                }
679
+					$Spotter = new Spotter($this->db);
680
+					$all = $Spotter->countAllMonths($filters);
681
+				}
682 682
                 
683
-                return $all;
683
+				return $all;
684 684
 	}
685 685
 	public function countFatalitiesLast12Months() {
686 686
 		global $globalStatsFilters, $globalDBdriver;
@@ -689,19 +689,19 @@  discard block
 block discarded – undo
689 689
 		} else {
690 690
 			$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year, EXTRACT(MONTH FROM stats_date) as month,cnt as count FROM stats WHERE stats_type = 'fatalities_bymonth' ORDER BY stats_date";
691 691
 		}
692
-                 try {
693
-                        $sth = $this->db->prepare($query);
694
-                        $sth->execute();
695
-                } catch(PDOException $e) {
696
-                        echo "error : ".$e->getMessage();
697
-                }
698
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
692
+				 try {
693
+						$sth = $this->db->prepare($query);
694
+						$sth->execute();
695
+				} catch(PDOException $e) {
696
+						echo "error : ".$e->getMessage();
697
+				}
698
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
699 699
                 
700
-                if (empty($all)) {
701
-            		$Accident = new Accident($this->db);
702
-            		$all = $Accident->countFatalitiesLast12Months();
703
-                }
704
-                return $all;
700
+				if (empty($all)) {
701
+					$Accident = new Accident($this->db);
702
+					$all = $Accident->countFatalitiesLast12Months();
703
+				}
704
+				return $all;
705 705
 	}
706 706
 	public function countFatalitiesByYear() {
707 707
 		global $globalStatsFilters, $globalDBdriver;
@@ -710,40 +710,40 @@  discard block
 block discarded – undo
710 710
 		} else {
711 711
 			$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year, cnt as count FROM stats WHERE stats_type = 'fatalities_byyear' ORDER BY stats_date";
712 712
 		}
713
-                 try {
714
-                        $sth = $this->db->prepare($query);
715
-                        $sth->execute();
716
-                } catch(PDOException $e) {
717
-                        echo "error : ".$e->getMessage();
718
-                }
719
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
713
+				 try {
714
+						$sth = $this->db->prepare($query);
715
+						$sth->execute();
716
+				} catch(PDOException $e) {
717
+						echo "error : ".$e->getMessage();
718
+				}
719
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
720 720
                 
721
-                if (empty($all)) {
722
-            		$Accident = new Accident($this->db);
723
-            		$all = $Accident->countFatalitiesByYear();
724
-                }
725
-                return $all;
721
+				if (empty($all)) {
722
+					$Accident = new Accident($this->db);
723
+					$all = $Accident->countFatalitiesByYear();
724
+				}
725
+				return $all;
726 726
 	}
727 727
 	public function countAllMilitaryMonths($filter_name = '') {
728 728
 		global $globalStatsFilters;
729 729
 		if ($filter_name == '') $filter_name = $this->filter_name;
730
-	    	$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";
731
-                 try {
732
-                        $sth = $this->db->prepare($query);
733
-                        $sth->execute(array(':filter_name' => $filter_name));
734
-                } catch(PDOException $e) {
735
-                        echo "error : ".$e->getMessage();
736
-                }
737
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
738
-                if (empty($all)) {
739
-            		$filters = array();
740
-            		if ($filter_name != '') {
741
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
730
+			$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";
731
+				 try {
732
+						$sth = $this->db->prepare($query);
733
+						$sth->execute(array(':filter_name' => $filter_name));
734
+				} catch(PDOException $e) {
735
+						echo "error : ".$e->getMessage();
736
+				}
737
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
738
+				if (empty($all)) {
739
+					$filters = array();
740
+					if ($filter_name != '') {
741
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
742 742
 			}
743
-            		$Spotter = new Spotter($this->db);
744
-            		$all = $Spotter->countAllMilitaryMonths($filters);
745
-                }
746
-                return $all;
743
+					$Spotter = new Spotter($this->db);
744
+					$all = $Spotter->countAllMilitaryMonths($filters);
745
+				}
746
+				return $all;
747 747
 	}
748 748
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
749 749
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -759,22 +759,22 @@  discard block
 block discarded – undo
759 759
 			}
760 760
 		}
761 761
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
762
-                 try {
763
-                        $sth = $this->db->prepare($query);
764
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
765
-                } catch(PDOException $e) {
766
-                        echo "error : ".$e->getMessage();
767
-                }
768
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
769
-                if (empty($all)) {
762
+				 try {
763
+						$sth = $this->db->prepare($query);
764
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
765
+				} catch(PDOException $e) {
766
+						echo "error : ".$e->getMessage();
767
+				}
768
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
769
+				if (empty($all)) {
770 770
 			$filters = array('airlines' => array($stats_airline));
771 771
 			if ($filter_name != '') {
772
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
772
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
773 773
 			}
774
-            		$Spotter = new Spotter($this->db);
775
-            		$all = $Spotter->countAllHours($orderby,$filters);
776
-                }
777
-                return $all;
774
+					$Spotter = new Spotter($this->db);
775
+					$all = $Spotter->countAllHours($orderby,$filters);
776
+				}
777
+				return $all;
778 778
 	}
779 779
 	
780 780
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
@@ -799,10 +799,10 @@  discard block
 block discarded – undo
799 799
 		if ($year == '') $year = date('Y');
800 800
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
801 801
 		if (empty($all)) {
802
-		        $filters = array();
802
+				$filters = array();
803 803
 			$filters = array('year' => $year,'month' => $month);
804
-            		if ($filter_name != '') {
805
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
804
+					if ($filter_name != '') {
805
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
806 806
 			}
807 807
 			$Spotter = new Spotter($this->db);
808 808
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -866,10 +866,10 @@  discard block
 block discarded – undo
866 866
 			$all = $result[0]['nb_airline'];
867 867
 		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
868 868
 		if (empty($all)) {
869
-            		$filters = array();
869
+					$filters = array();
870 870
 			$filters = array('year' => $year,'month' => $month);
871
-            		if ($filter_name != '') {
872
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
871
+					if ($filter_name != '') {
872
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
873 873
 			}
874 874
 			$Spotter = new Spotter($this->db);
875 875
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -939,44 +939,44 @@  discard block
 block discarded – undo
939 939
 		if ($filter_name == '') $filter_name = $this->filter_name;
940 940
 		$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";
941 941
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
942
-                 try {
943
-                        $sth = $this->db->prepare($query);
944
-                        $sth->execute($query_values);
945
-                } catch(PDOException $e) {
946
-                        echo "error : ".$e->getMessage();
947
-                }
948
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
949
-                return $all;
942
+				 try {
943
+						$sth = $this->db->prepare($query);
944
+						$sth->execute($query_values);
945
+				} catch(PDOException $e) {
946
+						echo "error : ".$e->getMessage();
947
+				}
948
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
949
+				return $all;
950 950
 	}
951 951
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
952 952
 		if ($filter_name == '') $filter_name = $this->filter_name;
953
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
954
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
955
-                 try {
956
-                        $sth = $this->db->prepare($query);
957
-                        $sth->execute($query_values);
958
-                } catch(PDOException $e) {
959
-                        echo "error : ".$e->getMessage();
960
-                }
961
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
962
-                return $all;
963
-        }
953
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
954
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
955
+				 try {
956
+						$sth = $this->db->prepare($query);
957
+						$sth->execute($query_values);
958
+				} catch(PDOException $e) {
959
+						echo "error : ".$e->getMessage();
960
+				}
961
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
962
+				return $all;
963
+		}
964 964
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
965 965
 		if ($filter_name == '') $filter_name = $this->filter_name;
966
-                $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
967
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
968
-                 try {
969
-                        $sth = $this->db->prepare($query);
970
-                        $sth->execute($query_values);
971
-                } catch(PDOException $e) {
972
-                        echo "error : ".$e->getMessage();
973
-                }
974
-        }
966
+				$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
967
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
968
+				 try {
969
+						$sth = $this->db->prepare($query);
970
+						$sth->execute($query_values);
971
+				} catch(PDOException $e) {
972
+						echo "error : ".$e->getMessage();
973
+				}
974
+		}
975 975
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
976 976
 		if ($filter_name == '') $filter_name = $this->filter_name;
977
-    		global $globalArchiveMonths, $globalDBdriver;
978
-    		if ($globalDBdriver == 'mysql') {
979
-    			if ($month == '') {
977
+			global $globalArchiveMonths, $globalDBdriver;
978
+			if ($globalDBdriver == 'mysql') {
979
+				if ($month == '') {
980 980
 				$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";
981 981
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
982 982
 			} else {
@@ -991,165 +991,165 @@  discard block
 block discarded – undo
991 991
 				$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";
992 992
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
993 993
 			}
994
-                }
995
-                 try {
996
-                        $sth = $this->db->prepare($query);
997
-                        $sth->execute($query_values);
998
-                } catch(PDOException $e) {
999
-                        echo "error : ".$e->getMessage();
1000
-                }
1001
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1002
-                return $all[0]['total'];
1003
-        }
994
+				}
995
+				 try {
996
+						$sth = $this->db->prepare($query);
997
+						$sth->execute($query_values);
998
+				} catch(PDOException $e) {
999
+						echo "error : ".$e->getMessage();
1000
+				}
1001
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1002
+				return $all[0]['total'];
1003
+		}
1004 1004
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1005
-    		global $globalArchiveMonths, $globalDBdriver;
1005
+			global $globalArchiveMonths, $globalDBdriver;
1006 1006
 		if ($filter_name == '') $filter_name = $this->filter_name;
1007
-    		if ($globalDBdriver == 'mysql') {
1007
+			if ($globalDBdriver == 'mysql') {
1008 1008
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
1009 1009
 		} else {
1010 1010
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1011
-                }
1012
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1013
-                 try {
1014
-                        $sth = $this->db->prepare($query);
1015
-                        $sth->execute($query_values);
1016
-                } catch(PDOException $e) {
1017
-                        echo "error : ".$e->getMessage();
1018
-                }
1019
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1020
-                return $all[0]['total'];
1021
-        }
1011
+				}
1012
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1013
+				 try {
1014
+						$sth = $this->db->prepare($query);
1015
+						$sth->execute($query_values);
1016
+				} catch(PDOException $e) {
1017
+						echo "error : ".$e->getMessage();
1018
+				}
1019
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1020
+				return $all[0]['total'];
1021
+		}
1022 1022
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1023
-    		global $globalArchiveMonths, $globalDBdriver;
1023
+			global $globalArchiveMonths, $globalDBdriver;
1024 1024
 		if ($filter_name == '') $filter_name = $this->filter_name;
1025
-    		if ($globalDBdriver == 'mysql') {
1025
+			if ($globalDBdriver == 'mysql') {
1026 1026
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1027
-                } else {
1027
+				} else {
1028 1028
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1029
-                }
1030
-                 try {
1031
-                        $sth = $this->db->prepare($query);
1032
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1033
-                } catch(PDOException $e) {
1034
-                        echo "error : ".$e->getMessage();
1035
-                }
1036
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1037
-                return $all[0]['total'];
1038
-        }
1029
+				}
1030
+				 try {
1031
+						$sth = $this->db->prepare($query);
1032
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1033
+				} catch(PDOException $e) {
1034
+						echo "error : ".$e->getMessage();
1035
+				}
1036
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1037
+				return $all[0]['total'];
1038
+		}
1039 1039
 	public function getStatsAirlineTotal($filter_name = '') {
1040
-    		global $globalArchiveMonths, $globalDBdriver;
1040
+			global $globalArchiveMonths, $globalDBdriver;
1041 1041
 		if ($filter_name == '') $filter_name = $this->filter_name;
1042
-    		if ($globalDBdriver == 'mysql') {
1042
+			if ($globalDBdriver == 'mysql') {
1043 1043
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1044
-                } else {
1044
+				} else {
1045 1045
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1046
-                }
1047
-                 try {
1048
-                        $sth = $this->db->prepare($query);
1049
-                        $sth->execute(array(':filter_name' => $filter_name));
1050
-                } catch(PDOException $e) {
1051
-                        echo "error : ".$e->getMessage();
1052
-                }
1053
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1054
-                return $all[0]['total'];
1055
-        }
1046
+				}
1047
+				 try {
1048
+						$sth = $this->db->prepare($query);
1049
+						$sth->execute(array(':filter_name' => $filter_name));
1050
+				} catch(PDOException $e) {
1051
+						echo "error : ".$e->getMessage();
1052
+				}
1053
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1054
+				return $all[0]['total'];
1055
+		}
1056 1056
 	public function getStatsOwnerTotal($filter_name = '') {
1057
-    		global $globalArchiveMonths, $globalDBdriver;
1057
+			global $globalArchiveMonths, $globalDBdriver;
1058 1058
 		if ($filter_name == '') $filter_name = $this->filter_name;
1059
-    		if ($globalDBdriver == 'mysql') {
1059
+			if ($globalDBdriver == 'mysql') {
1060 1060
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1061 1061
 		} else {
1062 1062
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1063
-                }
1064
-                 try {
1065
-                        $sth = $this->db->prepare($query);
1066
-                        $sth->execute(array(':filter_name' => $filter_name));
1067
-                } catch(PDOException $e) {
1068
-                        echo "error : ".$e->getMessage();
1069
-                }
1070
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1071
-                return $all[0]['total'];
1072
-        }
1063
+				}
1064
+				 try {
1065
+						$sth = $this->db->prepare($query);
1066
+						$sth->execute(array(':filter_name' => $filter_name));
1067
+				} catch(PDOException $e) {
1068
+						echo "error : ".$e->getMessage();
1069
+				}
1070
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1071
+				return $all[0]['total'];
1072
+		}
1073 1073
 	public function getStatsOwner($owner_name,$filter_name = '') {
1074
-    		global $globalArchiveMonths, $globalDBdriver;
1074
+			global $globalArchiveMonths, $globalDBdriver;
1075 1075
 		if ($filter_name == '') $filter_name = $this->filter_name;
1076 1076
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1077
-                 try {
1078
-                        $sth = $this->db->prepare($query);
1079
-                        $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1080
-                } catch(PDOException $e) {
1081
-                        echo "error : ".$e->getMessage();
1082
-                }
1083
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1084
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1085
-                else return 0;
1086
-        }
1077
+				 try {
1078
+						$sth = $this->db->prepare($query);
1079
+						$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1080
+				} catch(PDOException $e) {
1081
+						echo "error : ".$e->getMessage();
1082
+				}
1083
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1084
+				if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1085
+				else return 0;
1086
+		}
1087 1087
 	public function getStatsPilotTotal($filter_name = '') {
1088
-    		global $globalArchiveMonths, $globalDBdriver;
1088
+			global $globalArchiveMonths, $globalDBdriver;
1089 1089
 		if ($filter_name == '') $filter_name = $this->filter_name;
1090
-    		if ($globalDBdriver == 'mysql') {
1091
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1092
-            	} else {
1093
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1094
-            	}
1095
-                 try {
1096
-                        $sth = $this->db->prepare($query);
1097
-                        $sth->execute(array(':filter_name' => $filter_name));
1098
-                } catch(PDOException $e) {
1099
-                        echo "error : ".$e->getMessage();
1100
-                }
1101
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1102
-                return $all[0]['total'];
1103
-        }
1090
+			if ($globalDBdriver == 'mysql') {
1091
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1092
+				} else {
1093
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1094
+				}
1095
+				 try {
1096
+						$sth = $this->db->prepare($query);
1097
+						$sth->execute(array(':filter_name' => $filter_name));
1098
+				} catch(PDOException $e) {
1099
+						echo "error : ".$e->getMessage();
1100
+				}
1101
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1102
+				return $all[0]['total'];
1103
+		}
1104 1104
 	public function getStatsPilot($pilot,$filter_name = '') {
1105
-    		global $globalArchiveMonths, $globalDBdriver;
1105
+			global $globalArchiveMonths, $globalDBdriver;
1106 1106
 		if ($filter_name == '') $filter_name = $this->filter_name;
1107 1107
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1108
-                 try {
1109
-                        $sth = $this->db->prepare($query);
1110
-                        $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1111
-                } catch(PDOException $e) {
1112
-                        echo "error : ".$e->getMessage();
1113
-                }
1114
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1115
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1116
-                else return 0;
1117
-        }
1108
+				 try {
1109
+						$sth = $this->db->prepare($query);
1110
+						$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1111
+				} catch(PDOException $e) {
1112
+						echo "error : ".$e->getMessage();
1113
+				}
1114
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1115
+				if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1116
+				else return 0;
1117
+		}
1118 1118
 
1119 1119
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1120 1120
 		global $globalDBdriver;
1121 1121
 		if ($filter_name == '') $filter_name = $this->filter_name;
1122 1122
 		if ($globalDBdriver == 'mysql') {
1123 1123
 			$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";
1124
-                } else {
1124
+				} else {
1125 1125
 			$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);"; 
1126 1126
 		}
1127
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1128
-                 try {
1129
-                        $sth = $this->db->prepare($query);
1130
-                        $sth->execute($query_values);
1131
-                } catch(PDOException $e) {
1132
-                        return "error : ".$e->getMessage();
1133
-                }
1134
-        }
1127
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1128
+				 try {
1129
+						$sth = $this->db->prepare($query);
1130
+						$sth->execute($query_values);
1131
+				} catch(PDOException $e) {
1132
+						return "error : ".$e->getMessage();
1133
+				}
1134
+		}
1135 1135
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1136 1136
 		global $globalDBdriver;
1137 1137
 		if ($filter_name == '') $filter_name = $this->filter_name;
1138 1138
 		if ($globalDBdriver == 'mysql') {
1139 1139
 			$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";
1140 1140
 		} else {
1141
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1141
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1142 1142
 			$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);"; 
1143
-                }
1144
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1145
-                 try {
1146
-                        $sth = $this->db->prepare($query);
1147
-                        $sth->execute($query_values);
1148
-                } catch(PDOException $e) {
1149
-                        return "error : ".$e->getMessage();
1150
-                }
1151
-        }
1152
-        /*
1143
+				}
1144
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1145
+				 try {
1146
+						$sth = $this->db->prepare($query);
1147
+						$sth->execute($query_values);
1148
+				} catch(PDOException $e) {
1149
+						return "error : ".$e->getMessage();
1150
+				}
1151
+		}
1152
+		/*
1153 1153
 	public function getStatsSource($date,$stats_type = '') {
1154 1154
 		if ($stats_type == '') {
1155 1155
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -1218,25 +1218,25 @@  discard block
 block discarded – undo
1218 1218
 			$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";
1219 1219
 		} else {
1220 1220
 			$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);"; 
1221
-                }
1222
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1223
-                 try {
1224
-                        $sth = $this->db->prepare($query);
1225
-                        $sth->execute($query_values);
1226
-                } catch(PDOException $e) {
1227
-                        return "error : ".$e->getMessage();
1228
-                }
1229
-        }
1230
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1231
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1232
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1233
-                 try {
1234
-                        $sth = $this->db->prepare($query);
1235
-                        $sth->execute($query_values);
1236
-                } catch(PDOException $e) {
1237
-                        return "error : ".$e->getMessage();
1238
-                }
1239
-        }
1221
+				}
1222
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1223
+				 try {
1224
+						$sth = $this->db->prepare($query);
1225
+						$sth->execute($query_values);
1226
+				} catch(PDOException $e) {
1227
+						return "error : ".$e->getMessage();
1228
+				}
1229
+		}
1230
+	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1231
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1232
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1233
+				 try {
1234
+						$sth = $this->db->prepare($query);
1235
+						$sth->execute($query_values);
1236
+				} catch(PDOException $e) {
1237
+						return "error : ".$e->getMessage();
1238
+				}
1239
+		}
1240 1240
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1241 1241
 		global $globalDBdriver;
1242 1242
 		if ($globalDBdriver == 'mysql') {
@@ -1252,14 +1252,14 @@  discard block
 block discarded – undo
1252 1252
 				$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);"; 
1253 1253
 			}
1254 1254
 		}
1255
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1256
-                 try {
1257
-                        $sth = $this->db->prepare($query);
1258
-                        $sth->execute($query_values);
1259
-                } catch(PDOException $e) {
1260
-                        return "error : ".$e->getMessage();
1261
-                }
1262
-        }
1255
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1256
+				 try {
1257
+						$sth = $this->db->prepare($query);
1258
+						$sth->execute($query_values);
1259
+				} catch(PDOException $e) {
1260
+						return "error : ".$e->getMessage();
1261
+				}
1262
+		}
1263 1263
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1264 1264
 		global $globalDBdriver;
1265 1265
 		if ($globalDBdriver == 'mysql') {
@@ -1275,14 +1275,14 @@  discard block
 block discarded – undo
1275 1275
 				$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);"; 
1276 1276
 			}
1277 1277
 		}
1278
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1279
-                 try {
1280
-                        $sth = $this->db->prepare($query);
1281
-                        $sth->execute($query_values);
1282
-                } catch(PDOException $e) {
1283
-                        return "error : ".$e->getMessage();
1284
-                }
1285
-        }
1278
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1279
+				 try {
1280
+						$sth = $this->db->prepare($query);
1281
+						$sth->execute($query_values);
1282
+				} catch(PDOException $e) {
1283
+						return "error : ".$e->getMessage();
1284
+				}
1285
+		}
1286 1286
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1287 1287
 		global $globalDBdriver;
1288 1288
 		if ($globalDBdriver == 'mysql') {
@@ -1298,14 +1298,14 @@  discard block
 block discarded – undo
1298 1298
 				$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);"; 
1299 1299
 			}
1300 1300
 		}
1301
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1302
-                 try {
1303
-                        $sth = $this->db->prepare($query);
1304
-                        $sth->execute($query_values);
1305
-                } catch(PDOException $e) {
1306
-                        return "error : ".$e->getMessage();
1307
-                }
1308
-        }
1301
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1302
+				 try {
1303
+						$sth = $this->db->prepare($query);
1304
+						$sth->execute($query_values);
1305
+				} catch(PDOException $e) {
1306
+						return "error : ".$e->getMessage();
1307
+				}
1308
+		}
1309 1309
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1310 1310
 		global $globalDBdriver;
1311 1311
 		if ($globalDBdriver == 'mysql') {
@@ -1321,14 +1321,14 @@  discard block
 block discarded – undo
1321 1321
 				$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);"; 
1322 1322
 			}
1323 1323
 		}
1324
-                $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);
1325
-                 try {
1326
-                        $sth = $this->db->prepare($query);
1327
-                        $sth->execute($query_values);
1328
-                } catch(PDOException $e) {
1329
-                        return "error : ".$e->getMessage();
1330
-                }
1331
-        }
1324
+				$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);
1325
+				 try {
1326
+						$sth = $this->db->prepare($query);
1327
+						$sth->execute($query_values);
1328
+				} catch(PDOException $e) {
1329
+						return "error : ".$e->getMessage();
1330
+				}
1331
+		}
1332 1332
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1333 1333
 		global $globalDBdriver;
1334 1334
 		if ($globalDBdriver == 'mysql') {
@@ -1344,14 +1344,14 @@  discard block
 block discarded – undo
1344 1344
 				$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);"; 
1345 1345
 			}
1346 1346
 		}
1347
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1348
-                 try {
1349
-                        $sth = $this->db->prepare($query);
1350
-                        $sth->execute($query_values);
1351
-                } catch(PDOException $e) {
1352
-                        return "error : ".$e->getMessage();
1353
-                }
1354
-        }
1347
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1348
+				 try {
1349
+						$sth = $this->db->prepare($query);
1350
+						$sth->execute($query_values);
1351
+				} catch(PDOException $e) {
1352
+						return "error : ".$e->getMessage();
1353
+				}
1354
+		}
1355 1355
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1356 1356
 		global $globalDBdriver;
1357 1357
 		if ($globalDBdriver == 'mysql') {
@@ -1367,14 +1367,14 @@  discard block
 block discarded – undo
1367 1367
 				$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);"; 
1368 1368
 			}
1369 1369
 		}
1370
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1371
-                 try {
1372
-                        $sth = $this->db->prepare($query);
1373
-                        $sth->execute($query_values);
1374
-                } catch(PDOException $e) {
1375
-                        return "error : ".$e->getMessage();
1376
-                }
1377
-        }
1370
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1371
+				 try {
1372
+						$sth = $this->db->prepare($query);
1373
+						$sth->execute($query_values);
1374
+				} catch(PDOException $e) {
1375
+						return "error : ".$e->getMessage();
1376
+				}
1377
+		}
1378 1378
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1379 1379
 		global $globalDBdriver;
1380 1380
 		if ($globalDBdriver == 'mysql') {
@@ -1390,14 +1390,14 @@  discard block
 block discarded – undo
1390 1390
 				$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);"; 
1391 1391
 			}
1392 1392
 		}
1393
-                $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);
1394
-                 try {
1395
-                        $sth = $this->db->prepare($query);
1396
-                        $sth->execute($query_values);
1397
-                } catch(PDOException $e) {
1398
-                        return "error : ".$e->getMessage();
1399
-                }
1400
-        }
1393
+				$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);
1394
+				 try {
1395
+						$sth = $this->db->prepare($query);
1396
+						$sth->execute($query_values);
1397
+				} catch(PDOException $e) {
1398
+						return "error : ".$e->getMessage();
1399
+				}
1400
+		}
1401 1401
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1402 1402
 		global $globalDBdriver;
1403 1403
 		if ($airport_icao != '') {
@@ -1421,8 +1421,8 @@  discard block
 block discarded – undo
1421 1421
 			} catch(PDOException $e) {
1422 1422
 				return "error : ".$e->getMessage();
1423 1423
 			}
1424
-                }
1425
-        }
1424
+				}
1425
+		}
1426 1426
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1427 1427
 		global $globalDBdriver;
1428 1428
 		if ($airport_icao != '') {
@@ -1438,8 +1438,8 @@  discard block
 block discarded – undo
1438 1438
 			} catch(PDOException $e) {
1439 1439
 				return "error : ".$e->getMessage();
1440 1440
 			}
1441
-                }
1442
-        }
1441
+				}
1442
+		}
1443 1443
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1444 1444
 		global $globalDBdriver;
1445 1445
 		if ($airport_icao != '') {
@@ -1456,15 +1456,15 @@  discard block
 block discarded – undo
1456 1456
 					$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);"; 
1457 1457
 				}
1458 1458
 			}
1459
-	                $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);
1459
+					$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);
1460 1460
 			 try {
1461
-                    		$sth = $this->db->prepare($query);
1462
-	                        $sth->execute($query_values);
1463
-    		        } catch(PDOException $e) {
1464
-            		        return "error : ".$e->getMessage();
1465
-	                }
1466
-	        }
1467
-        }
1461
+							$sth = $this->db->prepare($query);
1462
+							$sth->execute($query_values);
1463
+					} catch(PDOException $e) {
1464
+							return "error : ".$e->getMessage();
1465
+					}
1466
+			}
1467
+		}
1468 1468
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1469 1469
 		global $globalDBdriver;
1470 1470
 		if ($airport_icao != '') {
@@ -1480,46 +1480,46 @@  discard block
 block discarded – undo
1480 1480
 			} catch(PDOException $e) {
1481 1481
 				return "error : ".$e->getMessage();
1482 1482
 			}
1483
-                }
1484
-        }
1483
+				}
1484
+		}
1485 1485
 
1486 1486
 	public function deleteStat($id) {
1487
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1488
-                $query_values = array(':id' => $id);
1489
-                 try {
1490
-                        $sth = $this->db->prepare($query);
1491
-                        $sth->execute($query_values);
1492
-                } catch(PDOException $e) {
1493
-                        return "error : ".$e->getMessage();
1494
-                }
1495
-        }
1487
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1488
+				$query_values = array(':id' => $id);
1489
+				 try {
1490
+						$sth = $this->db->prepare($query);
1491
+						$sth->execute($query_values);
1492
+				} catch(PDOException $e) {
1493
+						return "error : ".$e->getMessage();
1494
+				}
1495
+		}
1496 1496
 	public function deleteStatFlight($type) {
1497
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1498
-                $query_values = array(':type' => $type);
1499
-                 try {
1500
-                        $sth = $this->db->prepare($query);
1501
-                        $sth->execute($query_values);
1502
-                } catch(PDOException $e) {
1503
-                        return "error : ".$e->getMessage();
1504
-                }
1505
-        }
1497
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1498
+				$query_values = array(':type' => $type);
1499
+				 try {
1500
+						$sth = $this->db->prepare($query);
1501
+						$sth->execute($query_values);
1502
+				} catch(PDOException $e) {
1503
+						return "error : ".$e->getMessage();
1504
+				}
1505
+		}
1506 1506
 	public function deleteStatAirport($type) {
1507
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1508
-                $query_values = array(':type' => $type);
1509
-                 try {
1510
-                        $sth = $this->db->prepare($query);
1511
-                        $sth->execute($query_values);
1512
-                } catch(PDOException $e) {
1513
-                        return "error : ".$e->getMessage();
1514
-                }
1515
-        }
1507
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1508
+				$query_values = array(':type' => $type);
1509
+				 try {
1510
+						$sth = $this->db->prepare($query);
1511
+						$sth->execute($query_values);
1512
+				} catch(PDOException $e) {
1513
+						return "error : ".$e->getMessage();
1514
+				}
1515
+		}
1516 1516
         
1517
-        public function addOldStats() {
1518
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents;
1519
-    		$Common = new Common();
1520
-    		$Connection = new Connection();
1521
-    		date_default_timezone_set('UTC');
1522
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1517
+		public function addOldStats() {
1518
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents;
1519
+			$Common = new Common();
1520
+			$Connection = new Connection();
1521
+			date_default_timezone_set('UTC');
1522
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1523 1523
 			if ($globalDebug) echo 'Update stats !'."\n";
1524 1524
 			if (isset($last_update[0]['value'])) {
1525 1525
 				$last_update_day = $last_update[0]['value'];
@@ -1567,24 +1567,24 @@  discard block
 block discarded – undo
1567 1567
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1568 1568
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1569 1569
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1570
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1570
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1571 1571
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1572
-	        	$alldata = array();
1572
+				$alldata = array();
1573 1573
 	        	
1574
-    			foreach ($pall as $value) {
1575
-	        		$icao = $value['airport_departure_icao'];
1576
-    				$alldata[$icao] = $value;
1577
-	        	}
1578
-	        	foreach ($dall as $value) {
1579
-    				$icao = $value['airport_departure_icao'];
1580
-        			if (isset($alldata[$icao])) {
1581
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1582
-        			} else $alldata[$icao] = $value;
1583
-			}
1584
-    			$count = array();
1585
-    			foreach ($alldata as $key => $row) {
1586
-    				$count[$key] = $row['airport_departure_icao_count'];
1587
-        		}
1574
+				foreach ($pall as $value) {
1575
+					$icao = $value['airport_departure_icao'];
1576
+					$alldata[$icao] = $value;
1577
+				}
1578
+				foreach ($dall as $value) {
1579
+					$icao = $value['airport_departure_icao'];
1580
+					if (isset($alldata[$icao])) {
1581
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1582
+					} else $alldata[$icao] = $value;
1583
+			}
1584
+				$count = array();
1585
+				foreach ($alldata as $key => $row) {
1586
+					$count[$key] = $row['airport_departure_icao_count'];
1587
+				}
1588 1588
 			array_multisort($count,SORT_DESC,$alldata);
1589 1589
 			foreach ($alldata as $number) {
1590 1590
 				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);
@@ -1592,25 +1592,25 @@  discard block
 block discarded – undo
1592 1592
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1593 1593
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1594 1594
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1595
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1595
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1596 1596
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1597
-	        	$alldata = array();
1598
-    			foreach ($pall as $value) {
1599
-	        		$icao = $value['airport_arrival_icao'];
1600
-    				$alldata[$icao] = $value;
1601
-	        	}
1602
-	        	foreach ($dall as $value) {
1603
-    				$icao = $value['airport_arrival_icao'];
1604
-        			if (isset($alldata[$icao])) {
1605
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1606
-	        		} else $alldata[$icao] = $value;
1607
-    			}
1608
-        		$count = array();
1609
-        		foreach ($alldata as $key => $row) {
1610
-        			$count[$key] = $row['airport_arrival_icao_count'];
1611
-	        	}
1612
-    			array_multisort($count,SORT_DESC,$alldata);
1613
-                        foreach ($alldata as $number) {
1597
+				$alldata = array();
1598
+				foreach ($pall as $value) {
1599
+					$icao = $value['airport_arrival_icao'];
1600
+					$alldata[$icao] = $value;
1601
+				}
1602
+				foreach ($dall as $value) {
1603
+					$icao = $value['airport_arrival_icao'];
1604
+					if (isset($alldata[$icao])) {
1605
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1606
+					} else $alldata[$icao] = $value;
1607
+				}
1608
+				$count = array();
1609
+				foreach ($alldata as $key => $row) {
1610
+					$count[$key] = $row['airport_arrival_icao_count'];
1611
+				}
1612
+				array_multisort($count,SORT_DESC,$alldata);
1613
+						foreach ($alldata as $number) {
1614 1614
 				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);
1615 1615
 			}
1616 1616
 			if ($Connection->tableExists('countries')) {
@@ -1687,8 +1687,8 @@  discard block
 block discarded – undo
1687 1687
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1688 1688
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1689 1689
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1690
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1691
-        		/*
1690
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1691
+				/*
1692 1692
 	        	$alldata = array();
1693 1693
     			foreach ($pall as $value) {
1694 1694
 	        		$icao = $value['departure_airport_icao'];
@@ -1707,29 +1707,29 @@  discard block
 block discarded – undo
1707 1707
 	        	}
1708 1708
     			array_multisort($count,SORT_DESC,$alldata);
1709 1709
     			*/
1710
-    			foreach ($dall as $value) {
1711
-    				$icao = $value['departure_airport_icao'];
1712
-    				$ddate = $value['date'];
1713
-    				$find = false;
1714
-    				foreach ($pall as $pvalue) {
1715
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1716
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1717
-    						$find = true;
1718
-    						break;
1719
-    					}
1720
-    				}
1721
-    				if ($find === false) {
1722
-    					$pall[] = $value;
1723
-    				}
1724
-    			}
1725
-    			$alldata = $pall;
1710
+				foreach ($dall as $value) {
1711
+					$icao = $value['departure_airport_icao'];
1712
+					$ddate = $value['date'];
1713
+					$find = false;
1714
+					foreach ($pall as $pvalue) {
1715
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1716
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1717
+							$find = true;
1718
+							break;
1719
+						}
1720
+					}
1721
+					if ($find === false) {
1722
+						$pall[] = $value;
1723
+					}
1724
+				}
1725
+				$alldata = $pall;
1726 1726
 			foreach ($alldata as $number) {
1727 1727
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1728 1728
 			}
1729 1729
 			echo '...Arrival'."\n";
1730 1730
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1731
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1732
-        		/*
1731
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1732
+				/*
1733 1733
 	        	$alldata = array();
1734 1734
     			foreach ($pall as $value) {
1735 1735
 	        		$icao = $value['arrival_airport_icao'];
@@ -1749,22 +1749,22 @@  discard block
 block discarded – undo
1749 1749
     			*/
1750 1750
 
1751 1751
 
1752
-    			foreach ($dall as $value) {
1753
-    				$icao = $value['arrival_airport_icao'];
1754
-    				$ddate = $value['date'];
1755
-    				$find = false;
1756
-    				foreach ($pall as $pvalue) {
1757
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1758
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1759
-    						$find = true;
1760
-    						break;
1761
-    					}
1762
-    				}
1763
-    				if ($find === false) {
1764
-    					$pall[] = $value;
1765
-    				}
1766
-    			}
1767
-    			$alldata = $pall;
1752
+				foreach ($dall as $value) {
1753
+					$icao = $value['arrival_airport_icao'];
1754
+					$ddate = $value['date'];
1755
+					$find = false;
1756
+					foreach ($pall as $pvalue) {
1757
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1758
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1759
+							$find = true;
1760
+							break;
1761
+						}
1762
+					}
1763
+					if ($find === false) {
1764
+						$pall[] = $value;
1765
+					}
1766
+				}
1767
+				$alldata = $pall;
1768 1768
 			foreach ($alldata as $number) {
1769 1769
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1770 1770
 			}
@@ -1841,51 +1841,51 @@  discard block
 block discarded – undo
1841 1841
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1842 1842
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1843 1843
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1844
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1844
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1845 1845
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1846
-	        	//$alldata = array();
1847
-    			foreach ($dall as $value) {
1848
-    				$icao = $value['airport_departure_icao'];
1849
-    				$dicao = $value['airline_icao'];
1850
-    				$find = false;
1851
-    				foreach ($pall as $pvalue) {
1852
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1853
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1854
-    						$find = true;
1855
-    						break;
1856
-    					}
1857
-    				}
1858
-    				if ($find === false) {
1859
-    					$pall[] = $value;
1860
-    				}
1861
-    			}
1862
-    			$alldata = $pall;
1846
+				//$alldata = array();
1847
+				foreach ($dall as $value) {
1848
+					$icao = $value['airport_departure_icao'];
1849
+					$dicao = $value['airline_icao'];
1850
+					$find = false;
1851
+					foreach ($pall as $pvalue) {
1852
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1853
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1854
+							$find = true;
1855
+							break;
1856
+						}
1857
+					}
1858
+					if ($find === false) {
1859
+						$pall[] = $value;
1860
+					}
1861
+				}
1862
+				$alldata = $pall;
1863 1863
 			foreach ($alldata as $number) {
1864 1864
 				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);
1865 1865
 			}
1866 1866
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1867 1867
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1868 1868
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1869
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1869
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1870 1870
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1871
-	        	//$alldata = array();
1872
-    			foreach ($dall as $value) {
1873
-    				$icao = $value['airport_arrival_icao'];
1874
-    				$dicao = $value['airline_icao'];
1875
-    				$find = false;
1876
-    				foreach ($pall as $pvalue) {
1877
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1878
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1879
-    						$find = true;
1880
-    						break;
1881
-    					}
1882
-    				}
1883
-    				if ($find === false) {
1884
-    					$pall[] = $value;
1885
-    				}
1886
-    			}
1887
-    			$alldata = $pall;
1888
-                        foreach ($alldata as $number) {
1871
+				//$alldata = array();
1872
+				foreach ($dall as $value) {
1873
+					$icao = $value['airport_arrival_icao'];
1874
+					$dicao = $value['airline_icao'];
1875
+					$find = false;
1876
+					foreach ($pall as $pvalue) {
1877
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1878
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1879
+							$find = true;
1880
+							break;
1881
+						}
1882
+					}
1883
+					if ($find === false) {
1884
+						$pall[] = $value;
1885
+					}
1886
+				}
1887
+				$alldata = $pall;
1888
+						foreach ($alldata as $number) {
1889 1889
 				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);
1890 1890
 			}
1891 1891
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1918,47 +1918,47 @@  discard block
 block discarded – undo
1918 1918
 			}
1919 1919
 			if ($globalDebug) echo '...Departure'."\n";
1920 1920
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1921
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1922
-    			foreach ($dall as $value) {
1923
-    				$icao = $value['departure_airport_icao'];
1924
-    				$airline = $value['airline_icao'];
1925
-    				$ddate = $value['date'];
1926
-    				$find = false;
1927
-    				foreach ($pall as $pvalue) {
1928
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1929
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1930
-    						$find = true;
1931
-    						break;
1932
-    					}
1933
-    				}
1934
-    				if ($find === false) {
1935
-    					$pall[] = $value;
1936
-    				}
1937
-    			}
1938
-    			$alldata = $pall;
1921
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1922
+				foreach ($dall as $value) {
1923
+					$icao = $value['departure_airport_icao'];
1924
+					$airline = $value['airline_icao'];
1925
+					$ddate = $value['date'];
1926
+					$find = false;
1927
+					foreach ($pall as $pvalue) {
1928
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1929
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1930
+							$find = true;
1931
+							break;
1932
+						}
1933
+					}
1934
+					if ($find === false) {
1935
+						$pall[] = $value;
1936
+					}
1937
+				}
1938
+				$alldata = $pall;
1939 1939
 			foreach ($alldata as $number) {
1940 1940
 				$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']);
1941 1941
 			}
1942 1942
 			if ($globalDebug) echo '...Arrival'."\n";
1943 1943
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1944
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1945
-    			foreach ($dall as $value) {
1946
-    				$icao = $value['arrival_airport_icao'];
1947
-    				$airline = $value['airline_icao'];
1948
-    				$ddate = $value['date'];
1949
-    				$find = false;
1950
-    				foreach ($pall as $pvalue) {
1951
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1952
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1953
-    						$find = true;
1954
-    						break;
1955
-    					}
1956
-    				}
1957
-    				if ($find === false) {
1958
-    					$pall[] = $value;
1959
-    				}
1960
-    			}
1961
-    			$alldata = $pall;
1944
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1945
+				foreach ($dall as $value) {
1946
+					$icao = $value['arrival_airport_icao'];
1947
+					$airline = $value['airline_icao'];
1948
+					$ddate = $value['date'];
1949
+					$find = false;
1950
+					foreach ($pall as $pvalue) {
1951
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1952
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1953
+							$find = true;
1954
+							break;
1955
+						}
1956
+					}
1957
+					if ($find === false) {
1958
+						$pall[] = $value;
1959
+					}
1960
+				}
1961
+				$alldata = $pall;
1962 1962
 			foreach ($alldata as $number) {
1963 1963
 				$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']);
1964 1964
 			}
@@ -2043,44 +2043,44 @@  discard block
 block discarded – undo
2043 2043
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2044 2044
 				}
2045 2045
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2046
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2047
-		        	$alldata = array();
2048
-	    			foreach ($pall as $value) {
2049
-		        		$icao = $value['airport_departure_icao'];
2050
-    					$alldata[$icao] = $value;
2051
-	    			}
2052
-		        	foreach ($dall as $value) {
2053
-	    				$icao = $value['airport_departure_icao'];
2054
-        				if (isset($alldata[$icao])) {
2055
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2056
-        				} else $alldata[$icao] = $value;
2057
-				}
2058
-	    			$count = array();
2059
-    				foreach ($alldata as $key => $row) {
2060
-    					$count[$key] = $row['airport_departure_icao_count'];
2061
-    				}
2046
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2047
+					$alldata = array();
2048
+					foreach ($pall as $value) {
2049
+						$icao = $value['airport_departure_icao'];
2050
+						$alldata[$icao] = $value;
2051
+					}
2052
+					foreach ($dall as $value) {
2053
+						$icao = $value['airport_departure_icao'];
2054
+						if (isset($alldata[$icao])) {
2055
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2056
+						} else $alldata[$icao] = $value;
2057
+				}
2058
+					$count = array();
2059
+					foreach ($alldata as $key => $row) {
2060
+						$count[$key] = $row['airport_departure_icao_count'];
2061
+					}
2062 2062
 				array_multisort($count,SORT_DESC,$alldata);
2063 2063
 				foreach ($alldata as $number) {
2064
-    					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);
2064
+						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);
2065 2065
 				}
2066 2066
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2067
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2067
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2068 2068
 				$alldata = array();
2069
-    				foreach ($pall as $value) {
2070
-		        		$icao = $value['airport_arrival_icao'];
2071
-    					$alldata[$icao] = $value;
2072
-	    			}
2073
-		        	foreach ($dall as $value) {
2074
-	    				$icao = $value['airport_arrival_icao'];
2075
-        				if (isset($alldata[$icao])) {
2076
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2077
-		        		} else $alldata[$icao] = $value;
2078
-	    			}
2079
-        			$count = array();
2080
-        			foreach ($alldata as $key => $row) {
2081
-    					$count[$key] = $row['airport_arrival_icao_count'];
2082
-		        	}
2083
-        			array_multisort($count,SORT_DESC,$alldata);
2069
+					foreach ($pall as $value) {
2070
+						$icao = $value['airport_arrival_icao'];
2071
+						$alldata[$icao] = $value;
2072
+					}
2073
+					foreach ($dall as $value) {
2074
+						$icao = $value['airport_arrival_icao'];
2075
+						if (isset($alldata[$icao])) {
2076
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2077
+						} else $alldata[$icao] = $value;
2078
+					}
2079
+					$count = array();
2080
+					foreach ($alldata as $key => $row) {
2081
+						$count[$key] = $row['airport_arrival_icao_count'];
2082
+					}
2083
+					array_multisort($count,SORT_DESC,$alldata);
2084 2084
 				foreach ($alldata as $number) {
2085 2085
 					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);
2086 2086
 				}
@@ -2113,45 +2113,45 @@  discard block
 block discarded – undo
2113 2113
 				}
2114 2114
 				echo '...Departure'."\n";
2115 2115
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
2116
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2116
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2117 2117
 				foreach ($dall as $value) {
2118
-    					$icao = $value['departure_airport_icao'];
2119
-    					$ddate = $value['date'];
2120
-    					$find = false;
2121
-    					foreach ($pall as $pvalue) {
2122
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2123
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
2124
-	    						$find = true;
2125
-    							break;
2126
-    						}
2127
-    					}
2128
-    					if ($find === false) {
2129
-    						$pall[] = $value;
2130
-	    				}
2131
-    				}
2132
-	    			$alldata = $pall;
2118
+						$icao = $value['departure_airport_icao'];
2119
+						$ddate = $value['date'];
2120
+						$find = false;
2121
+						foreach ($pall as $pvalue) {
2122
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2123
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
2124
+								$find = true;
2125
+								break;
2126
+							}
2127
+						}
2128
+						if ($find === false) {
2129
+							$pall[] = $value;
2130
+						}
2131
+					}
2132
+					$alldata = $pall;
2133 2133
 				foreach ($alldata as $number) {
2134 2134
 					$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);
2135 2135
 				}
2136 2136
 				echo '...Arrival'."\n";
2137 2137
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2138
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2138
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2139 2139
 				foreach ($dall as $value) {
2140 2140
 					$icao = $value['arrival_airport_icao'];
2141 2141
 					$ddate = $value['date'];
2142
-    					$find = false;
2142
+						$find = false;
2143 2143
 					foreach ($pall as $pvalue) {
2144
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2145
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
2146
-    							$find = true;
2147
-    							break;
2148
-	    					}
2149
-    					}
2150
-    					if ($find === false) {
2151
-    						$pall[] = $value;
2152
-	    				}
2153
-    				}
2154
-    				$alldata = $pall;
2144
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2145
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
2146
+								$find = true;
2147
+								break;
2148
+							}
2149
+						}
2150
+						if ($find === false) {
2151
+							$pall[] = $value;
2152
+						}
2153
+					}
2154
+					$alldata = $pall;
2155 2155
 				foreach ($alldata as $number) {
2156 2156
 					$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);
2157 2157
 				}
Please login to merge, or discard this patch.
tools-geoid.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 try {
6 6
 $GeoidHeight = new GeoidHeight();
7 7
 } catch (Exception $e) {
8
-    echo $e;
8
+	echo $e;
9 9
 }
10 10
 $title = _("Geoid Height Calculator");
11 11
 require_once('header.php');
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Indentation   +458 added lines, -458 removed lines patch added patch discarded remove patch
@@ -76,38 +76,38 @@  discard block
 block discarded – undo
76 76
 		try {
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79
-                        $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
81
-                        return "error : ".$e->getMessage();
82
-                }
79
+						$sth->execute(array(':source' => $database_file));
80
+				} catch(PDOException $e) {
81
+						return "error : ".$e->getMessage();
82
+				}
83 83
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
85
-    		update_db::connect_sqlite($database_file);
84
+			if ($globalDebug) echo " - Add routes to DB -";
85
+			update_db::connect_sqlite($database_file);
86 86
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
87 87
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
88 88
 		try {
89
-                        $sth = update_db::$db_sqlite->prepare($query);
90
-                        $sth->execute();
91
-                } catch(PDOException $e) {
92
-                        return "error : ".$e->getMessage();
93
-                }
89
+						$sth = update_db::$db_sqlite->prepare($query);
90
+						$sth->execute();
91
+				} catch(PDOException $e) {
92
+						return "error : ".$e->getMessage();
93
+				}
94 94
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
95 95
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
96 96
 		$Connection = new Connection();
97 97
 		$sth_dest = $Connection->db->prepare($query_dest);
98 98
 		try {
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 102
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
103 103
 				$sth_dest->execute($query_dest_values);
104
-            		}
104
+					}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106 106
 		} catch(PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
110
-                return '';
110
+				return '';
111 111
 	}
112 112
 	public static function retrieve_route_oneworld($database_file) {
113 113
 		global $globalDebug, $globalTransaction;
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 		try {
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121
-                        $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
123
-                        return "error : ".$e->getMessage();
124
-                }
121
+						$sth->execute(array(':source' => 'oneworld'));
122
+				} catch(PDOException $e) {
123
+						return "error : ".$e->getMessage();
124
+				}
125 125
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
126
+			if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129 129
 		if ($fh = fopen($database_file,"r")) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			}
148 148
 			if ($globalTransaction) $Connection->db->commit();
149 149
 		}
150
-                return '';
150
+				return '';
151 151
 	}
152 152
 	
153 153
 	public static function retrieve_route_skyteam($database_file) {
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 		try {
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162
-                        $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
164
-                        return "error : ".$e->getMessage();
165
-                }
162
+						$sth->execute(array(':source' => 'skyteam'));
163
+				} catch(PDOException $e) {
164
+						return "error : ".$e->getMessage();
165
+				}
166 166
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
167
+			if ($globalDebug) echo " - Add routes to DB -";
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
192 192
 		}
193
-                return '';
193
+				return '';
194 194
 	}
195 195
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
196 196
 		global $globalTransaction;
@@ -199,27 +199,27 @@  discard block
 block discarded – undo
199 199
 		try {
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202
-                        $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
204
-                        return "error : ".$e->getMessage();
205
-                }
202
+						$sth->execute(array(':source' => $database_file));
203
+				} catch(PDOException $e) {
204
+						return "error : ".$e->getMessage();
205
+				}
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
207 207
 		try {
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210
-                        $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
212
-                        return "error : ".$e->getMessage();
213
-                }
210
+						$sth->execute(array(':source' => $database_file));
211
+				} catch(PDOException $e) {
212
+						return "error : ".$e->getMessage();
213
+				}
214 214
 
215
-    		update_db::connect_sqlite($database_file);
215
+			update_db::connect_sqlite($database_file);
216 216
 		$query = 'select * from Aircraft';
217 217
 		try {
218
-                        $sth = update_db::$db_sqlite->prepare($query);
219
-                        $sth->execute();
220
-                } catch(PDOException $e) {
221
-                        return "error : ".$e->getMessage();
222
-                }
218
+						$sth = update_db::$db_sqlite->prepare($query);
219
+						$sth->execute();
220
+				} catch(PDOException $e) {
221
+						return "error : ".$e->getMessage();
222
+				}
223 223
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
224 224
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
225 225
 		
@@ -230,17 +230,17 @@  discard block
 block discarded – undo
230 230
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 231
 		try {
232 232
 			if ($globalTransaction) $Connection->db->beginTransaction();
233
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 234
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237 237
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
241
-				    $sth_dest_owner->execute($query_dest_owner_values);
240
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
241
+					$sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243
-            		}
243
+					}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245 245
 		} catch(PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 		try {
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254
-                        $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
256
-                        return "error : ".$e->getMessage();
257
-                }
254
+						$sth->execute(array(':source' => $database_file));
255
+				} catch(PDOException $e) {
256
+						return "error : ".$e->getMessage();
257
+				}
258 258
 		return '';
259 259
 	}
260 260
 
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 		try {
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269
-                        $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
271
-                        return "error : ".$e->getMessage();
272
-                }
269
+						$sth->execute(array(':source' => $database_file));
270
+				} catch(PDOException $e) {
271
+						return "error : ".$e->getMessage();
272
+				}
273 273
 		
274 274
 		if ($fh = fopen($database_file,"r")) {
275 275
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -279,26 +279,26 @@  discard block
 block discarded – undo
279 279
 			$sth_dest = $Connection->db->prepare($query_dest);
280 280
 			try {
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282
-            			while (!feof($fh)) {
283
-            				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
282
+						while (!feof($fh)) {
283
+							$values = array();
284
+							$line = $Common->hex2str(fgets($fh,9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
289
-            				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
291
-            				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294
-            				$sth_search = $Connection->db->prepare($query_search);
286
+							$values['ModeS'] = substr($line,0,6);
287
+							$values['Registration'] = trim(substr($line,69,6));
288
+							$aircraft_name = trim(substr($line,48,6));
289
+							// Check if we can find ICAO, else set it to GLID
290
+							$aircraft_name_split = explode(' ',$aircraft_name);
291
+							$search_more = '';
292
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294
+							$sth_search = $Connection->db->prepare($query_search);
295 295
 					try {
296
-                                    		$sth_search->execute();
297
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
298
-	            				//if (count($result) > 0) {
299
-	            				if (isset($result['icao']) && $result['icao'] != '') {
300
-	            				    $values['ICAOTypeCode'] = $result['icao'];
301
-	            				} 
296
+											$sth_search->execute();
297
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
298
+								//if (count($result) > 0) {
299
+								if (isset($result['icao']) && $result['icao'] != '') {
300
+									$values['ICAOTypeCode'] = $result['icao'];
301
+								} 
302 302
 					} catch(PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 		try {
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324
-                        $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
326
-                        return "error : ".$e->getMessage();
327
-                }
324
+						$sth->execute(array(':source' => $database_file));
325
+				} catch(PDOException $e) {
326
+						return "error : ".$e->getMessage();
327
+				}
328 328
 		return '';
329 329
 	}
330 330
 
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 		try {
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338
-                        $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
340
-                        return "error : ".$e->getMessage();
341
-                }
338
+						$sth->execute(array(':source' => $database_file));
339
+				} catch(PDOException $e) {
340
+						return "error : ".$e->getMessage();
341
+				}
342 342
 		
343 343
 		if ($fh = fopen($database_file,"r")) {
344 344
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -349,25 +349,25 @@  discard block
 block discarded – undo
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351 351
 				$tmp = fgetcsv($fh,9999,',',"'");
352
-            			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
352
+						while (!feof($fh)) {
353
+							$line = fgetcsv($fh,9999,',',"'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
357
-            				$values['ModeS'] = $line[1];
358
-            				$values['Registration'] = $line[3];
359
-            				$values['ICAOTypeCode'] = '';
360
-            				$aircraft_name = $line[2];
361
-            				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
363
-            				$search_more = '';
364
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366
-            				$sth_search = $Connection->db->prepare($query_search);
357
+							$values['ModeS'] = $line[1];
358
+							$values['Registration'] = $line[3];
359
+							$values['ICAOTypeCode'] = '';
360
+							$aircraft_name = $line[2];
361
+							// Check if we can find ICAO, else set it to GLID
362
+							$aircraft_name_split = explode(' ',$aircraft_name);
363
+							$search_more = '';
364
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366
+							$sth_search = $Connection->db->prepare($query_search);
367 367
 					try {
368
-                                    		$sth_search->execute();
369
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
368
+											$sth_search->execute();
369
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371 371
 					} catch(PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
 		try {
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393
-                        $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
395
-                        return "error : ".$e->getMessage();
396
-                }
393
+						$sth->execute(array(':source' => $database_file));
394
+				} catch(PDOException $e) {
395
+						return "error : ".$e->getMessage();
396
+				}
397 397
 		return '';
398 398
 	}
399 399
 
@@ -404,16 +404,16 @@  discard block
 block discarded – undo
404 404
 		try {
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407
-                        $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
409
-                        return "error : ".$e->getMessage();
410
-                }
407
+						$sth->execute(array(':source' => $database_file));
408
+				} catch(PDOException $e) {
409
+						return "error : ".$e->getMessage();
410
+				}
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413 413
 		if ($fh = fopen($database_file,"r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
416
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
417 417
 		        
418 418
 			$Connection = new Connection();
419 419
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -421,126 +421,126 @@  discard block
 block discarded – undo
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423 423
 				$tmp = fgetcsv($fh,9999,',','"');
424
-            			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
426
-            				$values = array();
427
-            				//print_r($line);
428
-            				if ($country == 'F') {
429
-            				    $values['registration'] = $line[0];
430
-            				    $values['base'] = $line[4];
431
-            				    $values['owner'] = $line[5];
432
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
434
-					    $values['cancel'] = $line[7];
424
+						while (!feof($fh)) {
425
+							$line = fgetcsv($fh,9999,',','"');
426
+							$values = array();
427
+							//print_r($line);
428
+							if ($country == 'F') {
429
+								$values['registration'] = $line[0];
430
+								$values['base'] = $line[4];
431
+								$values['owner'] = $line[5];
432
+								if ($line[6] == '') $values['date_first_reg'] = null;
433
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
434
+						$values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436
-					    // TODO : add modeS & reg to aircraft_modes
437
-            				    $values['registration'] = $line[0];
438
-            				    $values['base'] = $line[3];
439
-            				    $values['owner'] = $line[2];
440
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
442
-					    $values['cancel'] = '';
443
-					    $values['modes'] = $line[7];
444
-					    $values['icao'] = $line[8];
436
+						// TODO : add modeS & reg to aircraft_modes
437
+								$values['registration'] = $line[0];
438
+								$values['base'] = $line[3];
439
+								$values['owner'] = $line[2];
440
+								if ($line[1] == '') $values['date_first_reg'] = null;
441
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
442
+						$values['cancel'] = '';
443
+						$values['modes'] = $line[7];
444
+						$values['icao'] = $line[8];
445 445
 					    
446 446
 					} elseif ($country == 'HB') {
447
-					    // TODO : add modeS & reg to aircraft_modes
448
-            				    $values['registration'] = $line[0];
449
-            				    $values['base'] = null;
450
-            				    $values['owner'] = $line[5];
451
-            				    $values['date_first_reg'] = null;
452
-					    $values['cancel'] = '';
453
-					    $values['modes'] = $line[4];
454
-					    $values['icao'] = $line[7];
447
+						// TODO : add modeS & reg to aircraft_modes
448
+								$values['registration'] = $line[0];
449
+								$values['base'] = null;
450
+								$values['owner'] = $line[5];
451
+								$values['date_first_reg'] = null;
452
+						$values['cancel'] = '';
453
+						$values['modes'] = $line[4];
454
+						$values['icao'] = $line[7];
455 455
 					} elseif ($country == 'OK') {
456
-					    // TODO : add modeS & reg to aircraft_modes
457
-            				    $values['registration'] = $line[3];
458
-            				    $values['base'] = null;
459
-            				    $values['owner'] = $line[5];
460
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
462
-					    $values['cancel'] = '';
456
+						// TODO : add modeS & reg to aircraft_modes
457
+								$values['registration'] = $line[3];
458
+								$values['base'] = null;
459
+								$values['owner'] = $line[5];
460
+								if ($line[18] == '') $values['date_first_reg'] = null;
461
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
462
+						$values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464
-					    // TODO : add modeS & reg to aircraft_modes
465
-            				    $values['registration'] = $line[0];
466
-            				    $values['base'] = null;
467
-            				    $values['owner'] = $line[12];
468
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
470
-
471
-					    $values['cancel'] = $line[39];
464
+						// TODO : add modeS & reg to aircraft_modes
465
+								$values['registration'] = $line[0];
466
+								$values['base'] = null;
467
+								$values['owner'] = $line[12];
468
+								if ($line[28] == '') $values['date_first_reg'] = null;
469
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
470
+
471
+						$values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
473
-            				    $values['registration'] = $line[0];
474
-            				    $values['base'] = null;
475
-            				    $values['owner'] = $line[4];
476
-            				    $values['date_first_reg'] = null;
477
-					    $values['cancel'] = '';
473
+								$values['registration'] = $line[0];
474
+								$values['base'] = null;
475
+								$values['owner'] = $line[4];
476
+								$values['date_first_reg'] = null;
477
+						$values['cancel'] = '';
478 478
 					} elseif ($country == 'CC') {
479
-            				    $values['registration'] = $line[0];
480
-            				    $values['base'] = null;
481
-            				    $values['owner'] = $line[6];
482
-            				    $values['date_first_reg'] = null;
483
-					    $values['cancel'] = '';
479
+								$values['registration'] = $line[0];
480
+								$values['base'] = null;
481
+								$values['owner'] = $line[6];
482
+								$values['date_first_reg'] = null;
483
+						$values['cancel'] = '';
484 484
 					} elseif ($country == 'HJ') {
485
-            				    $values['registration'] = $line[0];
486
-            				    $values['base'] = null;
487
-            				    $values['owner'] = $line[8];
488
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
490
-					    $values['cancel'] = '';
485
+								$values['registration'] = $line[0];
486
+								$values['base'] = null;
487
+								$values['owner'] = $line[8];
488
+								if ($line[7] == '') $values['date_first_reg'] = null;
489
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
490
+						$values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492
-            				    $values['registration'] = $line[0];
493
-            				    $values['base'] = null;
494
-            				    $values['owner'] = $line[4];
495
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
-					    $values['cancel'] = $line[7];
492
+								$values['registration'] = $line[0];
493
+								$values['base'] = null;
494
+								$values['owner'] = $line[4];
495
+								if ($line[6] == '') $values['date_first_reg'] = null;
496
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
+						$values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499
-            				    $values['registration'] = $line[0];
500
-            				    $values['base'] = null;
501
-            				    $values['owner'] = $line[4];
502
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
504
-					    $values['cancel'] = '';
499
+								$values['registration'] = $line[0];
500
+								$values['base'] = null;
501
+								$values['owner'] = $line[4];
502
+								if ($line[5] == '') $values['date_first_reg'] = null;
503
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
504
+						$values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506
-            				    $values['registration'] = $line[0];
507
-            				    $values['base'] = null;
508
-            				    $values['owner'] = $line[3];
509
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
511
-					    $values['cancel'] = '';
506
+								$values['registration'] = $line[0];
507
+								$values['base'] = null;
508
+								$values['owner'] = $line[3];
509
+								if ($line[7] == '') $values['date_first_reg'] = null;
510
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
511
+						$values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513
-            				    $values['registration'] = $line[0];
514
-            				    $values['base'] = null;
515
-            				    $values['owner'] = $line[3];
516
-            				    $values['date_first_reg'] = null;
517
-					    $values['cancel'] = '';
518
-					    $values['modes'] = $line[5];
519
-					    $values['icao'] = $line[9];
513
+								$values['registration'] = $line[0];
514
+								$values['base'] = null;
515
+								$values['owner'] = $line[3];
516
+								$values['date_first_reg'] = null;
517
+						$values['cancel'] = '';
518
+						$values['modes'] = $line[5];
519
+						$values['icao'] = $line[9];
520 520
 					} elseif ($country == 'M') {
521
-            				    $values['registration'] = $line[0];
522
-            				    $values['base'] = null;
523
-            				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
526
-					    $values['modes'] = $line[4];
527
-					    $values['icao'] = $line[10];
521
+								$values['registration'] = $line[0];
522
+								$values['base'] = null;
523
+								$values['owner'] = $line[6];
524
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
526
+						$values['modes'] = $line[4];
527
+						$values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529
-            				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
531
-					    $values['modes'] = $line[5];
532
-					    $values['icao'] = $line[6];
529
+								$values['registration'] = $line[0];
530
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
531
+						$values['modes'] = $line[5];
532
+						$values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534
-            				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
536
-					    $values['modes'] = $line[4];
537
-					    $values['icao'] = $line[5];
534
+								$values['registration'] = $line[0];
535
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
536
+						$values['modes'] = $line[4];
537
+						$values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
539
-            				    $values['registration'] = $line[0];
540
-            				    $values['base'] = null;
541
-            				    $values['owner'] = $line[3];
542
-            				    $values['date_first_reg'] = null;
543
-					    $values['cancel'] = '';
539
+								$values['registration'] = $line[0];
540
+								$values['base'] = null;
541
+								$values['owner'] = $line[3];
542
+								$values['date_first_reg'] = null;
543
+						$values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546 546
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
                         return "error : ".$e->getMessage();
674 674
                 }
675 675
                 */
676
-                /*
676
+				/*
677 677
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
678 678
 		try {
679 679
 			$Connection = new Connection();
@@ -918,10 +918,10 @@  discard block
 block discarded – undo
918 918
 		try {
919 919
 			$Connection = new Connection();
920 920
 			$sth = $Connection->db->prepare($query);
921
-                        $sth->execute(array(':source' => 'translation.csv'));
922
-                } catch(PDOException $e) {
923
-                        return "error : ".$e->getMessage();
924
-                }
921
+						$sth->execute(array(':source' => 'translation.csv'));
922
+				} catch(PDOException $e) {
923
+						return "error : ".$e->getMessage();
924
+				}
925 925
 
926 926
 		
927 927
 		//update_db::unzip($out_file);
@@ -940,21 +940,21 @@  discard block
 block discarded – undo
940 940
 					$data = $row;
941 941
 					$operator = $data[2];
942 942
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
943
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
944
-                                                //echo substr($operator, 0, 2)."\n";;
945
-                                                if (count($airline_array) > 0) {
943
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
944
+												//echo substr($operator, 0, 2)."\n";;
945
+												if (count($airline_array) > 0) {
946 946
 							//print_r($airline_array);
947 947
 							$operator = $airline_array[0]['icao'].substr($operator,2);
948
-                                                }
949
-                                        }
948
+												}
949
+										}
950 950
 					
951 951
 					$operator_correct = $data[3];
952 952
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
953
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954
-                                                if (count($airline_array) > 0) {
955
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
956
-                                            	}
957
-                                        }
953
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954
+												if (count($airline_array) > 0) {
955
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
956
+												}
957
+										}
958 958
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
959 959
 					try {
960 960
 						$sth = $Connection->db->prepare($query);
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 			//$Connection->db->commit();
969 969
 		}
970 970
 		return '';
971
-        }
971
+		}
972 972
 	
973 973
 	public static function translation_fam() {
974 974
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -978,10 +978,10 @@  discard block
 block discarded – undo
978 978
 		try {
979 979
 			$Connection = new Connection();
980 980
 			$sth = $Connection->db->prepare($query);
981
-                        $sth->execute(array(':source' => 'website_fam'));
982
-                } catch(PDOException $e) {
983
-                        return "error : ".$e->getMessage();
984
-                }
981
+						$sth->execute(array(':source' => 'website_fam'));
982
+				} catch(PDOException $e) {
983
+						return "error : ".$e->getMessage();
984
+				}
985 985
 
986 986
 		
987 987
 		//update_db::unzip($out_file);
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 			//$Connection->db->commit();
1011 1011
 		}
1012 1012
 		return '';
1013
-        }
1013
+		}
1014 1014
 
1015 1015
 	/*
1016 1016
 	* This function use FAA public data.
@@ -1022,19 +1022,19 @@  discard block
 block discarded – undo
1022 1022
 		try {
1023 1023
 			$Connection = new Connection();
1024 1024
 			$sth = $Connection->db->prepare($query);
1025
-                        $sth->execute(array(':source' => 'website_faa'));
1026
-                } catch(PDOException $e) {
1027
-                        return "error : ".$e->getMessage();
1028
-                }
1025
+						$sth->execute(array(':source' => 'website_faa'));
1026
+				} catch(PDOException $e) {
1027
+						return "error : ".$e->getMessage();
1028
+				}
1029 1029
 
1030 1030
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1031 1031
 		try {
1032 1032
 			$Connection = new Connection();
1033 1033
 			$sth = $Connection->db->prepare($query);
1034
-                        $sth->execute(array(':source' => 'website_faa'));
1035
-                } catch(PDOException $e) {
1036
-                        return "error : ".$e->getMessage();
1037
-                }
1034
+						$sth->execute(array(':source' => 'website_faa'));
1035
+				} catch(PDOException $e) {
1036
+						return "error : ".$e->getMessage();
1037
+				}
1038 1038
 
1039 1039
 		$delimiter = ",";
1040 1040
 		$mfr = array();
@@ -1110,17 +1110,17 @@  discard block
 block discarded – undo
1110 1110
 		}
1111 1111
 		print_r($mfr);
1112 1112
 		return '';
1113
-        }
1113
+		}
1114 1114
 	public static function modes_fam() {
1115 1115
 		global $tmp_dir, $globalTransaction;
1116 1116
 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";
1117 1117
 		try {
1118 1118
 			$Connection = new Connection();
1119 1119
 			$sth = $Connection->db->prepare($query);
1120
-                        $sth->execute(array(':source' => 'website_fam'));
1121
-                } catch(PDOException $e) {
1122
-                        return "error : ".$e->getMessage();
1123
-                }
1120
+						$sth->execute(array(':source' => 'website_fam'));
1121
+				} catch(PDOException $e) {
1122
+						return "error : ".$e->getMessage();
1123
+				}
1124 1124
 
1125 1125
 		
1126 1126
 		//update_db::unzip($out_file);
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 			if ($globalTransaction) $Connection->db->commit();
1151 1151
 		}
1152 1152
 		return '';
1153
-        }
1153
+		}
1154 1154
         
1155 1155
 	public static function owner_fam() {
1156 1156
 		global $tmp_dir, $globalTransaction;
@@ -1158,10 +1158,10 @@  discard block
 block discarded – undo
1158 1158
 		try {
1159 1159
 			$Connection = new Connection();
1160 1160
 			$sth = $Connection->db->prepare($query);
1161
-                        $sth->execute(array(':source' => 'website_fam'));
1162
-                } catch(PDOException $e) {
1163
-                        return "error : ".$e->getMessage();
1164
-                }
1161
+						$sth->execute(array(':source' => 'website_fam'));
1162
+				} catch(PDOException $e) {
1163
+						return "error : ".$e->getMessage();
1164
+				}
1165 1165
 
1166 1166
 		$delimiter = "\t";
1167 1167
 		$Connection = new Connection();
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 			if ($globalTransaction) $Connection->db->commit();
1188 1188
 		}
1189 1189
 		return '';
1190
-        }
1190
+		}
1191 1191
 
1192 1192
 	public static function routes_fam() {
1193 1193
 		global $tmp_dir, $globalTransaction, $globalDebug;
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 			if ($globalTransaction) $Connection->db->commit();
1223 1223
 		}
1224 1224
 		return '';
1225
-        }
1225
+		}
1226 1226
 
1227 1227
 	public static function marine_identity_fam() {
1228 1228
 		global $tmp_dir, $globalTransaction;
@@ -1230,10 +1230,10 @@  discard block
 block discarded – undo
1230 1230
 		try {
1231 1231
 			$Connection = new Connection();
1232 1232
 			$sth = $Connection->db->prepare($query);
1233
-                        $sth->execute();
1234
-                } catch(PDOException $e) {
1235
-                        return "error : ".$e->getMessage();
1236
-                }
1233
+						$sth->execute();
1234
+				} catch(PDOException $e) {
1235
+						return "error : ".$e->getMessage();
1236
+				}
1237 1237
 
1238 1238
 		
1239 1239
 		//update_db::unzip($out_file);
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
 			if ($globalTransaction) $Connection->db->commit();
1264 1264
 		}
1265 1265
 		return '';
1266
-        }
1266
+		}
1267 1267
 
1268 1268
 	public static function banned_fam() {
1269 1269
 		global $tmp_dir, $globalTransaction;
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 			if ($globalTransaction) $Connection->db->commit();
1298 1298
 		}
1299 1299
 		return '';
1300
-        }
1300
+		}
1301 1301
 
1302 1302
 	public static function tle($filename,$tletype) {
1303 1303
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1308,10 +1308,10 @@  discard block
 block discarded – undo
1308 1308
 		try {
1309 1309
 			$Connection = new Connection();
1310 1310
 			$sth = $Connection->db->prepare($query);
1311
-                        $sth->execute(array(':source' => $filename));
1312
-                } catch(PDOException $e) {
1313
-                        return "error : ".$e->getMessage();
1314
-                }
1311
+						$sth->execute(array(':source' => $filename));
1312
+				} catch(PDOException $e) {
1313
+						return "error : ".$e->getMessage();
1314
+				}
1315 1315
 		
1316 1316
 		$Connection = new Connection();
1317 1317
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1346,54 +1346,54 @@  discard block
 block discarded – undo
1346 1346
 			//$Connection->db->commit();
1347 1347
 		}
1348 1348
 		return '';
1349
-        }
1349
+		}
1350 1350
 
1351 1351
 	/**
1352
-        * Convert a HTML table to an array
1353
-        * @param String $data HTML page
1354
-        * @return Array array of the tables in HTML page
1355
-        */
1356
-        private static function table2array($data) {
1357
-                $html = str_get_html($data);
1358
-                $tabledata=array();
1359
-                foreach($html->find('tr') as $element)
1360
-                {
1361
-                        $td = array();
1362
-                        foreach( $element->find('th') as $row)
1363
-                        {
1364
-                                $td [] = trim($row->plaintext);
1365
-                        }
1366
-                        $td=array_filter($td);
1367
-                        $tabledata[] = $td;
1368
-
1369
-                        $td = array();
1370
-                        $tdi = array();
1371
-                        foreach( $element->find('td') as $row)
1372
-                        {
1373
-                                $td [] = trim($row->plaintext);
1374
-                                $tdi [] = trim($row->innertext);
1375
-                        }
1376
-                        $td=array_filter($td);
1377
-                        $tdi=array_filter($tdi);
1378
-                    //    $tabledata[]=array_merge($td,$tdi);
1379
-                        $tabledata[]=$td;
1380
-                }
1381
-                return(array_filter($tabledata));
1382
-        }
1383
-
1384
-       /**
1385
-        * Get data from form result
1386
-        * @param String $url form URL
1387
-        * @return String the result
1388
-        */
1389
-        private static function getData($url) {
1390
-                $ch = curl_init();
1391
-                curl_setopt($ch, CURLOPT_URL, $url);
1392
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1393
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1394
-                curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
1395
-                return curl_exec($ch);
1396
-        }
1352
+	 * Convert a HTML table to an array
1353
+	 * @param String $data HTML page
1354
+	 * @return Array array of the tables in HTML page
1355
+	 */
1356
+		private static function table2array($data) {
1357
+				$html = str_get_html($data);
1358
+				$tabledata=array();
1359
+				foreach($html->find('tr') as $element)
1360
+				{
1361
+						$td = array();
1362
+						foreach( $element->find('th') as $row)
1363
+						{
1364
+								$td [] = trim($row->plaintext);
1365
+						}
1366
+						$td=array_filter($td);
1367
+						$tabledata[] = $td;
1368
+
1369
+						$td = array();
1370
+						$tdi = array();
1371
+						foreach( $element->find('td') as $row)
1372
+						{
1373
+								$td [] = trim($row->plaintext);
1374
+								$tdi [] = trim($row->innertext);
1375
+						}
1376
+						$td=array_filter($td);
1377
+						$tdi=array_filter($tdi);
1378
+					//    $tabledata[]=array_merge($td,$tdi);
1379
+						$tabledata[]=$td;
1380
+				}
1381
+				return(array_filter($tabledata));
1382
+		}
1383
+
1384
+	   /**
1385
+	    * Get data from form result
1386
+	    * @param String $url form URL
1387
+	    * @return String the result
1388
+	    */
1389
+		private static function getData($url) {
1390
+				$ch = curl_init();
1391
+				curl_setopt($ch, CURLOPT_URL, $url);
1392
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1393
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1394
+				curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
1395
+				return curl_exec($ch);
1396
+		}
1397 1397
 /*
1398 1398
 	public static function waypoints() {
1399 1399
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -1476,7 +1476,7 @@  discard block
 block discarded – undo
1476 1476
 			if ($globalTransaction) $Connection->db->commit();
1477 1477
 		}
1478 1478
 		return '';
1479
-        }
1479
+		}
1480 1480
 
1481 1481
 	public static function ivao_airlines($filename) {
1482 1482
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1486,10 +1486,10 @@  discard block
 block discarded – undo
1486 1486
 		try {
1487 1487
 			$Connection = new Connection();
1488 1488
 			$sth = $Connection->db->prepare($query);
1489
-                        $sth->execute();
1490
-                } catch(PDOException $e) {
1491
-                        return "error : ".$e->getMessage();
1492
-                }
1489
+						$sth->execute();
1490
+				} catch(PDOException $e) {
1491
+						return "error : ".$e->getMessage();
1492
+				}
1493 1493
 
1494 1494
 		$header = NULL;
1495 1495
 		$delimiter = ':';
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
 			if ($globalTransaction) $Connection->db->commit();
1514 1514
 		}
1515 1515
 		return '';
1516
-        }
1516
+		}
1517 1517
 	
1518 1518
 	public static function update_airspace() {
1519 1519
 		global $tmp_dir, $globalDBdriver;
@@ -1523,11 +1523,11 @@  discard block
 block discarded – undo
1523 1523
 			$query = 'DROP TABLE airspace';
1524 1524
 			try {
1525 1525
 				$sth = $Connection->db->prepare($query);
1526
-                    		$sth->execute();
1527
-	                } catch(PDOException $e) {
1526
+							$sth->execute();
1527
+					} catch(PDOException $e) {
1528 1528
 				return "error : ".$e->getMessage();
1529
-	                }
1530
-	        }
1529
+					}
1530
+			}
1531 1531
 
1532 1532
 
1533 1533
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1582,10 +1582,10 @@  discard block
 block discarded – undo
1582 1582
 			$query = 'DROP TABLE countries';
1583 1583
 			try {
1584 1584
 				$sth = $Connection->db->prepare($query);
1585
-            	        	$sth->execute();
1586
-	                } catch(PDOException $e) {
1587
-    	                	echo "error : ".$e->getMessage();
1588
-	                }
1585
+							$sth->execute();
1586
+					} catch(PDOException $e) {
1587
+							echo "error : ".$e->getMessage();
1588
+					}
1589 1589
 		}
1590 1590
 		if ($globalDBdriver == 'mysql') {
1591 1591
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2114,11 +2114,11 @@  discard block
 block discarded – undo
2114 2114
 						$query = 'DROP TABLE airspace';
2115 2115
 						try {
2116 2116
 							$sth = $Connection->db->prepare($query);
2117
-    	    	    					$sth->execute();
2118
-			            		} catch(PDOException $e) {
2117
+										$sth->execute();
2118
+								} catch(PDOException $e) {
2119 2119
 							return "error : ".$e->getMessage();
2120
-		            			}
2121
-		    			}
2120
+								}
2121
+						}
2122 2122
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2123 2123
 					update_db::insert_airspace_version($airspace_md5);
2124 2124
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -2300,12 +2300,12 @@  discard block
 block discarded – undo
2300 2300
 		echo $data;
2301 2301
 		*/
2302 2302
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2303
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2304
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2305
-		    $result = fread($fh,100000000);
2306
-		    //echo $result;
2307
-		    //var_dump(str_get_html($result));
2308
-		    //print_r(self::table2array($result));
2303
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2304
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
2305
+			$result = fread($fh,100000000);
2306
+			//echo $result;
2307
+			//var_dump(str_get_html($result));
2308
+			//print_r(self::table2array($result));
2309 2309
 		}
2310 2310
 
2311 2311
 	}
@@ -2319,10 +2319,10 @@  discard block
 block discarded – undo
2319 2319
 		try {
2320 2320
 			$Connection = new Connection();
2321 2321
 			$sth = $Connection->db->prepare($query);
2322
-                        $sth->execute();
2323
-                } catch(PDOException $e) {
2324
-                        return "error : ".$e->getMessage();
2325
-                }
2322
+						$sth->execute();
2323
+				} catch(PDOException $e) {
2324
+						return "error : ".$e->getMessage();
2325
+				}
2326 2326
 
2327 2327
 		$error = '';
2328 2328
 		if ($globalDebug) echo "Notam : Download...";
@@ -2378,8 +2378,8 @@  discard block
 block discarded – undo
2378 2378
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2379 2379
 					$data['permanent'] = 0;
2380 2380
 				} else {
2381
-				    $data['date_end'] = NULL;
2382
-				    $data['permanent'] = 1;
2381
+					$data['date_end'] = NULL;
2382
+					$data['permanent'] = 1;
2383 2383
 				}
2384 2384
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2385 2385
 				$NOTAM = new NOTAM();
@@ -2453,13 +2453,13 @@  discard block
 block discarded – undo
2453 2453
 		try {
2454 2454
 			$Connection = new Connection();
2455 2455
 			$sth = $Connection->db->prepare($query);
2456
-                        $sth->execute();
2457
-                } catch(PDOException $e) {
2458
-                        return "error : ".$e->getMessage();
2459
-                }
2460
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2461
-                if ($row['nb'] > 0) return false;
2462
-                else return true;
2456
+						$sth->execute();
2457
+				} catch(PDOException $e) {
2458
+						return "error : ".$e->getMessage();
2459
+				}
2460
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2461
+				if ($row['nb'] > 0) return false;
2462
+				else return true;
2463 2463
 	}
2464 2464
 
2465 2465
 	public static function insert_last_update() {
@@ -2468,10 +2468,10 @@  discard block
 block discarded – undo
2468 2468
 		try {
2469 2469
 			$Connection = new Connection();
2470 2470
 			$sth = $Connection->db->prepare($query);
2471
-                        $sth->execute();
2472
-                } catch(PDOException $e) {
2473
-                        return "error : ".$e->getMessage();
2474
-                }
2471
+						$sth->execute();
2472
+				} catch(PDOException $e) {
2473
+						return "error : ".$e->getMessage();
2474
+				}
2475 2475
 	}
2476 2476
 
2477 2477
 	public static function check_airspace_version($version) {
@@ -2479,13 +2479,13 @@  discard block
 block discarded – undo
2479 2479
 		try {
2480 2480
 			$Connection = new Connection();
2481 2481
 			$sth = $Connection->db->prepare($query);
2482
-                        $sth->execute(array(':version' => $version));
2483
-                } catch(PDOException $e) {
2484
-                        return "error : ".$e->getMessage();
2485
-                }
2486
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2487
-                if ($row['nb'] > 0) return true;
2488
-                else return false;
2482
+						$sth->execute(array(':version' => $version));
2483
+				} catch(PDOException $e) {
2484
+						return "error : ".$e->getMessage();
2485
+				}
2486
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2487
+				if ($row['nb'] > 0) return true;
2488
+				else return false;
2489 2489
 	}
2490 2490
 
2491 2491
 	public static function check_geoid_version($version) {
@@ -2493,13 +2493,13 @@  discard block
 block discarded – undo
2493 2493
 		try {
2494 2494
 			$Connection = new Connection();
2495 2495
 			$sth = $Connection->db->prepare($query);
2496
-                        $sth->execute(array(':version' => $version));
2497
-                } catch(PDOException $e) {
2498
-                        return "error : ".$e->getMessage();
2499
-                }
2500
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2501
-                if ($row['nb'] > 0) return true;
2502
-                else return false;
2496
+						$sth->execute(array(':version' => $version));
2497
+				} catch(PDOException $e) {
2498
+						return "error : ".$e->getMessage();
2499
+				}
2500
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2501
+				if ($row['nb'] > 0) return true;
2502
+				else return false;
2503 2503
 	}
2504 2504
 
2505 2505
 	public static function check_marine_identity_version($version) {
@@ -2507,13 +2507,13 @@  discard block
 block discarded – undo
2507 2507
 		try {
2508 2508
 			$Connection = new Connection();
2509 2509
 			$sth = $Connection->db->prepare($query);
2510
-                        $sth->execute(array(':version' => $version));
2511
-                } catch(PDOException $e) {
2512
-                        return "error : ".$e->getMessage();
2513
-                }
2514
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2515
-                if ($row['nb'] > 0) return true;
2516
-                else return false;
2510
+						$sth->execute(array(':version' => $version));
2511
+				} catch(PDOException $e) {
2512
+						return "error : ".$e->getMessage();
2513
+				}
2514
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2515
+				if ($row['nb'] > 0) return true;
2516
+				else return false;
2517 2517
 	}
2518 2518
 
2519 2519
 
@@ -2535,10 +2535,10 @@  discard block
 block discarded – undo
2535 2535
 		try {
2536 2536
 			$Connection = new Connection();
2537 2537
 			$sth = $Connection->db->prepare($query);
2538
-                        $sth->execute(array(':version' => $version));
2539
-                } catch(PDOException $e) {
2540
-                        return "error : ".$e->getMessage();
2541
-                }
2538
+						$sth->execute(array(':version' => $version));
2539
+				} catch(PDOException $e) {
2540
+						return "error : ".$e->getMessage();
2541
+				}
2542 2542
 	}
2543 2543
 
2544 2544
 	public static function insert_marine_identity_version($version) {
@@ -2547,10 +2547,10 @@  discard block
 block discarded – undo
2547 2547
 		try {
2548 2548
 			$Connection = new Connection();
2549 2549
 			$sth = $Connection->db->prepare($query);
2550
-                        $sth->execute(array(':version' => $version));
2551
-                } catch(PDOException $e) {
2552
-                        return "error : ".$e->getMessage();
2553
-                }
2550
+						$sth->execute(array(':version' => $version));
2551
+				} catch(PDOException $e) {
2552
+						return "error : ".$e->getMessage();
2553
+				}
2554 2554
 	}
2555 2555
 
2556 2556
 	public static function check_last_notam_update() {
@@ -2563,13 +2563,13 @@  discard block
 block discarded – undo
2563 2563
 		try {
2564 2564
 			$Connection = new Connection();
2565 2565
 			$sth = $Connection->db->prepare($query);
2566
-                        $sth->execute();
2567
-                } catch(PDOException $e) {
2568
-                        return "error : ".$e->getMessage();
2569
-                }
2570
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2571
-                if ($row['nb'] > 0) return false;
2572
-                else return true;
2566
+						$sth->execute();
2567
+				} catch(PDOException $e) {
2568
+						return "error : ".$e->getMessage();
2569
+				}
2570
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2571
+				if ($row['nb'] > 0) return false;
2572
+				else return true;
2573 2573
 	}
2574 2574
 
2575 2575
 	public static function insert_last_notam_update() {
@@ -2578,10 +2578,10 @@  discard block
 block discarded – undo
2578 2578
 		try {
2579 2579
 			$Connection = new Connection();
2580 2580
 			$sth = $Connection->db->prepare($query);
2581
-                        $sth->execute();
2582
-                } catch(PDOException $e) {
2583
-                        return "error : ".$e->getMessage();
2584
-                }
2581
+						$sth->execute();
2582
+				} catch(PDOException $e) {
2583
+						return "error : ".$e->getMessage();
2584
+				}
2585 2585
 	}
2586 2586
 
2587 2587
 	public static function check_last_airspace_update() {
@@ -2594,13 +2594,13 @@  discard block
 block discarded – undo
2594 2594
 		try {
2595 2595
 			$Connection = new Connection();
2596 2596
 			$sth = $Connection->db->prepare($query);
2597
-                        $sth->execute();
2598
-                } catch(PDOException $e) {
2599
-                        return "error : ".$e->getMessage();
2600
-                }
2601
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2602
-                if ($row['nb'] > 0) return false;
2603
-                else return true;
2597
+						$sth->execute();
2598
+				} catch(PDOException $e) {
2599
+						return "error : ".$e->getMessage();
2600
+				}
2601
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2602
+				if ($row['nb'] > 0) return false;
2603
+				else return true;
2604 2604
 	}
2605 2605
 
2606 2606
 	public static function insert_last_airspace_update() {
@@ -2609,10 +2609,10 @@  discard block
 block discarded – undo
2609 2609
 		try {
2610 2610
 			$Connection = new Connection();
2611 2611
 			$sth = $Connection->db->prepare($query);
2612
-                        $sth->execute();
2613
-                } catch(PDOException $e) {
2614
-                        return "error : ".$e->getMessage();
2615
-                }
2612
+						$sth->execute();
2613
+				} catch(PDOException $e) {
2614
+						return "error : ".$e->getMessage();
2615
+				}
2616 2616
 	}
2617 2617
 
2618 2618
 	public static function check_last_geoid_update() {
@@ -2625,13 +2625,13 @@  discard block
 block discarded – undo
2625 2625
 		try {
2626 2626
 			$Connection = new Connection();
2627 2627
 			$sth = $Connection->db->prepare($query);
2628
-                        $sth->execute();
2629
-                } catch(PDOException $e) {
2630
-                        return "error : ".$e->getMessage();
2631
-                }
2632
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2633
-                if ($row['nb'] > 0) return false;
2634
-                else return true;
2628
+						$sth->execute();
2629
+				} catch(PDOException $e) {
2630
+						return "error : ".$e->getMessage();
2631
+				}
2632
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2633
+				if ($row['nb'] > 0) return false;
2634
+				else return true;
2635 2635
 	}
2636 2636
 
2637 2637
 	public static function insert_last_geoid_update() {
@@ -2640,10 +2640,10 @@  discard block
 block discarded – undo
2640 2640
 		try {
2641 2641
 			$Connection = new Connection();
2642 2642
 			$sth = $Connection->db->prepare($query);
2643
-                        $sth->execute();
2644
-                } catch(PDOException $e) {
2645
-                        return "error : ".$e->getMessage();
2646
-                }
2643
+						$sth->execute();
2644
+				} catch(PDOException $e) {
2645
+						return "error : ".$e->getMessage();
2646
+				}
2647 2647
 	}
2648 2648
 
2649 2649
 	public static function check_last_owner_update() {
@@ -2656,13 +2656,13 @@  discard block
 block discarded – undo
2656 2656
 		try {
2657 2657
 			$Connection = new Connection();
2658 2658
 			$sth = $Connection->db->prepare($query);
2659
-                        $sth->execute();
2660
-                } catch(PDOException $e) {
2661
-                        return "error : ".$e->getMessage();
2662
-                }
2663
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2664
-                if ($row['nb'] > 0) return false;
2665
-                else return true;
2659
+						$sth->execute();
2660
+				} catch(PDOException $e) {
2661
+						return "error : ".$e->getMessage();
2662
+				}
2663
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2664
+				if ($row['nb'] > 0) return false;
2665
+				else return true;
2666 2666
 	}
2667 2667
 
2668 2668
 	public static function insert_last_owner_update() {
@@ -2671,10 +2671,10 @@  discard block
 block discarded – undo
2671 2671
 		try {
2672 2672
 			$Connection = new Connection();
2673 2673
 			$sth = $Connection->db->prepare($query);
2674
-                        $sth->execute();
2675
-                } catch(PDOException $e) {
2676
-                        return "error : ".$e->getMessage();
2677
-                }
2674
+						$sth->execute();
2675
+				} catch(PDOException $e) {
2676
+						return "error : ".$e->getMessage();
2677
+				}
2678 2678
 	}
2679 2679
 	public static function check_last_schedules_update() {
2680 2680
 		global $globalDBdriver;
@@ -2686,13 +2686,13 @@  discard block
 block discarded – undo
2686 2686
 		try {
2687 2687
 			$Connection = new Connection();
2688 2688
 			$sth = $Connection->db->prepare($query);
2689
-                        $sth->execute();
2690
-                } catch(PDOException $e) {
2691
-                        return "error : ".$e->getMessage();
2692
-                }
2693
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2694
-                if ($row['nb'] > 0) return false;
2695
-                else return true;
2689
+						$sth->execute();
2690
+				} catch(PDOException $e) {
2691
+						return "error : ".$e->getMessage();
2692
+				}
2693
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2694
+				if ($row['nb'] > 0) return false;
2695
+				else return true;
2696 2696
 	}
2697 2697
 
2698 2698
 	public static function insert_last_schedules_update() {
@@ -2701,10 +2701,10 @@  discard block
 block discarded – undo
2701 2701
 		try {
2702 2702
 			$Connection = new Connection();
2703 2703
 			$sth = $Connection->db->prepare($query);
2704
-                        $sth->execute();
2705
-                } catch(PDOException $e) {
2706
-                        return "error : ".$e->getMessage();
2707
-                }
2704
+						$sth->execute();
2705
+				} catch(PDOException $e) {
2706
+						return "error : ".$e->getMessage();
2707
+				}
2708 2708
 	}
2709 2709
 	public static function check_last_tle_update() {
2710 2710
 		global $globalDBdriver;
@@ -2716,13 +2716,13 @@  discard block
 block discarded – undo
2716 2716
 		try {
2717 2717
 			$Connection = new Connection();
2718 2718
 			$sth = $Connection->db->prepare($query);
2719
-                        $sth->execute();
2720
-                } catch(PDOException $e) {
2721
-                        return "error : ".$e->getMessage();
2722
-                }
2723
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2724
-                if ($row['nb'] > 0) return false;
2725
-                else return true;
2719
+						$sth->execute();
2720
+				} catch(PDOException $e) {
2721
+						return "error : ".$e->getMessage();
2722
+				}
2723
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2724
+				if ($row['nb'] > 0) return false;
2725
+				else return true;
2726 2726
 	}
2727 2727
 
2728 2728
 	public static function insert_last_tle_update() {
@@ -2731,10 +2731,10 @@  discard block
 block discarded – undo
2731 2731
 		try {
2732 2732
 			$Connection = new Connection();
2733 2733
 			$sth = $Connection->db->prepare($query);
2734
-                        $sth->execute();
2735
-                } catch(PDOException $e) {
2736
-                        return "error : ".$e->getMessage();
2737
-                }
2734
+						$sth->execute();
2735
+				} catch(PDOException $e) {
2736
+						return "error : ".$e->getMessage();
2737
+				}
2738 2738
 	}
2739 2739
 	public static function check_last_marine_identity_update() {
2740 2740
 		global $globalDBdriver;
@@ -2746,13 +2746,13 @@  discard block
 block discarded – undo
2746 2746
 		try {
2747 2747
 			$Connection = new Connection();
2748 2748
 			$sth = $Connection->db->prepare($query);
2749
-                        $sth->execute();
2750
-                } catch(PDOException $e) {
2751
-                        return "error : ".$e->getMessage();
2752
-                }
2753
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2754
-                if ($row['nb'] > 0) return false;
2755
-                else return true;
2749
+						$sth->execute();
2750
+				} catch(PDOException $e) {
2751
+						return "error : ".$e->getMessage();
2752
+				}
2753
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2754
+				if ($row['nb'] > 0) return false;
2755
+				else return true;
2756 2756
 	}
2757 2757
 
2758 2758
 	public static function insert_last_marine_identity_update() {
@@ -2761,10 +2761,10 @@  discard block
 block discarded – undo
2761 2761
 		try {
2762 2762
 			$Connection = new Connection();
2763 2763
 			$sth = $Connection->db->prepare($query);
2764
-                        $sth->execute();
2765
-                } catch(PDOException $e) {
2766
-                        return "error : ".$e->getMessage();
2767
-                }
2764
+						$sth->execute();
2765
+				} catch(PDOException $e) {
2766
+						return "error : ".$e->getMessage();
2767
+				}
2768 2768
 	}
2769 2769
 	public static function delete_duplicatemodes() {
2770 2770
 		global $globalDBdriver;
@@ -2776,10 +2776,10 @@  discard block
 block discarded – undo
2776 2776
 		try {
2777 2777
 			$Connection = new Connection();
2778 2778
 			$sth = $Connection->db->prepare($query);
2779
-                        $sth->execute();
2780
-                } catch(PDOException $e) {
2781
-                        return "error : ".$e->getMessage();
2782
-                }
2779
+						$sth->execute();
2780
+				} catch(PDOException $e) {
2781
+						return "error : ".$e->getMessage();
2782
+				}
2783 2783
 	}
2784 2784
 	public static function delete_duplicateowner() {
2785 2785
 		global $globalDBdriver;
@@ -2791,10 +2791,10 @@  discard block
 block discarded – undo
2791 2791
 		try {
2792 2792
 			$Connection = new Connection();
2793 2793
 			$sth = $Connection->db->prepare($query);
2794
-                        $sth->execute();
2795
-                } catch(PDOException $e) {
2796
-                        return "error : ".$e->getMessage();
2797
-                }
2794
+						$sth->execute();
2795
+				} catch(PDOException $e) {
2796
+						return "error : ".$e->getMessage();
2797
+				}
2798 2798
 	}
2799 2799
 	
2800 2800
 	public static function update_all() {
Please login to merge, or discard this patch.
require/class.ACARS.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
 		$this->SI = new SpotterImport($this->db);
17 17
 	}
18 18
 	/**
19
-	* Change IATA to ICAO value for ident
20
-	*
21
-	* @param String $ident ident
22
-	* @return String the icao
23
-	*/
19
+	 * Change IATA to ICAO value for ident
20
+	 *
21
+	 * @param String $ident ident
22
+	 * @return String the icao
23
+	 */
24 24
 	public function ident2icao($ident) {
25 25
 		if (substr($ident,0,2) == 'AF') {
26 26
 			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	/**
39
-	* Deletes all info in the live table
40
-	*
41
-	* @return String success or false
42
-	*
43
-	*/
39
+	 * Deletes all info in the live table
40
+	 *
41
+	 * @return String success or false
42
+	 *
43
+	 */
44 44
 	public function deleteLiveAcarsData()
45 45
 	{
46 46
 		global $globalDBdriver;
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 
62 62
 	/**
63
-	* Deletes all info in the archive table
64
-	*
65
-	* @return String success or false
66
-	*
67
-	*/
63
+	 * Deletes all info in the archive table
64
+	 *
65
+	 * @return String success or false
66
+	 *
67
+	 */
68 68
 	public function deleteArchiveAcarsData()
69 69
 	{
70 70
 		global $globalACARSArchiveKeepMonths, $globalDBdriver;
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 
86 86
 
87 87
 	/**
88
-	* Parse ACARS data
89
-	*
90
-	* @param String ACARS data in acarsdec data
91
-	*
92
-	*/
88
+	 * Parse ACARS data
89
+	 *
90
+	 * @param String ACARS data in acarsdec data
91
+	 *
92
+	 */
93 93
 	public function parse($data) {
94 94
 		global $globalDebug, $globalACARSArchive;
95 95
 		//$Image = new Image($this->db);
@@ -719,11 +719,11 @@  discard block
 block discarded – undo
719 719
 	}
720 720
 
721 721
 	/**
722
-	* Add ACARS data
723
-	*
724
-	* @param String ACARS data in acarsdec data
725
-	*
726
-	*/
722
+	 * Add ACARS data
723
+	 *
724
+	 * @param String ACARS data in acarsdec data
725
+	 *
726
+	 */
727 727
 	function add($data) {
728 728
 		global $globalDebug, $globalACARSArchive;
729 729
 		$Image = new Image($this->db);
@@ -770,15 +770,15 @@  discard block
 block discarded – undo
770 770
 	}
771 771
 
772 772
 	/**
773
-	* Add Live ACARS data in DB
774
-	*
775
-	* @param String $ident ident
776
-	* @param String $registration Registration of the aircraft
777
-	* @param String $label Label of the ACARS message
778
-	* @param String $block_id Block id of the ACARS message
779
-	* @param String $msg_no Number of the ACARS message
780
-	* @param String $message ACARS message
781
-	*/
773
+	 * Add Live ACARS data in DB
774
+	 *
775
+	 * @param String $ident ident
776
+	 * @param String $registration Registration of the aircraft
777
+	 * @param String $label Label of the ACARS message
778
+	 * @param String $block_id Block id of the ACARS message
779
+	 * @param String $msg_no Number of the ACARS message
780
+	 * @param String $message ACARS message
781
+	 */
782 782
 	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
783 783
 		global $globalDebug;
784 784
 		date_default_timezone_set('UTC');
@@ -814,15 +814,15 @@  discard block
 block discarded – undo
814 814
 	}
815 815
 
816 816
 	/**
817
-	* Add Archive ACARS data in DB
818
-	*
819
-	* @param String $ident ident
820
-	* @param String $registration Registration of the aircraft
821
-	* @param String $label Label of the ACARS message
822
-	* @param String $block_id Block id of the ACARS message
823
-	* @param String $msg_no Number of the ACARS message
824
-	* @param String $message ACARS message
825
-	*/
817
+	 * Add Archive ACARS data in DB
818
+	 *
819
+	 * @param String $ident ident
820
+	 * @param String $registration Registration of the aircraft
821
+	 * @param String $label Label of the ACARS message
822
+	 * @param String $block_id Block id of the ACARS message
823
+	 * @param String $msg_no Number of the ACARS message
824
+	 * @param String $message ACARS message
825
+	 */
826 826
 	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
827 827
 		global $globalDebug;
828 828
 		date_default_timezone_set('UTC');
@@ -853,11 +853,11 @@  discard block
 block discarded – undo
853 853
 	}
854 854
 
855 855
 	/**
856
-	* Get Message title from label from DB
857
-	*
858
-	* @param String $label
859
-	* @return String Return ACARS title
860
-	*/
856
+	 * Get Message title from label from DB
857
+	 *
858
+	 * @param String $label
859
+	 * @return String Return ACARS title
860
+	 */
861 861
 	public function getTitlefromLabel($label) {
862 862
 		$Connection = new Connection($this->db);
863 863
 		$this->db = $Connection->db;
@@ -876,10 +876,10 @@  discard block
 block discarded – undo
876 876
 	}
877 877
 
878 878
 	/**
879
-	* List all Message title & label from DB
880
-	*
881
-	* @return Array Return ACARS data in array
882
-	*/
879
+	 * List all Message title & label from DB
880
+	 *
881
+	 * @return Array Return ACARS data in array
882
+	 */
883 883
 	public function getAllTitleLabel() {
884 884
 		$query = "SELECT * FROM acars_label ORDER BY title";
885 885
 		$query_values = array();
@@ -896,11 +896,11 @@  discard block
 block discarded – undo
896 896
 	}
897 897
 
898 898
 	/**
899
-	* Get Live ACARS data from DB
900
-	*
901
-	* @param String $ident
902
-	* @return Array Return ACARS data in array
903
-	*/
899
+	 * Get Live ACARS data from DB
900
+	 *
901
+	 * @param String $ident
902
+	 * @return Array Return ACARS data in array
903
+	 */
904 904
 	public function getLiveAcarsData($ident) {
905 905
 		$query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC";
906 906
 		$query_values = array(':ident' => $ident);
@@ -917,10 +917,10 @@  discard block
 block discarded – undo
917 917
 	}
918 918
 
919 919
 	/**
920
-	* Get Latest ACARS data from DB
921
-	*
922
-	* @return Array Return ACARS data in array
923
-	*/
920
+	 * Get Latest ACARS data from DB
921
+	 *
922
+	 * @return Array Return ACARS data in array
923
+	 */
924 924
 	public function getLatestAcarsData($limit = '',$label = '') {
925 925
 		global $globalURL, $globalDBdriver;
926 926
 		$Image = new Image($this->db);
@@ -1008,10 +1008,10 @@  discard block
 block discarded – undo
1008 1008
 	}
1009 1009
 
1010 1010
 	/**
1011
-	* Get Archive ACARS data from DB
1012
-	*
1013
-	* @return Array Return ACARS data in array
1014
-	*/
1011
+	 * Get Archive ACARS data from DB
1012
+	 *
1013
+	 * @return Array Return ACARS data in array
1014
+	 */
1015 1015
 	public function getArchiveAcarsData($limit = '',$label = '') {
1016 1016
 		global $globalURL, $globalDBdriver;
1017 1017
 		$Image = new Image($this->db);
@@ -1099,13 +1099,13 @@  discard block
 block discarded – undo
1099 1099
 	}
1100 1100
 
1101 1101
 	/**
1102
-	* Add ModeS data to DB
1103
-	*
1104
-	* @param String $ident ident
1105
-	* @param String $registration Registration of the aircraft
1106
-	* @param String $icao
1107
-	* @param String $ICAOTypeCode
1108
-	*/
1102
+	 * Add ModeS data to DB
1103
+	 *
1104
+	 * @param String $ident ident
1105
+	 * @param String $registration Registration of the aircraft
1106
+	 * @param String $icao
1107
+	 * @param String $ICAOTypeCode
1108
+	 */
1109 1109
 	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1110 1110
 		global $globalDebug, $globalDBdriver;
1111 1111
 		$ident = trim($ident);
Please login to merge, or discard this patch.
require/class.ATC.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@
 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;
19 19
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Indentation   +422 added lines, -422 removed lines patch added patch discarded remove patch
@@ -9,20 +9,20 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 require_once(dirname(__FILE__).'/class.GeoidHeight.php');
11 11
 if (isset($globalServerAPRS) && $globalServerAPRS) {
12
-    require_once(dirname(__FILE__).'/class.APRS.php');
12
+	require_once(dirname(__FILE__).'/class.APRS.php');
13 13
 }
14 14
 
15 15
 class SpotterImport {
16
-    private $all_flights = array();
17
-    private $last_delete_hourly = 0;
18
-    private $last_delete = 0;
19
-    private $stats = array();
20
-    private $tmd = 0;
21
-    private $source_location = array();
22
-    public $db = null;
23
-    public $nb = 0;
16
+	private $all_flights = array();
17
+	private $last_delete_hourly = 0;
18
+	private $last_delete = 0;
19
+	private $stats = array();
20
+	private $tmd = 0;
21
+	private $source_location = array();
22
+	public $db = null;
23
+	public $nb = 0;
24 24
 
25
-    public function __construct($dbc = null) {
25
+	public function __construct($dbc = null) {
26 26
 	global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid;
27 27
 	if (!(isset($globalNoDB) && $globalNoDB)) {
28 28
 		$Connection = new Connection($dbc);
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
38
-		    	$type = $srcst['stats_type'];
37
+			foreach($sourcestat as $srcst) {
38
+				$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40
-			    $source = $srcst['source_name'];
41
-			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
43
-	    		}
44
-		    }
40
+				$source = $srcst['source_name'];
41
+				$data = $srcst['source_data'];
42
+				$this->stats[$currentdate][$source][$type] = json_decode($data,true);
43
+				}
44
+			}
45 45
 		}
46 46
 	}
47 47
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59
-    }
59
+	}
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+	public function get_Schedule($id,$ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -78,42 +78,42 @@  discard block
 block discarded – undo
78 78
 	$operator = $Spotter->getOperator($ident);
79 79
 	$scheduleexist = false;
80 80
 	if ($Schedule->checkSchedule($operator) == 0) {
81
-	    $operator = $Translation->checkTranslation($ident);
82
-	    if ($Schedule->checkSchedule($operator) == 0) {
81
+		$operator = $Translation->checkTranslation($ident);
82
+		if ($Schedule->checkSchedule($operator) == 0) {
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88
-		    // Should also check if route schedule = route from DB
89
-		    if ($schedule['DepartureAirportIATA'] != '') {
85
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88
+			// Should also check if route schedule = route from DB
89
+			if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
91
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92
-			    if (trim($airport_icao) != '') {
91
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92
+				if (trim($airport_icao) != '') {
93 93
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94 94
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
95
-			    }
95
+				}
96
+			}
96 97
 			}
97
-		    }
98
-		    if ($schedule['ArrivalAirportIATA'] != '') {
98
+			if ($schedule['ArrivalAirportIATA'] != '') {
99 99
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
100
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101
-			    if (trim($airport_icao) != '') {
100
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101
+				if (trim($airport_icao) != '') {
102 102
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103 103
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
104
-			    }
104
+				}
105 105
 			}
106
-		    }
107
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
106
+			}
107
+			$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
108 108
 		}
109
-	    } else $scheduleexist = true;
109
+		} else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
111 111
 	// close connection, at least one way will work ?
112
-       if ($scheduleexist) {
112
+	   if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114
-    		$sch = $Schedule->getSchedule($operator);
114
+			$sch = $Schedule->getSchedule($operator);
115 115
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116
-       }
116
+	   }
117 117
 	$Spotter->db = null;
118 118
 	$Schedule->db = null;
119 119
 	$Translation->db = null;
@@ -128,78 +128,78 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 	  */
130 130
 	}
131
-    }
131
+	}
132 132
 
133
-    public function checkAll() {
133
+	public function checkAll() {
134 134
 	global $globalDebug, $globalNoImport;
135 135
 	if ($globalDebug) echo "Update last seen flights data...\n";
136 136
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
137
-	    foreach ($this->all_flights as $key => $flight) {
137
+		foreach ($this->all_flights as $key => $flight) {
138 138
 		if (isset($this->all_flights[$key]['id'])) {
139
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140
-    		    $Spotter = new Spotter($this->db);
141
-        	    $real_arrival = $this->arrival($key);
142
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
143
-        	}
144
-	    }
139
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140
+				$Spotter = new Spotter($this->db);
141
+				$real_arrival = $this->arrival($key);
142
+				if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
143
+			}
144
+		}
145
+	}
145 146
 	}
146
-    }
147 147
 
148
-    public function arrival($key) {
148
+	public function arrival($key) {
149 149
 	global $globalClosestMinDist, $globalDebug;
150 150
 	if ($globalDebug) echo 'Update arrival...'."\n";
151 151
 	$Spotter = new Spotter($this->db);
152
-        $airport_icao = '';
153
-        $airport_time = '';
154
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
152
+		$airport_icao = '';
153
+		$airport_time = '';
154
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
155 155
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
156
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157
-    	    if (isset($closestAirports[0])) {
158
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159
-        	    $airport_icao = $closestAirports[0]['icao'];
160
-        	    $airport_time = $this->all_flights[$key]['datetime'];
161
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
162
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
163
-        	    foreach ($closestAirports as $airport) {
164
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
165
-        		    $airport_icao = $airport['icao'];
166
-        		    $airport_time = $this->all_flights[$key]['datetime'];
167
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
168
-        		    break;
169
-        		}
170
-        	    }
171
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
172
-        		$airport_icao = $closestAirports[0]['icao'];
173
-        		$airport_time = $this->all_flights[$key]['datetime'];
174
-        	} else {
175
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
176
-        	}
177
-    	    } else {
178
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
179
-    	    }
156
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157
+			if (isset($closestAirports[0])) {
158
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159
+				$airport_icao = $closestAirports[0]['icao'];
160
+				$airport_time = $this->all_flights[$key]['datetime'];
161
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
162
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
163
+				foreach ($closestAirports as $airport) {
164
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
165
+					$airport_icao = $airport['icao'];
166
+					$airport_time = $this->all_flights[$key]['datetime'];
167
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
168
+					break;
169
+				}
170
+				}
171
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
172
+				$airport_icao = $closestAirports[0]['icao'];
173
+				$airport_time = $this->all_flights[$key]['datetime'];
174
+			} else {
175
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
176
+			}
177
+			} else {
178
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
179
+			}
180 180
 
181
-        } else {
182
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
183
-        }
184
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185
-    }
181
+		} else {
182
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
183
+		}
184
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185
+	}
186 186
 
187 187
 
188 188
 
189
-    public function del() {
189
+	public function del() {
190 190
 	global $globalDebug, $globalNoImport, $globalNoDB;
191 191
 	// Delete old infos
192 192
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
193 193
 	foreach ($this->all_flights as $key => $flight) {
194
-	    if (isset($flight['lastupdate'])) {
194
+		if (isset($flight['lastupdate'])) {
195 195
 		if ($flight['lastupdate'] < (time()-5900)) {
196
-		    $this->delKey($key);
196
+			$this->delKey($key);
197 197
 		}
198
-	    }
198
+		}
199
+	}
199 200
 	}
200
-    }
201 201
 
202
-    public function delKey($key) {
202
+	public function delKey($key) {
203 203
 	global $globalDebug, $globalNoImport, $globalNoDB;
204 204
 	// Delete old infos
205 205
 	if (isset($this->all_flights[$key]['id'])) {
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
 		}
215 215
 	}
216 216
 	unset($this->all_flights[$key]);
217
-    }
217
+	}
218 218
 
219
-    public function add($line) {
219
+	public function add($line) {
220 220
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass;
221 221
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
222 222
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -242,20 +242,20 @@  discard block
 block discarded – undo
242 242
 	
243 243
 	// SBS format is CSV format
244 244
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245
-	    //print_r($line);
246
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
247
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
245
+		//print_r($line);
246
+		if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
247
+  		if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
248 248
 
249 249
 		// Increment message number
250 250
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
251
-		    $current_date = date('Y-m-d');
252
-		    if (isset($line['source_name'])) $source = $line['source_name'];
253
-		    else $source = '';
254
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
255
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
256
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
257
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
258
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
251
+			$current_date = date('Y-m-d');
252
+			if (isset($line['source_name'])) $source = $line['source_name'];
253
+			else $source = '';
254
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
255
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
256
+				$this->stats[$current_date][$source]['msg']['date'] = time();
257
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
258
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
259 259
 		}
260 260
 		
261 261
 		/*
@@ -271,54 +271,54 @@  discard block
 block discarded – undo
271 271
 		//$this->db = $dbc;
272 272
 
273 273
 		//$hex = trim($line['hex']);
274
-	        if (!isset($line['id'])) $id = trim($line['hex']);
275
-	        else $id = trim($line['id']);
274
+			if (!isset($line['id'])) $id = trim($line['hex']);
275
+			else $id = trim($line['id']);
276 276
 		
277 277
 		if (!isset($this->all_flights[$id])) {
278
-		    if ($globalDebug) echo 'New flight...'."\n";
279
-		    $this->all_flights[$id] = array();
280
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
282
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
283
-		    if (!isset($line['id'])) {
278
+			if ($globalDebug) echo 'New flight...'."\n";
279
+			$this->all_flights[$id] = array();
280
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
282
+			if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
283
+			if (!isset($line['id'])) {
284 284
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
285 285
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
286 286
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
287 287
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
288
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
288
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
+			if ($globalAllFlights !== FALSE) $dataFound = true;
291 291
 		}
292 292
 		if (isset($line['source_type']) && $line['source_type'] != '') {
293
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
293
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
294 294
 		}
295 295
 		
296 296
 		//print_r($this->all_flights);
297 297
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
298
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
299
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
298
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
299
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
300 300
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
301
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
302
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
301
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
302
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
303 303
 			$timeelapsed = microtime(true);
304 304
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
305
-			    $Spotter = new Spotter($this->db);
306
-			    if (isset($this->all_flights[$id]['source_type'])) {
305
+				$Spotter = new Spotter($this->db);
306
+				if (isset($this->all_flights[$id]['source_type'])) {
307 307
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
308
-			    } else {
308
+				} else {
309 309
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
310
-			    }
311
-			    $Spotter->db = null;
312
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
310
+				}
311
+				$Spotter->db = null;
312
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
314 314
 			}
315
-		    }
316
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
317
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
315
+			}
316
+			if ($globalAllFlights !== FALSE) $dataFound = true;
317
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
318 318
 		}
319
-	        if (isset($line['id']) && !isset($line['hex'])) {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
321
-	        }
319
+			if (isset($line['id']) && !isset($line['hex'])) {
320
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
321
+			}
322 322
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
323 323
 			$icao = $line['aircraft_icao'];
324 324
 			$Spotter = new Spotter($this->db);
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 		}
348 348
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
349 349
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
350
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
350
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
351 351
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
352
-		    } else {
352
+			} else {
353 353
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
354 354
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
355 355
 				/*
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 				print_r($line);
359 359
 				*/
360 360
 				return '';
361
-		    }
361
+			}
362 362
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
363 363
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
364 364
 			return '';
@@ -374,21 +374,21 @@  discard block
 block discarded – undo
374 374
 		}
375 375
 
376 376
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
377
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
377
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
378 378
 		}
379 379
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
380
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
380
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
381 381
 		}
382 382
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
383
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
383
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
384 384
 		}
385 385
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
386
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
386
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
387 387
 		}
388 388
  
389 389
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
390 390
 
391
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
391
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
392 392
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
393 393
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
394 394
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -397,23 +397,23 @@  discard block
 block discarded – undo
397 397
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
398 398
 				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
399 399
 			} else {
400
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
401
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
400
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
401
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
402 402
 				$timeelapsed = microtime(true);
403
-            			$Spotter = new Spotter($this->db);
404
-            			$fromsource = NULL;
405
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
406
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
403
+						$Spotter = new Spotter($this->db);
404
+						$fromsource = NULL;
405
+						if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
406
+						elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
407 407
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
408 408
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
409 409
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
410
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
410
+						$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
411 411
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
412 412
 				$Spotter->db = null;
413 413
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
414
-			    }
414
+				}
415 415
 			}
416
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
416
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
417 417
 		    
418 418
 /*
419 419
 		    if (!isset($line['id'])) {
@@ -423,63 +423,63 @@  discard block
 block discarded – undo
423 423
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
424 424
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
425 425
   */
426
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
426
+			if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
427 427
 
428
-		    //$putinarchive = true;
429
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
428
+			//$putinarchive = true;
429
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
430 430
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
431
-		    }
432
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
431
+			}
432
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
433 433
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
434
-		    }
435
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
436
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
437
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
434
+			}
435
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
436
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
437
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
438 438
 			$timeelapsed = microtime(true);
439 439
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
440 440
 				$Spotter = new Spotter($this->db);
441 441
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
442 442
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
443
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
443
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
444 444
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
445
-                        }
446
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
445
+						}
446
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
447 447
 			$timeelapsed = microtime(true);
448 448
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
449
-			    $Spotter = new Spotter($this->db);
450
-			    $route = $Spotter->getRouteInfo(trim($line['ident']));
451
-			    if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
449
+				$Spotter = new Spotter($this->db);
450
+				$route = $Spotter->getRouteInfo(trim($line['ident']));
451
+				if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
452 452
 				$Translation = new Translation($this->db);
453 453
 				$ident = $Translation->checkTranslation(trim($line['ident']));
454 454
 				$route = $Spotter->getRouteInfo($ident);
455 455
 				$Translation->db = null;
456
-			    }
457
-			    $Spotter->db = null;
458
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
459
-                    	}
456
+				}
457
+				$Spotter->db = null;
458
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
459
+						}
460 460
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
461
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
462
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
461
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
462
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
463 463
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
464
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
465
-		    	    }
464
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
465
+					}
466 466
 			}
467 467
 			if (!isset($globalFork)) $globalFork = TRUE;
468 468
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
469 469
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
470 470
 			}
471
-		    }
471
+			}
472 472
 		}
473 473
 
474 474
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
475 475
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
476
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
477
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
478
-		    //$dataFound = true;
476
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
477
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
478
+			//$dataFound = true;
479 479
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
480
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
481
-		    if ($distance > 1000 && $distance < 10000) {
482
-		    // use datetime
480
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
481
+			if ($distance > 1000 && $distance < 10000) {
482
+			// use datetime
483 483
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
484 484
 			$speed = $speed*3.6;
485 485
 			if ($speed < 1000) {
@@ -488,48 +488,48 @@  discard block
 block discarded – undo
488 488
 	  		} else {
489 489
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
490 490
 	  		}
491
-		    }
491
+			}
492 492
 		}
493 493
 
494 494
 
495 495
 
496
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
497
-	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
498
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
499
-	    	    	return false;
500
-	    	    }
501
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
502
-	    	    else unset($timediff);
503
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
504
-	    	    else unset($timediff_archive);
505
-	    	    if ($this->tmd > 5
506
-	    	        || (isset($line['format_source']) 
507
-	    	    	    && $line['format_source'] == 'airwhere' 
508
-	    	    	    && ((!isset($this->all_flights[$id]['latitude']) 
509
-	    	    		|| !isset($this->all_flights[$id]['longitude'])) 
510
-	    	    		|| (isset($this->all_flights[$id]['latitude']) 
511
-	    	    		    && isset($this->all_flights[$id]['longitude']) 
512
-	    	    		    && $this->all_flights[$id]['latitude'] != $line['latitude'] 
513
-	    	    		    && $this->all_flights[$id]['longitude'] != $line['longitude']
514
-	    	    		)
515
-	    	    	    )
516
-	    	    	)
517
-	    		|| (isset($globalVA) && $globalVA) 
518
-	    	    	|| (isset($globalIVAO) && $globalIVAO)
519
-	    	    	|| (isset($globalVATSIM) && $globalVATSIM)
520
-	    	    	|| (isset($globalphpVMS) && $globalphpVMS)
521
-	    	    	|| (isset($globalVAM) && $globalVAM)
522
-	    	    	|| !isset($timediff)
523
-	    	    	|| $timediff > $globalLiveInterval
524
-	    	    	|| ($timediff > 30 
525
-	    	    	    && isset($this->all_flights[$id]['latitude']) 
526
-	    	    	    && isset($this->all_flights[$id]['longitude']) 
527
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
528
-	    	    	    )
529
-	    	    	) {
496
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
497
+				if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
498
+					if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
499
+					return false;
500
+				}
501
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
502
+				else unset($timediff);
503
+				if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
504
+				else unset($timediff_archive);
505
+				if ($this->tmd > 5
506
+					|| (isset($line['format_source']) 
507
+						&& $line['format_source'] == 'airwhere' 
508
+						&& ((!isset($this->all_flights[$id]['latitude']) 
509
+						|| !isset($this->all_flights[$id]['longitude'])) 
510
+						|| (isset($this->all_flights[$id]['latitude']) 
511
+							&& isset($this->all_flights[$id]['longitude']) 
512
+							&& $this->all_flights[$id]['latitude'] != $line['latitude'] 
513
+							&& $this->all_flights[$id]['longitude'] != $line['longitude']
514
+						)
515
+						)
516
+					)
517
+				|| (isset($globalVA) && $globalVA) 
518
+					|| (isset($globalIVAO) && $globalIVAO)
519
+					|| (isset($globalVATSIM) && $globalVATSIM)
520
+					|| (isset($globalphpVMS) && $globalphpVMS)
521
+					|| (isset($globalVAM) && $globalVAM)
522
+					|| !isset($timediff)
523
+					|| $timediff > $globalLiveInterval
524
+					|| ($timediff > 30 
525
+						&& isset($this->all_flights[$id]['latitude']) 
526
+						&& isset($this->all_flights[$id]['longitude']) 
527
+						&& $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
528
+						)
529
+					) {
530 530
 
531 531
 			if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) {
532
-			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
532
+				if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
533 533
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
534 534
 				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
535 535
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
 				$this->all_flights[$id]['putinarchive'] = true;
538 538
 				$this->tmd = 0;
539 539
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
540
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
541
-				    $timeelapsed = microtime(true);
542
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
540
+					if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
541
+					$timeelapsed = microtime(true);
542
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
543 543
 					$Spotter = new Spotter($this->db);
544 544
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
545 545
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
@@ -547,11 +547,11 @@  discard block
 block discarded – undo
547 547
 					$Spotter->db = null;
548 548
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
549 549
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
550
-				    }
550
+					}
551 551
 				}
552 552
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
553
-			    } 
554
-			    /*
553
+				} 
554
+				/*
555 555
 			    else {
556 556
 				if (!isset($timediff)) echo 'NO TIMEDIFF';
557 557
 				else {
@@ -565,16 +565,16 @@  discard block
 block discarded – undo
565 565
 			}
566 566
 
567 567
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
568
-			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
568
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
569 569
 				if (!isset($this->all_flights[$id]['archive_latitude'])) {
570 570
 					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
571 571
 					$this->all_flights[$id]['time_last_coord'] = time();
572 572
 				}
573 573
 				//if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
574 574
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
575
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
576
-				    $dataFound = true;
577
-				    $this->all_flights[$id]['time_last_coord'] = time();
575
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
576
+					$dataFound = true;
577
+					$this->all_flights[$id]['time_last_coord'] = time();
578 578
 				}
579 579
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
580 580
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -585,24 +585,24 @@  discard block
 block discarded – undo
585 585
 				    //$putinarchive = true;
586 586
 				}
587 587
 				*/
588
-			    /*
588
+				/*
589 589
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
590 590
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
591 591
 			    }
592 592
 			    */
593 593
 			}
594 594
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
595
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
596
-			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
595
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
596
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
597 597
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
598 598
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
599 599
 					$this->all_flights[$id]['time_last_coord'] = time();
600 600
 				}
601 601
 				//if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
602 602
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
603
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
604
-				    $dataFound = true;
605
-				    $this->all_flights[$id]['time_last_coord'] = time();
603
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
604
+					$dataFound = true;
605
+					$this->all_flights[$id]['time_last_coord'] = time();
606 606
 				}
607 607
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
608 608
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -620,67 +620,67 @@  discard block
 block discarded – undo
620 620
 			    */
621 621
 			}
622 622
 
623
-		    } else if ($globalDebug && $timediff > 30) {
623
+			} else if ($globalDebug && $timediff > 30) {
624 624
 			$this->tmd = $this->tmd + 1;
625 625
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
626 626
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
627 627
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
628 628
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
629
-		    }
629
+			}
630 630
 		}
631 631
 		if (isset($line['last_update']) && $line['last_update'] != '') {
632
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
633
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
632
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
633
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
634 634
 		}
635 635
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
636
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
637
-		    //$dataFound = true;
636
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
637
+			//$dataFound = true;
638 638
 		}
639 639
 		if (isset($line['format_source']) && $line['format_source'] != '') {
640
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
640
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
641 641
 		}
642 642
 		if (isset($line['source_name']) && $line['source_name'] != '') {
643
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
643
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
644 644
 		}
645 645
 		if (isset($line['emergency']) && $line['emergency'] != '') {
646
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
647
-		    //$dataFound = true;
646
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
647
+			//$dataFound = true;
648 648
 		}
649 649
 		if (isset($line['ground']) && $line['ground'] != '') {
650
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
650
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
651 651
 			// Here we force archive of flight because after ground it's a new one (or should be)
652 652
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
653 653
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
654 654
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
655
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
655
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
656 656
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
657
-		    }
658
-		    if ($line['ground'] != 1) $line['ground'] = 0;
659
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
660
-		    //$dataFound = true;
657
+			}
658
+			if ($line['ground'] != 1) $line['ground'] = 0;
659
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
660
+			//$dataFound = true;
661 661
 		}
662 662
 		if (isset($line['squawk']) && $line['squawk'] != '') {
663
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
664
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
665
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
666
-			    $highlight = '';
667
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
668
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
669
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
670
-			    if ($highlight != '') {
663
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
664
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
665
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
666
+				$highlight = '';
667
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
668
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
669
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
670
+				if ($highlight != '') {
671 671
 				$timeelapsed = microtime(true);
672 672
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
673
-				    $Spotter = new Spotter($this->db);
674
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
675
-				    $Spotter->db = null;
676
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
673
+					$Spotter = new Spotter($this->db);
674
+					$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
675
+					$Spotter->db = null;
676
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
677 677
 				}
678 678
 				//$putinarchive = true;
679 679
 				//$highlight = '';
680
-			    }
680
+				}
681 681
 			    
682
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
683
-		    //$dataFound = true;
682
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
683
+			//$dataFound = true;
684 684
 		}
685 685
 
686 686
 		if (isset($line['altitude']) && $line['altitude'] != '') {
@@ -691,13 +691,13 @@  discard block
 block discarded – undo
691 691
 					$line['altitude'] = $line['altitude'] - $geoid;
692 692
 				}
693 693
 			}
694
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
694
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
695 695
 			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
696 696
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
697 697
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
698 698
 			//$dataFound = true;
699
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
700
-		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
699
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
700
+			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
701 701
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
702 702
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
703 703
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -706,27 +706,27 @@  discard block
 block discarded – undo
706 706
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
707 707
 				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
708 708
 			}
709
-		    }
710
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
709
+			}
710
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
711 711
 		}
712 712
 
713 713
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
714
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
714
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
715 715
 		}
716 716
 		
717 717
 		if (isset($line['heading']) && $line['heading'] != '') {
718
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
719
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
720
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
721
-		    //$dataFound = true;
718
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
719
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
720
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
721
+			//$dataFound = true;
722 722
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
723
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
724
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
725
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
726
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
723
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
724
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
725
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
726
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
727 727
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
728
-  		    // If not enough messages and ACARS set heading to 0
729
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
728
+  			// If not enough messages and ACARS set heading to 0
729
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
730 730
   		}
731 731
 		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
732 732
 		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -739,125 +739,125 @@  discard block
 block discarded – undo
739 739
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
740 740
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
741 741
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
742
-		    $this->all_flights[$id]['lastupdate'] = time();
743
-		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
744
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
745
-			    //print_r($this->all_flights);
746
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
747
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
748
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
742
+			$this->all_flights[$id]['lastupdate'] = time();
743
+			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
744
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
745
+				//print_r($this->all_flights);
746
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
747
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
748
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
749 749
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
750
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
751
-				    $timeelapsed = microtime(true);
752
-				    $SpotterLive = new SpotterLive($this->db);
753
-				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
750
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
751
+					$timeelapsed = microtime(true);
752
+					$SpotterLive = new SpotterLive($this->db);
753
+					if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
754 754
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
755 755
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
756
-				    } elseif (isset($line['id'])) {
756
+					} elseif (isset($line['id'])) {
757 757
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
758 758
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
759
-				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
759
+					} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
760 760
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
761 761
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
762
-				    } else $recent_ident = '';
763
-				    $SpotterLive->db=null;
764
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
765
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
762
+					} else $recent_ident = '';
763
+					$SpotterLive->db=null;
764
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
765
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
766 766
 				} else $recent_ident = '';
767
-			    } else {
767
+				} else {
768 768
 				$recent_ident = '';
769 769
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
770
-			    }
771
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
772
-			    if($recent_ident == "")
773
-			    {
770
+				}
771
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
772
+				if($recent_ident == "")
773
+				{
774 774
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
775 775
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
776 776
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
777 777
 				//adds the spotter data for the archive
778 778
 				$ignoreImport = false;
779 779
 				foreach($globalAirportIgnore as $airportIgnore) {
780
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
780
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
781 781
 					$ignoreImport = true;
782
-				    }
782
+					}
783 783
 				}
784 784
 				if (count($globalAirportAccept) > 0) {
785
-				    $ignoreImport = true;
786
-				    foreach($globalAirportIgnore as $airportIgnore) {
785
+					$ignoreImport = true;
786
+					foreach($globalAirportIgnore as $airportIgnore) {
787 787
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
788
-					    $ignoreImport = false;
788
+						$ignoreImport = false;
789
+					}
789 790
 					}
790
-				    }
791 791
 				}
792 792
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
793
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
793
+					foreach($globalAirlineIgnore as $airlineIgnore) {
794 794
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
795
-					    $ignoreImport = true;
795
+						$ignoreImport = true;
796
+					}
796 797
 					}
797
-				    }
798 798
 				}
799 799
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
800
-				    $ignoreImport = true;
801
-				    foreach($globalAirlineAccept as $airlineAccept) {
800
+					$ignoreImport = true;
801
+					foreach($globalAirlineAccept as $airlineAccept) {
802 802
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
803
-					    $ignoreImport = false;
803
+						$ignoreImport = false;
804
+					}
804 805
 					}
805
-				    }
806 806
 				}
807 807
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
808
-				    $ignoreImport = true;
809
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
808
+					$ignoreImport = true;
809
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
810 810
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
811
-					    $ignoreImport = false;
811
+						$ignoreImport = false;
812
+					}
812 813
 					}
813
-				    }
814 814
 				}
815 815
 				
816 816
 				if (!$ignoreImport) {
817
-				    $highlight = '';
818
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
819
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
820
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
821
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
822
-				    $timeelapsed = microtime(true);
823
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
817
+					$highlight = '';
818
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
819
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
820
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
821
+					if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
822
+					$timeelapsed = microtime(true);
823
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
824 824
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
825
-					    $Spotter = new Spotter($this->db);
826
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
827
-					    $Spotter->db = null;
828
-					    if ($globalDebug && isset($result)) echo $result."\n";
825
+						$Spotter = new Spotter($this->db);
826
+						$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
827
+						$Spotter->db = null;
828
+						if ($globalDebug && isset($result)) echo $result."\n";
829 829
 					}
830
-				    }
831
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
832
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
830
+					}
831
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
832
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
833 833
 
834
-				    // Add source stat in DB
835
-				    $Stats = new Stats($this->db);
836
-				    if (!empty($this->stats)) {
834
+					// Add source stat in DB
835
+					$Stats = new Stats($this->db);
836
+					if (!empty($this->stats)) {
837 837
 					if ($globalDebug) echo 'Add source stats : ';
838
-				        foreach($this->stats as $date => $data) {
839
-					    foreach($data as $source => $sourced) {
840
-					        //print_r($sourced);
841
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
842
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
843
-				    		if (isset($sourced['msg'])) {
844
-				    		    if (time() - $sourced['msg']['date'] > 10) {
845
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
846
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
847
-			    			        unset($this->stats[$date][$source]['msg']);
848
-			    			    }
849
-			    			}
850
-			    		    }
851
-			    		    if ($date != date('Y-m-d')) {
852
-			    			unset($this->stats[$date]);
853
-			    		    }
854
-				    	}
855
-				    	if ($globalDebug) echo 'Done'."\n";
838
+						foreach($this->stats as $date => $data) {
839
+						foreach($data as $source => $sourced) {
840
+							//print_r($sourced);
841
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
842
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
843
+							if (isset($sourced['msg'])) {
844
+								if (time() - $sourced['msg']['date'] > 10) {
845
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
846
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
847
+									unset($this->stats[$date][$source]['msg']);
848
+								}
849
+							}
850
+							}
851
+							if ($date != date('Y-m-d')) {
852
+							unset($this->stats[$date]);
853
+							}
854
+						}
855
+						if ($globalDebug) echo 'Done'."\n";
856 856
 
857
-				    }
858
-				    $Stats->db = null;
859
-				    }
860
-				    $this->del();
857
+					}
858
+					$Stats->db = null;
859
+					}
860
+					$this->del();
861 861
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
862 862
 				//$ignoreImport = false;
863 863
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -875,41 +875,41 @@  discard block
 block discarded – undo
875 875
 			*/
876 876
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
877 877
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
878
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
879
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
880
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
878
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
879
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
880
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
881 881
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
882
-					    $SpotterLive = new SpotterLive($this->db);
883
-					    $SpotterLive->deleteLiveSpotterData();
884
-					    $SpotterLive->db=null;
882
+						$SpotterLive = new SpotterLive($this->db);
883
+						$SpotterLive->deleteLiveSpotterData();
884
+						$SpotterLive->db=null;
885 885
 					}
886
-				    }
887
-				    if ($globalDebug) echo " Done\n";
888
-				    $this->last_delete = time();
886
+					}
887
+					if ($globalDebug) echo " Done\n";
888
+					$this->last_delete = time();
889 889
 				}
890
-			    } else {
890
+				} else {
891 891
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
892
-				    $this->all_flights[$id]['id'] = $recent_ident;
893
-				    $this->all_flights[$id]['addedSpotter'] = 1;
892
+					$this->all_flights[$id]['id'] = $recent_ident;
893
+					$this->all_flights[$id]['addedSpotter'] = 1;
894 894
 				}
895 895
 				if (isset($globalDaemon) && !$globalDaemon) {
896
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
896
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
897 897
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
898
-					    $Spotter = new Spotter($this->db);
899
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
900
-					    $Spotter->db = null;
898
+						$Spotter = new Spotter($this->db);
899
+						$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
900
+						$Spotter->db = null;
901
+					}
901 902
 					}
902
-				    }
903 903
 				}
904 904
 				
905
-			    }
905
+				}
906 906
 			}
907
-		    }
908
-		    //adds the spotter LIVE data
909
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
910
-		    //echo "\nAdd in Live !! \n";
911
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
912
-		    if ($globalDebug) {
907
+			}
908
+			//adds the spotter LIVE data
909
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
910
+			//echo "\nAdd in Live !! \n";
911
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
912
+			if ($globalDebug) {
913 913
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
914 914
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
915 915
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -917,60 +917,60 @@  discard block
 block discarded – undo
917 917
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
918 918
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
919 919
 			}
920
-		    }
921
-		    $ignoreImport = false;
922
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
923
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
920
+			}
921
+			$ignoreImport = false;
922
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
923
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
924 924
 
925
-		    foreach($globalAirportIgnore as $airportIgnore) {
926
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
927
-			    $ignoreImport = true;
925
+			foreach($globalAirportIgnore as $airportIgnore) {
926
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
927
+				$ignoreImport = true;
928
+			}
928 929
 			}
929
-		    }
930
-		    if (count($globalAirportAccept) > 0) {
931
-		        $ignoreImport = true;
932
-		        foreach($globalAirportIgnore as $airportIgnore) {
933
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
930
+			if (count($globalAirportAccept) > 0) {
931
+				$ignoreImport = true;
932
+				foreach($globalAirportIgnore as $airportIgnore) {
933
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
934 934
 				$ignoreImport = false;
935
-			    }
935
+				}
936 936
 			}
937
-		    }
938
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
937
+			}
938
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
939 939
 			foreach($globalAirlineIgnore as $airlineIgnore) {
940
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
940
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
941 941
 				$ignoreImport = true;
942
-			    }
942
+				}
943 943
 			}
944
-		    }
945
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
944
+			}
945
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
946 946
 			$ignoreImport = true;
947 947
 			foreach($globalAirlineAccept as $airlineAccept) {
948
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
948
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
949 949
 				$ignoreImport = false;
950
-			    }
950
+				}
951
+			}
951 952
 			}
952
-		    }
953
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
953
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
954 954
 			$ignoreImport = true;
955 955
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
956
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
957
-			        $ignoreImport = false;
958
-			    }
956
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
957
+					$ignoreImport = false;
958
+				}
959
+			}
959 960
 			}
960
-		    }
961 961
 
962
-		    if (!$ignoreImport) {
962
+			if (!$ignoreImport) {
963 963
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
964 964
 				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
965 965
 				$timeelapsed = microtime(true);
966 966
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
967
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
967
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
968 968
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
969 969
 					$SpotterLive = new SpotterLive($this->db);
970 970
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
971 971
 					$SpotterLive->db = null;
972 972
 					if ($globalDebug) echo $result."\n";
973
-				    }
973
+					}
974 974
 				}
975 975
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
976 976
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 				//if ($line['format_source'] != 'aprs') {
983 983
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
984 984
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
985
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
985
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
986 986
 					$source = $this->all_flights[$id]['source_name'];
987 987
 					if ($source == '') $source = $this->all_flights[$id]['format_source'];
988 988
 					if (!isset($this->source_location[$source])) {
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 					if ($stats_heading == 16) $stats_heading = 0;
1009 1009
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1010 1010
 						for ($i=0;$i<=15;$i++) {
1011
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1011
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
1012 1012
 						}
1013 1013
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
1014 1014
 					} else {
@@ -1021,17 +1021,17 @@  discard block
 block discarded – undo
1021 1021
 					//var_dump($this->stats);
1022 1022
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1023 1023
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1024
-						    end($this->stats[$current_date][$source]['hist']);
1025
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1024
+							end($this->stats[$current_date][$source]['hist']);
1025
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
1026 1026
 						} else $mini = 0;
1027 1027
 						for ($i=$mini;$i<=$distance;$i+=10) {
1028
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1028
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
1029 1029
 						}
1030 1030
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
1031 1031
 					} else {
1032 1032
 						$this->stats[$current_date][$source]['hist'][$distance] += 1;
1033 1033
 					}
1034
-				    }
1034
+					}
1035 1035
 				}
1036 1036
 
1037 1037
 				$this->all_flights[$id]['lastupdate'] = time();
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 			//$this->del();
1042 1042
 			
1043 1043
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1044
-			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1044
+				if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1045 1045
 				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1046 1046
 				$SpotterLive = new SpotterLive($this->db);
1047 1047
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
@@ -1049,19 +1049,19 @@  discard block
 block discarded – undo
1049 1049
 				//SpotterLive->deleteLiveSpotterData();
1050 1050
 				if ($globalDebug) echo " Done\n";
1051 1051
 				$this->last_delete_hourly = time();
1052
-			    } else {
1052
+				} else {
1053 1053
 				$this->del();
1054 1054
 				$this->last_delete_hourly = time();
1055
-			    }
1055
+				}
1056 1056
 			}
1057 1057
 			
1058
-		    }
1059
-		    //$ignoreImport = false;
1058
+			}
1059
+			//$ignoreImport = false;
1060 1060
 		}
1061 1061
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1062 1062
 		if ($send) return $this->all_flights[$id];
1063
-	    }
1063
+		}
1064
+	}
1064 1065
 	}
1065
-    }
1066 1066
 }
1067 1067
 ?>
Please login to merge, or discard this patch.